FRAGMENT(JSObject, simple) { JS::Rooted<JSObject*> glob(cx, JS::CurrentGlobalOrNull(cx)); JS::Rooted<JSObject*> plain(cx, JS_NewPlainObject(cx)); JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx)); JS::Rooted<JSObject*> func(cx, (JSObject*) JS_NewFunction(cx, (JSNative) 1, 0, 0, global, "dys")); JS::Rooted<JSObject*> anon(cx, (JSObject*) JS_NewFunction(cx, (JSNative) 1, 0, 0, global, 0)); JS::Rooted<JSFunction*> funcPtr(cx, JS_NewFunction(cx, (JSNative) 1, 0, 0, global, "formFollows")); JSObject& plainRef = *plain; JSFunction& funcRef = *funcPtr; JSObject* plainRaw = plain; JSObject* funcRaw = func; breakpoint(); (void) glob; (void) plain; (void) func; (void) anon; (void) funcPtr; (void) &plainRef; (void) &funcRef; (void) plainRaw; (void) funcRaw; }
int main(int argc, const char *argv[]) { if(argc != 3 && argc != 4) { cerr << "Usage: " << argv[0] << " <store-id: x.y> <key: string> [<elem: string >]" << endl; return 1; } else { int v; int st; { w_istrstream anon(argv[1]); char dot; anon >> v; anon >> dot; anon >> st; } stid_t s(v,st); cvec_t key(argv[2], strlen(argv[2])); cvec_t elem; if(argc > 3) { elem.put(argv[3], strlen(argv[3])); } kvl_t kvl(s, key, elem); cout << "kvl(store= " << s << " key= " << key << " elem= " << elem << ")= " << kvl << endl; // calclulate kvl for null vector vec_t nul; kvl_t kvl1(s, nul, elem); cout << "kvl(store= " << s << " key= " << nul << " elem= " << elem << ")= " << kvl1 << endl; kvl_t kvl3(s, key, nul); cout << "kvl(store= " << s << " key= " << key << " elem= " << nul << ")= " << kvl3 << endl; kvl_t kvl2(s, nul, nul); cout << "kvl(store= " << s << " key= " << nul << " elem= " << nul << ")= " << kvl2 << endl; } return 0; }
void Stage::serialize(MetadataNode root, PipelineWriter::TagMap& tags) const { for (Stage *s : m_inputs) s->serialize(root, tags); auto tagname = [tags](const Stage *s) { const auto ti = tags.find(s); return ti->second; }; MetadataNode anon("pipeline"); anon.add("type", getName()); anon.add("tag", tagname(this)); m_options.toMetadata(anon); for (Stage *s : m_inputs) anon.addList("inputs", tagname(s)); root.addList(anon); }
void P(const char *s) { int len = strlen(s); istrstream anon(s,len); vec_t t; cout << "P:" << s << endl; anon >> t; cout << "input operator:" << endl; for(int i=0; i<t.count(); i++) { cout <<"vec["<<i<<"]=(" <<::dec((unsigned int)t.ptr(i)) <<"," <<t.len(i) <<")" << endl; } cout << "output operator:" << endl; cout << t; cout << endl; }
FRAGMENT(JSObject, simple) { AutoSuppressHazardsForTest noanalysis; JS::Rooted<JSObject*> glob(cx, JS::CurrentGlobalOrNull(cx)); JS::Rooted<JSObject*> plain(cx, JS_NewPlainObject(cx)); JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx)); JS::Rooted<JSObject*> func(cx, (JSObject*) JS_NewFunction(cx, (JSNative) 1, 0, 0, "dys")); JS::Rooted<JSObject*> anon(cx, (JSObject*) JS_NewFunction(cx, (JSNative) 1, 0, 0, nullptr)); JS::Rooted<JSFunction*> funcPtr(cx, JS_NewFunction(cx, (JSNative) 1, 0, 0, "formFollows")); JSObject& plainRef = *plain; JSFunction& funcRef = *funcPtr; JSObject* plainRaw = plain; JSObject* funcRaw = func; // JS_NewObject will now assert if you feed it a bad class name, so mangle // the name after construction. char namebuf[20] = "goodname"; static JSClass cls { namebuf }; JS::RootedObject badClassName(cx, JS_NewObject(cx, &cls)); strcpy(namebuf, "\xc7X"); breakpoint(); use(glob); use(plain); use(func); use(anon); use(funcPtr); use(&plainRef); use(&funcRef); use(plainRaw); use(funcRaw); }