28
22
GameJSParser * self = malloc (sizeof(GameJSParser));
29
23
if (file_name != NULL && stript != NULL) {
31
"You can not use both a script and a file when creating a GameJSParser.\n"
32
"Exacly ONE of these must be used."
25
"============================================================================\n"
26
"You can not use both a script and a file when creating a GameJSParser.\n"
27
"Exacly ONE of these must be used.\n"
28
"============================================================================\n"
34
30
game_js_parser_free (self);
36
32
} else if (file_name == NULL && stript == NULL) {
38
"WARNING: No script or file is set when constructing GameJSParser"
34
"============================================================================\n"
35
"WARNING: No script or file is set when constructing GameJSParser\n"
36
"============================================================================\n"
39
game_js_parser_free (self);
42
43
self->js_rt = JS_NewRuntime (JS_RUNTIME_SIZE);
44
45
if (!self->js_rt) {
45
print_error ("Could not contruct JSRunTime.");
47
"============================================================================\n"
48
"Could not contruct JSRunTime.\n"
49
"============================================================================\n"
49
self->js_cx = JS_NewContext (self->js_rt, 1024 * 8); /* Do not change. **/
54
self->js_cx = JS_NewContext (self->js_rt, 1024 * 8); /** Do not change. **/
51
56
if (!self->js_cx) {
52
print_error ("Could not contruct JSContext.");
58
"============================================================================\n"
59
"Could not contruct JSContext.\n"
60
"============================================================================\n"
53
62
game_js_parser_free (self);
56
65
self->js_global = JS_NewGlobalObject (self->js_cx, _js_global_class, NULL);
57
66
if (!self->js_global) {
58
print_error ( "Could not contruct the JS runtime global object.");
68
"============================================================================\n"
69
"Could not contruct JS runtime the global object.\n"
70
"============================================================================\n"
59
72
game_js_parser_free (self);