From d9b8933448424734187eff430bab92a730bada50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Jare=C5=A1?= Date: Wed, 26 Apr 2023 14:56:08 +0200 Subject: [PATCH 1/3] Rename modules os to cm_os and std to cm_std (originally #370) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pavel Jareš --- c/embeddedjs.c | 116 ++++++++++++++++++++++++-------------------- tests/js/config1.js | 1 - tests/js/net1.js | 2 - tests/js/zos1.js | 1 - 4 files changed, 64 insertions(+), 56 deletions(-) diff --git a/c/embeddedjs.c b/c/embeddedjs.c index a5b46f97a..811b4b721 100644 --- a/c/embeddedjs.c +++ b/c/embeddedjs.c @@ -72,6 +72,64 @@ typedef int64_t ssize_t; #include "nativeconversion.h" +#if defined(__IBMC__) || defined(__IBMCPP__) +#pragma convert(819) +#endif + +static char asciiStack[6] = "stack"; + +static char msgsndASCII[7] = "msgsnd"; +static char msgrcvASCII[7] = "msgrcv"; +static char msgctlASCII[7] = "msgctl"; +static char msggetASCII[7] = "msgget"; +static char chmodASCII[6] = "chmom"; + +static char IPC_PRIVATE_ASCII[12] = "IPC_PRIVATE"; +static char IPC_CREAT_ASCII[10] = "IPC_CREAT"; +static char IPC_EXCL_ASCII[9] = "IPC_EXCL"; +static char IPC_NOWAIT_ASCII[11] = "IPC_NOWAIT"; +static char MSG_EXCEPT_ASCII[11] = "MSG_EXCEPT"; +static char MSG_NOERROR_ASCII[12] = "MSG_NOERROR"; + +static char fileCopyASCII[9] = "fileCopy"; +static char fileCopyConvertedASCII[18] = "fileCopyConverted"; +static char dirnameASCII[8] = "dirname"; +static char stringFromBytesASCII[16] = "stringFromBytes"; + +static char getpidASCII[7] = "getpid"; +static char getppidASCII[8] = "getppid"; + +static char AUTO_DETECT_ASCII[12] = "AUTO_DETECT"; +static char NO_CONVERT_ASCII[11] = "NO_CONVERT"; +static char loadFileUTF8ASCII[13] = "loadFileUTF8"; +static char storeFileUTF8ASCII[14] = "storeFileUTF8"; +static char appendFileUTF8ASCII[15] = "appendFileUTF8"; +static char tcpPingASCII[8] = "tcpPing"; + +static char asciiPrototype[10] = "prototype"; + +// TODO: remove next major release, deprecated module std, it is replaced by cm_std +static char asciiSTD[4] = "std"; +// TODO: remove next major release, deprecated module os, it is replaced by cm_os +static char asciiOS[3] = "os"; +static char asciiCM_STD[7] = "cm_std"; +static char asciiCM_OS[6] = "cm_os"; +static char asciiExperiment[11] = "experiment"; +static char asciiZOS[4] = "zos"; +static char asciiNet[4] = "net"; +static char asciiPosix[6] = "posix"; +static char asciiXPlatform[10] = "xplatform"; + +static char lengthASCII[7] = "length"; + +static char asciiConsole[8] = "console"; +static char asciiLog[4] = "log"; +static char asciiDotJS[4] = ".js"; + +#if defined(__IBMC__) || defined(__IBMCPP__) +#pragma convert(pop) +#endif + struct trace_malloc_data { uint8_t *base; }; @@ -127,8 +185,6 @@ static void ejsDumpObject(JSContext *ctx, FILE *f, JSValueConst val) } } -static char asciiStack[6] ={ 0x73, 0x74, 0x61, 0x63, 0x6b, 0x00}; - static void ejsDumpError(JSContext *ctx, JSValueConst exception_val) { JSValue val; @@ -440,19 +496,6 @@ static JSValue posixIconvOpen(JSContext *ctx, JSValueConst this_val, #endif } -static char msgsndASCII[7] ={ 0x6d, 0x73, 0x67, 0x73, 0x6e, 0x64, 0x00}; -static char msgrcvASCII[7] ={ 0x6d, 0x73, 0x67, 0x72, 0x63, 0x76, 0x00}; -static char msgctlASCII[7] ={ 0x6d, 0x73, 0x67, 0x63, 0x74, 0x6c, 0x00}; -static char msggetASCII[7] ={ 0x6d, 0x73, 0x67, 0x67, 0x65, 0x74, 0x00}; -static char chmodASCII[6] ={ 0x63, 0x68, 0x6d, 0x6f, 0x6d, 0x00}; - -static char IPC_PRIVATE_ASCII[12] ={ 0x49, 0x50, 0x43, 0x5f, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x00}; -static char IPC_CREAT_ASCII[10] ={ 0x49, 0x50, 0x43, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x00}; -static char IPC_EXCL_ASCII[9] = { 0x49, 0x50, 0x43, 0x5f, 0x45, 0x58, 0x43, 0x4c, 0x00}; -static char IPC_NOWAIT_ASCII[11] ={0x49, 0x50, 0x43, 0x5f, 0x4e, 0x4f, 0x57, 0x41, 0x49, 0x54, 0x00}; -static char MSG_EXCEPT_ASCII[11] ={0x4d, 0x53, 0x47, 0x5f, 0x45, 0x58, 0x43, 0x45, 0x50, 0x54, 0x00}; -static char MSG_NOERROR_ASCII[12] ={0x4d, 0x53, 0x47, 0x5f, 0x4e, 0x4f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x00}; - /* ZOS Might not define all constants ?? (or not might not implement) */ #ifndef MSG_EXCEPT #define MSG_EXCEPT 020000 /* recv any msg except of specified type.*/ @@ -765,23 +808,6 @@ static JSValue xplatformGetpid(JSContext *ctx, JSValueConst this_val, return JS_NewInt64(ctx,(int64_t)pid); } - -static char fileCopyASCII[9] = {0x66, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x70, 0x79, 0x00 }; -static char fileCopyConvertedASCII[18] = {0x66, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x70, 0x79, - 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x00 }; -static char dirnameASCII[8] = {0x64, 0x69, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x00 }; -static char stringFromBytesASCII[16] = {0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x46, 0x72, 0x6f, 0x6d, 0x42, 0x79, 0x74, 0x65, 0x73, 0x00 }; - -static char getpidASCII[7] = {0x67, 0x65, 0x74, 0x70, 0x69, 0x64, 0x00 }; -static char getppidASCII[8] = {0x67, 0x65, 0x74, 0x70, 0x70, 0x69, 0x64, 0x00 }; - -static char AUTO_DETECT_ASCII[12] = {0x41, 0x55, 0x54, 0x4f, 0x5f, 0x44, 0x45, 0x54, 0x45, 0x43, 0x54, 0x00 }; -static char NO_CONVERT_ASCII[11] = {0x4e, 0x4f, 0x5f, 0x43, 0x4f, 0x4e, 0x56, 0x45, 0x52, 0x54, 0x00 }; -static char loadFileUTF8ASCII[13] = {0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x55, 0x54, 0x46, 0x38, 0x00 }; -static char storeFileUTF8ASCII[14] = {0x73, 0x74, 0x6f, 0x72, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x55, 0x54, 0x46, 0x38, 0x00 }; -static char appendFileUTF8ASCII[15] = {0x61, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x55, 0x54, 0x46, 0x38, 0x00 }; -static char tcpPingASCII[8] ={0x74, 0x63, 0x70, 0x50, 0x69, 0x6e, 0x67, 0x00}; - static const JSCFunctionListEntry xplatformFunctions[] = { JS_CFUNC_DEF(fileCopyASCII, 2, xplatformFileCopy), JS_CFUNC_DEF(fileCopyConvertedASCII, 4, xplatformFileCopyConverted), @@ -1061,9 +1087,6 @@ static const JSCFunctionListEntry js_experiment_funcs[] = { JS_CFUNC_DEF("boop", 0, js_experiment_boop ), }; -static char asciiPrototype[10] = { 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x74, 0x79, 0x70, 0x65, 0}; - static JSValue thingy_ctor(JSContext *ctx, JSValueConst new_target, int argc, JSValueConst *argv){ JSValue obj = JS_UNDEFINED, proto; @@ -1134,16 +1157,6 @@ static int js_experiment_init(JSContext *ctx, JSModuleDef *m) return 0; } -static char asciiSTD[4] ={ 0x73, 0x74, 0x64, 0}; -static char asciiOS[3] ={ 0x6F, 0x73, 0}; -static char asciiExperiment[11] ={ 0x65, 0x78, 0x70, 0x65, - 0x72, 0x69, 0x6d, 0x65, - 0x6e, 0x74, 0}; -static char asciiZOS[4] = { 0x7a, 0x6F, 0x73, 0}; -static char asciiNet[4] = { 0x6e, 0x65, 0x74, 0}; -static char asciiPosix[6] = { 0x70, 0x6F, 0x73, 0x69, 0x78, 0}; -static char asciiXPlatform[10] = { 0x78, 0x70, 0x6C, 0x61, 0x74, 0x66, 0x6F, 0x72, 0x6D, 0}; - JSModuleDef *js_init_module_experiment(JSContext *ctx, const char *module_name) { JSModuleDef *m; @@ -1439,8 +1452,14 @@ static JSContext *makeEmbeddedJSContext(JSRuntime *rt){ static void initContextModules(JSContext *ctx, EJSNativeModule **nativeModules, int nativeModuleCount){ /* system modules */ /* printf("before init std\n");*/ + + // TODO: remove next major release, deprecated module std, it is replaced by cm_std js_init_module_std(ctx, asciiSTD); + // TODO: remove next major release, deprecated module os, it is replaced by cm_os js_init_module_os(ctx, asciiOS); + + js_init_module_std(ctx, asciiCM_STD); + js_init_module_os(ctx, asciiCM_OS); js_init_module_experiment(ctx, asciiExperiment); ejsInitModuleZOS(ctx, asciiZOS); ejsInitModuleNet(ctx, asciiNet); @@ -1527,8 +1546,6 @@ static char *copyToNative(const char *source, ShortLivedHeap *slh){ return dest; } -static char lengthASCII[7] ={0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x00}; - static Json *jsToJson1(EmbeddedJS *ejs, JsonBuilder *b, Json *parent, char *parentKey, JSValue value, @@ -1948,9 +1965,6 @@ static JSValue js_native_print(JSContext *ctx, JSValueConst this_val, return JS_UNDEFINED; } -static char asciiConsole[8] = { 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x00 }; -static char asciiLog[4] = { 0x6c, 0x6f, 0x67, 0x00}; - static bool endsWith(char *s, char *suffix){ int len = strlen(s); int suffixLen = strlen(suffix); @@ -1960,8 +1974,6 @@ static bool endsWith(char *s, char *suffix){ return !memcmp(s+len-suffixLen,suffix,suffixLen); } -static char asciiDotJS[4] = { 0x2e, 0x6a, 0x73, 0x00 }; - JSModuleDef *ejsModuleLoader(JSContext *ctx, const char *moduleName, void *opaque) { JSModuleDef *m; diff --git a/tests/js/config1.js b/tests/js/config1.js index 73107e923..26cf80b3d 100644 --- a/tests/js/config1.js +++ b/tests/js/config1.js @@ -1,4 +1,3 @@ -import * as os from 'os'; import { ConfigManager } from "Configuration"; console.log("hello ConfigMgr, args were ["+scriptArgs+"]"); diff --git a/tests/js/net1.js b/tests/js/net1.js index 16ec03294..c2c437482 100644 --- a/tests/js/net1.js +++ b/tests/js/net1.js @@ -1,5 +1,3 @@ -import * as zos from 'zos'; -import * as os from 'os'; import * as net from 'net'; /* diff --git a/tests/js/zos1.js b/tests/js/zos1.js index ea0c0d32c..37b02204f 100644 --- a/tests/js/zos1.js +++ b/tests/js/zos1.js @@ -1,5 +1,4 @@ import * as zos from 'zos'; -import * as os from 'os'; var test1 = function(filename){ let zstats = zos.zstat(filename); From 8679fe8cd1ab2667428f19a8426627fb2716ae7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Jare=C5=A1?= Date: Fri, 28 Apr 2023 16:26:33 +0200 Subject: [PATCH 2/3] different confition to encode in ascii MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pavel Jareš --- c/embeddedjs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/c/embeddedjs.c b/c/embeddedjs.c index 811b4b721..f11f40252 100644 --- a/c/embeddedjs.c +++ b/c/embeddedjs.c @@ -72,7 +72,7 @@ typedef int64_t ssize_t; #include "nativeconversion.h" -#if defined(__IBMC__) || defined(__IBMCPP__) +#ifdef __ZOWE_OS_ZOS #pragma convert(819) #endif @@ -126,7 +126,7 @@ static char asciiConsole[8] = "console"; static char asciiLog[4] = "log"; static char asciiDotJS[4] = ".js"; -#if defined(__IBMC__) || defined(__IBMCPP__) +#ifdef __ZOWE_OS_ZOS #pragma convert(pop) #endif From 8c2ed407d4d3186630f787233b006ffad879621b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Jare=C5=A1?= Date: Fri, 28 Apr 2023 16:55:24 +0200 Subject: [PATCH 3/3] rollback encoding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pavel Jareš --- c/embeddedjs.c | 112 ++++++++++++++++++++++++------------------------- 1 file changed, 54 insertions(+), 58 deletions(-) diff --git a/c/embeddedjs.c b/c/embeddedjs.c index f11f40252..2628940c2 100644 --- a/c/embeddedjs.c +++ b/c/embeddedjs.c @@ -72,64 +72,6 @@ typedef int64_t ssize_t; #include "nativeconversion.h" -#ifdef __ZOWE_OS_ZOS -#pragma convert(819) -#endif - -static char asciiStack[6] = "stack"; - -static char msgsndASCII[7] = "msgsnd"; -static char msgrcvASCII[7] = "msgrcv"; -static char msgctlASCII[7] = "msgctl"; -static char msggetASCII[7] = "msgget"; -static char chmodASCII[6] = "chmom"; - -static char IPC_PRIVATE_ASCII[12] = "IPC_PRIVATE"; -static char IPC_CREAT_ASCII[10] = "IPC_CREAT"; -static char IPC_EXCL_ASCII[9] = "IPC_EXCL"; -static char IPC_NOWAIT_ASCII[11] = "IPC_NOWAIT"; -static char MSG_EXCEPT_ASCII[11] = "MSG_EXCEPT"; -static char MSG_NOERROR_ASCII[12] = "MSG_NOERROR"; - -static char fileCopyASCII[9] = "fileCopy"; -static char fileCopyConvertedASCII[18] = "fileCopyConverted"; -static char dirnameASCII[8] = "dirname"; -static char stringFromBytesASCII[16] = "stringFromBytes"; - -static char getpidASCII[7] = "getpid"; -static char getppidASCII[8] = "getppid"; - -static char AUTO_DETECT_ASCII[12] = "AUTO_DETECT"; -static char NO_CONVERT_ASCII[11] = "NO_CONVERT"; -static char loadFileUTF8ASCII[13] = "loadFileUTF8"; -static char storeFileUTF8ASCII[14] = "storeFileUTF8"; -static char appendFileUTF8ASCII[15] = "appendFileUTF8"; -static char tcpPingASCII[8] = "tcpPing"; - -static char asciiPrototype[10] = "prototype"; - -// TODO: remove next major release, deprecated module std, it is replaced by cm_std -static char asciiSTD[4] = "std"; -// TODO: remove next major release, deprecated module os, it is replaced by cm_os -static char asciiOS[3] = "os"; -static char asciiCM_STD[7] = "cm_std"; -static char asciiCM_OS[6] = "cm_os"; -static char asciiExperiment[11] = "experiment"; -static char asciiZOS[4] = "zos"; -static char asciiNet[4] = "net"; -static char asciiPosix[6] = "posix"; -static char asciiXPlatform[10] = "xplatform"; - -static char lengthASCII[7] = "length"; - -static char asciiConsole[8] = "console"; -static char asciiLog[4] = "log"; -static char asciiDotJS[4] = ".js"; - -#ifdef __ZOWE_OS_ZOS -#pragma convert(pop) -#endif - struct trace_malloc_data { uint8_t *base; }; @@ -185,6 +127,8 @@ static void ejsDumpObject(JSContext *ctx, FILE *f, JSValueConst val) } } +static char asciiStack[6] ={ 0x73, 0x74, 0x61, 0x63, 0x6b, 0x00}; + static void ejsDumpError(JSContext *ctx, JSValueConst exception_val) { JSValue val; @@ -496,6 +440,19 @@ static JSValue posixIconvOpen(JSContext *ctx, JSValueConst this_val, #endif } +static char msgsndASCII[7] ={ 0x6d, 0x73, 0x67, 0x73, 0x6e, 0x64, 0x00}; +static char msgrcvASCII[7] ={ 0x6d, 0x73, 0x67, 0x72, 0x63, 0x76, 0x00}; +static char msgctlASCII[7] ={ 0x6d, 0x73, 0x67, 0x63, 0x74, 0x6c, 0x00}; +static char msggetASCII[7] ={ 0x6d, 0x73, 0x67, 0x67, 0x65, 0x74, 0x00}; +static char chmodASCII[6] ={ 0x63, 0x68, 0x6d, 0x6f, 0x6d, 0x00}; + +static char IPC_PRIVATE_ASCII[12] ={ 0x49, 0x50, 0x43, 0x5f, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x00}; +static char IPC_CREAT_ASCII[10] ={ 0x49, 0x50, 0x43, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x00}; +static char IPC_EXCL_ASCII[9] = { 0x49, 0x50, 0x43, 0x5f, 0x45, 0x58, 0x43, 0x4c, 0x00}; +static char IPC_NOWAIT_ASCII[11] ={0x49, 0x50, 0x43, 0x5f, 0x4e, 0x4f, 0x57, 0x41, 0x49, 0x54, 0x00}; +static char MSG_EXCEPT_ASCII[11] ={0x4d, 0x53, 0x47, 0x5f, 0x45, 0x58, 0x43, 0x45, 0x50, 0x54, 0x00}; +static char MSG_NOERROR_ASCII[12] ={0x4d, 0x53, 0x47, 0x5f, 0x4e, 0x4f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x00}; + /* ZOS Might not define all constants ?? (or not might not implement) */ #ifndef MSG_EXCEPT #define MSG_EXCEPT 020000 /* recv any msg except of specified type.*/ @@ -808,6 +765,23 @@ static JSValue xplatformGetpid(JSContext *ctx, JSValueConst this_val, return JS_NewInt64(ctx,(int64_t)pid); } + +static char fileCopyASCII[9] = {0x66, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x70, 0x79, 0x00 }; +static char fileCopyConvertedASCII[18] = {0x66, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x70, 0x79, + 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x00 }; +static char dirnameASCII[8] = {0x64, 0x69, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x00 }; +static char stringFromBytesASCII[16] = {0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x46, 0x72, 0x6f, 0x6d, 0x42, 0x79, 0x74, 0x65, 0x73, 0x00 }; + +static char getpidASCII[7] = {0x67, 0x65, 0x74, 0x70, 0x69, 0x64, 0x00 }; +static char getppidASCII[8] = {0x67, 0x65, 0x74, 0x70, 0x70, 0x69, 0x64, 0x00 }; + +static char AUTO_DETECT_ASCII[12] = {0x41, 0x55, 0x54, 0x4f, 0x5f, 0x44, 0x45, 0x54, 0x45, 0x43, 0x54, 0x00 }; +static char NO_CONVERT_ASCII[11] = {0x4e, 0x4f, 0x5f, 0x43, 0x4f, 0x4e, 0x56, 0x45, 0x52, 0x54, 0x00 }; +static char loadFileUTF8ASCII[13] = {0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x55, 0x54, 0x46, 0x38, 0x00 }; +static char storeFileUTF8ASCII[14] = {0x73, 0x74, 0x6f, 0x72, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x55, 0x54, 0x46, 0x38, 0x00 }; +static char appendFileUTF8ASCII[15] = {0x61, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x55, 0x54, 0x46, 0x38, 0x00 }; +static char tcpPingASCII[8] ={0x74, 0x63, 0x70, 0x50, 0x69, 0x6e, 0x67, 0x00}; + static const JSCFunctionListEntry xplatformFunctions[] = { JS_CFUNC_DEF(fileCopyASCII, 2, xplatformFileCopy), JS_CFUNC_DEF(fileCopyConvertedASCII, 4, xplatformFileCopyConverted), @@ -1087,6 +1061,9 @@ static const JSCFunctionListEntry js_experiment_funcs[] = { JS_CFUNC_DEF("boop", 0, js_experiment_boop ), }; +static char asciiPrototype[10] = { 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x74, 0x79, 0x70, 0x65, 0}; + static JSValue thingy_ctor(JSContext *ctx, JSValueConst new_target, int argc, JSValueConst *argv){ JSValue obj = JS_UNDEFINED, proto; @@ -1157,6 +1134,18 @@ static int js_experiment_init(JSContext *ctx, JSModuleDef *m) return 0; } +static char asciiSTD[4] ={ 0x73, 0x74, 0x64, 0}; +static char asciiOS[3] ={ 0x6F, 0x73, 0}; +static char asciiCM_STD[7] = { 0x63, 0x6d, 0x5f, 0x73, 0x74, 0x64, 0 }; +static char asciiCM_OS[6] = { 0x63, 0x6d, 0x5f, 0x6f, 0x73, 0 }; +static char asciiExperiment[11] ={ 0x65, 0x78, 0x70, 0x65, + 0x72, 0x69, 0x6d, 0x65, + 0x6e, 0x74, 0}; +static char asciiZOS[4] = { 0x7a, 0x6F, 0x73, 0}; +static char asciiNet[4] = { 0x6e, 0x65, 0x74, 0}; +static char asciiPosix[6] = { 0x70, 0x6F, 0x73, 0x69, 0x78, 0}; +static char asciiXPlatform[10] = { 0x78, 0x70, 0x6C, 0x61, 0x74, 0x66, 0x6F, 0x72, 0x6D, 0}; + JSModuleDef *js_init_module_experiment(JSContext *ctx, const char *module_name) { JSModuleDef *m; @@ -1546,6 +1535,8 @@ static char *copyToNative(const char *source, ShortLivedHeap *slh){ return dest; } +static char lengthASCII[7] ={0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x00}; + static Json *jsToJson1(EmbeddedJS *ejs, JsonBuilder *b, Json *parent, char *parentKey, JSValue value, @@ -1965,6 +1956,9 @@ static JSValue js_native_print(JSContext *ctx, JSValueConst this_val, return JS_UNDEFINED; } +static char asciiConsole[8] = { 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x00 }; +static char asciiLog[4] = { 0x6c, 0x6f, 0x67, 0x00}; + static bool endsWith(char *s, char *suffix){ int len = strlen(s); int suffixLen = strlen(suffix); @@ -1974,6 +1968,8 @@ static bool endsWith(char *s, char *suffix){ return !memcmp(s+len-suffixLen,suffix,suffixLen); } +static char asciiDotJS[4] = { 0x2e, 0x6a, 0x73, 0x00 }; + JSModuleDef *ejsModuleLoader(JSContext *ctx, const char *moduleName, void *opaque) { JSModuleDef *m;