_BUILDING DISTRIBUTED APPLICATIONS WITH GALAXY_ by Stan Dolberg Example 1 (a) typedef struct myStruct myStruct; struct myStruct { short first; vlonglong second; double third; vfixed fourth; }; (b) vscrap * myCreateStructScrap (myStruct *ptr) { vdatatag *dtag; vscrap *scrap; dtag = vdatatagCreateCompound(); vdatatagConstructCompound(dtag, vdatatagGetShort(), vdatatagGetLonglong(), vdatatagGetDoubleFloat(), vdatatagGetFixed(), NULL); scrap = vdatatagScrapFromValue(dtag, ptr); return (scrap); } Example 2: (a) typedef struct barney barney; struct barney { unsigned int purple; float dinosaur; vfixed beast; barney *next; }; barney *listTop; --------------------------------------------------------------------------- (b) ptr = vdatatagCreatePointer(); dtag = vdatatagcreateCompound(); vdatatagConstructCompound(dtag, vdatatagGetUnsignedInteger(), vdatatagGetSingleFloat(), vdatatagGetFixed(), ptr, NULL); vdatatagSetPointerDatatag(ptr, dtag); Example 3: (a) vsessionSetStatementArgs(session, listTop); (b) vserviceGetPrimitiveArgs(prim, scrap, &listTop); Example 4: (a) vcolorspec *colorspec; vresource res; vscrap *scrap; res = vresourceCreateMem(); vcolorStoreSpec(spec, res); scrap = vresourceGetScrap(res, NULL); /* signature for statement has vdatatagGetScrap() * as argument datatag */ vsessionSetStatementArgs(session, scrap); vscrapDestroy(scrap); vresourceDestroyMem(res); --------------------------------------------------------------------------- (b) vresource res, one; vcolorSpec *spec; vscrap *scrap; /* signature for primitive has vdatatagGetScrap() * as argument datatag */ vserviceGetPrimitiveArgs(prim, args, &scrap); res = vresourceCreateMem(); one = vresourceCreate(res, vname_Foo, vresourceUNTYPED); vresourceSetScrap(one, NULL, scrap); spec = vcolorLoadSpec(one); vscrapDestroy(scrap); vresourceDestroyMem(res) Example 5: { vsignature sig; vsignatureCreate(); vsignatureSetTag(sig, vnameInterGlobalLiteral("my primitive")); vsignatureSetReturnDatatag(sig, vdatatagGetInteger()); vsignatureConstructArgs(sig, vdatatagGetShort(), vdatatagGetFixed(), vdatatagGetLongLong(), vdatatagGetString(), vdatatagGetInteger(), NULL); } Example 6: { vsession *sessionBroker; sessionBroker = vsessionCreate(); vsessionSetAtrributesFromScrap(sessionBroker, vdasserCreateAttributeScrap()); vsessionBegin(sessionBroker); ... vsessionEnd(sessionBroker); } Example 7: { vsessionStatement *statement; vsession *sessionBroker; vscrap *scrapSpec; // initialize sessionBroker scrapSpec = vscrapCreateDictionary(); statement = vdasservMakeMatchStatement(sessionBroker, scrapSpec); vessionSetStatementNotify(statement, exampleMatchNotify); vessionSendStatement(statement); ... }