summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlessio Treglia <alessio@debian.org>2012-05-15 19:17:56 +0200
committerAlessio Treglia <alessio@debian.org>2012-05-15 19:17:56 +0200
commit09c1eee91febf291c5b8dec11978d1ac25ac22ee (patch)
treeec60824729f3aca3350dd9585f913f65295aa202 /src
parent1f70b6d5efecc2797620bc00b62ff6f84c3400d7 (diff)
Imported Upstream version 0.4.5+svn4035~dfsg0
Diffstat (limited to 'src')
-rw-r--r--src/media_tools/mpd.c19
-rw-r--r--src/media_tools/mpegts.c3
-rw-r--r--src/scenegraph/dom_smjs.c68
-rw-r--r--src/scenegraph/svg_smjs.c114
-rw-r--r--src/scenegraph/vrml_smjs.c308
-rw-r--r--src/terminal/media_memory.c4
-rw-r--r--src/terminal/object_manager.c15
-rw-r--r--src/terminal/scene.c19
8 files changed, 291 insertions, 259 deletions
diff --git a/src/media_tools/mpd.c b/src/media_tools/mpd.c
index bf2578a..21c6c7a 100644
--- a/src/media_tools/mpd.c
+++ b/src/media_tools/mpd.c
@@ -385,7 +385,8 @@ static GF_MPD_SegmentTemplate *gf_mpd_parse_segment_template(GF_XMLNode *root)
while ( (att = gf_list_enum(root->attributes, &i)) ) {
if (!strcmp(att->name, "media")) seg->media = gf_mpd_parse_string(att->value);
else if (!strcmp(att->name, "index")) seg->index = gf_mpd_parse_string(att->value);
- else if (!strcmp(att->name, "initialization")) seg->initialization = gf_mpd_parse_string(att->value);
+ else if (!strcmp(att->name, "initialization") ) seg->initialization = gf_mpd_parse_string(att->value);
+ else if (!strcmp(att->name, "initialisation") ) seg->initialization = gf_mpd_parse_string(att->value);
else if (!strcmp(att->name, "bitstreamSwitching")) seg->bitstream_switching = gf_mpd_parse_string(att->value);
}
gf_mpd_parse_multiple_segment_base((GF_MPD_MultipleSegmentBase *)seg, root);
@@ -928,7 +929,7 @@ GF_Err gf_mpd_init_from_dom(GF_XMLNode *root, GF_MPD *mpd, const char *default_b
GF_EXPORT
GF_Err gf_m3u8_to_mpd(const char *m3u8_file, const char *base_url,
const char *mpd_file,
- u32 reload_count, char *mimeTypeForM3U8Segments, GF_ClientService *service, Bool do_import, Bool use_mpd_templates)
+ u32 reload_count, char *mimeTypeForM3U8Segments, Bool do_import, Bool use_mpd_templates, GF_FileDownload *getter)
{
GF_Err e;
char *sep, *template_base, *template_ext;
@@ -989,7 +990,18 @@ GF_Err gf_m3u8_to_mpd(const char *m3u8_file, const char *base_url,
GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[MPD Generator] Not downloading, programs are identical for %s...\n", pe->url));
continue;
}
- if (service) {
+ if (getter && getter->new_session && getter->del_session && getter->get_cache_name) {
+ e = getter->new_session(getter, suburl);
+ if (e) {
+ gf_free(suburl);
+ break;
+ }
+ if (e==GF_OK) {
+ e = parse_sub_playlist(getter->get_cache_name(getter), &pl, suburl, prog, pe);
+ }
+ getter->del_session(getter);
+
+#if 0
GF_DownloadSession *sess = gf_term_download_new(service, suburl, GF_NETIO_SESSION_NOT_THREADED, NULL, NULL);
if (!sess) {
gf_free(suburl);
@@ -1000,6 +1012,7 @@ GF_Err gf_m3u8_to_mpd(const char *m3u8_file, const char *base_url,
e = parse_sub_playlist(gf_dm_sess_get_cache_name(sess), &pl, suburl, prog, pe);
}
gf_term_download_del(sess);
+#endif
gf_free(suburl);
} else { /* for use in MP4Box */
if (strstr(suburl, "://") && !strstr(suburl, "://") ) {
diff --git a/src/media_tools/mpegts.c b/src/media_tools/mpegts.c
index 6c214e3..78521db 100644
--- a/src/media_tools/mpegts.c
+++ b/src/media_tools/mpegts.c
@@ -2155,7 +2155,10 @@ static void gf_m2ts_process_packet(GF_M2TS_Demuxer *ts, unsigned char *data)
}
paf = &af;
memset(paf, 0, sizeof(GF_M2TS_AdaptationField));
+ //this will stop you when processing invalid (yet existing) mpeg2ts streams in debug
assert(af_size>=0 && af_size<=182);
+ if ( !(af_size>=0 && af_size<=182))
+ GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG-2 TS] Detected wrong adaption field size %u when control value is 3\n", af_size));
if (af_size) gf_m2ts_get_adaptation_field(ts, paf, data+5, af_size, hdr.pid);
pos += 1+af_size;
payload_size = 183 - af_size;
diff --git a/src/scenegraph/dom_smjs.c b/src/scenegraph/dom_smjs.c
index 5ff9594..878cd63 100644
--- a/src/scenegraph/dom_smjs.c
+++ b/src/scenegraph/dom_smjs.c
@@ -61,7 +61,7 @@ static GFINLINE GF_SceneGraph *xml_get_scenegraph(JSContext *c)
GF_SceneGraph *scene;
JSObject *global = JS_GetGlobalObject(c);
assert(global);
- scene = JS_GetPrivate(c, global);
+ scene = SMJS_GET_PRIVATE(c, global);
assert(scene);
return scene;
}
@@ -200,14 +200,14 @@ JSBool dom_throw_exception(JSContext *c, u32 code)
GF_Node *dom_get_node(JSContext *c, JSObject *obj)
{
- GF_Node *n = obj ? JS_GetPrivate(c, obj) : NULL;
+ GF_Node *n = obj ? SMJS_GET_PRIVATE(c, obj) : NULL;
if (n && n->sgprivate) return n;
return NULL;
}
GF_Node *dom_get_element(JSContext *c, JSObject *obj)
{
- GF_Node *n = JS_GetPrivate(c, obj);
+ GF_Node *n = SMJS_GET_PRIVATE(c, obj);
if (!n || !n->sgprivate) return NULL;
if (n->sgprivate->tag==TAG_DOMText) return NULL;
return n;
@@ -215,7 +215,7 @@ GF_Node *dom_get_element(JSContext *c, JSObject *obj)
GF_SceneGraph *dom_get_doc(JSContext *c, JSObject *obj)
{
- GF_SceneGraph *sg = JS_GetPrivate(c, obj);
+ GF_SceneGraph *sg = SMJS_GET_PRIVATE(c, obj);
if (sg && !sg->__reserved_null) return sg;
return NULL;
}
@@ -237,7 +237,7 @@ static jsval dom_document_construct(JSContext *c, GF_SceneGraph *sg)
if (!jsclass) jsclass = &dom_rt->domDocumentClass;
new_obj = JS_NewObject(c, jsclass, 0, 0);
- JS_SetPrivate(c, new_obj, sg);
+ SMJS_SET_PRIVATE(c, new_obj, sg);
sg->document = new_obj;
return OBJECT_TO_JSVAL(new_obj);
}
@@ -272,7 +272,7 @@ static jsval dom_base_node_construct(JSContext *c, JSClass *_class, GF_Node *n)
gf_node_register(n, NULL);
new_obj = JS_NewObject(c, _class, 0, 0);
- JS_SetPrivate(c, new_obj, n);
+ SMJS_SET_PRIVATE(c, new_obj, n);
if (!n->sgprivate->interact) GF_SAFEALLOC(n->sgprivate->interact, struct _node_interactive_ext);
if (!n->sgprivate->interact->js_binding) {
@@ -409,7 +409,7 @@ static jsval dom_nodelist_construct(JSContext *c, GF_ParentNode *n)
gf_node_register((GF_Node*)n, NULL);
new_obj = JS_NewObject(c, &dom_rt->domNodeListClass, 0, 0);
- JS_SetPrivate(c, new_obj, nl);
+ SMJS_SET_PRIVATE(c, new_obj, nl);
return OBJECT_TO_JSVAL(new_obj);
}
@@ -419,7 +419,7 @@ static void dom_nodelist_finalize(JSContext *c, JSObject *obj)
if (!JS_InstanceOf(c, obj, &dom_rt->domNodeListClass, NULL) )
return;
- nl = (DOMNodeList *) JS_GetPrivate(c, obj);
+ nl = (DOMNodeList *) SMJS_GET_PRIVATE(c, obj);
if (!nl) return;
if (nl->owner) {
@@ -449,7 +449,7 @@ static JSBool SMJS_FUNCTION(dom_nodelist_item)
if ((argc!=1) || !JSVAL_IS_INT(argv[0]))
return JS_TRUE;
- nl = (DOMNodeList *)JS_GetPrivate(c, obj);
+ nl = (DOMNodeList *)SMJS_GET_PRIVATE(c, obj);
count = gf_node_list_get_count(nl->owner ? nl->owner->children : nl->child);
idx = JSVAL_TO_INT(argv[0]);
if ((idx<0) || ((u32) idx>=count)) {
@@ -472,7 +472,7 @@ static JSBool dom_nodelist_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GE
switch (SMJS_ID_TO_INT(id)) {
case 0:
- nl = (DOMNodeList *) JS_GetPrivate(c, obj);
+ nl = (DOMNodeList *) SMJS_GET_PRIVATE(c, obj);
*vp = INT_TO_JSVAL( gf_node_list_get_count(nl->owner ? nl->owner->children : nl->child) );
return JS_TRUE;
}
@@ -763,12 +763,12 @@ JSBool SMJS_FUNCTION(dom_event_remove_listener)
/*dom3 node*/
static void dom_node_finalize(JSContext *c, JSObject *obj)
{
- GF_Node *n = (GF_Node *) JS_GetPrivate(c, obj);
+ GF_Node *n = (GF_Node *) SMJS_GET_PRIVATE(c, obj);
/*the JS proto of the svgClass or a destroyed object*/
if (!n) return;
if (!n->sgprivate) return;
- JS_SetPrivate(c, obj, NULL);
+ SMJS_SET_PRIVATE(c, obj, NULL);
gf_list_del_item(n->sgprivate->scenegraph->objects, obj);
dom_js_pre_destroy(c, n->sgprivate->scenegraph, n);
@@ -1353,11 +1353,11 @@ void dom_document_finalize(JSContext *c, JSObject *obj)
{
GF_SceneGraph *sg = dom_get_doc(c, obj);
- sg = (GF_SceneGraph*) JS_GetPrivate(c, obj);
+ sg = (GF_SceneGraph*) SMJS_GET_PRIVATE(c, obj);
/*the JS proto of the svgClass or a destroyed object*/
if (!sg) return;
- JS_SetPrivate(c, sg->document, NULL);
+ SMJS_SET_PRIVATE(c, sg->document, NULL);
sg->document = NULL;
if (sg->RootNode) {
gf_node_unregister(sg->RootNode, NULL);
@@ -1546,7 +1546,7 @@ static JSBool SMJS_FUNCTION(xml_document_elements_by_tag)
if (name && !strcmp(name, "*")) name = NULL;
xml_doc_gather_nodes((GF_ParentNode*)sg->RootNode, name, nl);
new_obj = JS_NewObject(c, &dom_rt->domNodeListClass, 0, 0);
- JS_SetPrivate(c, new_obj, nl);
+ SMJS_SET_PRIVATE(c, new_obj, nl);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(new_obj));
SMJS_FREE(c, name);
return JS_TRUE;
@@ -2051,7 +2051,7 @@ static JSBool SMJS_FUNCTION(xml_element_elements_by_tag)
}
xml_doc_gather_nodes((GF_ParentNode*)n, name, nl);
new_obj = JS_NewObject(c, &dom_rt->domNodeListClass, 0, 0);
- JS_SetPrivate(c, new_obj, nl);
+ SMJS_SET_PRIVATE(c, new_obj, nl);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(new_obj) );
SMJS_FREE(c, name);
@@ -2150,7 +2150,7 @@ static JSBool dom_text_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER
static JSBool SMJS_FUNCTION(event_stop_propagation)
{
SMJS_OBJ
- GF_DOM_Event *evt = JS_GetPrivate(c, obj);
+ GF_DOM_Event *evt = SMJS_GET_PRIVATE(c, obj);
if (!evt) return JS_TRUE;
evt->event_phase |= GF_DOM_EVENT_PHASE_CANCEL;
return JS_TRUE;
@@ -2158,7 +2158,7 @@ static JSBool SMJS_FUNCTION(event_stop_propagation)
static JSBool SMJS_FUNCTION(event_stop_immediate_propagation)
{
SMJS_OBJ
- GF_DOM_Event *evt = JS_GetPrivate(c, obj);
+ GF_DOM_Event *evt = SMJS_GET_PRIVATE(c, obj);
if (!evt) return JS_TRUE;
evt->event_phase |= GF_DOM_EVENT_PHASE_CANCEL_ALL;
return JS_TRUE;
@@ -2166,7 +2166,7 @@ static JSBool SMJS_FUNCTION(event_stop_immediate_propagation)
static JSBool SMJS_FUNCTION(event_prevent_default)
{
SMJS_OBJ
- GF_DOM_Event *evt = JS_GetPrivate(c, obj);
+ GF_DOM_Event *evt = SMJS_GET_PRIVATE(c, obj);
if (!evt) return JS_TRUE;
evt->event_phase |= GF_DOM_EVENT_PHASE_PREVENT;
return JS_TRUE;
@@ -2175,7 +2175,7 @@ static JSBool SMJS_FUNCTION(event_prevent_default)
static JSBool event_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, jsval *vp)
{
JSString *s;
- GF_DOM_Event *evt = JS_GetPrivate(c, obj);
+ GF_DOM_Event *evt = SMJS_GET_PRIVATE(c, obj);
if (evt==NULL) return JS_TRUE;
if (SMJS_ID_IS_INT(id)) {
switch (SMJS_ID_TO_INT(id)) {
@@ -2531,7 +2531,7 @@ static void xml_http_finalize(JSContext *c, JSObject *obj)
{
XMLHTTPContext *ctx;
if (!JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return;
- ctx = (XMLHTTPContext *)JS_GetPrivate(c, obj);
+ ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj);
if (ctx) {
if (ctx->onreadystatechange) gf_js_remove_root(c, &(ctx->onreadystatechange), GF_JSGC_VAL);
xml_http_reset(ctx);
@@ -2547,7 +2547,7 @@ static JSBool SMJS_FUNCTION(xml_http_constructor)
GF_SAFEALLOC(p, XMLHTTPContext);
p->c = c;
p->_this = obj;
- JS_SetPrivate(c, obj, p);
+ SMJS_SET_PRIVATE(c, obj, p);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(obj) );
return JS_TRUE;
}
@@ -2588,7 +2588,7 @@ static JSBool SMJS_FUNCTION(xml_http_open)
SMJS_ARGS
if (!JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return JS_TRUE;
- ctx = (XMLHTTPContext *)JS_GetPrivate(c, obj);
+ ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj);
if (!ctx) return JS_TRUE;
/*reset*/
@@ -2657,7 +2657,7 @@ static JSBool SMJS_FUNCTION(xml_http_set_header)
SMJS_ARGS
if (!JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return JS_TRUE;
- ctx = (XMLHTTPContext *)JS_GetPrivate(c, obj);
+ ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj);
if (!ctx) return JS_TRUE;
if (ctx->readyState!=1) return JS_TRUE;
@@ -2896,7 +2896,7 @@ static JSBool SMJS_FUNCTION(xml_http_send)
SMJS_ARGS
if (!JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return JS_TRUE;
- ctx = (XMLHTTPContext *)JS_GetPrivate(c, obj);
+ ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj);
if (!ctx) return JS_TRUE;
if (ctx->readyState!=1) return JS_TRUE;
@@ -3000,7 +3000,7 @@ static JSBool SMJS_FUNCTION(xml_http_abort)
SMJS_OBJ
if (!JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return JS_TRUE;
- ctx = (XMLHTTPContext *)JS_GetPrivate(c, obj);
+ ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj);
if (!ctx) return JS_TRUE;
sess = ctx->sess;
@@ -3019,7 +3019,7 @@ static JSBool SMJS_FUNCTION(xml_http_get_all_headers)
SMJS_OBJ
if (!JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return JS_TRUE;
- ctx = (XMLHTTPContext *)JS_GetPrivate(c, obj);
+ ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj);
if (!ctx) return JS_TRUE;
/*must be received or loaded*/
@@ -3053,7 +3053,7 @@ static JSBool SMJS_FUNCTION(xml_http_get_header)
SMJS_OBJ
SMJS_ARGS
if (!argc || !JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return JS_TRUE;
- ctx = (XMLHTTPContext *)JS_GetPrivate(c, obj);
+ ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj);
if (!ctx) return JS_TRUE;
if (!JSVAL_CHECK_STRING(argv[0])) return JS_TRUE;
@@ -3086,7 +3086,7 @@ static JSBool xml_http_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER
JSString *s;
XMLHTTPContext *ctx;
if (!JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return JS_TRUE;
- ctx = (XMLHTTPContext *)JS_GetPrivate(c, obj);
+ ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj);
if (!ctx) return JS_TRUE;
if (SMJS_ID_IS_INT(id)) {
@@ -3145,7 +3145,7 @@ static JSBool xml_http_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER
{
XMLHTTPContext *ctx;
if (!JS_InstanceOf(c, obj, &dom_rt->xmlHTTPRequestClass, NULL) ) return JS_TRUE;
- ctx = (XMLHTTPContext *)JS_GetPrivate(c, obj);
+ ctx = (XMLHTTPContext *)SMJS_GET_PRIVATE(c, obj);
if (!ctx) return JS_TRUE;
if (SMJS_ID_IS_INT(id)) {
@@ -3433,7 +3433,7 @@ static JSBool SMJS_FUNCTION(dcci_search_property)
GF_SAFEALLOC(nl, DOMNodeList);
dcci_prop_collect(nl, n, ns, name, deep, 1);
new_obj = JS_NewObject(c, &dom_rt->domNodeListClass, 0, 0);
- JS_SetPrivate(c, new_obj, nl);
+ SMJS_SET_PRIVATE(c, new_obj, nl);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(new_obj) );
SMJS_FREE(c, ns);
SMJS_FREE(c, name);
@@ -3837,7 +3837,7 @@ void dom_js_pre_destroy(JSContext *c, GF_SceneGraph *sg, GF_Node *n)
if (n) {
if (n->sgprivate->interact && n->sgprivate->interact->js_binding && n->sgprivate->interact->js_binding->node) {
JSObject *obj = n->sgprivate->interact->js_binding->node;
- JS_SetPrivate(c, obj, NULL);
+ SMJS_SET_PRIVATE(c, obj, NULL);
n->sgprivate->interact->js_binding->node=NULL;
if (gf_list_del_item(sg->objects, obj)>=0) {
gf_js_remove_root(c, &(n->sgprivate->interact->js_binding->node), GF_JSGC_OBJECT);
@@ -3853,7 +3853,7 @@ void dom_js_pre_destroy(JSContext *c, GF_SceneGraph *sg, GF_Node *n)
JSObject *obj = gf_list_get(sg->objects, 0);
n = dom_get_node(c, obj);
if (n) {
- JS_SetPrivate(c, obj, NULL);
+ SMJS_SET_PRIVATE(c, obj, NULL);
n->sgprivate->interact->js_binding->node=NULL;
gf_node_unregister(n, NULL);
gf_js_remove_root(c, &(n->sgprivate->interact->js_binding->node), GF_JSGC_OBJECT);
@@ -3907,7 +3907,7 @@ static void dom_js_define_document_ex(JSContext *c, JSObject *global, GF_SceneGr
obj = JS_DefineObject(c, global, name, __class, 0, 0 );
gf_node_register(doc->RootNode, NULL);
- JS_SetPrivate(c, obj, doc);
+ SMJS_SET_PRIVATE(c, obj, doc);
doc->document = obj;
}
diff --git a/src/scenegraph/svg_smjs.c b/src/scenegraph/svg_smjs.c
index d322061..63ab3a5 100644
--- a/src/scenegraph/svg_smjs.c
+++ b/src/scenegraph/svg_smjs.c
@@ -139,7 +139,7 @@ static JSBool SMJS_FUNCTION(svg_nav_to_location)
SMJS_OBJ
SMJS_ARGS
if ((argc!=1) || !JS_InstanceOf(c, obj, &svg_rt->globalClass, NULL)) return JS_TRUE;
- sg = JS_GetPrivate(c, obj);
+ sg = SMJS_GET_PRIVATE(c, obj);
par.uri.url = SMJS_CHARS(c, argv[0]);
par.uri.nb_params = 0;
ScriptAction(sg, GF_JSAPI_OP_LOAD_URL, sg->RootNode, &par);
@@ -183,7 +183,7 @@ static JSBool SMJS_FUNCTION(svg_echo)
SMJS_OBJ
SMJS_ARGS
if ((argc!=1) || !JS_InstanceOf(c, obj, &svg_rt->globalClass, NULL)) return JS_TRUE;
- sg = JS_GetPrivate(c, obj);
+ sg = SMJS_GET_PRIVATE(c, obj);
if (!sg) return JS_TRUE;
if (JSVAL_IS_STRING(argv[0])) {
@@ -227,7 +227,7 @@ static JSBool global_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER,
if (!JS_InstanceOf(c, obj, &svg_rt->globalClass, NULL) )
return JS_TRUE;
- sg = JS_GetPrivate(c, obj);
+ sg = SMJS_GET_PRIVATE(c, obj);
if (SMJS_ID_IS_INT(id)) {
switch (SMJS_ID_TO_INT(id)) {
/*namespaceURI*/
@@ -353,7 +353,7 @@ static JSBool svg_element_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GET
rc->x = FIX2FLT(par.pt.x);
rc->y = FIX2FLT(par.pt.y);
rc->sg = n->sgprivate->scenegraph;
- JS_SetPrivate(c, r, rc);
+ SMJS_SET_PRIVATE(c, r, rc);
*vp = OBJECT_TO_JSVAL(r);
return JS_TRUE;
}
@@ -368,7 +368,7 @@ static JSBool svg_element_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GET
rc->w = FIX2FLT(par.rc.width);
rc->h = FIX2FLT(par.rc.height);
rc->sg = n->sgprivate->scenegraph;
- JS_SetPrivate(c, r, rc);
+ SMJS_SET_PRIVATE(c, r, rc);
*vp = OBJECT_TO_JSVAL(r);
return JS_TRUE;
}
@@ -841,7 +841,7 @@ JSBool SMJS_FUNCTION(svg_udom_get_matrix_trait)
gf_mx2d_init(*mx);
gf_mx2d_copy(*mx, ((SVG_Transform*)info.far_ptr)->mat);
- JS_SetPrivate(c, mO, mx);
+ SMJS_SET_PRIVATE(c, mO, mx);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(mO) );
return JS_TRUE;
}
@@ -875,7 +875,7 @@ JSBool SMJS_FUNCTION(svg_udom_get_rect_trait)
rc->y = FIX2FLT(v->y);
rc->w = FIX2FLT(v->width);
rc->h = FIX2FLT(v->height);
- JS_SetPrivate(c, newObj, rc);
+ SMJS_SET_PRIVATE(c, newObj, rc);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(newObj) );
return JS_TRUE;
}
@@ -936,7 +936,7 @@ JSBool SMJS_FUNCTION(svg_udom_get_rgb_color_trait)
rgb->r = (u8) (255*FIX2FLT(col->red)) ;
rgb->g = (u8) (255*FIX2FLT(col->green)) ;
rgb->b = (u8) (255*FIX2FLT(col->blue)) ;
- JS_SetPrivate(c, newObj, rgb);
+ SMJS_SET_PRIVATE(c, newObj, rgb);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(newObj) );
return JS_TRUE;
}
@@ -950,7 +950,7 @@ JSBool SMJS_FUNCTION(svg_udom_get_rgb_color_trait)
rgb->r = (u8) (255*FIX2FLT(paint->color.red) );
rgb->g = (u8) (255*FIX2FLT(paint->color.green) );
rgb->b = (u8) (255*FIX2FLT(paint->color.blue) );
- JS_SetPrivate(c, newObj, rgb);
+ SMJS_SET_PRIVATE(c, newObj, rgb);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(newObj) );
return JS_TRUE;
}
@@ -1089,7 +1089,7 @@ JSBool SMJS_FUNCTION(svg_udom_set_matrix_trait)
if (JSVAL_IS_NULL(argv[1]) || !JSVAL_IS_OBJECT(argv[1])) return JS_TRUE;
mO = JSVAL_TO_OBJECT(argv[1]);
if (!JS_InstanceOf(c, mO, &svg_rt->matrixClass, NULL) ) return JS_TRUE;
- mx = JS_GetPrivate(c, mO);
+ mx = SMJS_GET_PRIVATE(c, mO);
if (!mx) return JS_TRUE;
szName = SMJS_CHARS(c, argv[0]);
@@ -1122,7 +1122,7 @@ JSBool SMJS_FUNCTION(svg_udom_set_rect_trait)
if (JSVAL_IS_NULL(argv[1]) || !JSVAL_IS_OBJECT(argv[1])) return JS_TRUE;
rO = JSVAL_TO_OBJECT(argv[1]);
if (!JS_InstanceOf(c, rO, &svg_rt->rectClass, NULL) ) return JS_TRUE;
- rc = JS_GetPrivate(c, rO);
+ rc = SMJS_GET_PRIVATE(c, rO);
if (!rc) return JS_TRUE;
szName = SMJS_CHARS(c, argv[0]);
@@ -1158,7 +1158,7 @@ JSBool SMJS_FUNCTION(svg_udom_set_path_trait)
if (JSVAL_IS_NULL(argv[1]) || !JSVAL_IS_OBJECT(argv[1])) return JS_TRUE;
pO = JSVAL_TO_OBJECT(argv[1]);
if (!JS_InstanceOf(c, pO, &svg_rt->pathClass, NULL) ) return JS_TRUE;
- path = JS_GetPrivate(c, pO);
+ path = SMJS_GET_PRIVATE(c, pO);
if (!path) return JS_TRUE;
szName = SMJS_CHARS(c, argv[0]);
@@ -1225,7 +1225,7 @@ JSBool SMJS_FUNCTION(svg_udom_set_rgb_color_trait)
colO = JSVAL_TO_OBJECT(argv[1]);
if (!colO) return JS_TRUE;
if (!JS_InstanceOf(c, colO, &svg_rt->rgbClass, NULL) ) return JS_TRUE;
- rgb = JS_GetPrivate(c, colO);
+ rgb = SMJS_GET_PRIVATE(c, colO);
if (!rgb) return JS_TRUE;
SMJS_SET_RVAL(JSVAL_VOID);
@@ -1278,7 +1278,7 @@ static JSBool SMJS_FUNCTION_EXT(svg_get_bbox, Bool get_screen)
rc->y = FIX2FLT(par.bbox.min_edge.y);
rc->w = FIX2FLT(par.bbox.max_edge.x - par.bbox.min_edge.x);
rc->h = FIX2FLT(par.bbox.max_edge.y - par.bbox.min_edge.y);
- JS_SetPrivate(c, rO, rc);
+ SMJS_SET_PRIVATE(c, rO, rc);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(rO) );
} else {
SMJS_SET_RVAL( JSVAL_VOID );
@@ -1307,7 +1307,7 @@ JSBool SMJS_FUNCTION(svg_udom_get_screen_ctm)
JSObject *mO = JS_NewObject(c, &svg_rt->matrixClass, 0, 0);
GF_Matrix2D *mx = gf_malloc(sizeof(GF_Matrix2D));
gf_mx2d_from_mx(mx, &par.mx);
- JS_SetPrivate(c, mO, mx);
+ SMJS_SET_PRIVATE(c, mO, mx);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(mO) );
return JS_TRUE;
}
@@ -1339,7 +1339,7 @@ JSBool SMJS_FUNCTION(svg_udom_create_matrix_components)
JS_ValueToNumber(c, argv[5], &v);
mx->m[5] = FLT2FIX(v);
mat = JS_NewObject(c, &svg_rt->matrixClass, 0, 0);
- JS_SetPrivate(c, mat, mx);
+ SMJS_SET_PRIVATE(c, mat, mx);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(mat) );
return JS_TRUE;
}
@@ -1353,7 +1353,7 @@ JSBool SMJS_FUNCTION(svg_udom_create_rect)
GF_SAFEALLOC(rc, rectCI);
r = JS_NewObject(c, &svg_rt->rectClass, 0, 0);
- JS_SetPrivate(c, r, rc);
+ SMJS_SET_PRIVATE(c, r, rc);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(r) );
return JS_TRUE;
}
@@ -1367,7 +1367,7 @@ JSBool SMJS_FUNCTION(svg_udom_create_point)
GF_SAFEALLOC(pt, pointCI);
r = JS_NewObject(c, &svg_rt->pointClass, 0, 0);
- JS_SetPrivate(c, r, pt);
+ SMJS_SET_PRIVATE(c, r, pt);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(r) );
return JS_TRUE;
}
@@ -1381,7 +1381,7 @@ JSBool SMJS_FUNCTION(svg_udom_create_path)
GF_SAFEALLOC(path, pathCI);
p = JS_NewObject(c, &svg_rt->pathClass, 0, 0);
- JS_SetPrivate(c, p, path);
+ SMJS_SET_PRIVATE(c, p, path);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(p) );
return JS_TRUE;
}
@@ -1400,7 +1400,7 @@ JSBool SMJS_FUNCTION(svg_udom_create_color)
col->g = JSVAL_TO_INT(argv[1]);
col->b = JSVAL_TO_INT(argv[2]);
p = JS_NewObject(c, &svg_rt->rgbClass, 0, 0);
- JS_SetPrivate(c, p, col);
+ SMJS_SET_PRIVATE(c, p, col);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(p) );
return JS_TRUE;
}
@@ -1538,7 +1538,7 @@ static JSFunctionSpec connectionFuncs[] = {
static void baseCI_finalize(JSContext *c, JSObject *obj)
{
- void *data = JS_GetPrivate(c, obj);
+ void *data = SMJS_GET_PRIVATE(c, obj);
if (data) gf_free(data);
}
@@ -1546,7 +1546,7 @@ static JSBool rgb_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, jsv
{
if (!JS_InstanceOf(c, obj, &svg_rt->rgbClass, NULL) ) return JS_TRUE;
if (SMJS_ID_IS_INT(id)) {
- rgbCI *col = JS_GetPrivate(c, obj);
+ rgbCI *col = SMJS_GET_PRIVATE(c, obj);
if (!col) return JS_TRUE;
switch (SMJS_ID_TO_INT(id)) {
case 0: *vp = INT_TO_JSVAL(col->r); return JS_TRUE;
@@ -1562,7 +1562,7 @@ static JSBool rgb_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, jsv
{
if (!JS_InstanceOf(c, obj, &svg_rt->rgbClass, NULL) ) return JS_TRUE;
if (SMJS_ID_IS_INT(id)) {
- rgbCI *col = JS_GetPrivate(c, obj);
+ rgbCI *col = SMJS_GET_PRIVATE(c, obj);
if (!col) return JS_TRUE;
switch (SMJS_ID_TO_INT(id)) {
case 0: col->r = JSVAL_TO_INT(*vp); return JS_TRUE;
@@ -1579,7 +1579,7 @@ static JSBool rect_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, js
{
if (!JS_InstanceOf(c, obj, &svg_rt->rectClass, NULL) ) return JS_TRUE;
if (SMJS_ID_IS_INT(id)) {
- rectCI *rc = JS_GetPrivate(c, obj);
+ rectCI *rc = SMJS_GET_PRIVATE(c, obj);
if (!rc) return JS_TRUE;
if (rc->sg) {
GF_JSAPIParam par;
@@ -1604,7 +1604,7 @@ static JSBool rect_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, js
if (!JS_InstanceOf(c, obj, &svg_rt->rectClass, NULL) ) return JS_TRUE;
if (SMJS_ID_IS_INT(id)) {
jsdouble d;
- rectCI *rc = JS_GetPrivate(c, obj);
+ rectCI *rc = SMJS_GET_PRIVATE(c, obj);
if (!rc) return JS_TRUE;
JS_ValueToNumber(c, *vp, &d);
switch (SMJS_ID_TO_INT(id)) {
@@ -1622,7 +1622,7 @@ static JSBool point_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, j
{
if (!JS_InstanceOf(c, obj, &svg_rt->pointClass, NULL) ) return JS_TRUE;
if (SMJS_ID_IS_INT(id)) {
- pointCI *pt = JS_GetPrivate(c, obj);
+ pointCI *pt = SMJS_GET_PRIVATE(c, obj);
if (!pt) return JS_TRUE;
if (pt->sg) {
GF_JSAPIParam par;
@@ -1643,7 +1643,7 @@ static JSBool point_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, j
if (!JS_InstanceOf(c, obj, &svg_rt->pointClass, NULL) ) return JS_TRUE;
if (SMJS_ID_IS_INT(id)) {
jsdouble d;
- pointCI *pt = JS_GetPrivate(c, obj);
+ pointCI *pt = SMJS_GET_PRIVATE(c, obj);
if (!pt) return JS_TRUE;
JS_ValueToNumber(c, *vp, &d);
switch (SMJS_ID_TO_INT(id)) {
@@ -1684,7 +1684,7 @@ static JSObject *svg_new_path_object(JSContext *c, SVG_PathData *d)
}
}
obj = JS_NewObject(c, &svg_rt->pathClass, 0, 0);
- JS_SetPrivate(c, obj, p);
+ SMJS_SET_PRIVATE(c, obj, p);
return obj;
#endif
}
@@ -1694,7 +1694,7 @@ static JSBool pathCI_constructor(JSContext *c, JSObject *obj, uintN argc, jsval
{
pathCI *p;
GF_SAFEALLOC(p, pathCI);
- JS_SetPrivate(c, obj, p);
+ SMJS_SET_PRIVATE(c, obj, p);
*rval = OBJECT_TO_JSVAL(obj);
return JS_TRUE;
}
@@ -1702,7 +1702,7 @@ static JSBool pathCI_constructor(JSContext *c, JSObject *obj, uintN argc, jsval
static void pathCI_finalize(JSContext *c, JSObject *obj)
{
- pathCI *p = JS_GetPrivate(c, obj);
+ pathCI *p = SMJS_GET_PRIVATE(c, obj);
if (p) {
if (p->pts) gf_free(p->pts);
if (p->tags) gf_free(p->tags);
@@ -1714,7 +1714,7 @@ static JSBool path_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, js
{
if (!JS_InstanceOf(c, obj, &svg_rt->pathClass, NULL) ) return JS_TRUE;
if (SMJS_ID_IS_INT(id)) {
- pathCI *p = JS_GetPrivate(c, obj);
+ pathCI *p = SMJS_GET_PRIVATE(c, obj);
if (!p) return JS_TRUE;
switch (SMJS_ID_TO_INT(id)) {
case 0: *vp = INT_TO_JSVAL(p->nb_coms); return JS_TRUE;
@@ -1730,7 +1730,7 @@ static JSBool SMJS_FUNCTION(svg_path_get_segment)
SMJS_OBJ
SMJS_ARGS
if (!JS_InstanceOf(c, obj, &svg_rt->pathClass, NULL) ) return JS_TRUE;
- p = JS_GetPrivate(c, obj);
+ p = SMJS_GET_PRIVATE(c, obj);
if (!p) return JS_TRUE;
if ((argc!=1) || !JSVAL_IS_INT(argv[0])) return JS_TRUE;
idx = JSVAL_TO_INT(argv[0]);
@@ -1757,7 +1757,7 @@ static JSBool SMJS_FUNCTION(svg_path_get_segment_param)
SMJS_ARGS
u32 i, idx, param_idx, pt_idx;
if (!JS_InstanceOf(c, obj, &svg_rt->pathClass, NULL) ) return JS_TRUE;
- p = JS_GetPrivate(c, obj);
+ p = SMJS_GET_PRIVATE(c, obj);
if (!p) return JS_TRUE;
if ((argc!=2) || !JSVAL_IS_INT(argv[0]) || !JSVAL_IS_INT(argv[1])) return JS_TRUE;
idx = JSVAL_TO_INT(argv[0]);
@@ -1846,7 +1846,7 @@ static JSBool SMJS_FUNCTION(svg_path_move_to)
SMJS_OBJ
SMJS_ARGS
if (!JS_InstanceOf(c, obj, &svg_rt->pathClass, NULL) ) return JS_TRUE;
- p = JS_GetPrivate(c, obj);
+ p = SMJS_GET_PRIVATE(c, obj);
if (!p) return JS_TRUE;
if ((argc!=2) || !JSVAL_IS_NUMBER(argv[0]) || !JSVAL_IS_NUMBER(argv[1])) return JS_TRUE;
JS_ValueToNumber(c, argv[0], &x);
@@ -1867,7 +1867,7 @@ static JSBool SMJS_FUNCTION(svg_path_line_to)
SMJS_OBJ
SMJS_ARGS
if (!JS_InstanceOf(c, obj, &svg_rt->pathClass, NULL) ) return JS_TRUE;
- p = JS_GetPrivate(c, obj);
+ p = SMJS_GET_PRIVATE(c, obj);
if (!p) return JS_TRUE;
if ((argc!=2) || !JSVAL_IS_NUMBER(argv[0]) || !JSVAL_IS_NUMBER(argv[1])) return JS_TRUE;
JS_ValueToNumber(c, argv[0], &x);
@@ -1889,7 +1889,7 @@ static JSBool SMJS_FUNCTION(svg_path_quad_to)
SMJS_OBJ
SMJS_ARGS
if (!JS_InstanceOf(c, obj, &svg_rt->pathClass, NULL) ) return JS_TRUE;
- p = JS_GetPrivate(c, obj);
+ p = SMJS_GET_PRIVATE(c, obj);
if (!p) return JS_TRUE;
if ((argc!=4) || !JSVAL_IS_NUMBER(argv[0]) || !JSVAL_IS_NUMBER(argv[1]) || !JSVAL_IS_NUMBER(argv[2]) || !JSVAL_IS_NUMBER(argv[3])) return JS_TRUE;
JS_ValueToNumber(c, argv[0], &x1);
@@ -1912,7 +1912,7 @@ static JSBool SMJS_FUNCTION(svg_path_curve_to)
SMJS_OBJ
SMJS_ARGS
if (!JS_InstanceOf(c, obj, &svg_rt->pathClass, NULL) ) return JS_TRUE;
- p = JS_GetPrivate(c, obj);
+ p = SMJS_GET_PRIVATE(c, obj);
if (!p) return JS_TRUE;
if ((argc!=6) || !JSVAL_IS_NUMBER(argv[0]) || !JSVAL_IS_NUMBER(argv[1]) || !JSVAL_IS_NUMBER(argv[2]) || !JSVAL_IS_NUMBER(argv[3]) || !JSVAL_IS_NUMBER(argv[4]) || !JSVAL_IS_NUMBER(argv[5])) return JS_TRUE;
JS_ValueToNumber(c, argv[0], &x1);
@@ -1935,7 +1935,7 @@ static JSBool SMJS_FUNCTION(svg_path_close)
pathCI *p;
SMJS_OBJ
if (!JS_InstanceOf(c, obj, &svg_rt->pathClass, NULL) ) return JS_TRUE;
- p = JS_GetPrivate(c, obj);
+ p = SMJS_GET_PRIVATE(c, obj);
if (!p) return JS_TRUE;
if (argc) return JS_TRUE;
p->tags = gf_realloc(p->tags, sizeof(u8)*(p->nb_coms+1) );
@@ -1948,7 +1948,7 @@ static JSBool matrix_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER,
{
GF_Matrix2D *mx;
if (!JS_InstanceOf(c, obj, &svg_rt->matrixClass, NULL) ) return JS_TRUE;
- mx = JS_GetPrivate(c, obj);
+ mx = SMJS_GET_PRIVATE(c, obj);
if (!SMJS_ID_IS_INT(id)) return JS_TRUE;
if (!mx) return JS_TRUE;
@@ -1968,7 +1968,7 @@ static JSBool matrix_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER,
jsdouble d;
GF_Matrix2D *mx;
if (!JS_InstanceOf(c, obj, &svg_rt->matrixClass, NULL) ) return JS_TRUE;
- mx = JS_GetPrivate(c, obj);
+ mx = SMJS_GET_PRIVATE(c, obj);
if (!SMJS_ID_IS_INT(id)) return JS_TRUE;
JS_ValueToNumber(c, *vp, &d);
@@ -1989,7 +1989,7 @@ static JSBool SMJS_FUNCTION(svg_mx2d_get_component)
SMJS_OBJ
SMJS_ARGS
if (!JS_InstanceOf(c, obj, &svg_rt->matrixClass, NULL) ) return JS_TRUE;
- mx = JS_GetPrivate(c, obj);
+ mx = SMJS_GET_PRIVATE(c, obj);
if (!mx || (argc!=1)) return JS_TRUE;
if (!JSVAL_IS_INT(argv[0])) return JS_TRUE;
switch (JSVAL_TO_INT(argv[0])) {
@@ -2010,12 +2010,12 @@ static JSBool SMJS_FUNCTION(svg_mx2d_multiply)
SMJS_OBJ
SMJS_ARGS
if (!JS_InstanceOf(c, obj, &svg_rt->matrixClass, NULL) ) return JS_TRUE;
- mx1 = JS_GetPrivate(c, obj);
+ mx1 = SMJS_GET_PRIVATE(c, obj);
if (!mx1 || (argc!=1)) return JS_TRUE;
if (!JSVAL_IS_OBJECT(argv[0])) return JS_TRUE;
mat = JSVAL_TO_OBJECT(argv[0]);
if (!JS_InstanceOf(c, mat, &svg_rt->matrixClass, NULL) ) return JS_TRUE;
- mx2 = JS_GetPrivate(c, mat);
+ mx2 = SMJS_GET_PRIVATE(c, mat);
if (!mx2) return JS_TRUE;
gf_mx2d_add_matrix(mx1, mx2);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(obj) );
@@ -2027,7 +2027,7 @@ static JSBool SMJS_FUNCTION(svg_mx2d_inverse)
GF_Matrix2D *mx1;
SMJS_OBJ
if (!JS_InstanceOf(c, obj, &svg_rt->matrixClass, NULL) ) return JS_TRUE;
- mx1 = JS_GetPrivate(c, obj);
+ mx1 = SMJS_GET_PRIVATE(c, obj);
if (!mx1) return JS_TRUE;
gf_mx2d_inverse(mx1);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(obj) );
@@ -2041,7 +2041,7 @@ static JSBool SMJS_FUNCTION(svg_mx2d_translate)
SMJS_OBJ
SMJS_ARGS
if (!JS_InstanceOf(c, obj, &svg_rt->matrixClass, NULL) ) return JS_TRUE;
- mx1 = JS_GetPrivate(c, obj);
+ mx1 = SMJS_GET_PRIVATE(c, obj);
if (!mx1 || (argc!=2)) return JS_TRUE;
JS_ValueToNumber(c, argv[0], &x);
JS_ValueToNumber(c, argv[1], &y);
@@ -2061,7 +2061,7 @@ static JSBool SMJS_FUNCTION(svg_mx2d_scale)
SMJS_OBJ
SMJS_ARGS
if (!JS_InstanceOf(c, obj, &svg_rt->matrixClass, NULL) ) return JS_TRUE;
- mx1 = JS_GetPrivate(c, obj);
+ mx1 = SMJS_GET_PRIVATE(c, obj);
if (!mx1 || (argc!=1)) return JS_TRUE;
JS_ValueToNumber(c, argv[0], &scale);
gf_mx2d_init(mx2);
@@ -2078,7 +2078,7 @@ static JSBool SMJS_FUNCTION(svg_mx2d_rotate)
SMJS_OBJ
SMJS_ARGS
if (!JS_InstanceOf(c, obj, &svg_rt->matrixClass, NULL) ) return JS_TRUE;
- mx1 = JS_GetPrivate(c, obj);
+ mx1 = SMJS_GET_PRIVATE(c, obj);
if (!mx1 || (argc!=1)) return JS_TRUE;
JS_ValueToNumber(c, argv[0], &angle);
gf_mx2d_init(mx2);
@@ -2097,7 +2097,7 @@ jsval svg_udom_new_rect(JSContext *c, Fixed x, Fixed y, Fixed width, Fixed heigh
rc->w = FIX2FLT(width);
rc->h = FIX2FLT(height);
rc->sg = NULL;
- JS_SetPrivate(c, r, rc);
+ SMJS_SET_PRIVATE(c, r, rc);
return OBJECT_TO_JSVAL(r);
}
@@ -2108,7 +2108,7 @@ jsval svg_udom_new_point(JSContext *c, Fixed x, Fixed y)
pt->x = FIX2FLT(x);
pt->y = FIX2FLT(y);
pt->sg = NULL;
- JS_SetPrivate(c, p, pt);
+ SMJS_SET_PRIVATE(c, p, pt);
return OBJECT_TO_JSVAL(p);
}
@@ -2140,7 +2140,7 @@ static void svg_init_js_api(GF_SceneGraph *scene)
JS_InitStandardClasses(scene->svg_js->js_ctx, scene->svg_js->global);
/*remember pointer to scene graph!!*/
- JS_SetPrivate(scene->svg_js->js_ctx, scene->svg_js->global, scene);
+ SMJS_SET_PRIVATE(scene->svg_js->js_ctx, scene->svg_js->global, scene);
{
JSPropertySpec globalClassProps[] = {
{"connected", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_READONLY, 0, 0},
@@ -2364,10 +2364,10 @@ Bool svg_script_execute(GF_SceneGraph *sg, char *utf8_script, GF_DOM_Event *even
gf_sg_lock_javascript(sg->svg_js->js_ctx, 1);
- prev_event = JS_GetPrivate(sg->svg_js->js_ctx, sg->svg_js->event);
- JS_SetPrivate(sg->svg_js->js_ctx, sg->svg_js->event, event);
+ prev_event = SMJS_GET_PRIVATE(sg->svg_js->js_ctx, sg->svg_js->event);
+ SMJS_SET_PRIVATE(sg->svg_js->js_ctx, sg->svg_js->event, event);
ret = JS_EvaluateScript(sg->svg_js->js_ctx, sg->svg_js->global, utf8_script, strlen(utf8_script), 0, 0, &rval);
- JS_SetPrivate(sg->svg_js->js_ctx, sg->svg_js->event, prev_event);
+ SMJS_SET_PRIVATE(sg->svg_js->js_ctx, sg->svg_js->event, prev_event);
if (ret==JS_FALSE) {
char *sep = strchr(utf8_script, '(');
@@ -2672,13 +2672,13 @@ static Bool svg_script_execute_handler(GF_Node *node, GF_DOM_Event *event, GF_No
#endif
gf_sg_lock_javascript(svg_js->js_ctx, 1);
- prev_event = JS_GetPrivate(svg_js->js_ctx, svg_js->event);
+ prev_event = SMJS_GET_PRIVATE(svg_js->js_ctx, svg_js->event);
/*break loops*/
if (prev_event && (prev_event->type==event->type) && (prev_event->target==event->target)) {
gf_sg_lock_javascript(svg_js->js_ctx, 0);
return 0;
}
- JS_SetPrivate(svg_js->js_ctx, svg_js->event, event);
+ SMJS_SET_PRIVATE(svg_js->js_ctx, svg_js->event, event);
svg_js->in_script = 1;
@@ -2698,7 +2698,7 @@ static Bool svg_script_execute_handler(GF_Node *node, GF_DOM_Event *event, GF_No
JSObject *evt;
jsval argv[1];
evt = gf_dom_new_event(svg_js->js_ctx);
- JS_SetPrivate(svg_js->js_ctx, evt, event);
+ SMJS_SET_PRIVATE(svg_js->js_ctx, evt, event);
argv[0] = OBJECT_TO_JSVAL(evt);
if (hdl->js_fun) {
@@ -2725,7 +2725,7 @@ static Bool svg_script_execute_handler(GF_Node *node, GF_DOM_Event *event, GF_No
JS_ClearPendingException(svg_js->js_ctx);
}
- JS_SetPrivate(svg_js->js_ctx, svg_js->event, prev_event);
+ SMJS_SET_PRIVATE(svg_js->js_ctx, svg_js->event, prev_event);
if (txt && hdl) hdl->js_fun=0;
while (svg_js->force_gc) {
diff --git a/src/scenegraph/vrml_smjs.c b/src/scenegraph/vrml_smjs.c
index f7d481c..0ec8310 100644
--- a/src/scenegraph/vrml_smjs.c
+++ b/src/scenegraph/vrml_smjs.c
@@ -591,7 +591,7 @@ static JSObject *node_get_binding(GF_ScriptPriv *priv, GF_Node *node, Bool is_co
gf_node_register(node, NULL);
obj = JS_NewObject(priv->js_ctx, &js_rt->SFNodeClass, 0, 0);
- JS_SetPrivate(priv->js_ctx, obj, field);
+ SMJS_SET_PRIVATE(priv->js_ctx, obj, field);
field->obj = obj;
gf_list_add(priv->js_cache, obj);
@@ -793,7 +793,7 @@ static JSBool SMJS_FUNCTION(addRoute)
if (!JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFNodeClass, NULL) ) return JS_FALSE;
- ptr = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0]));
+ ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0]));
assert(ptr->field.fieldType==GF_SG_VRML_SFNODE);
n1 = * ((GF_Node **)ptr->field.far_ptr);
if (!n1) return JS_FALSE;
@@ -818,7 +818,7 @@ static JSBool SMJS_FUNCTION(addRoute)
/*regular route*/
if (JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[2]), &js_rt->SFNodeClass, NULL) && JSVAL_IS_STRING(argv[3]) ) {
GF_Route *r;
- ptr = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[2]));
+ ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[2]));
assert(ptr->field.fieldType==GF_SG_VRML_SFNODE);
n2 = * ((GF_Node **)ptr->field.far_ptr);
if (!n2) return JS_FALSE;
@@ -901,7 +901,7 @@ static JSBool SMJS_FUNCTION(deleteRoute)
if (!JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFNodeClass, NULL) ) return JS_FALSE;
if (JSVAL_IS_STRING(argv[1]) && JSVAL_IS_NULL(argv[2]) && JSVAL_IS_NULL(argv[3])) {
- ptr = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0]));
+ ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0]));
assert(ptr->field.fieldType==GF_SG_VRML_SFNODE);
n1 = * ((GF_Node **)ptr->field.far_ptr);
f1 = SMJS_CHARS(c, argv[1]);
@@ -918,10 +918,10 @@ static JSBool SMJS_FUNCTION(deleteRoute)
if (!JSVAL_IS_OBJECT(argv[2]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[2]), &js_rt->SFNodeClass, NULL) ) return JS_FALSE;
if (!JSVAL_IS_STRING(argv[1]) || !JSVAL_IS_STRING(argv[3])) return JS_FALSE;
- ptr = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0]));
+ ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0]));
assert(ptr->field.fieldType==GF_SG_VRML_SFNODE);
n1 = * ((GF_Node **)ptr->field.far_ptr);
- ptr = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[2]));
+ ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[2]));
assert(ptr->field.fieldType==GF_SG_VRML_SFNODE);
n2 = * ((GF_Node **)ptr->field.far_ptr);
@@ -993,7 +993,7 @@ static JSBool SMJS_FUNCTION(loadURL)
JS_ValueToObject(c, argv[0], &p);
- f = (GF_JSField *) JS_GetPrivate(c, p);
+ f = (GF_JSField *) SMJS_GET_PRIVATE(c, p);
if (!f || !f->js_list) return JS_FALSE;
JS_GetArrayLength(c, f->js_list, &len);
@@ -1259,7 +1259,7 @@ static GFINLINE void sffield_toString(char *str, void *f_ptr, u32 fieldType)
static void JS_ObjectDestroyed(JSContext *c, JSObject *obj, GF_JSField *ptr, Bool is_js_call)
{
- JS_SetPrivate(c, obj, NULL);
+ SMJS_SET_PRIVATE(c, obj, NULL);
if (ptr) {
/*if ptr is a node, remove node binding*/
@@ -1305,7 +1305,7 @@ static JSBool SMJS_FUNCTION(field_toString)
JSString *s;
jsval item;
SMJS_OBJ
- GF_JSField *f = (GF_JSField *) JS_GetPrivate(c, obj);
+ GF_JSField *f = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
if (!f) return JS_FALSE;
strcpy(str, "");
@@ -1344,7 +1344,7 @@ static JSBool SMJS_FUNCTION(field_toString)
break;
default:
if (JSVAL_IS_OBJECT(item)) {
- GF_JSField *sf = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(item));
+ GF_JSField *sf = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(item));
sffield_toString(str, sf->field.far_ptr, sf->field.fieldType);
}
break;
@@ -1377,7 +1377,7 @@ static JSBool SMJS_FUNCTION(SFNodeConstructor)
field->field.fieldType = GF_SG_VRML_SFNODE;
field->node = NULL;
field->field.far_ptr = &field->node;
- JS_SetPrivate(c, obj, field);
+ SMJS_SET_PRIVATE(c, obj, field);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(obj) );
return JS_TRUE;
}
@@ -1445,7 +1445,7 @@ locate_proto:
}
static void node_finalize_ex(JSContext *c, JSObject *obj, Bool is_js_call)
{
- GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj);
+ GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
JS_ObjectDestroyed(c, obj, ptr, is_js_call);
@@ -1478,7 +1478,7 @@ static JSBool node_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, js
GF_ScriptPriv *priv;
if (! JS_InstanceOf(c, obj, &js_rt->SFNodeClass, NULL) ) return JS_FALSE;
- ptr = (GF_JSField *) JS_GetPrivate(c, obj);
+ ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
assert(ptr->field.fieldType==GF_SG_VRML_SFNODE);
n = * ((GF_Node **)ptr->field.far_ptr);
priv = JS_GetScriptStack(c);
@@ -1540,7 +1540,7 @@ static JSBool node_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, js
char *fieldname;
GF_JSField *ptr;
if (! JS_InstanceOf(c, obj, &js_rt->SFNodeClass, NULL) ) return JS_FALSE;
- ptr = (GF_JSField *) JS_GetPrivate(c, obj);
+ ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
/*this is the prototype*/
if (!ptr) {
@@ -1596,7 +1596,7 @@ static JSBool SMJS_FUNCTION(node_toString)
const char *name;
SMJS_OBJ
if (! JS_InstanceOf(c, obj, &js_rt->SFNodeClass, NULL) ) return JS_FALSE;
- f = (GF_JSField *) JS_GetPrivate(c, obj);
+ f = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
if (!f) return JS_FALSE;
str[0] = 0;
@@ -1624,7 +1624,7 @@ static JSBool SMJS_FUNCTION(node_getTime)
GF_JSField *f;
SMJS_OBJ
if (! JS_InstanceOf(c, obj, &js_rt->SFNodeClass, NULL) ) return JS_FALSE;
- f = (GF_JSField *) JS_GetPrivate(c, obj);
+ f = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
if (!f) return JS_FALSE;
n = * ((GF_Node **)f->field.far_ptr);
@@ -1636,7 +1636,7 @@ static JSBool SMJS_FUNCTION(node_getTime)
/* Generic field destructor */
static void field_finalize(JSContext *c, JSObject *obj)
{
- GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj);
+ GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
JS_ObjectDestroyed(c, obj, ptr, 1);
if (!ptr) return;
@@ -1664,7 +1664,7 @@ static GFINLINE GF_JSField *SFImage_Create(JSContext *c, JSObject *obj, u32 w, u
v->pixels = (u8 *) gf_malloc(sizeof(u8) * nbComp * w * h);
len = MIN(nbComp * w * h, pixels->count);
for (i=0; i<len; i++) v->pixels[i] = (u8) pixels->vals[i];
- JS_SetPrivate(c, obj, field);
+ SMJS_SET_PRIVATE(c, obj, field);
return field;
}
static JSBool SMJS_FUNCTION(SFImageConstructor)
@@ -1679,7 +1679,7 @@ static JSBool SMJS_FUNCTION(SFImageConstructor)
w = JSVAL_TO_INT(argv[0]);
h = JSVAL_TO_INT(argv[1]);
nbComp = JSVAL_TO_INT(argv[2]);
- pixels = (MFInt32 *) ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[3])))->field.far_ptr;
+ pixels = (MFInt32 *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[3])))->field.far_ptr;
SFImage_Create(c, obj, w, h, nbComp, pixels);
return JS_TRUE;
}
@@ -1687,7 +1687,7 @@ static JSBool SMJS_FUNCTION(SFImageConstructor)
static JSBool image_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, jsval *vp)
{
GF_ScriptPriv *priv = JS_GetScriptStack(c);
- GF_JSField *val = (GF_JSField *) JS_GetPrivate(c, obj);
+ GF_JSField *val = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
SFImage *sfi;
if (!val) return JS_FALSE;
sfi = (SFImage*)val->field.far_ptr;
@@ -1699,7 +1699,7 @@ static JSBool image_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, j
case 3:
{
u32 i, len;
- JSObject *an_obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFInt32Class, 0, priv->js_obj);
+ JSObject *an_obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFInt32Class, priv->js_obj);
len = sfi->width*sfi->height*sfi->numComponents;
for (i=0; i<len; i++) {
jsval newVal = INT_TO_JSVAL(sfi->pixels[i]);
@@ -1718,7 +1718,7 @@ static JSBool image_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, j
{
u32 ival;
Bool changed = 0;
- GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj);
+ GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
SFImage *sfi;
/*this is the prototype*/
@@ -1753,7 +1753,7 @@ static JSBool image_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, j
MFInt32 *pixels;
u32 len, i;
if (!JSVAL_IS_OBJECT(*vp) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(*vp), &js_rt->MFInt32Class, NULL)) return JS_FALSE;
- pixels = (MFInt32 *) ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(*vp)))->field.far_ptr;
+ pixels = (MFInt32 *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*vp)))->field.far_ptr;
if (sfi->pixels) gf_free(sfi->pixels);
len = sfi->width*sfi->height*sfi->numComponents;
sfi->pixels = (char *) gf_malloc(sizeof(char)*len);
@@ -1781,7 +1781,7 @@ static GFINLINE GF_JSField *SFVec2f_Create(JSContext *c, JSObject *obj, Fixed x,
field->field.fieldType = GF_SG_VRML_SFVEC2F;
v->x = x;
v->y = y;
- JS_SetPrivate(c, obj, field);
+ SMJS_SET_PRIVATE(c, obj, field);
return field;
}
static JSBool SMJS_FUNCTION(SFVec2fConstructor)
@@ -1796,7 +1796,7 @@ static JSBool SMJS_FUNCTION(SFVec2fConstructor)
}
static JSBool vec2f_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, jsval *vp)
{
- GF_JSField *val = (GF_JSField *) JS_GetPrivate(c, obj);
+ GF_JSField *val = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
if (SMJS_ID_IS_INT(id)) {
switch (SMJS_ID_TO_INT(id)) {
@@ -1813,7 +1813,7 @@ static JSBool vec2f_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, j
jsdouble d;
Fixed v;
Bool changed = 0;
- GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj);
+ GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
/*this is the prototype*/
if (!ptr) {
@@ -1852,9 +1852,9 @@ static JSBool SMJS_FUNCTION(vec2f_add)
if (argc<=0 || !JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFVec2fClass, NULL))
return JS_FALSE;
- v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
- v2 = ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr;
- pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, JS_GetParent(c, obj));
+ v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
+ v2 = ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr;
+ pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, SMJS_GET_PARENT(c, obj));
SFVec2f_Create(c, pNew, v1->x + v2->x, v1->y + v2->y);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) );
return JS_TRUE;
@@ -1868,9 +1868,9 @@ static JSBool SMJS_FUNCTION(vec2f_subtract)
if (argc<=0 || !JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFVec2fClass, NULL))
return JS_FALSE;
- v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
- v2 = ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr;
- pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, JS_GetParent(c, obj));
+ v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
+ v2 = ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr;
+ pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, SMJS_GET_PARENT(c, obj));
SFVec2f_Create(c, pNew, v1->x - v2->x, v1->y - v2->y);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) );
return JS_TRUE;
@@ -1880,8 +1880,8 @@ static JSBool SMJS_FUNCTION(vec2f_negate)
SFVec2f *v1;
JSObject *pNew;
SMJS_OBJ
- v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
- pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, JS_GetParent(c, obj));
+ v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
+ pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, SMJS_GET_PARENT(c, obj));
SFVec2f_Create(c, pNew, -v1->x , -v1->y );
SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) );
return JS_TRUE;
@@ -1895,8 +1895,8 @@ static JSBool SMJS_FUNCTION(vec2f_multiply)
SMJS_ARGS
SMJS_OBJ
if (argc<=0) return JS_FALSE;
- v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
- pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, JS_GetParent(c, obj));
+ v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
+ pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, SMJS_GET_PARENT(c, obj));
JS_ValueToNumber(c, argv[0], &d );
v = FLT2FIX( d);
SFVec2f_Create(c, pNew, gf_mulfix(v1->x , v), gf_mulfix(v1->y, v) );
@@ -1912,8 +1912,8 @@ static JSBool SMJS_FUNCTION(vec2f_divide)
SMJS_ARGS
SMJS_OBJ
if (argc<=0) return JS_FALSE;
- v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
- pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, JS_GetParent(c, obj));
+ v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
+ pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, SMJS_GET_PARENT(c, obj));
JS_ValueToNumber(c, argv[0], &d );
v = FLT2FIX(d);
SFVec2f_Create(c, pNew, gf_divfix(v1->x, v), gf_divfix(v1->y, v));
@@ -1925,7 +1925,7 @@ static JSBool SMJS_FUNCTION(vec2f_length)
Double res;
SFVec2f *v1;
SMJS_OBJ
- v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
+ v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
res = FIX2FLT(gf_v2d_len(v1));
SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, res) );
return JS_TRUE;
@@ -1936,9 +1936,9 @@ static JSBool SMJS_FUNCTION(vec2f_normalize)
Fixed res;
JSObject *pNew;
SMJS_OBJ
- v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
+ v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
res = gf_v2d_len(v1);
- pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, JS_GetParent(c, obj));
+ pNew = JS_NewObject(c, &js_rt->SFVec2fClass, 0, SMJS_GET_PARENT(c, obj));
SFVec2f_Create(c, pNew, gf_divfix(v1->x, res), gf_divfix(v1->y, res) );
SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) );
return JS_TRUE;
@@ -1951,8 +1951,8 @@ static JSBool SMJS_FUNCTION(vec2f_dot)
if (argc<=0 || !JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFVec2fClass, NULL))
return JS_FALSE;
- v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
- v2 = ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr;
+ v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
+ v2 = ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr;
SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, FIX2FLT( gf_mulfix(v1->x, v2->x) + gf_mulfix(v1->y, v2->y) ) ) );
return JS_TRUE;
}
@@ -1970,7 +1970,7 @@ static GFINLINE GF_JSField *SFVec3f_Create(JSContext *c, JSObject *obj, Fixed x,
v->x = x;
v->y = y;
v->z = z;
- JS_SetPrivate(c, obj, field);
+ SMJS_SET_PRIVATE(c, obj, field);
return field;
}
static JSBool SMJS_FUNCTION(SFVec3fConstructor)
@@ -1986,7 +1986,7 @@ static JSBool SMJS_FUNCTION(SFVec3fConstructor)
}
static JSBool vec3f_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, jsval *vp)
{
- GF_JSField *val = (GF_JSField *) JS_GetPrivate(c, obj);
+ GF_JSField *val = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
if (SMJS_ID_IS_INT(id)) {
switch (SMJS_ID_TO_INT(id)) {
case 0: *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFVec3f*)val->field.far_ptr)->x) ); break;
@@ -2002,7 +2002,7 @@ static JSBool vec3f_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, j
jsdouble d;
Fixed v;
Bool changed = 0;
- GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj);
+ GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
/*this is the prototype*/
if (!ptr) {
@@ -2043,9 +2043,9 @@ static JSBool SMJS_FUNCTION(vec3f_add)
if (argc<=0 || !JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFVec3fClass, NULL))
return JS_FALSE;
- v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
- v2 = ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr;
- pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, JS_GetParent(c, obj));
+ v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
+ v2 = ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr;
+ pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, SMJS_GET_PARENT(c, obj));
SFVec3f_Create(c, pNew, v1->x + v2->x, v1->y + v2->y, v1->z + v2->z);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) );
return JS_TRUE;
@@ -2059,9 +2059,9 @@ static JSBool SMJS_FUNCTION(vec3f_subtract)
if (argc<=0 || !JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFVec3fClass, NULL))
return JS_FALSE;
- v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
- v2 = ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr;
- pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, JS_GetParent(c, obj));
+ v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
+ v2 = ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr;
+ pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, SMJS_GET_PARENT(c, obj));
SFVec3f_Create(c, pNew, v1->x - v2->x, v1->y - v2->y, v1->z - v2->z);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) );
return JS_TRUE;
@@ -2071,8 +2071,8 @@ static JSBool SMJS_FUNCTION(vec3f_negate)
SFVec3f *v1;
JSObject *pNew;
SMJS_OBJ
- v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
- pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, JS_GetParent(c, obj));
+ v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
+ pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, SMJS_GET_PARENT(c, obj));
SFVec3f_Create(c, pNew, -v1->x , -v1->y , -v1->z );
SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) );
return JS_TRUE;
@@ -2087,8 +2087,8 @@ static JSBool SMJS_FUNCTION(vec3f_multiply)
SMJS_ARGS
if (argc<=0) return JS_FALSE;
- v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
- pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, JS_GetParent(c, obj));
+ v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
+ pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, SMJS_GET_PARENT(c, obj));
JS_ValueToNumber(c, argv[0], &d );
v = FLT2FIX(d);
SFVec3f_Create(c, pNew, gf_mulfix(v1->x, v), gf_mulfix(v1->y, v), gf_mulfix(v1->z, v) );
@@ -2104,8 +2104,8 @@ static JSBool SMJS_FUNCTION(vec3f_divide)
SMJS_OBJ
SMJS_ARGS
if (argc<=0) return JS_FALSE;
- v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
- pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, JS_GetParent(c, obj));
+ v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
+ pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, SMJS_GET_PARENT(c, obj));
JS_ValueToNumber(c, argv[0], &d );
v = FLT2FIX(d);
SFVec3f_Create(c, pNew, gf_divfix(v1->x, v), gf_divfix(v1->y, v), gf_divfix(v1->z, v));
@@ -2117,7 +2117,7 @@ static JSBool SMJS_FUNCTION(vec3f_length)
Fixed res;
SFVec3f *v1;
SMJS_OBJ
- v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
+ v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
res = gf_vec_len(*v1);
SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, FIX2FLT(res) ) );
return JS_TRUE;
@@ -2127,9 +2127,9 @@ static JSBool SMJS_FUNCTION(vec3f_normalize)
SFVec3f v1;
JSObject *pNew;
SMJS_OBJ
- v1 = * (SFVec3f *) ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
+ v1 = * (SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
gf_vec_norm(&v1);
- pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, JS_GetParent(c, obj));
+ pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, SMJS_GET_PARENT(c, obj));
SFVec3f_Create(c, pNew, v1.x, v1.y, v1.z);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) );
return JS_TRUE;
@@ -2142,8 +2142,8 @@ static JSBool SMJS_FUNCTION(vec3f_dot)
if (argc<=0 || !JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFVec3fClass, NULL))
return JS_FALSE;
- v1 = *(SFVec3f *) ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
- v2 = *(SFVec3f *) ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr;
+ v1 = *(SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
+ v2 = *(SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr;
SMJS_SET_RVAL( JS_MAKE_DOUBLE(c, FIX2FLT(gf_vec_dot(v1, v2)) ) );
return JS_TRUE;
}
@@ -2156,9 +2156,9 @@ static JSBool SMJS_FUNCTION(vec3f_cross)
if (argc<=0 || !JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFVec3fClass, NULL))
return JS_FALSE;
- v1 = * (SFVec3f *) ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
- v2 = * (SFVec3f *) ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr;
- pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, JS_GetParent(c, obj));
+ v1 = * (SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
+ v2 = * (SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr;
+ pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, SMJS_GET_PARENT(c, obj));
v3 = gf_vec_cross(v1, v2);
SFVec3f_Create(c, pNew, v3.x, v3.y, v3.z);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) );
@@ -2180,7 +2180,7 @@ static GFINLINE GF_JSField *SFRotation_Create(JSContext *c, JSObject *obj, Fixed
v->y = y;
v->z = z;
v->q = q;
- JS_SetPrivate(c, obj, field);
+ SMJS_SET_PRIVATE(c, obj, field);
return field;
}
static JSBool SMJS_FUNCTION(SFRotationConstructor)
@@ -2208,7 +2208,7 @@ static JSBool SMJS_FUNCTION(SFRotationConstructor)
if (!JSVAL_IS_OBJECT(argv[0])) return JS_FALSE;
an_obj = JSVAL_TO_OBJECT(argv[0]);
if (! JS_InstanceOf(c, an_obj, &js_rt->SFVec3fClass, NULL)) return JS_FALSE;
- v1 = * (SFVec3f *) ((GF_JSField *) JS_GetPrivate(c, an_obj))->field.far_ptr;
+ v1 = * (SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, an_obj))->field.far_ptr;
if (JSVAL_IS_DOUBLE(argv[1])) {
JS_ValueToNumber(c, argv[1], &a);
SFRotation_Create(c, obj, v1.x, v1.y, v1.z, FLT2FIX(a));
@@ -2218,7 +2218,7 @@ static JSBool SMJS_FUNCTION(SFRotationConstructor)
if (!JSVAL_IS_OBJECT(argv[1])) return JS_FALSE;
an_obj = JSVAL_TO_OBJECT(argv[1]);
if (!JS_InstanceOf(c, an_obj, &js_rt->SFVec3fClass, NULL)) return JS_FALSE;
- v2 = * (SFVec3f *) ((GF_JSField *) JS_GetPrivate(c, an_obj))->field.far_ptr;
+ v2 = * (SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, an_obj))->field.far_ptr;
l1 = gf_vec_len(v1);
l2 = gf_vec_len(v2);
dot = gf_divfix(gf_vec_dot(v1, v2), gf_mulfix(l1, l2) );
@@ -2232,7 +2232,7 @@ static JSBool SMJS_FUNCTION(SFRotationConstructor)
static JSBool rot_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, jsval *vp)
{
- GF_JSField *val = (GF_JSField *) JS_GetPrivate(c, obj);
+ GF_JSField *val = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
if (SMJS_ID_IS_INT(id)) {
switch (SMJS_ID_TO_INT(id)) {
case 0: *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFRotation*)val->field.far_ptr)->x)); break;
@@ -2249,7 +2249,7 @@ static JSBool rot_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, jsv
jsdouble d;
Fixed v;
Bool changed = 0;
- GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj);
+ GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
/*this is the prototype*/
if (!ptr) {
@@ -2291,8 +2291,8 @@ static JSBool SMJS_FUNCTION(rot_getAxis)
SFRotation r;
JSObject *pNew;
SMJS_OBJ
- r = * (SFRotation *) ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
- pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, JS_GetParent(c, obj));
+ r = * (SFRotation *) ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
+ pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, SMJS_GET_PARENT(c, obj));
SFVec3f_Create(c, pNew, r.x, r.y, r.z);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) );
return JS_TRUE;
@@ -2302,8 +2302,8 @@ static JSBool SMJS_FUNCTION(rot_inverse)
SFRotation r;
JSObject *pNew;
SMJS_OBJ
- r = * (SFRotation *) ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
- pNew = JS_NewObject(c, &js_rt->SFRotationClass, 0, JS_GetParent(c, obj));
+ r = * (SFRotation *) ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
+ pNew = JS_NewObject(c, &js_rt->SFRotationClass, 0, SMJS_GET_PARENT(c, obj));
SFRotation_Create(c, pNew, r.x, r.y, r.z, r.q-GF_PI);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) );
return JS_TRUE;
@@ -2320,14 +2320,14 @@ static JSBool SMJS_FUNCTION(rot_multiply)
if (argc<=0 || !JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFRotationClass, NULL))
return JS_FALSE;
- r1 = * (SFRotation *) ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
- r2 = * (SFRotation *) ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr;
+ r1 = * (SFRotation *) ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
+ r2 = * (SFRotation *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr;
q1 = gf_quat_from_rotation(r1);
q2 = gf_quat_from_rotation(r2);
q1 = gf_quat_multiply(&q1, &q2);
r1 = gf_quat_to_rotation(&q1);
- pNew = JS_NewObject(c, &js_rt->SFRotationClass, 0, JS_GetParent(c, obj));
+ pNew = JS_NewObject(c, &js_rt->SFRotationClass, 0, SMJS_GET_PARENT(c, obj));
SFRotation_Create(c, pNew, r1.x, r1.y, r1.z, r1.q);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) );
return JS_TRUE;
@@ -2345,12 +2345,12 @@ static JSBool SMJS_FUNCTION(rot_multVec)
if (argc<=0 || !JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFVec3fClass, NULL))
return JS_FALSE;
- r = *(SFRotation *) ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
- v = *(SFVec3f *) ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr;
+ r = *(SFRotation *) ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
+ v = *(SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr;
gf_mx_init(mx);
gf_mx_add_rotation(&mx, r.q, r.x, r.y, r.z);
gf_mx_apply_vec(&mx, &v);
- pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, JS_GetParent(c, obj));
+ pNew = JS_NewObject(c, &js_rt->SFVec3fClass, 0, SMJS_GET_PARENT(c, obj));
SFVec3f_Create(c, pNew, v.x, v.y, v.z);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) );
return JS_TRUE;
@@ -2367,10 +2367,10 @@ static JSBool SMJS_FUNCTION(rot_setAxis)
if (argc<=0 || !JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFVec3fClass, NULL))
return JS_FALSE;
- ptr = (GF_JSField *) JS_GetPrivate(c, obj);
+ ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
r = (SFRotation *) ptr->field.far_ptr;
- v = *(SFVec3f *) ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr;
+ v = *(SFVec3f *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr;
r->x = v.x;
r->y = v.y;
@@ -2390,14 +2390,14 @@ static JSBool SMJS_FUNCTION(rot_slerp)
if (!JSVAL_IS_DOUBLE(argv[1]) || !JSVAL_IS_OBJECT(argv[0]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[0]), &js_rt->SFRotationClass, NULL)) return JS_FALSE;
- v1 = *(SFRotation *) ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
- v2 = *(SFRotation *) ((GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr;
+ v1 = *(SFRotation *) ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
+ v2 = *(SFRotation *) ((GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(argv[0])))->field.far_ptr;
JS_ValueToNumber(c, argv[1], &d );
q1 = gf_quat_from_rotation(v1);
q2 = gf_quat_from_rotation(v2);
q1 = gf_quat_slerp(q1, q2, FLT2FIX( d));
res = gf_quat_to_rotation(&q1);
- pNew = JS_NewObject(c, &js_rt->SFRotationClass, 0, JS_GetParent(c, obj));
+ pNew = JS_NewObject(c, &js_rt->SFRotationClass, 0, SMJS_GET_PARENT(c, obj));
SFRotation_Create(c, pNew, res.x, res.y, res.z, res.q);
SMJS_SET_RVAL( OBJECT_TO_JSVAL(pNew) );
return JS_TRUE;
@@ -2415,7 +2415,7 @@ static GFINLINE GF_JSField *SFColor_Create(JSContext *c, JSObject *obj, Fixed r,
v->red = r;
v->green = g;
v->blue = b;
- JS_SetPrivate(c, obj, field);
+ SMJS_SET_PRIVATE(c, obj, field);
return field;
}
static JSBool SMJS_FUNCTION(SFColorConstructor)
@@ -2431,7 +2431,7 @@ static JSBool SMJS_FUNCTION(SFColorConstructor)
}
static JSBool color_getProperty(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, jsval *vp)
{
- GF_JSField *val = (GF_JSField *) JS_GetPrivate(c, obj);
+ GF_JSField *val = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
if (SMJS_ID_IS_INT(id)) {
switch (SMJS_ID_TO_INT(id)) {
case 0: *vp = JS_MAKE_DOUBLE(c, FIX2FLT( ((SFColor*)val->field.far_ptr)->red)); break;
@@ -2448,7 +2448,7 @@ static JSBool color_setProperty(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, j
jsdouble d;
Fixed v;
Bool changed = 0;
- GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj);
+ GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
/*this is the prototype*/
if (!ptr) {
if (! SMJS_ID_IS_STRING(id)) return JS_FALSE;
@@ -2486,9 +2486,9 @@ static JSBool SMJS_FUNCTION(color_setHSV)
jsdouble h, s, v;
SMJS_OBJ
SMJS_ARGS
- GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj);
+ GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
if (argc != 3) return JS_FALSE;
- v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
+ v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
JS_ValueToNumber( c, argv[0], &h);
JS_ValueToNumber( c, argv[1], &s);
JS_ValueToNumber( c, argv[2], &v);
@@ -2507,7 +2507,7 @@ static JSBool SMJS_FUNCTION(color_getHSV)
jsval vec[3];
JSObject *arr;
SMJS_OBJ
- v1 = ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
+ v1 = ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
hsv = *v1;
SFColor_toHSV(&hsv);
vec[0] = JS_MAKE_DOUBLE(c, FIX2FLT(hsv.red));
@@ -2536,7 +2536,7 @@ static void setup_js_array(JSContext *c, JSObject *obj, GF_JSField *ptr, uintN a
ptr = NewJSField(c); \
ptr->field.fieldType = _fieldType; \
setup_js_array(c, obj, ptr, (jsint) argc, argv); \
- JS_SetPrivate(c, obj, ptr); \
+ SMJS_SET_PRIVATE(c, obj, ptr); \
SMJS_SET_RVAL( OBJECT_TO_JSVAL(obj) ); \
return obj == 0 ? JS_FALSE : JS_TRUE; \
@@ -2572,7 +2572,7 @@ static JSBool SMJS_FUNCTION(MFNodeConstructor)
static void array_finalize_ex(JSContext *c, JSObject *obj, Bool is_js_call)
{
- GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj);
+ GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
JS_ObjectDestroyed(c, obj, ptr, 1);
@@ -2601,7 +2601,7 @@ static void array_finalize(JSContext *c, JSObject *obj)
JSBool array_getElement(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, jsval *rval)
{
u32 i;
- GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj);
+ GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
if (SMJS_ID_IS_INT(id)) {
i = SMJS_ID_TO_INT(id);
if (ptr->field.fieldType==GF_SG_VRML_MFNODE) {
@@ -2628,7 +2628,7 @@ JSBool array_setElement(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, jsval *rv
JSString *str;
char *str_val;
void *sf_slot;
- GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj);
+ GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
ind = SMJS_ID_TO_INT(id);
ret = JS_GetArrayLength(c, ptr->js_list, &len);
@@ -2668,7 +2668,7 @@ JSBool array_setElement(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, jsval *rv
case GF_SG_VRML_MFVEC3F:
case GF_SG_VRML_MFCOLOR:
case GF_SG_VRML_MFROTATION:
- a_val = OBJECT_TO_JSVAL( JS_ConstructObject(c, the_sf_class, 0, obj) );
+ a_val = OBJECT_TO_JSVAL( SMJS_CONSTRUCT_OBJECT(c, the_sf_class, obj) );
break;
default:
a_val = INT_TO_JSVAL(0);
@@ -2721,7 +2721,7 @@ JSBool array_setElement(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, jsval *rv
if (!ptr->owner) return JS_TRUE;
/*get new node*/
- from = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(*rval));
+ from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*rval));
new_n = *(GF_Node**)from->field.far_ptr;
#if 0
@@ -2794,19 +2794,19 @@ JSBool array_setElement(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, jsval *rv
break;
case GF_SG_VRML_MFVEC2F:
- from = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(*rval));
+ from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*rval));
gf_sg_vrml_field_copy(& ((MFVec2f *)ptr->field.far_ptr)->vals[ind], from->field.far_ptr, from->field.fieldType);
break;
case GF_SG_VRML_MFVEC3F:
- from = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(*rval));
+ from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*rval));
gf_sg_vrml_field_copy(& ((MFVec3f *)ptr->field.far_ptr)->vals[ind], from->field.far_ptr, from->field.fieldType);
break;
case GF_SG_VRML_MFROTATION:
- from = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(*rval));
+ from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*rval));
gf_sg_vrml_field_copy(& ((MFRotation *)ptr->field.far_ptr)->vals[ind], from->field.far_ptr, from->field.fieldType);
break;
case GF_SG_VRML_MFCOLOR:
- from = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(*rval));
+ from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(*rval));
gf_sg_vrml_field_copy(& ((MFColor *)ptr->field.far_ptr)->vals[ind], from->field.far_ptr, from->field.fieldType);
break;
}
@@ -2820,7 +2820,7 @@ JSBool array_setLength(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, jsval *val
u32 len, i, sftype;
JSBool ret;
JSClass *the_sf_class;
- GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj);
+ GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
if (!JSVAL_IS_INT(*val) || JSVAL_TO_INT(*val) < 0) return JS_FALSE;
len = JSVAL_TO_INT(*val);
@@ -2873,7 +2873,7 @@ JSBool array_setLength(JSContext *c, JSObject *obj, SMJS_PROP_SETTER, jsval *val
for (i=0; i<len; i++) {
jsval a_val;
if (the_sf_class) {
- JSObject *an_obj = JS_ConstructObject(c, the_sf_class, 0, obj);
+ JSObject *an_obj = SMJS_CONSTRUCT_OBJECT(c, the_sf_class, obj);
a_val = OBJECT_TO_JSVAL(an_obj );
} else {
switch (sftype) {
@@ -2899,7 +2899,7 @@ JSBool array_getLength(JSContext *c, JSObject *obj, SMJS_PROP_GETTER, jsval *val
{
JSBool ret;
jsuint len;
- GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj);
+ GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
if (ptr->field.fieldType==GF_SG_VRML_MFNODE) {
len = gf_node_list_get_count(*(GF_ChildNodeItem **)ptr->field.far_ptr);
@@ -2924,11 +2924,11 @@ static JSBool SMJS_FUNCTION(MFVec2fConstructor)
setup_js_array(c, obj, ptr, 0, 0);
JS_SetArrayLength(c, ptr->js_list, argc);
- JS_SetPrivate(c, obj, ptr);
+ SMJS_SET_PRIVATE(c, obj, ptr);
for (i=0; i<argc; i++) {
if (!JSVAL_IS_OBJECT(argv[i]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[i]), &js_rt->SFVec2fClass, NULL) ) {
- item = JS_ConstructObject(c, &js_rt->SFVec2fClass, 0, obj);
+ item = SMJS_CONSTRUCT_OBJECT(c, &js_rt->SFVec2fClass, obj);
val = OBJECT_TO_JSVAL(item);
JS_SetElement(c, ptr->js_list, i, &val);
} else {
@@ -2953,11 +2953,11 @@ static JSBool SMJS_FUNCTION(MFVec3fConstructor)
ptr->field.fieldType = GF_SG_VRML_MFVEC3F;
setup_js_array(c, obj, ptr, 0, 0);
JS_SetArrayLength(c, ptr->js_list, argc);
- JS_SetPrivate(c, obj, ptr);
+ SMJS_SET_PRIVATE(c, obj, ptr);
for (i=0; i<argc; i++) {
if (!JSVAL_IS_OBJECT(argv[i]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[i]), &js_rt->SFVec3fClass, NULL) ) {
- item = JS_ConstructObject(c, &js_rt->SFVec3fClass, 0, obj);
+ item = SMJS_CONSTRUCT_OBJECT(c, &js_rt->SFVec3fClass, obj);
val = OBJECT_TO_JSVAL(item);
JS_SetElement(c, ptr->js_list, i, &val);
} else {
@@ -2982,11 +2982,11 @@ static JSBool SMJS_FUNCTION(MFRotationConstructor)
ptr->field.fieldType = GF_SG_VRML_MFROTATION;
setup_js_array(c, obj, ptr, 0, 0);
JS_SetArrayLength(c, ptr->js_list, argc);
- JS_SetPrivate(c, obj, ptr);
+ SMJS_SET_PRIVATE(c, obj, ptr);
for (i=0; i<argc; i++) {
if (!JSVAL_IS_OBJECT(argv[i]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[i]), &js_rt->SFRotationClass, NULL) ) {
- item = JS_ConstructObject(c, &js_rt->SFVec3fClass, 0, obj);
+ item = SMJS_CONSTRUCT_OBJECT(c, &js_rt->SFVec3fClass, obj);
val = OBJECT_TO_JSVAL(item);
JS_SetElement(c, ptr->js_list, i, &val);
} else {
@@ -3011,11 +3011,11 @@ static JSBool SMJS_FUNCTION(MFColorConstructor)
ptr->field.fieldType = GF_SG_VRML_MFCOLOR;
setup_js_array(c, obj, ptr, 0, 0);
JS_SetArrayLength(c, ptr->js_list, argc);
- JS_SetPrivate(c, obj, ptr);
+ SMJS_SET_PRIVATE(c, obj, ptr);
for (i=0; i<argc; i++) {
if (!JSVAL_IS_OBJECT(argv[i]) || !JS_InstanceOf(c, JSVAL_TO_OBJECT(argv[i]), &js_rt->SFColorClass, NULL) ) {
- item = JS_ConstructObject(c, &js_rt->SFColorClass, 0, obj);
+ item = SMJS_CONSTRUCT_OBJECT(c, &js_rt->SFColorClass, obj);
val = OBJECT_TO_JSVAL(item);
JS_SetElement(c, ptr->js_list, i, &val);
} else {
@@ -3038,7 +3038,7 @@ JSBool SMJS_FUNCTION(vrml_event_add_listener)
GF_JSField *ptr;
SMJS_OBJ
if (! JS_InstanceOf(c, obj, &js_rt->SFNodeClass, NULL) ) return JS_FALSE;
- ptr = (GF_JSField *) JS_GetPrivate(c, obj);
+ ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
assert(ptr->field.fieldType==GF_SG_VRML_SFNODE);
node = * ((GF_Node **)ptr->field.far_ptr);
@@ -3050,7 +3050,7 @@ JSBool SMJS_FUNCTION(vrml_event_remove_listener)
GF_JSField *ptr;
SMJS_OBJ
if (! JS_InstanceOf(c, obj, &js_rt->SFNodeClass, NULL) ) return JS_FALSE;
- ptr = (GF_JSField *) JS_GetPrivate(c, obj);
+ ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
assert(ptr->field.fieldType==GF_SG_VRML_SFNODE);
node = * ((GF_Node **)ptr->field.far_ptr);
@@ -3143,7 +3143,7 @@ void gf_sg_script_init_sm_api(GF_ScriptPriv *sc, GF_Node *script)
JS_DefineFunctions(sc->js_ctx, sc->js_obj, globalFunctions );
}
/*remember pointer to scene graph!!*/
- JS_SetPrivate(sc->js_ctx, sc->js_obj, script->sgprivate->scenegraph);
+ SMJS_SET_PRIVATE(sc->js_ctx, sc->js_obj, script->sgprivate->scenegraph);
JS_DefineProperty(sc->js_ctx, sc->js_obj, "FALSE", BOOLEAN_TO_JSVAL(JS_FALSE), 0, 0, JSPROP_READONLY | JSPROP_PERMANENT );
@@ -3436,7 +3436,7 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF
case GF_SG_VRML_SFVEC2F:
{
if (JS_InstanceOf(c, obj, &js_rt->SFVec2fClass, NULL) ) {
- p = (GF_JSField *) JS_GetPrivate(c, obj);
+ p = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
gf_sg_vrml_field_copy(field->far_ptr, p->field.far_ptr, GF_SG_VRML_SFVEC2F);
Script_FieldChanged(c, owner, parent, field);
}
@@ -3445,7 +3445,7 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF
case GF_SG_VRML_SFVEC3F:
{
if (JS_InstanceOf(c, obj, &js_rt->SFVec3fClass, NULL) ) {
- p = (GF_JSField *) JS_GetPrivate(c, obj);
+ p = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
gf_sg_vrml_field_copy(field->far_ptr, p->field.far_ptr, GF_SG_VRML_SFVEC3F);
Script_FieldChanged(c, owner, parent, field);
}
@@ -3454,7 +3454,7 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF
case GF_SG_VRML_SFROTATION:
{
if ( JS_InstanceOf(c, obj, &js_rt->SFRotationClass, NULL) ) {
- p = (GF_JSField *) JS_GetPrivate(c, obj);
+ p = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
gf_sg_vrml_field_copy(field->far_ptr, p->field.far_ptr, GF_SG_VRML_SFROTATION);
Script_FieldChanged(c, owner, parent, field);
}
@@ -3463,7 +3463,7 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF
case GF_SG_VRML_SFCOLOR:
{
if (JS_InstanceOf(c, obj, &js_rt->SFColorClass, NULL) ) {
- p = (GF_JSField *) JS_GetPrivate(c, obj);
+ p = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
gf_sg_vrml_field_copy(field->far_ptr, p->field.far_ptr, GF_SG_VRML_SFCOLOR);
Script_FieldChanged(c, owner, parent, field);
}
@@ -3480,7 +3480,7 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF
if (JSVAL_IS_NULL(val)) {
Script_FieldChanged(c, owner, parent, field);
} else if (JS_InstanceOf(c, obj, &js_rt->SFNodeClass, NULL) ) {
- GF_Node *n = * (GF_Node**) ((GF_JSField *) JS_GetPrivate(c, obj))->field.far_ptr;
+ GF_Node *n = * (GF_Node**) ((GF_JSField *) SMJS_GET_PRIVATE(c, obj))->field.far_ptr;
* ((GF_Node **)field->far_ptr) = n;
gf_node_register(n, owner);
Script_FieldChanged(c, owner, parent, field);
@@ -3490,7 +3490,7 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF
case GF_SG_VRML_SFIMAGE:
{
if ( JS_InstanceOf(c, obj, &js_rt->SFImageClass, NULL) ) {
- p = (GF_JSField *) JS_GetPrivate(c, obj);
+ p = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
gf_sg_vrml_field_copy(field->far_ptr, p->field.far_ptr, GF_SG_VRML_SFIMAGE);
Script_FieldChanged(c, owner, parent, field);
}
@@ -3518,7 +3518,7 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF
) return;
- p = (GF_JSField *) JS_GetPrivate(c, obj);
+ p = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
JS_GetArrayLength(c, p->js_list, &len);
/*special handling for MF node, reset list first*/
@@ -3535,7 +3535,7 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF
if (!JSVAL_IS_OBJECT(item)) break;
node_obj = JSVAL_TO_OBJECT(item);
if ( !JS_InstanceOf(c, node_obj, &js_rt->SFNodeClass, NULL)) break;
- from = (GF_JSField *) JS_GetPrivate(c, node_obj);
+ from = (GF_JSField *) SMJS_GET_PRIVATE(c, node_obj);
child = * ((GF_Node**)from->field.far_ptr);
@@ -3611,25 +3611,25 @@ void gf_sg_script_to_node_field(JSContext *c, jsval val, GF_FieldInfo *field, GF
case GF_SG_VRML_MFVEC2F:
if ( JSVAL_IS_OBJECT(item) && JS_InstanceOf(c, JSVAL_TO_OBJECT(item), &js_rt->SFVec2fClass, NULL) ) {
- from = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(item));
+ from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(item));
gf_sg_vrml_field_copy(& ((MFVec2f*)field->far_ptr)->vals[i], from->field.far_ptr, GF_SG_VRML_SFVEC2F);
}
break;
case GF_SG_VRML_MFVEC3F:
if ( JSVAL_IS_OBJECT(item) && JS_InstanceOf(c, JSVAL_TO_OBJECT(item), &js_rt->SFVec3fClass, NULL) ) {
- from = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(item));
+ from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(item));
gf_sg_vrml_field_copy(& ((MFVec3f*)field->far_ptr)->vals[i], from->field.far_ptr, GF_SG_VRML_SFVEC3F);
}
break;
case GF_SG_VRML_MFROTATION:
if ( JSVAL_IS_OBJECT(item) && JS_InstanceOf(c, JSVAL_TO_OBJECT(item), &js_rt->SFRotationClass, NULL) ) {
- from = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(item));
+ from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(item));
gf_sg_vrml_field_copy(& ((MFRotation*)field->far_ptr)->vals[i], from->field.far_ptr, GF_SG_VRML_SFROTATION);
}
break;
case GF_SG_VRML_MFCOLOR:
if ( JSVAL_IS_OBJECT(item) && JS_InstanceOf(c, JSVAL_TO_OBJECT(item), &js_rt->SFColorClass, NULL) ) {
- from = (GF_JSField *) JS_GetPrivate(c, JSVAL_TO_OBJECT(item));
+ from = (GF_JSField *) SMJS_GET_PRIVATE(c, JSVAL_TO_OBJECT(item));
gf_sg_vrml_field_copy(& ((MFColor*)field->far_ptr)->vals[i], from->field.far_ptr, GF_SG_VRML_SFCOLOR);
}
break;
@@ -3753,7 +3753,7 @@ static void gf_sg_script_update_cached_object(GF_ScriptPriv *priv, JSObject *obj
JSObject *an_obj;
JS_GetElement(priv->js_ctx, jsf->js_list, (jsint) j, &newVal);
an_obj = JSVAL_TO_OBJECT(newVal);
- if (an_obj) slot = JS_GetPrivate(priv->js_ctx, an_obj);
+ if (an_obj) slot = SMJS_GET_PRIVATE(priv->js_ctx, an_obj);
if (slot && (slot->node==f->node)) {
gf_list_add(temp_objs, an_obj);
break;
@@ -3771,7 +3771,7 @@ static void gf_sg_script_update_cached_object(GF_ScriptPriv *priv, JSObject *obj
if (JS_SetArrayLength(priv->js_ctx, jsf->js_list, count) != JS_TRUE) return;
for (j=0; j<count; j++) {
JSObject *an_obj = gf_list_get(temp_objs, j);
- slot = JS_GetPrivate(priv->js_ctx, an_obj);
+ slot = SMJS_GET_PRIVATE(priv->js_ctx, an_obj);
newVal = OBJECT_TO_JSVAL(an_obj);
JS_SetElement(priv->js_ctx, jsf->js_list, (jsint) j, &newVal);
}
@@ -3792,7 +3792,7 @@ static void gf_sg_script_update_cached_object(GF_ScriptPriv *priv, JSObject *obj
#define SETUP_MF_FIELD \
if (!obj) return JSVAL_NULL; \
- jsf = (GF_JSField *) JS_GetPrivate(priv->js_ctx, obj); \
+ jsf = (GF_JSField *) SMJS_GET_PRIVATE(priv->js_ctx, obj); \
jsf->owner = parent; \
if (parent) gf_node_get_field(parent, field->fieldIndex, &jsf->field); \
@@ -3893,7 +3893,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No
return JSVAL_NULL;
obj = node_get_binding(priv, *(GF_Node**) field->far_ptr, 0);
- jsf = JS_GetPrivate(priv->js_ctx, obj);
+ jsf = SMJS_GET_PRIVATE(priv->js_ctx, obj);
if (!jsf->owner)
jsf->owner = parent;
else
@@ -3904,7 +3904,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No
case GF_SG_VRML_MFBOOL:
{
MFBool *f = (MFBool *) field->far_ptr;
- obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFBoolClass, 0, priv->js_obj);
+ obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFBoolClass, priv->js_obj);
SETUP_MF_FIELD
for (i = 0; i<f->count; i++) {
jsval newVal = BOOLEAN_TO_JSVAL(f->vals[i]);
@@ -3915,7 +3915,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No
case GF_SG_VRML_MFINT32:
{
MFInt32 *f = (MFInt32 *) field->far_ptr;
- obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFInt32Class, 0, priv->js_obj);
+ obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFInt32Class, priv->js_obj);
SETUP_MF_FIELD
for (i=0; i<f->count; i++) {
jsval newVal = INT_TO_JSVAL(f->vals[i]);
@@ -3926,7 +3926,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No
case GF_SG_VRML_MFFLOAT:
{
MFFloat *f = (MFFloat *) field->far_ptr;
- obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFFloatClass, 0, priv->js_obj);
+ obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFFloatClass, priv->js_obj);
SETUP_MF_FIELD
for (i=0; i<f->count; i++) {
jsval newVal = JS_MAKE_DOUBLE(priv->js_ctx, FIX2FLT(f->vals[i]));
@@ -3937,7 +3937,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No
case GF_SG_VRML_MFTIME:
{
MFTime *f = (MFTime *) field->far_ptr;
- obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFTimeClass, 0, priv->js_obj);
+ obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFTimeClass, priv->js_obj);
SETUP_MF_FIELD
for (i=0; i<f->count; i++) {
jsval newVal = JS_MAKE_DOUBLE(priv->js_ctx, f->vals[i]);
@@ -3948,7 +3948,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No
case GF_SG_VRML_MFSTRING:
{
MFString *f = (MFString *) field->far_ptr;
- obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFStringClass, 0, priv->js_obj);
+ obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFStringClass, priv->js_obj);
SETUP_MF_FIELD
for (i=0; i<f->count; i++) {
s = JS_NewStringCopyZ(priv->js_ctx, f->vals[i]);
@@ -3960,7 +3960,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No
case GF_SG_VRML_MFURL:
{
MFURL *f = (MFURL *) field->far_ptr;
- obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFUrlClass, 0, priv->js_obj);
+ obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFUrlClass, priv->js_obj);
SETUP_MF_FIELD
for (i=0; i<f->count; i++) {
if (f->vals[i].OD_ID > 0) {
@@ -3979,7 +3979,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No
case GF_SG_VRML_MFVEC2F:
{
MFVec2f *f = (MFVec2f *) field->far_ptr;
- obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFVec2fClass, 0, priv->js_obj);
+ obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFVec2fClass, priv->js_obj);
SETUP_MF_FIELD
for (i=0; i<f->count; i++) {
JSObject *pf = JS_NewObject(priv->js_ctx, &js_rt->SFVec2fClass, 0, obj);
@@ -3993,7 +3993,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No
case GF_SG_VRML_MFVEC3F:
{
MFVec3f *f = (MFVec3f *) field->far_ptr;
- obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFVec3fClass, 0, priv->js_obj);
+ obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFVec3fClass, priv->js_obj);
SETUP_MF_FIELD
for (i=0; i<f->count; i++) {
JSObject *pf = JS_NewObject(priv->js_ctx, &js_rt->SFVec3fClass, 0, obj);
@@ -4007,7 +4007,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No
case GF_SG_VRML_MFROTATION:
{
MFRotation *f = (MFRotation*) field->far_ptr;
- obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFRotationClass, 0, priv->js_obj);
+ obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFRotationClass, priv->js_obj);
SETUP_MF_FIELD
for (i=0; i<f->count; i++) {
JSObject *pf = JS_NewObject(priv->js_ctx, &js_rt->SFRotationClass, 0, obj);
@@ -4021,7 +4021,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No
case GF_SG_VRML_MFCOLOR:
{
MFColor *f = (MFColor *) field->far_ptr;
- obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFColorClass, 0, priv->js_obj);
+ obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFColorClass, priv->js_obj);
SETUP_MF_FIELD
for (i=0; i<f->count; i++) {
JSObject *pf = JS_NewObject(priv->js_ctx, &js_rt->SFColorClass, 0, obj);
@@ -4037,7 +4037,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No
{
u32 size;
GF_ChildNodeItem *f = * ((GF_ChildNodeItem **)field->far_ptr);
- obj = JS_ConstructObject(priv->js_ctx, &js_rt->MFNodeClass, 0, priv->js_obj);
+ obj = SMJS_CONSTRUCT_OBJECT(priv->js_ctx, &js_rt->MFNodeClass, priv->js_obj);
SETUP_MF_FIELD
size = gf_node_list_get_count(f);
@@ -4063,7 +4063,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No
gf_sg_proto_instanciate(proto_inst);
}
- slot = JS_GetPrivate(priv->js_ctx, pf);
+ slot = SMJS_GET_PRIVATE(priv->js_ctx, pf);
if (!slot->owner) slot->owner = parent;
newVal = OBJECT_TO_JSVAL(pf);
@@ -4083,7 +4083,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No
if (!obj) return JSVAL_NULL;
//store field associated with object if needed
if (jsf) {
- JS_SetPrivate(priv->js_ctx, obj, jsf);
+ SMJS_SET_PRIVATE(priv->js_ctx, obj, jsf);
/*if this is the obj corresponding to an existing field/node, store it and prevent GC on object*/
if (parent) {
@@ -4117,7 +4117,7 @@ jsval gf_sg_script_to_smjs_field(GF_ScriptPriv *priv, GF_FieldInfo *field, GF_No
jsval item;
JS_GetElement(jsf->js_ctx, jsf->js_list, (jsint) i, &item);
if (JSVAL_IS_OBJECT(item)) {
- GF_JSField *afield = JS_GetPrivate(jsf->js_ctx, JSVAL_TO_OBJECT(item));
+ GF_JSField *afield = SMJS_GET_PRIVATE(jsf->js_ctx, JSVAL_TO_OBJECT(item));
if (afield->owner != parent) continue;
if ( gf_list_find(parent->sgprivate->interact->js_binding->fields, afield) < 0) {
@@ -4140,7 +4140,7 @@ static void JS_ReleaseRootObjects(GF_ScriptPriv *priv)
/*we don't walk through the list since unprotecting an element could trigger GC which in turn could modify this list content*/
JSObject *obj = gf_list_last(priv->js_cache);
gf_list_rem_last(priv->js_cache);
- jsf = (GF_JSField *) JS_GetPrivate(priv->js_ctx, obj);
+ jsf = (GF_JSField *) SMJS_GET_PRIVATE(priv->js_ctx, obj);
if (!jsf) continue;
/* !!! WARNING !!!
@@ -4559,7 +4559,7 @@ static void JSScript_NodeModified(GF_SceneGraph *sg, GF_Node *node, GF_FieldInfo
count = gf_list_count(priv->js_cache);
for (i=0; i<count; i++) {
JSObject *obj = gf_list_get(priv->js_cache, i);
- jsf = JS_GetPrivate(priv->js_ctx, obj);
+ jsf = SMJS_GET_PRIVATE(priv->js_ctx, obj);
if (jsf->node && (jsf->node==node)) {
jsf->node = NULL;
/*Ivica patch*/
@@ -4640,7 +4640,7 @@ static void JSScript_NodeModified(GF_SceneGraph *sg, GF_Node *node, GF_FieldInfo
jsval item;
JS_GetElement(jsf->js_ctx, jsf->js_list, (jsint) j, &item);
if (JSVAL_IS_OBJECT(item)) {
- GF_JSField *afield = JS_GetPrivate(jsf->js_ctx, JSVAL_TO_OBJECT(item));
+ GF_JSField *afield = SMJS_GET_PRIVATE(jsf->js_ctx, JSVAL_TO_OBJECT(item));
afield->owner = NULL;
}
}
@@ -4693,7 +4693,7 @@ void gf_sg_handle_dom_event_for_vrml(GF_Node *node, GF_DOM_Event *event, GF_Node
GF_LOG(GF_LOG_DEBUG, GF_LOG_INTERACT, ("[DOM Events] Executing script code from VRML handler\n"));
priv = JS_GetScriptStack(hdl->js_context);
- prev_event = JS_GetPrivate(priv->js_ctx, priv->event);
+ prev_event = SMJS_GET_PRIVATE(priv->js_ctx, priv->event);
/*break loops*/
if (prev_event && (prev_event->type==event->type) && (prev_event->target==event->target))
return;
@@ -4709,10 +4709,10 @@ void gf_sg_handle_dom_event_for_vrml(GF_Node *node, GF_DOM_Event *event, GF_Node
prev_type = event->is_vrml;
event->is_vrml = 1;
- JS_SetPrivate(priv->js_ctx, priv->event, event);
+ SMJS_SET_PRIVATE(priv->js_ctx, priv->event, event);
- JS_SetPrivate(priv->js_ctx, evt, event);
+ SMJS_SET_PRIVATE(priv->js_ctx, evt, event);
argv[0] = OBJECT_TO_JSVAL(evt);
if (hdl->js_fun_val) {
@@ -4729,7 +4729,7 @@ void gf_sg_handle_dom_event_for_vrml(GF_Node *node, GF_DOM_Event *event, GF_Node
}
event->is_vrml = prev_type;
- JS_SetPrivate(priv->js_ctx, priv->event, prev_event);
+ SMJS_SET_PRIVATE(priv->js_ctx, priv->event, prev_event);
gf_sg_lock_javascript(priv->js_ctx, 0);
@@ -4763,7 +4763,7 @@ GF_Node *gf_sg_js_get_node(JSContext *c, JSObject *obj)
{
#ifndef GPAC_DISABLE_VRML
if (js_rt && JS_InstanceOf(c, obj, &js_rt->SFNodeClass, NULL) ) {
- GF_JSField *ptr = (GF_JSField *) JS_GetPrivate(c, obj);
+ GF_JSField *ptr = (GF_JSField *) SMJS_GET_PRIVATE(c, obj);
if (ptr->field.fieldType==GF_SG_VRML_SFNODE) return * ((GF_Node **)ptr->field.far_ptr);
}
#endif
diff --git a/src/terminal/media_memory.c b/src/terminal/media_memory.c
index 4c8741e..9a538b5 100644
--- a/src/terminal/media_memory.c
+++ b/src/terminal/media_memory.c
@@ -333,10 +333,6 @@ void gf_cm_unlock_input(GF_CompositionMemory *cb, GF_CMUnit *cu, u32 cu_size, Bo
}
gf_odm_lock(cb->odm, 1);
- if (cu->TS < cb->input->TS)
- cu = cu;
-
-
if (codec_reordering) {
cb->input = cb->input->next;
} else {
diff --git a/src/terminal/object_manager.c b/src/terminal/object_manager.c
index 938811b..c0467ed 100644
--- a/src/terminal/object_manager.c
+++ b/src/terminal/object_manager.c
@@ -626,9 +626,10 @@ void gf_odm_setup_object(GF_ObjectManager *odm, GF_ClientService *serv)
e = ODM_ValidateOD(odm, &hasInline);
if (e) {
- gf_term_message(odm->term, odm->net_service->url, "MPEG-4 Service Error", e);
+ GF_Terminal *term = odm->term;
+ gf_term_message(term, odm->net_service->url, "MPEG-4 Service Error", e);
gf_odm_disconnect(odm, 1);
- gf_term_lock_net(odm->term, 0);
+ gf_term_lock_net(term, 0);
return;
}
@@ -760,7 +761,7 @@ void gf_odm_setup_object(GF_ObjectManager *odm, GF_ClientService *serv)
}
if (odm->parentscene==odm->term->root_scene) {
gf_term_lock_net(odm->term, 0);
- gf_mx_v(odm->term->net_mx);
+
evt.type = GF_EVENT_STREAMLIST;
gf_term_send_event(odm->term,&evt);
@@ -823,12 +824,12 @@ GF_Err gf_odm_setup_es(GF_ObjectManager *odm, GF_ESD *esd, GF_ClientService *ser
if (ck) break;
- odm_par = odm->parentscene->root_od->parentscene ? odm->parentscene->root_od->parentscene->root_od : NULL;
+ odm_par = (odm_par->parentscene && odm_par->parentscene->root_od->parentscene ) ? odm_par->parentscene->root_od->parentscene->root_od : NULL;
}
}
if (ck)
goto clock_setup;
- GF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, ("[ODM] Cannot inherit timeline from parent scene for scene %s\n", odm->net_service->url));
+ GF_LOG(GF_LOG_WARNING, GF_LOG_MEDIA, ("[ODM] Cannot inherit timeline from parent scene for scene %s - new clock will be created\n", odm->net_service->url));
}
/*get clocks namespace (eg, parent scene)*/
@@ -883,6 +884,10 @@ GF_Err gf_odm_setup_es(GF_ObjectManager *odm, GF_ESD *esd, GF_ClientService *ser
ck = gf_clock_attach(ck_namespace, scene, clockID, esd->ESID, flag);
if (!ck) return GF_OUT_OF_MEM;
esd->OCRESID = ck->clockID;
+ /*special case for non-dynamic scenes forcing clock share of all subscene, we assign the
+ parent scene clock to the first clock created in the sunscenes*/
+ if (scene->root_od->parentscene && scene->root_od->parentscene->force_single_timeline && !scene->root_od->parentscene->dyn_ck)
+ scene->root_od->parentscene->dyn_ck = ck;
clock_setup:
/*create a channel for this stream*/
diff --git a/src/terminal/scene.c b/src/terminal/scene.c
index f28c221..ef8e6b3 100644
--- a/src/terminal/scene.c
+++ b/src/terminal/scene.c
@@ -332,6 +332,7 @@ static void gf_scene_insert_object(GF_Scene *scene, GF_MediaObject *mo, Bool loc
odm->parentscene = scene;
odm->term = scene->root_od->term;
root_od = scene->root_od;
+ if (scene->force_single_timeline) lock_timelines = 1;
url = mo->URLs.vals[0].url;
if (url) {
@@ -673,6 +674,10 @@ GF_MediaObject *gf_scene_get_media_object_ex(GF_Scene *scene, MFURL *url, u32 ob
gf_term_lock_net(scene->root_od->term, 1);
+ /*we may have overriden the time lines in parent scene, thus all objects in this scene have the same clock*/
+ if (scene->root_od->parentscene && scene->root_od->parentscene->force_single_timeline)
+ lock_timelines = 1;
+
/*the first pass is needed to detect objects already inserted and registered with the given nodes, regardless of
the force_new_if_not_attached flag. This ty^pically occurs when a resource is first created then linked to an animation/inline*/
restart:
@@ -1542,6 +1547,7 @@ GF_SceneGraph *gf_scene_enum_extra_scene(GF_SceneGraph *sg, u32 *i)
void gf_scene_generate_views(GF_Scene *scene, char *url)
{
+ char *url_search;
GF_Node *n1, *switcher;
#if USE_TEXTURES
GF_Node *n2;
@@ -1551,7 +1557,8 @@ void gf_scene_generate_views(GF_Scene *scene, char *url)
#endif
GF_Event evt;
gf_sg_reset(scene->graph);
-
+
+ scene->force_single_timeline = 1;
n1 = is_create_node(scene->graph, TAG_MPEG4_OrderedGroup, NULL);
gf_sg_set_root_node(scene->graph, n1);
gf_node_register(n1, NULL);
@@ -1561,8 +1568,15 @@ void gf_scene_generate_views(GF_Scene *scene, char *url)
gf_node_list_add_child( &((GF_ParentNode *)n1)->children, switcher);
((M_Switch*)switcher)->whichChoice = -2;
+ url_search = url;
while (1) {
- char *sep = strchr(url, ':');
+ char *sep = strchr(url_search, ':');
+ /*if :// or :\ is found, skip it*/
+ if (sep && ( ((sep[1] == '/') && (sep[2] == '/')) || (sep[1] == '\\') ) ) {
+ url_search = sep+1;
+ continue;
+ }
+
if (sep) sep[0] = 0;
#if USE_TEXTURES
/*create a shape and bitmap node*/
@@ -1600,6 +1614,7 @@ void gf_scene_generate_views(GF_Scene *scene, char *url)
if (!sep) break;
sep[0] = ':';
url = sep+1;
+ url_search = url;
}
gf_sc_set_option(scene->root_od->term->compositor, GF_OPT_USE_OPENGL, 1);