MCPcopy Create free account
hub / github.com/buke/quickjs-go / js_std_init

Function js_std_init

deps/quickjs/quickjs-libc.c:1970–1992  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1968};
1969
1970static int js_std_init(JSContext *ctx, JSModuleDef *m)
1971{
1972 JSValue proto;
1973 JSRuntime *rt = JS_GetRuntime(ctx);
1974 JSThreadState *ts = js_get_thread_state(rt);
1975
1976 /* FILE class */
1977 /* the class ID is created once */
1978 JS_NewClassID(rt, &ts->std_file_class_id);
1979 /* the class is created once per runtime */
1980 JS_NewClass(rt, ts->std_file_class_id, &js_std_file_class);
1981 proto = JS_NewObject(ctx);
1982 JS_SetPropertyFunctionList(ctx, proto, js_std_file_proto_funcs,
1983 countof(js_std_file_proto_funcs));
1984 JS_SetClassProto(ctx, ts->std_file_class_id, proto);
1985
1986 JS_SetModuleExportList(ctx, m, js_std_funcs,
1987 countof(js_std_funcs));
1988 JS_SetModuleExport(ctx, m, "in", js_new_std_file(ctx, stdin, false));
1989 JS_SetModuleExport(ctx, m, "out", js_new_std_file(ctx, stdout, false));
1990 JS_SetModuleExport(ctx, m, "err", js_new_std_file(ctx, stderr, false));
1991 return 0;
1992}
1993
1994JSModuleDef *js_init_module_std(JSContext *ctx, const char *module_name)
1995{

Callers

nothing calls this directly

Calls 2

js_get_thread_stateFunction · 0.85
js_new_std_fileFunction · 0.85

Tested by

no test coverage detected