void Module::codegenDefinition(std::ostream &out) const { for(const auto &e : exports()) { e->codegenDefinition(out); } }
void MongoHelpersInfo::postInstall(JSContext* cx, JS::HandleObject global, JS::HandleObject proto) { ObjectWrapper protoWrapper(cx, proto); ObjectWrapper globalWrapper(cx, global); // Initialize the reflection API and move it under the MongoHelpers object uassert(ErrorCodes::JSInterpreterFailure, "Error initializing javascript reflection API", JS_InitReflectParse(cx, global)); JS::RootedValue reflectValue(cx); globalWrapper.getValue(kReflectName, &reflectValue); globalWrapper.deleteProperty(kReflectName); protoWrapper.setValue(kReflectName, reflectValue); JS::RootedValue exports(cx); getScope(cx)->execSetup(JSFiles::mongohelpers); globalWrapper.getValue(kExportsObjectName, &exports); globalWrapper.deleteProperty(kExportsObjectName); ObjectWrapper exportsWrapper(cx, exports); JS::RootedValue copyExport(cx); exportsWrapper.enumerate([&](JS::HandleId _id) { exportsWrapper.getValue(_id, ©Export); protoWrapper.setValue(_id, copyExport); return true; }); }
JSObject *JSOS::RegisterModule(JSContext *cx) { JS::RootedObject exports(cx, JSOS::ExposeObject(cx, "OS")); // Platform JS::RootedString platformStr(cx, JSUtils::NewStringWithEncoding(cx, NIDIUM_PLATFORM, strlen(NIDIUM_PLATFORM), "utf8")); JS::RootedValue platform(cx, JS::StringValue(platformStr)); JS_DefineProperty(cx, exports, "platform", platform, JSPROP_PERMANENT | JSPROP_READONLY | JSPROP_ENUMERATE); // Language #ifdef NIDIUM_PRODUCT_FRONTEND Interface::SystemInterface* interface = Interface::SystemInterface::GetInstance(); const char *clang = interface->getLanguage(); JS::RootedString langStr(cx, JSUtils::NewStringWithEncoding(cx, clang, strlen(clang), "utf8")); JS::RootedValue lang(cx, JS::StringValue(langStr)); JS_DefineProperty(cx, exports, "language", lang, JSPROP_PERMANENT | JSPROP_READONLY | JSPROP_ENUMERATE); #endif return exports; }
void Module::codegenMethodTable(std::ostream &out) const { out << "static PyMethodDef methods[] = {\n"; { IndentingOStreambuf indenter(out); for(const auto &e : exports()) { e->codegenMethodTable(out); } out << "{0, 0, 0, 0}\n"; } out << "};\n"; }
/** issue a query filling the model storage * this will change when I will learn how to call SWI-Prolog completion interface */ void Completion::initialize(QSet<QString> &strings, bool reload) { /*static QSet<QString> preds;*/ Q_UNUSED(reload) //static QMap<QString, QSet<QString>> cmods; T Mod, Exp, PI; for (module_property mp(Mod, exports(Exp)); mp; ) { for (L exp(Exp); exp.next(PI); ) //preds.insert(t2w(exp)); strings.insert(t2w(PI)); } /* if (curr.isEmpty() || reload) { curr.clear(); SwiPrologEngine::in_thread _int; try { PlTerm p,m,a,l,v; PlQuery q("setof", PlTermv(p, quv(m, quv(a, join(PlCompound("current_predicate", mod(m, arith(p, a))), neg(C("sub_atom", PlTermv(p, zero, one, _V, A("$")))) ))), l)); if (q.next_solution()) for (PlTail x(l); x.next(v); ) curr << t2w(v); PlTerm M, Ms; if (PlCall("setof", PlTermv(M, PlCompound("current_module", M), Ms))) for (PlTail x(Ms); x.next(M); ) curr << t2w(M); } catch(PlException e) { qDebug() << t2w(e); } } strings.unite(curr); */ }
static void show_scope(const wchar_t *var_name, int scope, io_streams_t &streams, const environment_t &vars) { const wchar_t *scope_name; switch (scope) { case ENV_LOCAL: { scope_name = L"local"; break; } case ENV_GLOBAL: { scope_name = L"global"; break; } case ENV_UNIVERSAL: { scope_name = L"universal"; break; } default: { DIE("invalid scope"); break; } } const auto var = vars.get(var_name, scope); if (!var) { streams.out.append_format(_(L"$%ls: not set in %ls scope\n"), var_name, scope_name); return; } const wchar_t *exportv = var->exports() ? _(L"exported") : _(L"unexported"); wcstring_list_t vals = var->as_list(); streams.out.append_format(_(L"$%ls: set in %ls scope, %ls, with %d elements\n"), var_name, scope_name, exportv, vals.size()); for (size_t i = 0; i < vals.size(); i++) { if (vals.size() > 100) { if (i == 50) streams.out.append(L"...\n"); if (i >= 50 && i < vals.size() - 50) continue; } const wcstring value = vals[i]; const wcstring escaped_val = escape_string(value, ESCAPE_NO_QUOTED, STRING_STYLE_SCRIPT); streams.out.append_format(_(L"$%ls[%d]: length=%d value=|%ls|\n"), var_name, i + 1, value.size(), escaped_val.c_str()); } }
void Module::codegenInit(std::ostream &out) const { out << "PyMODINIT_FUNC PyInit_" << name() << "()\n" << "{\n" << " PyObject *mod = PyModule_Create(&module);\n" << " if(!mod) return 0;\n"; { IndentingOStreambuf indenter(out); for(const auto &e : exports()) { e->codegenInit(out); } } out << " return mod;\n}\n"; }
void init(Handle<Object> ex) { ObjectHandle exports(ex); Connection::Initialize(exports); Watch::Initialize(exports); Timeout::Initialize(exports); Message::Initialize(exports); MessageIter::Initialize(exports); PendingCall::Initialize(exports); Server::Initialize(exports); defineFunction(exports, "createMethodCall", Message::CreateMethodCall); defineFunction(exports, "createMethodReturn", Message::CreateMethodReturn); defineFunction(exports, "createErrorMessage", Message::CreateErrorMessage); defineFunction(exports, "createSignal", Message::CreateSignal); defineFunction(exports, "introspectionXmlToJs", introspectionXmlToJs); init_constants(exports); }
void Module::codegenDeclaration(std::ostream &out) const { assert(!_sourceTUPath.empty()); for(int i = 0; i < 10; ++i) { out << "//\n"; } out << "// AUTOGENERATED CONTENT. DO NOT MODIFY.\n"; for(int i = 0; i < 10; ++i) { out << "//\n"; } out << "#include <Python.h>\n"; out << "#include \"autobind.hpp\"\n"; for(const auto &e : exports()) { e->codegenDeclaration(out); } out << boost::format("#include \"%s\"\n") % _sourceTUPath; }
#include "nfsping.h" #include "rpc.h" #include "util.h" /* local prototypes */ static void usage(void); static u_int mount_perror(mountstat3); static mountres3 *get_root_filehandle(char *, CLIENT *, char *); static int print_exports(char *, struct exportnode *); /* globals */ int verbose = 0; void usage() { printf("Usage: nfsmount [options] host[:mountpoint]\n\ -e print exports (like showmount -e)\n\ -h display this help and exit\n\ -m use multiple target IP addresses if found\n\ -S addr set source address\n\ -T use TCP (default UDP)\n\ -v verbose output\n\ "); exit(3); } u_int mount_perror(mountstat3 fhs_status) { static const char *labels[] = { [MNT3ERR_NOENT] = "MNT3ERR_NOENT", [MNT3ERR_ACCES] = "MNT3ERR_ACCES",