void RSA_TestInstantiations() { RSASS<PKCS1v15, SHA1>::Verifier x1(1, 1); RSASS<PKCS1v15, SHA1>::Signer x2(NullRNG(), 1); RSASS<PKCS1v15, SHA1>::Verifier x3(x2); RSASS<PKCS1v15, SHA1>::Verifier x4(x2.GetKey()); RSASS<PSS, SHA1>::Verifier x5(x3); #ifndef __MWERKS__ RSASS<PSSR, SHA1>::Signer x6 = x2; x3 = x2; x6 = x2; #endif RSAES<PKCS1v15>::Encryptor x7(x2); #ifndef __GNUC__ RSAES<PKCS1v15>::Encryptor x8(x3); #endif RSAES<OAEP<SHA1> >::Encryptor x9(x2); x4 = x2.GetKey(); RSASS<PKCS1v15, SHA3_256>::Verifier x10(1, 1); RSASS<PKCS1v15, SHA3_256>::Signer x11(NullRNG(), 1); RSASS<PKCS1v15, SHA3_256>::Verifier x12(x11); RSASS<PKCS1v15, SHA3_256>::Verifier x13(x11.GetKey()); }
int main(void) { // 3.4.5 Class member access // p 2 // if the id-expression in a class member access is an // unqualified-id, and the type of the object expression is of class // type C (or pointer to class type C), the unqualified-id is looked // up in the scope of class C. If the type of the object-expression // is of pointer to scalar type, the unqualified-id is looked up in // the context of the complete postfix-expression. // p 3 // if the unqualitified id is ~type-name, and the type of the object // expression is of a class type C (or pointer to class type C), the // type-name is looked up in the context of the entire // postfix-expression and in the scope of class C. The type-name // shall refer to a class-name. If type-name is found in both // contexts, the name shall refer to the same class type. If the // type of the object expression is of scalar type, the type-name is // looked up in the complete postfix-expression. typedef X localtype; // // 1 non-templatized, pointer, unqualified // X x01 ; X *px = &x01; px->~X(); X x02 (66); px = &x02; px->~localtype(); X x03 (68); px = &x03; px->~classtype(); //-g++ //p3: unqual-id lookup in object and postfix-expr X x04 (70); px = &x04; px->~globaltype(); // p 1 // . . . the id-expression is first looked up in the class of the // object-expression. If the identifier is not found, itis then // looked up in the context of the entier postfix-expression and // shall name a class or function template. If the lookup in the // class of the object-expression finds a template, the name is also // looked up in teh context of the entier postfix-expression and // 1 if the name is not found, use the name from the object-expr // 2 if the name found in postfix-expr != class template, use object-expr // 3 if name found is class template, name must match object-expr or error // p 4 // if the id-expr in a class member acess is a qualified-id, the // id-expression is looked up in both the context of the entire // postfix-expr and in the scope of the class of the object-expr. If // the name is found in both contexts, the id-expr shall refer to // the same entity. // // 2 non-templatized, pointer, qualified // X x05 ; px = &x05; px->X::~X(); X x06 (66); px = &x06; px->X::~localtype(); X x07 (68); px = &x07; px->X::~classtype(); // -edg X x08 (70); px = &x08; px->X::~globaltype(); X x09 (66); px = &x09; px->localtype::~localtype(); X x10 (68); px = &x10; px->classtype::~classtype(); X x11 (70); px = &x11; px->globaltype::~globaltype(); X x12 (66); px = &x12; px->classtype::~localtype(); X x13 (68); px = &x13; px->globaltype::~localtype(); X x14 (70); px = &x14; px->localtype::~globaltype(); X x15 (70); px = &x15; px->classtype::~globaltype(); X x16 (70); px = &x16; px->localtype::~classtype(); //-edg X x17 (70); px = &x17; px->globaltype::~classtype(); //-edg #if 0 // // non-templatized, non-pointer // X xo5 ; xo5.~X(); //unqualified localtype xo6 (66); xo6.~localtype(); X xo7 (68); xo7.~classtype(); X xo8 (70); xo8.~globaltype(); // // templatized, pointer // X_tem<int> xto1 ; X_tem<int> *pxt = &xto1; pxt->~X_tem(); //unqualified typedef X_tem<int> localtype_tem; localtype_tem xto2 (66); pxt = &xto2; pxt->~localtype_tem(); //paragraph 2: unqualitifed id looked up in scope of post-fix expr if object X_tem<int> xto3 (68); pxt = &xto3; pxt->~classtype_tem(); X_tem<int> xto4 (70); pxt = &xto4; pxt->~globaltype_tem(); // // templatized, non-pointer // X_tem<int> xto5 ; xto5.~X_tem(); //unqualified localtype_tem xto6 (66); xto6.~localtype_tem(); X_tem<int> xto7 (68); xto7.~classtype_tem(); X_tem<int> xto8 (70); xto8.~globaltype_tem(); #endif return 0; }
void CreateHeightFieldMesh (NewtonCollision* collision, Entity* ent) { int width; int height; dFloat hScale; dFloat vScale; unsigned short* elevations; NewtonCollisionInfoRecord collisionInfo; // keep the compiler happy memset (&collisionInfo, 0, sizeof (NewtonCollisionInfoRecord)); NewtonCollisionGetInfo (collision, &collisionInfo); // get the info from the collision mesh and create a visual mesh width = collisionInfo.m_heightField.m_width; height = collisionInfo.m_heightField.m_height; elevations = collisionInfo.m_heightField.m_elevation; vScale = collisionInfo.m_heightField.m_verticalScale; hScale = collisionInfo.m_heightField.m_horizonalScale; // allocate space to store vertex data ent->m_vertexCount = width * height; ent->m_vertex = (dFloat*) malloc (3 * width * height * sizeof (dFloat)); ent->m_normal = (dFloat*) malloc (3 * width * height * sizeof (dFloat)); ent->m_uv = (dFloat*) malloc (2 * width * height * sizeof (dFloat)); // scan the height field and convert every cell into two triangles for (int z = 0; z < height; z ++) { int z0; int z1; z0 = ((z - 1) < 0) ? 0 : z - 1; z1 = ((z + 1) > (height - 1)) ? height - 1 : z + 1 ; for (int x = 0; x < width; x ++) { int x0; int x1; x0 = ((x - 1) < 0) ? 0 : x - 1; x1 = ((x + 1) > (width - 1)) ? width - 1 : x + 1 ; dVector p0 (hScale * x0, elevations[z * width + x1] * vScale, hScale * z); dVector p1 (hScale * x1, elevations[z * width + x0] * vScale, hScale * z); dVector x10 (p1 - p0); dVector q0 (hScale * x, elevations[z0 * width + x] * vScale, hScale * z0); dVector q1 (hScale * x, elevations[z1 * width + x] * vScale, hScale * z1); dVector z10 (q1 - q0); dVector normal (z10 * x10); normal = normal.Scale (dSqrt (1.0f / (normal % normal))); dVector point (hScale * x, elevations[z * width + x] * vScale, hScale * z); ent->m_vertex[(z * width + x) * 3 + 0] = point.m_x; ent->m_vertex[(z * width + x) * 3 + 1] = point.m_y; ent->m_vertex[(z * width + x) * 3 + 2] = point.m_z; ent->m_normal[(z * width + x) * 3 + 0] = normal.m_x; ent->m_normal[(z * width + x) * 3 + 1] = normal.m_y; ent->m_normal[(z * width + x) * 3 + 2] = normal.m_z; ent->m_uv[(z * width + x) * 2 + 0] = x * TEXTURE_SCALE; ent->m_uv[(z * width + x) * 2 + 1] = z * TEXTURE_SCALE; } } // since the bitmap sample is 256 x 256, i fix into a single 16 bit index vertex array with ent->m_subMeshCount = 1; ent->m_subMeshes = (Entity::SubMesh*) malloc (sizeof (Entity::SubMesh)); // allocate space to the index list ent->m_subMeshes[0].m_textureHandle = LoadTexture ("grassAndDirt.tga"); ent->m_subMeshes[0].m_indexCount = (width - 1) * (height - 1) * 6; ent->m_subMeshes[0].m_indexArray = (unsigned short*) malloc (ent->m_subMeshes[0].m_indexCount * sizeof (unsigned short)); // now following the grid pattern and create and index list int index; int vertexIndex; index = 0; vertexIndex = 0; for (int z = 0; z < height - 1; z ++) { vertexIndex = z * width; for (int x = 0; x < width - 1; x ++) { ent->m_subMeshes[0].m_indexArray[index + 0] = GLushort (vertexIndex); ent->m_subMeshes[0].m_indexArray[index + 1] = GLushort (vertexIndex + width); ent->m_subMeshes[0].m_indexArray[index + 2] = GLushort (vertexIndex + 1); index += 3; ent->m_subMeshes[0].m_indexArray[index + 0] = GLushort (vertexIndex + 1); ent->m_subMeshes[0].m_indexArray[index + 1] = GLushort (vertexIndex + width); ent->m_subMeshes[0].m_indexArray[index + 2] = GLushort (vertexIndex + width + 1); index += 3; vertexIndex ++; } } // Optimize the mesh for hardware rendering if possible ent->OptimizeMesh(); /* dVector boxP0; dVector boxP1; // get the position of the aabb of this geometry dMatrix matrix (ent->m_curRotation, ent->m_curPosition); NewtonCollisionCalculateAABB (collision, &matrix[0][0], &boxP0.m_x, &boxP1.m_x); // place the origin of the visual mesh at the center of the height field matrix.m_posit = (boxP0 + boxP1).Scale (-0.5f); matrix.m_posit.m_w = 1.0f; ent->m_curPosition = matrix.m_posit; ent->m_prevPosition = matrix.m_posit; // create the level rigid body body = NewtonCreateBody(world, collision); // release the collision tree (this way the application does not have to do book keeping of Newton objects NewtonReleaseCollision (world, collision); // save the pointer to the graphic object with the body. NewtonBodySetUserData (body, ent); // set the global position of this body NewtonBodySetMatrix (body, &matrix[0][0]); // set the destructor for this object // NewtonBodySetDestructorCallback (body, Destructor); // get the position of the aabb of this geometry NewtonCollisionCalculateAABB (collision, &matrix[0][0], &boxP0.m_x, &boxP1.m_x); // add some extra padding the world size boxP0.m_x -= 10.0f; boxP0.m_y -= 10.0f; boxP0.m_z -= 10.0f; boxP1.m_x += 10.0f; boxP1.m_y += 400.0f; boxP1.m_z += 10.0f; // set the world size NewtonSetWorldSize (world, &boxP0.m_x, &boxP1.m_x); return body; */ }
Dims and brightens an incandescent lamp on an X10 lamp module. Example was built using a PL513 X10 One-Way Interface Module from http://www.smarthome.com as the modem, and a Powerhouse X10 Lamp Module from Smarthome to plug the lamp in. created 15 June 2007 by Tom Igoe */ #define zcPin 2 #define dataPin 3 // set up a new x10 instance: x10 myHouse = x10(zcPin, dataPin); void setup() { Serial.begin(9600); // send a "Lights ON" command 3 times: myHouse.write(A, ON,3); } void loop() { Serial.println("Lights up:"); // send a "lights BRIGHT" command 19 times. // it takes 19 BRIGHT or DIM commands to get // an incandescent lamp dim or bright. myHouse.write(A, ON,3); //delay(50); myHouse.write(B, OFF,3);
* parser gets "…1 BS BS BS NL BS BS 2 NL", which * it translates into "…1 BS BS SP BS BS 2" */ "\n[Section]\n\n" "setting1=" /* a line above LINE_MAX length */ x1000("ABCD") "\n", "[Section]\n" "setting1=" /* a line above LINE_MAX length, with continuation */ x1000("ABCD") "\\\n" "foobar", "[Section]\n" "setting1=" /* a line above the allowed limit: 9 + 1050000 + 1 */ x1000(x1000("x") x10("abcde")) "\n", "[Section]\n" "setting1=" /* many continuation lines, together above the limit */ x1000(x1000("x") x10("abcde") "\\\n") "xxx", }; static void test_config_parse(unsigned i, const char *s) { char name[] = "/tmp/test-conf-parser.XXXXXX"; int fd, r; _cleanup_fclose_ FILE *f = NULL; _cleanup_free_ char *setting1 = NULL; const ConfigTableItem items[] = { { "Section", "setting1", config_parse_string, 0, &setting1}, {}