#include <signal.h>
JSValueRef seed_print_ref;
+JSValueRef seed_printerr_ref;
static JSValueRef
seed_include (JSContextRef ctx,
return JSValueMakeUndefined (ctx);
}
+static JSValueRef
+seed_printerr (JSContextRef ctx,
+ JSObjectRef function,
+ JSObjectRef this_object,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef *exception)
+{
+ gchar *buf;
+ if (argumentCount != 1)
+ {
+ seed_make_exception (ctx, exception, "ArgumentError",
+ "printerr expected 1 argument, got %zd",
+ argumentCount);
+ return JSValueMakeNull (ctx);
+ }
+
+ buf = seed_value_to_string (ctx, arguments[0], exception);
+
+ g_printerr ("%s\n", buf);
+ g_free (buf);
+
+ return JSValueMakeUndefined (ctx);
+}
+
const gchar *
seed_g_type_name_to_string (GITypeInfo * type)
{
seed_print_ref);
JSValueProtect (local_eng->context, seed_print_ref);
+ seed_printerr_ref =
+ JSObjectMakeFunctionWithCallback (local_eng->context, NULL, &seed_printerr);
+ seed_object_set_property (local_eng->context, obj, "printerr", seed_printerr_ref);
+ seed_object_set_property (local_eng->context, local_eng->global, "printerr",
+ seed_printerr_ref);
+ JSValueProtect (local_eng->context, seed_printerr_ref);
+
seed_create_function (local_eng->context,
"check_syntax", &seed_check_syntax, obj);
seed_create_function (local_eng->context,
#include "seed-private.h"
extern JSValueRef seed_print_ref;
+extern JSValueRef seed_printerr_ref;
void seed_init_builtins (SeedEngine * local_eng, gint * argc, gchar *** argv);
};
#endif /* SEED_ENABLE_DEBUG */
-static bool
+static bool
seed_gobject_has_instance (JSContextRef ctx, JSObjectRef constructor,
JSValueRef possible_instance, JSValueRef* exception)
{
!JSValueIsObject (ctx, possible_instance) ||
!JSValueIsObjectOfClass (ctx, possible_instance, gobject_class))
return FALSE;
-
+
constructor_type = (GType) JSObjectGetPrivate (constructor);
value_type = G_OBJECT_TYPE ((GObject *)
JSObjectGetPrivate ((JSObjectRef) possible_instance));
seed_object_set_property (ctx, global, "GType", seed_gtype_constructor);
seed_object_set_property (ctx, global, "Seed", seed_obj_ref);
seed_object_set_property (ctx, global, "print", seed_print_ref);
+ seed_object_set_property (ctx, global, "printerr", seed_printerr_ref);
JSEvaluateScript (ctx, defaults_script, NULL, NULL, 0, NULL);
JSValueUnprotect (eng->context, eng->global);
JSGlobalContextRelease (eng->context);
JSContextGroupRelease (eng->group);
-
+
g_free (eng);
}
SEED_NOTE (MISC, "failed to parse arguments.");
return FALSE;
}
-
+
if (seed_arg_print_version)
{
g_print("%s\n", "Seed " VERSION);
return seed_init_with_context_group (argc, argv, context_group);
}
+