byteArray.h | byteArray.h | |||
---|---|---|---|---|
skipping to change at line 36 | skipping to change at line 36 | |||
#if !defined (__GJS_GJS_H__) && !defined (GJS_COMPILATION) | #if !defined (__GJS_GJS_H__) && !defined (GJS_COMPILATION) | |||
#error "Only <gjs/gjs.h> can be included directly." | #error "Only <gjs/gjs.h> can be included directly." | |||
#endif | #endif | |||
#include <glib.h> | #include <glib.h> | |||
#include "gjs/jsapi-util.h" | #include "gjs/jsapi-util.h" | |||
G_BEGIN_DECLS | G_BEGIN_DECLS | |||
JSBool gjs_typecheck_bytearray (JSContext *context, | ||||
JSObject *obj, | ||||
JSBool throw); | ||||
JSBool gjs_define_byte_array_stuff (JSContext *context, | JSBool gjs_define_byte_array_stuff (JSContext *context, | |||
JSObject *in_object); | JSObject *in_object); | |||
JSObject * gjs_byte_array_from_byte_array (JSContext *context, | JSObject * gjs_byte_array_from_byte_array (JSContext *context, | |||
GByteArray *array); | GByteArray *array); | |||
JSObject * gjs_byte_array_from_bytes (JSContext *context, | ||||
GBytes *bytes); | ||||
GByteArray * gjs_byte_array_get_byte_array (JSContext *context, | GByteArray * gjs_byte_array_get_byte_array (JSContext *context, | |||
JSObject *object); | JSObject *object); | |||
GBytes * gjs_byte_array_get_bytes (JSContext *context, | ||||
JSObject *object); | ||||
void gjs_byte_array_peek_data (JSContext *context, | ||||
JSObject *object, | ||||
guint8 **out_data, | ||||
gsize *out_len); | ||||
G_END_DECLS | G_END_DECLS | |||
#endif /* __GJS_BYTE_ARRAY_H__ */ | #endif /* __GJS_BYTE_ARRAY_H__ */ | |||
End of changes. 3 change blocks. | ||||
0 lines changed or deleted | 15 lines changed or added | |||
compat.h | compat.h | |||
---|---|---|---|---|
skipping to change at line 40 | skipping to change at line 40 | |||
#define __GJS_COMPAT_H__ | #define __GJS_COMPAT_H__ | |||
#pragma GCC diagnostic push | #pragma GCC diagnostic push | |||
#pragma GCC diagnostic ignored "-Wstrict-prototypes" | #pragma GCC diagnostic ignored "-Wstrict-prototypes" | |||
#pragma GCC diagnostic ignored "-Winvalid-offsetof" | #pragma GCC diagnostic ignored "-Winvalid-offsetof" | |||
#include <jsapi.h> | #include <jsapi.h> | |||
#include <jsdbgapi.h> // Needed by some bits | #include <jsdbgapi.h> // Needed by some bits | |||
#pragma GCC diagnostic pop | #pragma GCC diagnostic pop | |||
#include <glib.h> | #include <glib.h> | |||
#include <gjs/jsapi-util.h> | ||||
G_BEGIN_DECLS | G_BEGIN_DECLS | |||
/* This file inspects jsapi.h and attempts to provide a compatibility shim. | /* This file inspects jsapi.h and attempts to provide a compatibility shim. | |||
* See https://bugzilla.gnome.org/show_bug.cgi?id=622896 for some initial d iscussion. | * See https://bugzilla.gnome.org/show_bug.cgi?id=622896 for some initial d iscussion. | |||
*/ | */ | |||
/** | /** | |||
* GJS_NATIVE_CONSTRUCTOR_DECLARE: | * GJS_NATIVE_CONSTRUCTOR_DECLARE: | |||
* Prototype a constructor. | * Prototype a constructor. | |||
*/ | */ | |||
skipping to change at line 69 | skipping to change at line 71 | |||
* be at the very top. | * be at the very top. | |||
*/ | */ | |||
#define GJS_NATIVE_CONSTRUCTOR_VARIABLES(name) \ | #define GJS_NATIVE_CONSTRUCTOR_VARIABLES(name) \ | |||
JSObject *object = NULL; \ | JSObject *object = NULL; \ | |||
jsval *argv G_GNUC_UNUSED = JS_ARGV(context, vp); | jsval *argv G_GNUC_UNUSED = JS_ARGV(context, vp); | |||
/** | /** | |||
* GJS_NATIVE_CONSTRUCTOR_PRELUDE: | * GJS_NATIVE_CONSTRUCTOR_PRELUDE: | |||
* Call after the initial variable declaration. | * Call after the initial variable declaration. | |||
*/ | */ | |||
#define GJS_NATIVE_CONSTRUCTOR_PRELUDE(name) | #define GJS_NATIVE_CONSTRUCTOR_PRELUDE(name) \ | |||
\ | { \ | |||
{ | if (!JS_IsConstructing(context, vp)) { \ | |||
\ | gjs_throw_constructor_error(context); \ | |||
if (!JS_IsConstructing(context, vp)) { \ | return JS_FALSE; \ | |||
gjs_throw_constructor_error(context); | } \ | |||
\ | object = gjs_new_object_for_constructor(context, &gjs_##name##_clas | |||
return JS_FALSE; | s, vp); \ | |||
\ | if (object == NULL) \ | |||
} | return JS_FALSE; \ | |||
\ | ||||
object = JS_NewObjectForConstructor(context, vp); | ||||
\ | ||||
if (object == NULL) | ||||
\ | ||||
return JS_FALSE; | ||||
\ | ||||
} | } | |||
/** | /** | |||
* GJS_NATIVE_CONSTRUCTOR_FINISH: | * GJS_NATIVE_CONSTRUCTOR_FINISH: | |||
* Call this at the end of a constructor when it's completed | * Call this at the end of a constructor when it's completed | |||
* successfully. | * successfully. | |||
*/ | */ | |||
#define GJS_NATIVE_CONSTRUCTOR_FINISH(name) \ | #define GJS_NATIVE_CONSTRUCTOR_FINISH(name) \ | |||
JS_SET_RVAL(context, vp, OBJECT_TO_JSVAL(object)); | JS_SET_RVAL(context, vp, OBJECT_TO_JSVAL(object)); | |||
/** | ||||
* GJS_NATIVE_CONSTRUCTOR_DEFINE_ABSTRACT: | ||||
* Defines a constructor whose only purpose is to throw an error | ||||
* and fail. To be used with classes that require a constructor (because th | ||||
ey have | ||||
* instances), but whose constructor cannot be used from JS code. | ||||
*/ | ||||
#define GJS_NATIVE_CONSTRUCTOR_DEFINE_ABSTRACT(name) \ | ||||
GJS_NATIVE_CONSTRUCTOR_DECLARE(name) \ | ||||
{ \ | ||||
gjs_throw_abstract_constructor_error(context, vp); \ | ||||
return JS_FALSE; \ | ||||
} | ||||
G_END_DECLS | G_END_DECLS | |||
#endif /* __GJS_COMPAT_H__ */ | #endif /* __GJS_COMPAT_H__ */ | |||
End of changes. 3 change blocks. | ||||
17 lines changed or deleted | 26 lines changed or added | |||
jsapi-util.h | jsapi-util.h | |||
---|---|---|---|---|
skipping to change at line 76 | skipping to change at line 76 | |||
* NULL) | * NULL) | |||
* priv_from_js_with_typecheck: a convenience function to call | * priv_from_js_with_typecheck: a convenience function to call | |||
* 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_static_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); \ | return JS_GetInstancePrivate(context, object, &class, NULL); \ | |||
} \ | } \ | |||
__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; \ | |||
} | } | |||
#define GJS_DEFINE_DYNAMIC_PRIV_FROM_JS(type, class) \ | ||||
__attribute__((unused)) static inline JSBool \ | ||||
do_base_typecheck(JSContext *context, \ | ||||
JSObject *object, \ | ||||
JSBool throw) \ | ||||
{ \ | ||||
return gjs_typecheck_dynamic_instance(context, object, &class, thro | ||||
w); \ | ||||
} \ | ||||
static inline type* \ | ||||
priv_from_js(JSContext *context, \ | ||||
JSObject *object) \ | ||||
{ \ | ||||
return JS_GetPrivate(context, object); \ | ||||
} \ | ||||
__attribute__((unused)) static JSBool \ | ||||
priv_from_js_with_typecheck(JSContext *context, \ | ||||
JSObject *object, \ | ||||
type **out) \ | ||||
{ \ | ||||
if (!do_base_typecheck(context, object, JS_FALSE)) \ | ||||
return JS_FALSE; \ | ||||
*out = priv_from_js(context, object); \ | ||||
return JS_TRUE; \ | ||||
} | ||||
/** | /** | |||
* GJS_DEFINE_PROTO: | * GJS_DEFINE_PROTO: | |||
* @tn: The name of the prototype, as a string | * @tn: The name of the prototype, as a string | |||
* @cn: The name of the prototype, separated by _ | * @cn: The name of the prototype, separated by _ | |||
* | * | |||
* A convenience macro for prototype implementations. | * A convenience macro for prototype implementations. | |||
*/ | */ | |||
#define GJS_DEFINE_PROTO(tn, cn) \ | #define GJS_DEFINE_PROTO(tn, cn) \ | |||
GJS_NATIVE_CONSTRUCTOR_DECLARE(cn); \ | GJS_NATIVE_CONSTRUCTOR_DECLARE(cn); \ | |||
_GJS_DEFINE_PROTO_FULL(tn, cn, gjs_##cn##_constructor) | _GJS_DEFINE_PROTO_FULL(tn, cn, gjs_##cn##_constructor) | |||
skipping to change at line 228 | skipping to change at line 203 | |||
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, | |||
const char *obj_descript ion, | const char *obj_descript ion, | |||
const char *property_nam e, | const char *property_nam e, | |||
jsval *value_p); | jsval *value_p); | |||
JSObject * gjs_init_class_dynamic (JSContext *context, | ||||
JSObject *gjs_new_object_for_constructor (JSContext *context, | ||||
JSClass *clasp, | ||||
jsval *vp); | ||||
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, | uintN 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 **prototype_p) | ||||
; | ||||
void gjs_throw_constructor_error (JSContext *context); | void gjs_throw_constructor_error (JSContext *context); | |||
void gjs_throw_abstract_constructor_error (JSContext *context, | ||||
jsval *vp); | ||||
JSBool gjs_typecheck_static_instance (JSContext *context, | JSBool gjs_typecheck_instance (JSContext *context, | |||
JSObject *obj, | ||||
JSClass *static_clasp, | ||||
JSBool _throw); | ||||
JSBool gjs_typecheck_dynamic_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, | uintN argc, | |||
jsval *argv); | jsval *argv); | |||
JSObject* gjs_define_string_array (JSContext *context, | JSObject* gjs_define_string_array (JSContext *context, | |||
JSObject *obj, | JSObject *obj, | |||
End of changes. 6 change blocks. | ||||
34 lines changed or deleted | 14 lines changed or added | |||