| jsapi-util.h | | jsapi-util.h | |
| | | | |
| skipping to change at line 78 | | skipping to change at line 78 | |
| * do_base_typecheck and priv_from_js | | * do_base_typecheck and priv_from_js | |
| */ | | */ | |
| #define GJS_DEFINE_PRIV_FROM_JS(type, class) \ | | #define GJS_DEFINE_PRIV_FROM_JS(type, class) \ | |
| __attribute__((unused)) static inline JSBool \ | | __attribute__((unused)) static inline JSBool \ | |
| do_base_typecheck(JSContext *context, \ | | do_base_typecheck(JSContext *context, \ | |
| JSObject *object, \ | | JSObject *object, \ | |
| JSBool throw) \ | | JSBool throw) \ | |
| { \ | | { \ | |
| return gjs_typecheck_instance(context, object, &class, throw); \ | | return gjs_typecheck_instance(context, object, &class, throw); \ | |
| } \ | | } \ | |
|
| static inline type* \ | | static inline type * \ | |
| priv_from_js(JSContext *context, \ | | priv_from_js(JSContext *context, \ | |
| JSObject *object) \ | | JSObject *object) \ | |
| { \ | | { \ | |
|
| return JS_GetInstancePrivate(context, object, &class, NULL); \ | | type *priv; \ | |
| | | JS_BeginRequest(context); \ | |
| | | priv = JS_GetInstancePrivate(context, object, &class, NULL); \ | |
| | | JS_EndRequest(context); \ | |
| | | return priv; \ | |
| } \ | | } \ | |
| __attribute__((unused)) static JSBool \ | | __attribute__((unused)) static JSBool \ | |
| priv_from_js_with_typecheck(JSContext *context, \ | | priv_from_js_with_typecheck(JSContext *context, \ | |
| JSObject *object, \ | | JSObject *object, \ | |
| type **out) \ | | type **out) \ | |
| { \ | | { \ | |
| if (!do_base_typecheck(context, object, JS_FALSE)) \ | | if (!do_base_typecheck(context, object, JS_FALSE)) \ | |
| return JS_FALSE; \ | | return JS_FALSE; \ | |
| *out = priv_from_js(context, object); \ | | *out = priv_from_js(context, object); \ | |
| return JS_TRUE; \ | | return JS_TRUE; \ | |
| | | | |
| skipping to change at line 125 | | skipping to change at line 129 | |
| #define GJS_DEFINE_PROTO_ABSTRACT(tn, cn) \ | | #define GJS_DEFINE_PROTO_ABSTRACT(tn, cn) \ | |
| _GJS_DEFINE_PROTO_FULL(tn, cn, NULL) | | _GJS_DEFINE_PROTO_FULL(tn, cn, NULL) | |
| | | | |
| #define _GJS_DEFINE_PROTO_FULL(type_name, cname, ctor) \ | | #define _GJS_DEFINE_PROTO_FULL(type_name, cname, ctor) \ | |
| static JSPropertySpec gjs_##cname##_proto_props[]; \ | | static JSPropertySpec gjs_##cname##_proto_props[]; \ | |
| static JSFunctionSpec gjs_##cname##_proto_funcs[]; \ | | static JSFunctionSpec gjs_##cname##_proto_funcs[]; \ | |
| static void gjs_##cname##_finalize(JSContext *context, JSObject *obj); \ | | static void gjs_##cname##_finalize(JSContext *context, JSObject *obj); \ | |
| static JSBool gjs_##cname##_new_resolve(JSContext *context, \ | | static JSBool gjs_##cname##_new_resolve(JSContext *context, \ | |
| JSObject *obj, \ | | JSObject *obj, \ | |
| jsval id, \ | | jsval id, \ | |
|
| uintN flags, \ | | unsigned flags, \ | |
| JSObject **objp) \ | | JSObject **objp) \ | |
| { \ | | { \ | |
| return JS_TRUE; \ | | return JS_TRUE; \ | |
| } \ | | } \ | |
| static struct JSClass gjs_##cname##_class = { \ | | static struct JSClass gjs_##cname##_class = { \ | |
| type_name, \ | | type_name, \ | |
| JSCLASS_HAS_PRIVATE | \ | | JSCLASS_HAS_PRIVATE | \ | |
|
| JSCLASS_NEW_RESOLVE | \ | | JSCLASS_NEW_RESOLVE, \ | |
| JSCLASS_NEW_RESOLVE_GETS_START, \ | | | |
| JS_PropertyStub, \ | | JS_PropertyStub, \ | |
| JS_PropertyStub, \ | | JS_PropertyStub, \ | |
| JS_PropertyStub, \ | | JS_PropertyStub, \ | |
| JS_StrictPropertyStub, \ | | JS_StrictPropertyStub, \ | |
| JS_EnumerateStub,\ | | JS_EnumerateStub,\ | |
| (JSResolveOp) gjs_##cname##_new_resolve, \ | | (JSResolveOp) gjs_##cname##_new_resolve, \ | |
| JS_ConvertStub, \ | | JS_ConvertStub, \ | |
| gjs_##cname##_finalize, \ | | gjs_##cname##_finalize, \ | |
| NULL, \ | | NULL, \ | |
| NULL, \ | | NULL, \ | |
| | | | |
| skipping to change at line 173 | | skipping to change at line 176 | |
| if (prototype == NULL) { \ | | if (prototype == NULL) { \ | |
| return JSVAL_NULL; \ | | return JSVAL_NULL; \ | |
| } \ | | } \ | |
| if (!gjs_object_require_property( \ | | if (!gjs_object_require_property( \ | |
| context, global, NULL, \ | | context, global, NULL, \ | |
| gjs_##cname##_class.name, &rval)) { \ | | gjs_##cname##_class.name, &rval)) { \ | |
| return JSVAL_NULL; \ | | return JSVAL_NULL; \ | |
| } \ | | } \ | |
| if (!JS_DefineProperty(context, module, proto_name, \ | | if (!JS_DefineProperty(context, module, proto_name, \ | |
| rval, NULL, NULL, GJS_MODULE_PROP_FLAGS)) \ | | rval, NULL, NULL, GJS_MODULE_PROP_FLAGS)) \ | |
|
| return JS_FALSE; \ | | return JSVAL_NULL; \ | |
| } \ | | } \ | |
| return rval; \ | | return rval; \ | |
| } | | } | |
| | | | |
| gboolean gjs_init_context_standard (JSContext *context); | | gboolean gjs_init_context_standard (JSContext *context); | |
| | | | |
|
| void gjs_runtime_init (JSRuntime *runtime); | | JSContext* gjs_runtime_get_context (JSRuntime *runtime); | |
| void gjs_runtime_destroy (JSRuntime *runtime); | | | |
| | | | |
| JSContext* gjs_runtime_get_current_context (JSRuntime *runtime); | | | |
| void gjs_runtime_set_default_context (JSRuntime *runtime, | | | |
| JSContext *context); | | | |
| JSContext* gjs_runtime_get_default_context (JSRuntime *runtime); | | | |
| void gjs_runtime_push_context (JSRuntime *runtime, | | | |
| JSContext *context); | | | |
| void gjs_runtime_pop_context (JSRuntime *runtime); | | | |
| JSObject* gjs_get_import_global (JSContext *context); | | JSObject* gjs_get_import_global (JSContext *context); | |
| gboolean gjs_object_has_property (JSContext *context, | | gboolean gjs_object_has_property (JSContext *context, | |
| JSObject *obj, | | JSObject *obj, | |
| const char *property_nam
e); | | const char *property_nam
e); | |
| gboolean gjs_object_get_property (JSContext *context, | | gboolean gjs_object_get_property (JSContext *context, | |
| JSObject *obj, | | JSObject *obj, | |
| const char *property_nam
e, | | const char *property_nam
e, | |
| jsval *value_p); | | jsval *value_p); | |
| gboolean gjs_object_require_property (JSContext *context, | | gboolean gjs_object_require_property (JSContext *context, | |
| JSObject *obj, | | JSObject *obj, | |
| | | | |
| skipping to change at line 214 | | skipping to change at line 208 | |
| JSObject *gjs_new_object_for_constructor (JSContext *context, | | JSObject *gjs_new_object_for_constructor (JSContext *context, | |
| JSClass *clasp, | | JSClass *clasp, | |
| jsval *vp); | | jsval *vp); | |
| JSBool gjs_init_class_dynamic (JSContext *context, | | JSBool gjs_init_class_dynamic (JSContext *context, | |
| JSObject *in_object, | | JSObject *in_object, | |
| JSObject *parent_proto
, | | JSObject *parent_proto
, | |
| const char *ns_name, | | const char *ns_name, | |
| const char *class_name, | | const char *class_name, | |
| JSClass *clasp, | | JSClass *clasp, | |
| JSNative constructor, | | JSNative constructor, | |
|
| uintN nargs, | | unsigned nargs, | |
| JSPropertySpec *ps, | | JSPropertySpec *ps, | |
| JSFunctionSpec *fs, | | JSFunctionSpec *fs, | |
| JSPropertySpec *static_ps, | | JSPropertySpec *static_ps, | |
| JSFunctionSpec *static_fs, | | JSFunctionSpec *static_fs, | |
| JSObject **constructor_
p, | | JSObject **constructor_
p, | |
| JSObject **prototype_p)
; | | JSObject **prototype_p)
; | |
| void gjs_throw_constructor_error (JSContext *context); | | void gjs_throw_constructor_error (JSContext *context); | |
| void gjs_throw_abstract_constructor_error (JSContext *context, | | void gjs_throw_abstract_constructor_error (JSContext *context, | |
| jsval *vp); | | jsval *vp); | |
| | | | |
| JSBool gjs_typecheck_instance (JSContext *context, | | JSBool gjs_typecheck_instance (JSContext *context, | |
| JSObject *obj, | | JSObject *obj, | |
| JSClass *static_clasp, | | JSClass *static_clasp, | |
| JSBool _throw); | | JSBool _throw); | |
| | | | |
| JSObject* gjs_construct_object_dynamic (JSContext *context, | | JSObject* gjs_construct_object_dynamic (JSContext *context, | |
| JSObject *proto, | | JSObject *proto, | |
|
| uintN argc, | | unsigned argc, | |
| jsval *argv); | | jsval *argv); | |
| JSObject* gjs_define_string_array (JSContext *context, | | JSObject* gjs_define_string_array (JSContext *context, | |
| JSObject *obj, | | JSObject *obj, | |
| const char *array_name, | | const char *array_name, | |
| gssize array_length
, | | gssize array_length
, | |
| const char **array_values
, | | const char **array_values
, | |
|
| uintN attrs); | | unsigned attrs); | |
| void gjs_throw (JSContext *context, | | void gjs_throw (JSContext *context, | |
| const char *format, | | const char *format, | |
| ...) G_GNUC_PRINTF (2, 3); | | ...) G_GNUC_PRINTF (2, 3); | |
| void gjs_throw_custom (JSContext *context, | | void gjs_throw_custom (JSContext *context, | |
| const char *error_class, | | const char *error_class, | |
| const char *format, | | const char *format, | |
| ...) G_GNUC_PRINTF (3, 4); | | ...) G_GNUC_PRINTF (3, 4); | |
| void gjs_throw_literal (JSContext *context, | | void gjs_throw_literal (JSContext *context, | |
| const char *string); | | const char *string); | |
| void gjs_throw_g_error (JSContext *context, | | void gjs_throw_g_error (JSContext *context, | |
| | | | |
| skipping to change at line 272 | | skipping to change at line 266 | |
| GjsDebugTopic topic, | | GjsDebugTopic topic, | |
| const char *prefix); | | const char *prefix); | |
| #endif | | #endif | |
| char* gjs_value_debug_string (JSContext *context, | | char* gjs_value_debug_string (JSContext *context, | |
| jsval value); | | jsval value); | |
| void gjs_explain_scope (JSContext *context, | | void gjs_explain_scope (JSContext *context, | |
| const char *title); | | const char *title); | |
| JSBool gjs_call_function_value (JSContext *context, | | JSBool gjs_call_function_value (JSContext *context, | |
| JSObject *obj, | | JSObject *obj, | |
| jsval fval, | | jsval fval, | |
|
| uintN argc, | | unsigned argc, | |
| jsval *argv, | | jsval *argv, | |
| jsval *rval); | | jsval *rval); | |
| void gjs_error_reporter (JSContext *context, | | void gjs_error_reporter (JSContext *context, | |
| const char *message, | | const char *message, | |
| JSErrorReport *report); | | JSErrorReport *report); | |
| JSBool gjs_get_prop_verbose_stub (JSContext *context, | | JSBool gjs_get_prop_verbose_stub (JSContext *context, | |
| JSObject *obj, | | JSObject *obj, | |
| jsval id, | | jsval id, | |
| jsval *value_p); | | jsval *value_p); | |
| JSBool gjs_set_prop_verbose_stub (JSContext *context, | | JSBool gjs_set_prop_verbose_stub (JSContext *context, | |
| | | | |
| skipping to change at line 309 | | skipping to change at line 303 | |
| const char *utf8_string, | | const char *utf8_string, | |
| gssize n_bytes, | | gssize n_bytes, | |
| jsval *value_p); | | jsval *value_p); | |
| JSBool gjs_string_to_filename (JSContext *context, | | JSBool gjs_string_to_filename (JSContext *context, | |
| const jsval string_val, | | const jsval string_val, | |
| char **filename_str
ing_p); | | char **filename_str
ing_p); | |
| JSBool gjs_string_from_filename (JSContext *context, | | JSBool gjs_string_from_filename (JSContext *context, | |
| const char *filename_str
ing, | | const char *filename_str
ing, | |
| gssize n_bytes, | | gssize n_bytes, | |
| jsval *value_p); | | jsval *value_p); | |
|
| char* gjs_string_get_ascii (JSContext *context, | | | |
| jsval value); | | | |
| JSBool gjs_string_get_binary_data (JSContext *context, | | | |
| jsval value, | | | |
| char **data_p, | | | |
| gsize *len_p); | | | |
| JSBool gjs_string_from_binary_data (JSContext *context, | | | |
| const char *data, | | | |
| gsize len, | | | |
| jsval *value_p); | | | |
| JSBool gjs_string_get_uint16_data (JSContext *context, | | JSBool gjs_string_get_uint16_data (JSContext *context, | |
| jsval value, | | jsval value, | |
| guint16 **data_p, | | guint16 **data_p, | |
| gsize *len_p); | | gsize *len_p); | |
| JSBool gjs_get_string_id (JSContext *context, | | JSBool gjs_get_string_id (JSContext *context, | |
| jsid id, | | jsid id, | |
| char **name_p); | | char **name_p); | |
| | | | |
| gboolean gjs_unichar_from_string (JSContext *context, | | gboolean gjs_unichar_from_string (JSContext *context, | |
| jsval string, | | jsval string, | |
| | | | |
| skipping to change at line 342 | | skipping to change at line 326 | |
| | | | |
| JSBool gjs_value_to_int64 (JSContext *context, | | JSBool gjs_value_to_int64 (JSContext *context, | |
| const jsval val, | | const jsval val, | |
| gint64 *result); | | gint64 *result); | |
| | | | |
| jsval gjs_date_from_time_t (JSContext *context, time_t ti
me); | | jsval gjs_date_from_time_t (JSContext *context, time_t ti
me); | |
| | | | |
| JSBool gjs_parse_args (JSContext *context, | | JSBool gjs_parse_args (JSContext *context, | |
| const char *function_name, | | const char *function_name, | |
| const char *format, | | const char *format, | |
|
| uintN argc, | | unsigned argc, | |
| jsval *argv, | | jsval *argv, | |
| ...); | | ...); | |
| | | | |
| GjsRootedArray* gjs_rooted_array_new (void); | | GjsRootedArray* gjs_rooted_array_new (void); | |
| void gjs_rooted_array_append (JSContext *context, | | void gjs_rooted_array_append (JSContext *context, | |
| GjsRootedArray *array, | | GjsRootedArray *array, | |
| jsval value); | | jsval value); | |
| jsval gjs_rooted_array_get (JSContext *context, | | jsval gjs_rooted_array_get (JSContext *context, | |
| GjsRootedArray *array, | | GjsRootedArray *array, | |
| int i); | | int i); | |
| | | | |
| skipping to change at line 373 | | skipping to change at line 357 | |
| jsval initialize
r); | | jsval initialize
r); | |
| void gjs_root_value_locations (JSContext *context, | | void gjs_root_value_locations (JSContext *context, | |
| jsval *locations, | | jsval *locations, | |
| int n_location
s); | | int n_location
s); | |
| void gjs_unroot_value_locations (JSContext *context, | | void gjs_unroot_value_locations (JSContext *context, | |
| jsval *locations, | | jsval *locations, | |
| int n_location
s); | | int n_location
s); | |
| | | | |
| /* Functions intended for more "internal" use */ | | /* Functions intended for more "internal" use */ | |
| | | | |
|
| gboolean gjs_try_string_to_filename (JSContext *context, | | | |
| const jsval filename_val, | | | |
| char **filename_strin | | | |
| g_p, | | | |
| GError **error); | | | |
| | | | |
| gboolean gjs_try_string_to_utf8 (JSContext *context, | | | |
| const jsval strin | | | |
| g_val, | | | |
| char **utf8_string | | | |
| _p, | | | |
| GError **error); | | | |
| | | | |
| void gjs_maybe_gc (JSContext *context); | | void gjs_maybe_gc (JSContext *context); | |
| | | | |
| G_END_DECLS | | G_END_DECLS | |
| | | | |
| #endif /* __GJS_JSAPI_UTIL_H__ */ | | #endif /* __GJS_JSAPI_UTIL_H__ */ | |
| | | | |
End of changes. 13 change blocks. |
| 44 lines changed or deleted | | 15 lines changed or added | |
|