|
|
|
|
|
|
82
|
JSValueRef function_read_file(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject,
|
82
|
JSValueRef function_read_file(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject,
|
|
83
|
size_t argc, const JSValueRef args[], JSValueRef* exception) {
|
83
|
size_t argc, const JSValueRef args[], JSValueRef* exception) {
|
|
84
|
// TODO: implement fully
|
84
|
// TODO: implement fully
|
|
85
|
fprintf(stderr, "WARN: %s: stub\n", __func__);
|
|
|
|
86
|
|
85
|
|
|
87
|
if (argc == 1 && JSValueGetType(ctx, args[0]) == kJSTypeString) {
|
86
|
if (argc == 1 && JSValueGetType(ctx, args[0]) == kJSTypeString) {
|
|
88
|
char path[100];
|
87
|
char path[100];
|
|
|
|
|
|
|
90
|
JSStringGetUTF8CString(path_str, path, 100);
|
89
|
JSStringGetUTF8CString(path_str, path, 100);
|
|
91
|
JSStringRelease(path_str);
|
90
|
JSStringRelease(path_str);
|
|
92
|
|
91
|
|
|
93
|
debug_print_value("read_file", ctx, args[0]);
|
|
|
|
|
|
92
|
// debug_print_value("read_file", ctx, args[0]);
|
|
94
|
|
93
|
|
|
95
|
char full_path[150];
|
94
|
char full_path[150];
|
|
96
|
// TODO: should not load from here?
|
95
|
// TODO: should not load from here?
|
|
|
|
|
|
|
115
|
JSValueRef function_load(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject,
|
114
|
JSValueRef function_load(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject,
|
|
116
|
size_t argc, const JSValueRef args[], JSValueRef* exception) {
|
115
|
size_t argc, const JSValueRef args[], JSValueRef* exception) {
|
|
117
|
// TODO: implement fully
|
116
|
// TODO: implement fully
|
|
118
|
fprintf(stderr, "WARN: %s: stub\n", __func__);
|
|
|
|
119
|
|
117
|
|
|
120
|
if (argc == 1 && JSValueGetType(ctx, args[0]) == kJSTypeString) {
|
118
|
if (argc == 1 && JSValueGetType(ctx, args[0]) == kJSTypeString) {
|
|
121
|
char path[100];
|
119
|
char path[100];
|
|
|
|
|
|
|
123
|
JSStringGetUTF8CString(path_str, path, 100);
|
121
|
JSStringGetUTF8CString(path_str, path, 100);
|
|
124
|
JSStringRelease(path_str);
|
122
|
JSStringRelease(path_str);
|
|
125
|
|
123
|
|
|
126
|
debug_print_value("load", ctx, args[0]);
|
|
|
|
|
|
124
|
// debug_print_value("load", ctx, args[0]);
|
|
127
|
|
125
|
|
|
128
|
char full_path[150];
|
126
|
char full_path[150];
|
|
129
|
// TODO: should not load from here?
|
127
|
// TODO: should not load from here?
|
|
|
|
|
|
|
209
|
if (argc == 2
|
207
|
if (argc == 2
|
|
210
|
&& JSValueGetType(ctx, args[0]) == kJSTypeString
|
208
|
&& JSValueGetType(ctx, args[0]) == kJSTypeString
|
|
211
|
&& JSValueGetType(ctx, args[1]) == kJSTypeString) {
|
209
|
&& JSValueGetType(ctx, args[1]) == kJSTypeString) {
|
|
212
|
debug_print_value("eval", ctx, args[0]);
|
|
|
|
|
|
210
|
// debug_print_value("eval", ctx, args[0]);
|
|
213
|
|
211
|
|
|
214
|
JSStringRef sourceRef = JSValueToStringCopy(ctx, args[0], NULL);
|
212
|
JSStringRef sourceRef = JSValueToStringCopy(ctx, args[0], NULL);
|
|
215
|
JSStringRef pathRef = JSValueToStringCopy(ctx, args[1], NULL);
|
213
|
JSStringRef pathRef = JSValueToStringCopy(ctx, args[1], NULL);
|
|
|
|
|
|
|
726
|
return buf;
|
724
|
return buf;
|
|
727
|
|
725
|
|
|
728
|
err:
|
726
|
err:
|
|
729
|
printf("get_contents(\"%s\"): %s: %s\n", path, err_prefix, strerror(errno));
|
|
|
|
|
|
727
|
//printf("get_contents(\"%s\"): %s: %s\n", path, err_prefix, strerror(errno));
|
|
730
|
return NULL;
|
728
|
return NULL;
|
|
731
|
}
|
729
|
}
|
|
732
|
|
730
|
|