|
|
@ -9,7 +9,7 @@ char console_log_buf[CONSOLE_LOG_BUF_SIZE];
|
|
9
|
9
|
|
|
10
|
10
|
JSStringRef to_string(JSContextRef ctx, JSValueRef val);
|
|
11
|
11
|
|
|
12
|
|
JSValueRef console_log(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
|
|
|
12
|
JSValueRef function_console_log(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
|
|
13
|
13
|
for (int i = 0; i < argumentCount; i++) {
|
|
14
|
14
|
if (i > 0) {
|
|
15
|
15
|
fprintf(stdout, " ");
|
|
|
@ -24,7 +24,7 @@ JSValueRef console_log(JSContextRef ctx, JSObjectRef function, JSObjectRef thisO
|
|
24
|
24
|
return JSValueMakeUndefined(ctx);
|
|
25
|
25
|
}
|
|
26
|
26
|
|
|
27
|
|
JSValueRef console_error(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
|
|
|
27
|
JSValueRef function_console_error(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
|
|
28
|
28
|
for (int i = 0; i < argumentCount; i++) {
|
|
29
|
29
|
if (i > 0) {
|
|
30
|
30
|
fprintf(stderr, " ");
|
|
|
@ -56,8 +56,8 @@ int main(int argc, char **argv) {
|
|
56
|
56
|
|
|
57
|
57
|
JSObjectRef global_obj = JSContextGetGlobalObject(ctx);
|
|
58
|
58
|
|
|
59
|
|
register_global_function(ctx, "CONSOLE_LOG", console_log);
|
|
60
|
|
register_global_function(ctx, "CONSOLE_ERROR", console_error);
|
|
|
59
|
register_global_function(ctx, "CONSOLE_LOG", function_console_log);
|
|
|
60
|
register_global_function(ctx, "CONSOLE_ERROR", function_console_error);
|
|
61
|
61
|
|
|
62
|
62
|
JSStringRef init_source = JSStringCreateWithUTF8CString("<init>");
|
|
63
|
63
|
JSStringRef init_script = JSStringCreateWithUTF8CString("var console = {};"\
|