38int JS_SetPrivateFw(JSContext *cx, JSObject* obj,
void *data);
39JSObject* JS_NewGlobalObjectFw(JSContext *cx, JSClass *clasp);
40void * JS_GetPrivateFw(JSContext *cx,JSObject*_obj);
41JSObject* JS_GetParentFw(JSContext *cx, JSObject *me);
42JSObject * JS_ConstructObjectWithArgumentsFw(JSContext *cx, JSClass *clasp, JSObject *parent,
unsigned argc, jsval *argv);
43JSObject * JS_ConstructObjectFw(JSContext *cx, JSClass *clasp,
void *whatever, JSObject *parent);
44JSObject * JS_GetPrototypeFw(JSContext *cx, JSObject * obj);
45JSClass * JS_GetClassFw(JSContext *cx, JSObject * obj);
46#define STRING_SIZE 256
50#define jsuint uint32_t
52#define jsdouble double
54#define JS_FinalizeStub NULL
55#define JSSCRIPT2 JSScript
56#define JS_GET_CLASS JS_GetClassFw
57JSBool JS_NewNumberValue(JSContext *cx, jsdouble d, jsval *rval);
77#include "../vrml_parser/CRoutes.h"
78#include "../opengl/OpenGL_Utils.h"
80#include "../main/ProdCon.h"
81#include "../scenegraph/RenderFuncs.h"
92void getCurrentSpeed();
95#include "../ui/common.h"
103struct X3D_Anchor* get_EAIEventsIn_AnchorNode();
111int capabilitiesHandler_getTableLength(
int* table);
112int capabilitiesHandler_getComponentLevel(
int *table,
int comp);
113int capabilitiesHandler_getProfileLevel(
int prof);
114const int *capabilitiesHandler_getProfileComponent(
int prof);
115const int *capabilitiesHandler_getCapabilitiesTable();
116typedef struct intTableIndex{
133#include "jsUtils_sm.h"
134#include "jsVRMLClasses_sm.h"
135#include "jsVRMLBrowser_sm.h"
143#define SetPropertyStub JS_StrictPropertyStub
148BrowserGetProperty(JSContext *cx, JS::Handle<JSObject*> hobj, JS::Handle<jsid> hiid, JS::MutableHandle<JS::Value> hvp);
151BrowserSetProperty(JSContext *cx, JS::Handle<JSObject*> hobj, JS::Handle<jsid> hiid, JSBool strict, JS::MutableHandle<JS::Value> hvp);
153int jsrrunScript(JSContext *_context, JSObject *_globalObj,
char *script, jsval *rval);
210static JSClass Browser = {
214 JS_DeletePropertyStub,
229static JSBool doVRMLRoute(JSContext *context, JSObject *obj, uintN argc, jsval *argv,
const char *browserFunc);
231static JSFunctionSpec (BrowserFunctions)[] = {
232 {
"getName", VrmlBrowserGetName, 0},
233 {
"getVersion", VrmlBrowserGetVersion, 0},
234 {
"getCurrentSpeed", VrmlBrowserGetCurrentSpeed, 0},
235 {
"getCurrentFrameRate", VrmlBrowserGetCurrentFrameRate, 0},
236 {
"getWorldURL", VrmlBrowserGetWorldURL, 0},
237 {
"replaceWorld", VrmlBrowserReplaceWorld, 0},
238 {
"loadURL", VrmlBrowserLoadURL, 0},
239 {
"setDescription", VrmlBrowserSetDescription, 0},
240 {
"createVrmlFromString", VrmlBrowserCreateVrmlFromString, 0},
241 {
"createVrmlFromURL", VrmlBrowserCreateVrmlFromURL, 0},
242 {
"createX3DFromString", VrmlBrowserCreateX3DFromString, 0},
243 {
"createX3DFromURL", VrmlBrowserCreateVrmlFromURL, 0},
244 {
"addRoute", VrmlBrowserAddRoute, 0},
245 {
"deleteRoute", VrmlBrowserDeleteRoute, 0},
246 {
"print", VrmlBrowserPrint, 0},
247 {
"println", VrmlBrowserPrintln, 0},
270ComponentInfoGetProperty(JSContext *cx, JS::Handle<JSObject*> hobj, JS::Handle<jsid> hiid, JS::MutableHandle<JS::Value> hvp){
271 JSObject *obj = *hobj.address();
272 jsid iid = *hiid.address();
273 jsval *vp = hvp.address();
277 int _index, *_table, _nameIndex;
284 if (!JS_IdToValue(cx,iid,&
id)) {
285 printf(
"JS_IdToValue failed in ComponentInfoGetProperty.\n");
289 if ((ptr = (IntTableIndex)JS_GetPrivateFw(cx, obj)) == NULL) {
290 printf(
"JS_GetPrivate failed in ExecutionContextGetProperty.\n");
298 if (JSVAL_IS_INT(
id))
300 int index = JSVAL_TO_INT(
id);
304 _nameIndex = _table[2*_index];
305 JS_SET_RVAL(cx,vp,STRING_TO_JSVAL(JS_NewStringCopyZ(cx,COMPONENTS[_nameIndex])));
309 int level = capabilitiesHandler_getComponentLevel(_table,_index);
310 JS_SET_RVAL(cx,vp,INT_TO_JSVAL(level));
314 JS_SET_RVAL(cx,vp,STRING_TO_JSVAL(JS_NewStringCopyZ(cx,
"freewrl.sourceforge.net")));
321ComponentInfoSetProperty(JSContext *cx, JS::Handle<JSObject*> hobj, JS::Handle<jsid> hiid, JSBool strict, JS::MutableHandle<JS::Value> hvp){
322 JSObject *obj = *hobj.address();
323 jsid iid = *hiid.address();
324 jsval *vp = hvp.address();
329ComponentInfoFinalize(JSContext *cx, JSObject *obj)
332 if ((ptr = (IntTableIndex)JS_GetPrivateFw(cx, obj)) == NULL) {
340static JSClass ComponentInfoClass = {
344 JS_DeletePropertyStub,
345 ComponentInfoGetProperty,
346 ComponentInfoSetProperty,
353static JSPropertySpec (ComponentInfoProperties)[] = {
355 {
"name", 0, JSPROP_ENUMERATE},
356 {
"Title", 1, JSPROP_ENUMERATE},
357 {
"level", 2, JSPROP_ENUMERATE},
358 {
"providerUrl", 3, JSPROP_ENUMERATE},
369ComponentInfoArrayGetProperty(JSContext *cx, JS::Handle<JSObject*> hobj, JS::Handle<jsid> hiid, JS::MutableHandle<JS::Value> hvp){
370 JSObject *obj = *hobj.address();
371 jsid iid = *hiid.address();
372 jsval *vp = hvp.address();
381 if (!JS_IdToValue(cx,iid,&
id)) {
382 printf(
"JS_IdToValue failed in ComponentInfoArrayGetProperty.\n");
386 if ((_table = (
int *)JS_GetPrivateFw(cx, obj)) == NULL) {
387 printf(
"JS_GetPrivate failed in ProfileInfoGetProperty.\n");
391 if (JSVAL_IS_INT(
id))
393 int index = JSVAL_TO_INT(
id);
398 int _length = capabilitiesHandler_getTableLength(_table);
399 JS_SET_RVAL(cx,vp,INT_TO_JSVAL(_length));
400 }
else if(index > -1 && index < COMPONENTS_COUNT )
403 IntTableIndex tableindex = (IntTableIndex)MALLOC(
void *,
sizeof(
struct intTableIndex));
405 _obj = JS_NewObject(cx,&ComponentInfoClass,NULL,obj);
406 tableindex->index = index;
407 tableindex->table = _table;
408 if (!JS_DefineProperties(cx, _obj, ComponentInfoProperties)) {
409 printf(
"JS_DefineProperties failed in ComponentInfoProperties.\n");
413 if (!JS_SetPrivateFw(cx, _obj, (
void*)tableindex)) {
414 printf(
"JS_SetPrivate failed in ComponentInfoArray.\n");
418 JS_SET_RVAL(cx,vp,OBJECT_TO_JSVAL(_obj));
425ComponentInfoArraySetProperty(JSContext *cx, JS::Handle<JSObject*> hobj, JS::Handle<jsid> hiid, JSBool strict, JS::MutableHandle<JS::Value> hvp){
426 JSObject *obj = *hobj.address();
427 jsid iid = *hiid.address();
428 jsval *vp = hvp.address();
434static JSClass ComponentInfoArrayClass = {
435 "ComponentInfoArray",
438 JS_DeletePropertyStub,
439 ComponentInfoArrayGetProperty,
440 ComponentInfoArraySetProperty,
447static JSPropertySpec (ComponentInfoArrayProperties)[] = {
448 {
"length", -1, JSPROP_READONLY | JSPROP_SHARED | JSPROP_PERMANENT},
461ProfileInfoGetProperty(JSContext *cx, JS::Handle<JSObject*> hobj, JS::Handle<jsid> hiid, JS::MutableHandle<JS::Value> hvp){
462 JSObject *obj = *hobj.address();
463 jsid iid = *hiid.address();
464 jsval *vp = hvp.address();
473 if (!JS_IdToValue(cx,iid,&
id)) {
474 printf(
"JS_IdToValue failed in ProfileInfoGetProperty.\n");
478 if ((ptr = (
int *)JS_GetPrivateFw(cx, obj)) == NULL) {
479 printf(
"JS_GetPrivate failed in ProfileInfoGetProperty.\n");
486 if (JSVAL_IS_INT(
id))
488 int index = JSVAL_TO_INT(
id);
492 JS_SET_RVAL(cx,vp,STRING_TO_JSVAL(JS_NewStringCopyZ(cx,PROFILES[_index])));
496 int level = capabilitiesHandler_getProfileLevel(_index);
497 JS_SET_RVAL(cx,vp,INT_TO_JSVAL(level));
502 JS_SET_RVAL(cx,vp,STRING_TO_JSVAL(JS_NewStringCopyZ(cx,
"freewrl.sourceforge.net")));
506 const int *_table = capabilitiesHandler_getProfileComponent(_index);
509 _obj = JS_NewObject(cx,&ComponentInfoArrayClass,NULL,obj);
510 if (!JS_DefineProperties(cx, _obj, ComponentInfoArrayProperties)) {
511 printf(
"JS_DefineProperties failed in ComponentInfoArrayProperties.\n");
515 if (!JS_SetPrivateFw(cx, _obj, (
void*)_table)) {
516 printf(
"JS_SetPrivate failed in ComponentInfoArray.\n");
519 JS_SET_RVAL(cx,vp,OBJECT_TO_JSVAL(_obj));
527ProfileInfoSetProperty(JSContext *cx, JS::Handle<JSObject*> hobj, JS::Handle<jsid> hiid, JSBool strict, JS::MutableHandle<JS::Value> hvp){
528 JSObject *obj = *hobj.address();
529 jsid iid = *hiid.address();
530 jsval *vp = hvp.address();
536static JSClass ProfileInfoClass = {
540 JS_DeletePropertyStub,
541 ProfileInfoGetProperty,
542 ProfileInfoSetProperty,
549static JSPropertySpec (ProfileInfoProperties)[] = {
551 {
"name", 0, JSPROP_ENUMERATE},
552 {
"Title", 1, JSPROP_ENUMERATE},
553 {
"level", 2, JSPROP_ENUMERATE},
554 {
"providerUrl", 3, JSPROP_ENUMERATE},
555 {
"components", 4, JSPROP_ENUMERATE},
565ProfileInfoArrayGetProperty(JSContext *cx, JS::Handle<JSObject*> hobj, JS::Handle<jsid> hiid, JS::MutableHandle<JS::Value> hvp){
566 JSObject *obj = *hobj.address();
567 jsid iid = *hiid.address();
568 jsval *vp = hvp.address();
576 if (!JS_IdToValue(cx,iid,&
id)) {
577 printf(
"JS_IdToValue failed in ProfileInfoArrayGetProperty.\n");
581 if (JSVAL_IS_INT(
id))
583 int index = JSVAL_TO_INT(
id);
585 int _length = PROFILES_COUNT;
586 JS_SET_RVAL(cx,vp,INT_TO_JSVAL(_length));
591 int* _index = (
int*)MALLOC(
void *,
sizeof(
int));
592 _obj = JS_NewObject(cx,&ProfileInfoClass,NULL,obj);
594 if (!JS_DefineProperties(cx, _obj, ProfileInfoProperties)) {
595 printf(
"JS_DefineProperties failed in ProfileInfoProperties.\n");
599 if (!JS_SetPrivateFw(cx, _obj, (
void*)_index)) {
600 printf(
"JS_SetPrivate failed in ProfileInfoArray.\n");
604 JS_SET_RVAL(cx,vp,OBJECT_TO_JSVAL(_obj));
610ProfileInfoArraySetProperty(JSContext *cx, JS::Handle<JSObject*> hobj, JS::Handle<jsid> hiid, JSBool strict, JS::MutableHandle<JS::Value> hvp){
611 JSObject *obj = *hobj.address();
612 jsid iid = *hiid.address();
613 jsval *vp = hvp.address();
620static JSClass ProfileInfoArrayClass = {
624 JS_DeletePropertyStub,
625 ProfileInfoArrayGetProperty,
626 ProfileInfoArraySetProperty,
633static JSPropertySpec (ProfileInfoArrayProperties)[] = {
634 {
"length", -1, JSPROP_READONLY | JSPROP_SHARED | JSPROP_PERMANENT},
643X3DRouteGetProperty(JSContext *cx, JS::Handle<JSObject*> hobj, JS::Handle<jsid> hiid, JS::MutableHandle<JS::Value> hvp){
644 JSObject *obj = *hobj.address();
645 jsid iid = *hiid.address();
646 jsval *vp = hvp.address();
653 int fromOffset, toOffset;
654 const char *fieldname;
660 if (!JS_IdToValue(cx,iid,&
id)) {
661 printf(
"JS_IdToValue failed in ProfileInfoGetProperty.\n");
665 if ((ptr = (
int *)JS_GetPrivateFw(cx, obj)) == NULL) {
666 printf(
"JS_GetPrivate failed in ProfileInfoGetProperty.\n");
672 getSpecificRoute (_index,&fromNode, &fromOffset, &toNode, &toOffset);
682 if (JSVAL_IS_INT(
id))
684 int index = JSVAL_TO_INT(
id);
694 sfnn->handle = fromNode;
696 sfnn->handle = toNode;
698 _obj = JS_NewObject(cx,&SFNodeClass,NULL,obj);
699 if (!JS_DefineProperties(cx, _obj, SFNodeProperties)) {
700 printf(
"JS_DefineProperties failed in Route sourceNode.\n");
703 if (!JS_DefineFunctions(cx, _obj, SFNodeFunctions)) {
704 printf(
"JS_DefineFunctions failed in Route sourceNode.\n");
708 if (!JS_SetPrivateFw(cx, _obj, (
void*)sfnn)) {
709 printf(
"JS_SetPrivate failed in Route sourceNode.\n");
713 JS_SET_RVAL(cx,vp,OBJECT_TO_JSVAL(_obj));
718 fieldname = findFIELDNAMESfromNodeOffset0(fromNode,fromOffset);
719 _str = JS_NewStringCopyZ(cx,fieldname);
720 JS_SET_RVAL(cx,vp,STRING_TO_JSVAL(_str));
723 fieldname = findFIELDNAMESfromNodeOffset0(toNode,toOffset);
724 _str = JS_NewStringCopyZ(cx,fieldname);
725 JS_SET_RVAL(cx,vp,STRING_TO_JSVAL(_str));
733X3DRouteSetProperty(JSContext *cx, JS::Handle<JSObject*> hobj, JS::Handle<jsid> hiid, JSBool strict, JS::MutableHandle<JS::Value> hvp){
734 JSObject *obj = *hobj.address();
735 jsid iid = *hiid.address();
736 jsval *vp = hvp.address();
741static JSClass X3DRouteClass = {
745 JS_DeletePropertyStub,
754static JSPropertySpec (X3DRouteProperties)[] = {
756 {
"sourceNode", 0, JSPROP_ENUMERATE},
757 {
"sourceField", 1, JSPROP_ENUMERATE},
758 {
"destinationNode", 2, JSPROP_ENUMERATE},
759 {
"destinationField", 3, JSPROP_ENUMERATE},
770RouteArrayGetProperty(JSContext *cx, JS::Handle<JSObject*> hobj, JS::Handle<jsid> hiid, JS::MutableHandle<JS::Value> hvp){
771 JSObject *obj = *hobj.address();
772 jsid iid = *hiid.address();
773 jsval *vp = hvp.address();
782 if (!JS_IdToValue(cx,iid,&
id)) {
783 printf(
"JS_IdToValue failed in RouteArrayGetProperty.\n");
788 if (JSVAL_IS_INT(
id))
790 int index = JSVAL_TO_INT(
id);
792 int _length = getCRouteCount();
793 JS_SET_RVAL(cx,vp,INT_TO_JSVAL(_length));
798 int* _index = (
int*) MALLOC(
void *,
sizeof(
int));
799 _obj = JS_NewObject(cx,&X3DRouteClass,NULL,obj);
801 if (!JS_DefineProperties(cx, _obj, X3DRouteProperties)) {
802 printf(
"JS_DefineProperties failed in RouteArray.\n");
806 if (!JS_SetPrivateFw(cx, _obj, (
void*)_index)) {
807 printf(
"JS_SetPrivate failed in RouteArray.\n");
811 JS_SET_RVAL(cx,vp,OBJECT_TO_JSVAL(_obj));
818RouteArraySetProperty(JSContext *cx, JS::Handle<JSObject*> hobj, JS::Handle<jsid> hiid, JSBool strict, JS::MutableHandle<JS::Value> hvp){
819 JSObject *obj = *hobj.address();
820 jsid iid = *hiid.address();
821 jsval *vp = hvp.address();
827static JSClass RouteArrayClass = {
831 JS_DeletePropertyStub,
832 RouteArrayGetProperty,
833 RouteArraySetProperty,
840static JSPropertySpec (RouteArrayProperties)[] = {
841 {
"length", -1, JSPROP_READONLY | JSPROP_SHARED | JSPROP_PERMANENT},
848static JSFunctionSpec (ExecutionContextFunctions)[] = {
870static JSPropertySpec (ExecutionContextProperties)[] = {
872 {
"specificationVersion", 0, JSPROP_ENUMERATE},
873 {
"encoding", 1, JSPROP_ENUMERATE},
874 {
"profile", 2, JSPROP_ENUMERATE},
875 {
"components", 3, JSPROP_ENUMERATE},
876 {
"worldURL", 4, JSPROP_ENUMERATE},
877 {
"rootNodes", 5, JSPROP_ENUMERATE},
878 {
"protos", 6, JSPROP_ENUMERATE},
879 {
"externprotos", 7, JSPROP_ENUMERATE},
880 {
"routes", 8, JSPROP_ENUMERATE},
883 {
"isScene", 9, JSPROP_ENUMERATE},
890typedef struct X3D_Node * ExecutionContextNative;
893ExecutionContextGetProperty(JSContext *cx, JS::Handle<JSObject*> hobj, JS::Handle<jsid> hiid, JS::MutableHandle<JS::Value> hvp){
894 JSObject *obj = *hobj.address();
895 jsid iid = *hiid.address();
896 jsval *vp = hvp.address();
898 ExecutionContextNative *ptr;
906 if (!JS_IdToValue(cx,iid,&
id)) {
907 printf(
"JS_IdToValue failed in ExecutionContextGetProperty.\n");
912 if ((ptr = (ExecutionContextNative *)JS_GetPrivateFw(cx, obj)) == NULL) {
913 printf(
"JS_GetPrivate failed in ExecutionContextGetProperty.\n");
917 if (JSVAL_IS_INT(
id)) {
918 switch (JSVAL_TO_INT(
id)) {
922 sprintf(cs,
"{%d,%d,%d}",inputFileVersion[0],inputFileVersion[1],inputFileVersion[2]);
923 _str = JS_NewStringCopyZ(cx,cs);
925 JS_SET_RVAL(cx,vp,STRING_TO_JSVAL(_str));
929 _str = JS_NewStringCopyZ(cx,
"not filled in yet sb. VRML or XML or ..");
930 JS_SET_RVAL(cx,vp,STRING_TO_JSVAL(_str));
934 int index = gglobal()->Mainloop.scene_profile;
937 int* _index = MALLOC(
int *,
sizeof(
int));
938 _obj = JS_NewObject(cx,&ProfileInfoClass,NULL,obj);
940 if (!JS_DefineProperties(cx, _obj, ProfileInfoProperties)) {
941 printf(
"JS_DefineProperties failed in ExecutionContextProfileInfoProperties.\n");
945 if (!JS_SetPrivateFw(cx, _obj, (
void*)_index)) {
946 printf(
"JS_SetPrivate failed in ExecutionContextProfileInfoArray.\n");
950 JS_SET_RVAL(cx,vp,OBJECT_TO_JSVAL(_obj));
957 const int *_table = gglobal()->Mainloop.scene_components;
960 _obj = JS_NewObject(cx,&ComponentInfoArrayClass,NULL,obj);
961 if (!JS_DefineProperties(cx, _obj, ComponentInfoArrayProperties)) {
962 printf(
"JS_DefineProperties failed in ExecutionContext_ComponentInfoArrayProperties.\n");
966 if (!JS_SetPrivateFw(cx, _obj, (
void*)_table)) {
967 printf(
"JS_SetPrivate failed in ExecutionContext_ComponentInfoArray.\n");
970 JS_SET_RVAL(cx,vp,OBJECT_TO_JSVAL(_obj));
974 _str = JS_NewStringCopyZ(cx, gglobal()->Mainloop.url);
975 JS_SET_RVAL(cx,vp,STRING_TO_JSVAL(_str));
988 _obj = JS_NewObject(cx,&MFNodeClass,NULL,obj);
995 if (!JS_DefineFunctions(cx, _obj, MFNodeFunctions)) {
996 printf(
"JS_DefineProperties failed in SFRotationConstr.\n");
1005 JS_SET_RVAL(cx,vp,OBJECT_TO_JSVAL(_obj));
1015 _obj = JS_NewObject(cx,&RouteArrayClass,NULL,obj);
1016 if (!JS_DefineProperties(cx, _obj, RouteArrayProperties)) {
1017 printf(
"JS_DefineProperties failed in ExecutionContext_X3DRouteArrayProperties.\n");
1024 JS_SET_RVAL(cx,vp,OBJECT_TO_JSVAL(_obj));
1029 JS_SET_RVAL(cx,vp,BOOLEAN_TO_JSVAL(JS_TRUE));
1038ExecutionContextSetProperty(JSContext *cx, JS::Handle<JSObject*> hobj, JS::Handle<jsid> hiid, JSBool strict, JS::MutableHandle<JS::Value> hvp){
1039 JSObject *obj = *hobj.address();
1040 jsid iid = *hiid.address();
1041 jsval *vp = hvp.address();
1045static JSClass ExecutionContextClass = {
1047 JSCLASS_HAS_PRIVATE,
1049 JS_DeletePropertyStub,
1050 ExecutionContextGetProperty,
1051 ExecutionContextSetProperty,
1059static JSPropertySpec (BrowserProperties)[] = {
1060 {
"name", 0, JSPROP_ENUMERATE},
1061 {
"version", 1, JSPROP_ENUMERATE},
1062 {
"currentSpeed", 2, JSPROP_ENUMERATE},
1063 {
"currentFrameRate", 3, JSPROP_ENUMERATE},
1064 {
"description", 4, JSPROP_ENUMERATE},
1065 {
"supportedComponents", 5, JSPROP_ENUMERATE},
1066 {
"supportedProfiles", 6, JSPROP_ENUMERATE},
1067 {
"currentScene", 7, JSPROP_ENUMERATE},
1072BrowserGetProperty(JSContext *cx, JS::Handle<JSObject*> hobj, JS::Handle<jsid> hiid, JS::MutableHandle<JS::Value> hvp){
1073 JSObject *obj = *hobj.address();
1074 jsid iid = *hiid.address();
1075 jsval *vp = hvp.address();
1086 if (!JS_IdToValue(cx,iid,&
id)) {
1087 printf(
"JS_IdToValue failed in BrowserGetProperty.\n");
1097 if ((ptr = (
BrowserNative *)JS_GetPrivateFw(cx, obj)) == NULL) {
1098 printf(
"JS_GetPrivate failed in BrowserGetProperty.\n");
1102 if (JSVAL_IS_INT(
id)) {
1103 switch (JSVAL_TO_INT(
id)) {
1105 _str = JS_NewStringCopyZ(cx,BrowserName);
1106 JS_SET_RVAL(cx,vp,STRING_TO_JSVAL(_str));
1109 _str = JS_NewStringCopyZ(cx, libFreeWRL_get_version());
1110 JS_SET_RVAL(context,vp,STRING_TO_JSVAL(_str));
1115 d = gglobal()->Mainloop.BrowserSpeed;
1116 if (JS_NewNumberValue(cx, d, vp) == JS_FALSE) {
1117 printf(
"JS_NewDouble failed for %f in BrowserGetProperty.\n",d);
1122 d = gglobal()->Mainloop.BrowserFPS;
1123 if (JS_NewNumberValue(cx, d, vp) == JS_FALSE) {
1124 printf(
"JS_NewDouble failed for %f in BrowserGetProperty.\n",d);
1129 _str = JS_NewStringCopyZ(cx, get_status());
1130 JS_SET_RVAL(context,vp,STRING_TO_JSVAL(_str));
1136 _obj = JS_NewObject(cx,&ComponentInfoArrayClass,NULL,obj);
1137 if (!JS_DefineProperties(cx, _obj, ComponentInfoArrayProperties)) {
1138 printf(
"JS_DefineProperties failed in ComponentInfoArrayProperties.\n");
1145 if (!JS_SetPrivateFw(cx, _obj, (
void*)capabilitiesHandler_getCapabilitiesTable())) {
1146 printf(
"JS_SetPrivate failed in ExecutionContext.\n");
1150 JS_SET_RVAL(cx,vp,OBJECT_TO_JSVAL(_obj));
1158 _obj = JS_NewObject(cx,&ProfileInfoArrayClass,NULL,obj);
1159 if (!JS_DefineProperties(cx, _obj, ProfileInfoArrayProperties)) {
1160 printf(
"JS_DefineProperties failed in ExecutionContextProperties.\n");
1173 JS_SET_RVAL(cx,vp,OBJECT_TO_JSVAL(_obj));
1186 ExecutionContextNative ec = MALLOC(ExecutionContextNative,
sizeof(ExecutionContextNative));
1187 _obj = JS_NewObject(cx,&ExecutionContextClass,NULL,obj);
1191 if (!JS_DefineProperties(cx, _obj, ExecutionContextProperties)) {
1192 printf(
"JS_DefineProperties failed in ExecutionContextProperties.\n");
1195 if (!JS_DefineFunctions(cx, _obj, ExecutionContextFunctions)) {
1196 printf(
"JS_DefineProperties failed in ExecutionContextFunctions.\n");
1200 if (!JS_SetPrivateFw(cx, _obj, ec)) {
1201 printf(
"JS_SetPrivate failed in ExecutionContext.\n");
1205 JS_SET_RVAL(cx,vp,OBJECT_TO_JSVAL(_obj));
1217BrowserSetProperty(JSContext *cx, JS::Handle<JSObject*> hobj, JS::Handle<jsid> hiid, JSBool strict, JS::MutableHandle<JS::Value> hvp){
1218 JSObject *obj = *hobj.address();
1219 jsid iid = *hiid.address();
1220 jsval *vp = hvp.address();
1228 if (!JS_IdToValue(cx,iid,&
id)) {
1229 printf(
"JS_IdToValue failed in BrowserSetProperty.\n");
1234 if ((ptr = (
BrowserNative *)JS_GetPrivateFw(cx, obj)) == NULL) {
1235 printf(
"JS_GetPrivate failed in BrowserSetProperty.\n");
1240 if (!JS_ConvertValue(cx, *vp, JSTYPE_STRING, &_val)) {
1241 printf(
"JS_ConvertValue failed in BrowserSetProperty.\n");
1245 if (JSVAL_IS_INT(
id)) {
1246 switch (JSVAL_TO_INT(
id)) {
1253 ss = JS_ValueToString(cx, _val);
1254 cs = JS_EncodeString(cx, ss);
1275typedef struct pjsVRMLBrowser{
1278 jsval JSCreate_global_return_val;
1282void *jsVRMLBrowser_constructor(){
1283 void *v = MALLOC(
void *,
sizeof(
struct pjsVRMLBrowser));
1284 memset(v,0,
sizeof(
struct pjsVRMLBrowser));
1287void jsVRMLBrowser_init(
struct iiglobal::tjsVRMLBrowser *t){
1290 t->prv = jsVRMLBrowser_constructor();
1292 ppjsVRMLBrowser p = (ppjsVRMLBrowser)t->prv;
1295 t->JSCreate_global_return_val = &p->JSCreate_global_return_val;
1304void jsRegisterRoute(
1305 struct X3D_Node* from,
int fromOfs,
1307 int len,
const char *adrem) {
1310 if (strcmp(
"addRoute",adrem) == 0)
1314 CRoutes_Register(ad, from, fromOfs, to, toOfs , len,
1315 returnInterpolatorPointer(to->_nodeType), 0, 0);
1320void conCat (
char *out,
char *in) {
1322 while (strlen (in) > 0) {
1323 strcat (out,
" :loadURLStringBreak:");
1324 while (*out !=
'\0') out++;
1326 if (*in ==
'[') in++;
1327 while ((*in !=
'\0') && (*in ==
' ')) in++;
1331 while (*in !=
'"') { *out = *in; out++; in++; }
1337 if (*in ==
'"') in++;
1338 if (*in ==
',') in++;
1339 if (*in ==
']') in++;
1345void createLoadUrlString(
char *out,
int outLen,
char *url,
char *param) {
1365 commacount1 = 0; commacount2 = 0;
1366 tptr = url;
while (*tptr !=
'\0') {
if (*tptr ==
'"') commacount1 ++; tptr++; }
1367 tptr = param;
while (*tptr !=
'\0') {
if (*tptr ==
'"') commacount2 ++; tptr++; }
1368 commacount1 = commacount1 / 2;
1369 commacount2 = commacount2 / 2;
1371 if ((
int)(strlen(url) +
1373 (commacount1 * strlen (
" :loadURLStringBreak:")) +
1374 (commacount2 * strlen (
" :loadURLStringBreak:"))) > (outLen - 20)) {
1375 printf (
"createLoadUrlString, string too long\n");
1379 sprintf (out,
"%d %d",commacount1,commacount2);
1382 while (*out !=
'\0') out++;
1386 while (*out !=
'\0') out++;
1392VrmlBrowserInit(JSContext *context, JSObject *globalObj,
BrowserNative *brow)
1396 *(jsval *)tg->jsVRMLBrowser.JSCreate_global_return_val = INT_TO_JSVAL(0);
1399 printf(
"VrmlBrowserInit\n");
1402 obj = JS_DefineObject(context, globalObj,
"Browser", &Browser, NULL,
1403 JSPROP_ENUMERATE | JSPROP_PERMANENT);
1404 if (!JS_DefineFunctions(context, obj, BrowserFunctions)) {
1405 printf(
"JS_DefineFunctions failed in VrmlBrowserInit.\n");
1410 if (!JS_DefineProperties(context, obj, BrowserProperties)) {
1411 printf(
"JS_DefineProperties failed in VrmlBrowserInit.\n");
1415 if (!JS_SetPrivateFw(context, obj, brow)) {
1416 printf(
"JS_SetPrivate failed in VrmlBrowserInit.\n");
1424VrmlBrowserGetName(JSContext *context, uintN argc, jsval *vp) {
1425 JSObject *obj = JS_THIS_OBJECT(context,vp);
1426 jsval *argv = JS_ARGV(context,vp);
1434 _str = JS_NewStringCopyZ(context,BrowserName);
1435 JS_SET_RVAL(context,vp,STRING_TO_JSVAL(_str));
1443VrmlBrowserGetVersion(JSContext *context, uintN argc, jsval *vp) {
1444 JSObject *obj = JS_THIS_OBJECT(context,vp);
1445 jsval *argv = JS_ARGV(context,vp);
1453 _str = JS_NewStringCopyZ(context, libFreeWRL_get_version());
1454 JS_SET_RVAL(context,vp,STRING_TO_JSVAL(_str));
1460VrmlBrowserGetCurrentSpeed(JSContext *context, uintN argc, jsval *vp) {
1461 JSObject *obj = JS_THIS_OBJECT(context,vp);
1462 jsval *argv = JS_ARGV(context,vp);
1473 sprintf (
string,
"%f",gglobal()->Mainloop.BrowserSpeed);
1474 _str = JS_NewStringCopyZ(context,
string);
1475 JS_SET_RVAL(context,vp,STRING_TO_JSVAL(_str));
1481VrmlBrowserGetCurrentFrameRate(JSContext *context, uintN argc, jsval *vp) {
1482 JSObject *obj = JS_THIS_OBJECT(context,vp);
1483 jsval *argv = JS_ARGV(context,vp);
1486 char FPSstring[1000];
1492 sprintf (FPSstring,
"%6.2f",gglobal()->Mainloop.BrowserFPS);
1493 _str = JS_NewStringCopyZ(context,FPSstring);
1494 JS_SET_RVAL(context,vp,STRING_TO_JSVAL(_str));
1500VrmlBrowserGetWorldURL(JSContext *context, uintN argc, jsval *vp) {
1501 JSObject *obj = JS_THIS_OBJECT(context,vp);
1502 jsval *argv = JS_ARGV(context,vp);
1510 _str = JS_NewStringCopyZ(context,BrowserFullPath);
1511 JS_SET_RVAL(context,vp,STRING_TO_JSVAL(_str));
1517VrmlBrowserReplaceWorld(JSContext *context, uintN argc, jsval *vp) {
1518 jsval *argv = JS_ARGV(context,vp);
1522 jsval _rval = INT_TO_JSVAL(0);
1523 const char *_c_args =
"MFNode nodes",
1527 if (JS_ConvertArguments(context, argc, argv, _c_format, &_obj)) {
1528 if ((_cls = JS_GET_CLASS(context, _obj)) == NULL) {
1529 printf(
"JS_GetClass failed in VrmlBrowserReplaceWorld.\n");
1533 if (memcmp(
"MFNode", _cls->name, strlen(_cls->name)) != 0) {
1534 printf(
"\nIncorrect argument in VrmlBrowserReplaceWorld.\n");
1537 _str = JS_ValueToString(context, argv[0]);
1538 _costr = JS_EncodeString(context,_str);
1542 while (*tptr !=
'\0') {
1543 if(*tptr ==
'[') *tptr =
' ';
1544 if(*tptr ==
']') *tptr =
' ';
1545 if(*tptr ==
',') *tptr =
' ';
1550 JS_free(context,_costr);
1552 printf(
"\nIncorrect argument format for replaceWorld(%s).\n", _c_args);
1555 JS_SET_RVAL(context,vp,_rval);
1561VrmlBrowserLoadURL(JSContext *context, uintN argc, jsval *vp) {
1562 jsval *argv = JS_ARGV(context,vp);
1566 const char *_c_args =
"MFString url, MFString parameter",
1568 #define myBufSize 2000
1570 char myBuf[myBufSize];
1572 if (JS_ConvertArguments(context, argc, argv, _c_format, &(_obj[0]), &(_obj[1]))) {
1573 if ((_cls[0] = JS_GET_CLASS(context, _obj[0])) == NULL) {
1574 printf(
"JS_GetClass failed for arg 0 in VrmlBrowserLoadURL.\n");
1577 if ((_cls[1] = JS_GET_CLASS(context, _obj[1])) == NULL) {
1578 printf(
"JS_GetClass failed for arg 1 in VrmlBrowserLoadURL.\n");
1581 if (memcmp(
"MFString", (_cls[0])->name, strlen((_cls[0])->name)) != 0 &&
1582 memcmp(
"MFString", (_cls[1])->name, strlen((_cls[1])->name)) != 0) {
1583 printf(
"\nIncorrect arguments in VrmlBrowserLoadURL.\n");
1586 _str[0] = JS_ValueToString(context, argv[0]);
1587 _costr[0] = JS_EncodeString(context,_str[0]);
1589 _str[1] = JS_ValueToString(context, argv[1]);
1590 _costr[1] = JS_EncodeString(context,_str[1]);
1597 createLoadUrlString(myBuf,myBufSize,_costr[0], _costr[1]);
1598 createLoadURL(myBuf);
1601 setAnchorsAnchor( get_EAIEventsIn_AnchorNode());
1603 gglobal()->RenderFuncs.BrowserAction = TRUE;
1605 JS_free(context,_costr[0]);
1606 JS_free(context,_costr[1]);
1608 printf(
"\nIncorrect argument format for loadURL(%s).\n", _c_args);
1611 JS_SET_RVAL(context,vp,INT_TO_JSVAL(0));
1618VrmlBrowserSetDescription(JSContext *context, uintN argc, jsval *vp) {
1619 jsval *argv = JS_ARGV(context,vp);
1621 const char *_c_format =
"S", *_c_args =
"SFString description";
1627 JS_ConvertArguments(context, argc, argv, _c_format, &js_c)) {
1632 JS_SET_RVAL(context,vp,INT_TO_JSVAL(0));
1634 printf(
"\nIncorrect argument format for setDescription(%s).\n", _c_args);
1642VrmlBrowserCreateVrmlFromString(JSContext *context, uintN argc, jsval *vp) {
1643 JSObject *obj = JS_THIS_OBJECT(context,vp);
1644 jsval *argv = JS_ARGV(context,vp);
1646 jsval *rval = &_my_rval;
1647 const char *_c_format =
"S", *_c_args =
"SFString vrmlSyntax";
1656 const char *separator;
1667 *rval = INT_TO_JSVAL(0);
1670 JS_ConvertArguments(context, argc, argv, _c_format, &js_c)) {
1671 _c = JS_EncodeString(context,js_c);
1674 printf(
"VrmlBrowserCreateVrmlFromString: obj = %u, str = \"%s\"\n",
1679 gglobal()->ProdCon.savedParser = (
void *)globalParser; globalParser = NULL;
1680 retGroup = (
struct X3D_Group*)createNewX3DNode0(NODE_Group);
1681 ra = EAI_CreateVrml(
"String",_c,X3D_NODE(rootNode()),retGroup);
1682 globalParser = (
struct VRMLParser*)gglobal()->ProdCon.savedParser;
1687 xstr = MALLOC (
char *, MallocdSize);
1688 strcpy (xstr,
"new MFNode(");
1690 for (count=0; count<retGroup->children.n; count ++) {
1691 tmpstr = MALLOC(
char *, strlen(_c) + 100);
1692 sprintf (tmpstr,
"%s new SFNode('%s','%p')",separator, _c, (
void*) retGroup->children.p[count]);
1694 wantedsize = (int) (strlen(tmpstr) + strlen(xstr) + 1);
1696 if (wantedsize >= MallocdSize) {
1697 MallocdSize = wantedsize +200;
1698 xstr = (
char *)REALLOC (xstr,MallocdSize);
1702 strncat (xstr,tmpstr,strlen(tmpstr));
1703 FREE_IF_NZ (tmpstr);
1709 JS_free(context,_c);
1712 printf (
"running runscript on :%s:\n",xstr);
1716 jsrrunScript(context, obj, xstr, rval);
1720 printf(
"\nIncorrect argument format for createVrmlFromString(%s).\n", _c_args);
1725 JS_SET_RVAL(context,vp,*rval);
1731VrmlBrowserCreateX3DFromString(JSContext *context, uintN argc, jsval *vp) {
1732 JSObject *obj = JS_THIS_OBJECT(context,vp);
1733 jsval *argv = JS_ARGV(context,vp);
1735 jsval *rval = &_my_rval;
1736 const char *_c_format =
"S", *_c_args =
"SFString x3dSyntax";
1745 const char *separator;
1756 *rval = INT_TO_JSVAL(0);
1759 JS_ConvertArguments(context, argc, argv, _c_format, &js_c)) {
1760 _c = JS_EncodeString(context,js_c);
1763 printf(
"VrmlBrowserCreateVrmlFromString: obj = %u, str = \"%s\"\n",
1769 retGroup = (
struct X3D_Group*)createNewX3DNode(NODE_Group);
1770 ra = EAI_CreateX3d(
"String",_c,X3D_NODE(retGroup),retGroup);
1776 xstr = MALLOC (
char *, MallocdSize);
1777 strcpy (xstr,
"new MFNode(");
1779 for (count=0; count<retGroup->children.n; count ++) {
1780 tmpstr = MALLOC(
char *, strlen(_c) + 100);
1781 sprintf (tmpstr,
"%s new SFNode('%s','%p')",separator, _c, (
void*) retGroup->children.p[count]);
1782 wantedsize = (int) (strlen(tmpstr) + strlen(xstr));
1783 if (wantedsize > MallocdSize) {
1784 MallocdSize = wantedsize +200;
1785 xstr = (
char *)REALLOC (xstr,MallocdSize);
1789 strncat (xstr,tmpstr,strlen(tmpstr));
1790 FREE_IF_NZ (tmpstr);
1794 markForDispose(X3D_NODE(retGroup),FALSE);
1796 JS_free(context,_c);
1799 printf (
"running runscript on :%s:\n",xstr);
1803 jsrrunScript(context, obj, xstr, rval);
1807 printf(
"\nIncorrect argument format for createVrmlFromString(%s).\n", _c_args);
1812 JS_SET_RVAL(context,vp,*rval);
1818VrmlBrowserCreateVrmlFromURL(JSContext *context, uintN argc, jsval *vp) {
1819 jsval *argv = JS_ARGV(context,vp);
1821 jsval *rval = &_my_rval;
1829 #define myFileSizeLimit 4000
1849 printf (
"JS start of createVrmlFromURL\n");
1853 *rval = INT_TO_JSVAL(0);
1857 if (argv[0].isObject()) {
1858 if ((_cls[0] = JS_GET_CLASS(context, JSVAL_TO_OBJECT(argv[0]))) == NULL) {
1859 printf(
"JS_GetClass failed for arg 0 in VrmlBrowserLoadURL.\n");
1863 printf (
"VrmlBrowserCreateVrmlFromURL - expect first parameter to be an object\n");
1869 if (argv[1].isObject()) {
1870 if ((_cls[1] = JS_GET_CLASS(context, JSVAL_TO_OBJECT(argv[1]))) == NULL) {
1871 printf(
"JS_GetClass failed for arg 1 in VrmlBrowserLoadURL.\n");
1875 printf (
"VrmlBrowserCreateVrmlFromURL - expect first parameter to be an object\n");
1880 printf (
"JS createVrml - step 2\n");
1881 printf (
"JS create - we should havve a MFString and SFNode, have :%s: :%s:\n",(_cls[0])->name, (_cls[1])->name);
1885 if (memcmp(
"MFString", (_cls[0])->name, strlen((_cls[0])->name)) != 0 &&
1886 memcmp(
"SFNode", (_cls[1])->name, strlen((_cls[1])->name)) != 0) {
1887 printf(
"Incorrect arguments in VrmlBrowserLoadURL.\n");
1892 if (JSVAL_IS_STRING(argv[2])) {
1893 _str[1] = JSVAL_TO_STRING(argv[2]);
1894 fieldStr = JS_EncodeString(context,_str[1]);
1897 printf (
"field string is :%s:\n",fieldStr);
1900 printf (
"Expected a string in createVrmlFromURL\n");
1905 printf (
"passed object type tests\n");
1909 _str[0] = JS_ValueToString(context, argv[0]);
1910 _costr0 = JS_EncodeString(context,_str[0]);
1913 printf (
"URL string is %s\n",_costr0);
1918 if ((oldPtr = (
SFNodeNative *)JS_GetPrivateFw(context, JSVAL_TO_OBJECT(argv[1]))) == NULL) {
1919 printf(
"JS_GetPrivate failed in VrmlBrowserLoadURL for SFNode parameter.\n");
1921 JS_free(context,_costr0);
1922 JS_free(context,fieldStr);
1926 myptr = X3D_NODE(oldPtr->handle);
1927 if (myptr == NULL) {
1928 printf (
"CreateVrmlFromURL, internal error - SFNodeNative memory pointer is NULL\n");
1930 JS_free(context,_costr0);
1931 JS_free(context,fieldStr);
1938 printf (
"SFNode handle %d, old X3DString %s\n",oldPtr->handle, oldPtr->X3DString);
1939 printf (
"myptr %d\n",myptr);
1940 printf (
"points to a %s\n",stringNodeType(myptr->_nodeType));
1945 if (
sizeof (_costr0) > (myFileSizeLimit-200)) {
1946 printf (
"VrmlBrowserCreateVrmlFromURL, url too long...\n");
1948 JS_free(context,_costr0);
1949 JS_free(context,fieldStr);
1964 Parser_scanStringValueToMem(X3D_NODE(&url),0,FIELDTYPE_MFString, _costr0, FALSE);
1967 res = resource_create_multi(&url);
1968 res->whereToPlaceData = myptr;
1972 fieldInt = findRoutedFieldInFIELDNAMES (myptr, fieldStr, TRUE);
1975 findFieldInOFFSETS(myptr->_nodeType, fieldInt, &offs, &type, &accessType);
1977 ConsoleMessage (
"Can not find field :%s: in nodeType :%s:",fieldStr,stringNodeType(myptr->_nodeType));
1979 JS_free(context,_costr0);
1980 JS_free(context,fieldStr);
1986 res->offsetFromWhereToPlaceData = offs;
1987 parser_process_res_VRML_X3D(res);
1995 MARK_EVENT(myptr,offs);
1997 JS_SET_RVAL(context,vp,*rval);
1998 JS_free(context,fieldStr);
1999 JS_free(context,_costr0);
2005VrmlBrowserAddRoute(JSContext *context, uintN argc, jsval *vp) {
2006 JSObject *obj = JS_THIS_OBJECT(context,vp);
2007 jsval *argv = JS_ARGV(context,vp);
2009 if (!doVRMLRoute(context, obj, argc, argv,
"addRoute")) {
2010 printf(
"doVRMLRoute failed in VrmlBrowserAddRoute.\n");
2013 JS_SET_RVAL(context,vp,INT_TO_JSVAL(0));
2018VrmlBrowserPrint(JSContext *context, uintN argc, jsval *vp) {
2019 JSObject *obj = JS_THIS_OBJECT(context,vp);
2020 jsval *argv = JS_ARGV(context,vp);
2025 UNUSED (context); UNUSED(obj);
2027 for (count=0; count < argc; count++) {
2028 if (JSVAL_IS_STRING(argv[count])) {
2029 _str = JSVAL_TO_STRING(argv[count]);
2030 _id_c = JS_EncodeString(context,_str);
2032 #if defined(AQUA) || defined(_MSC_VER)
2033 ConsoleMessage(_id_c);
2034 gglobal()->ConsoleMessage.consMsgCount = 0;
2036 #ifdef HAVE_NOTOOLKIT
2037 printf (
"%s", _id_c);
2039 printf (
"%s\n", _id_c);
2040 ConsoleMessage(_id_c);
2041 gglobal()->ConsoleMessage.consMsgCount = 0;
2044 JS_free(context,_id_c);
2052 #if defined(AQUA) || defined(_MSC_VER)
2053 ConsoleMessage(
"\n");
2054 gglobal()->ConsoleMessage.consMsgCount = 0;
2055 #elif !defined(_MSC_VER)
2056 #ifdef HAVE_NOTOOLKIT
2060 JS_SET_RVAL(context,vp,INT_TO_JSVAL(0));
2065VrmlBrowserPrintln(JSContext *context, uintN argc, jsval *vp) {
2067 VrmlBrowserPrint(context,argc,vp);
2070 #if defined(AQUA) || defined(_MSC_VER)
2072 gglobal()->ConsoleMessage.consMsgCount = 0;
2074 #ifdef HAVE_NOTOOLKIT
2082VrmlBrowserDeleteRoute(JSContext *context, uintN argc, jsval *vp) {
2083 JSObject *obj = JS_THIS_OBJECT(context,vp);
2084 jsval *argv = JS_ARGV(context,vp);
2086 if (!doVRMLRoute(context, obj, argc, argv,
"deleteRoute")) {
2087 printf(
"doVRMLRoute failed in VrmlBrowserDeleteRoute.\n");
2091 JS_SET_RVAL(context,vp,INT_TO_JSVAL(0));
2101static JSBool doVRMLRoute(JSContext *context, JSObject *obj, uintN argc, jsval *argv,
const char *callingFunc) {
2102 JSObject *fromNodeObj, *toNodeObj;
2106 *fromFieldString, *toFieldString;
2107 const char *_c_args =
2108 "SFNode fromNode, SFString fromEventOut, SFNode toNode, SFString toEventIn",
2109 *_c_format =
"oSoS";
2110 JSString *fromFieldStringJS, *toFieldStringJS;
2113 int fromOfs, toOfs, len;
2114 int fromtype, totype;
2120 printf (
"Problem with script - add/delete route command needs 4 parameters\n");
2125 if (JS_ConvertArguments(context, argc, argv, _c_format,
2126 &fromNodeObj, &fromFieldStringJS, &toNodeObj, &toFieldStringJS)) {
2127 fromFieldString = JS_EncodeString(context,fromFieldStringJS);
2128 toFieldString = JS_EncodeString(context,toFieldStringJS);
2130 if ((_cls[0] = JS_GET_CLASS(context, fromNodeObj)) == NULL) {
2131 printf(
"JS_GetClass failed for arg 0 in doVRMLRoute called from %s.\n",
2135 if ((_cls[1] = JS_GET_CLASS(context, toNodeObj)) == NULL) {
2136 printf(
"JS_GetClass failed for arg 2 in doVRMLRoute called from %s.\n",
2142 if (memcmp(
"SFNode", (_cls[0])->name, strlen((_cls[0])->name)) != 0 &&
2143 memcmp(
"SFNode", (_cls[1])->name, strlen((_cls[1])->name)) != 0) {
2144 printf(
"\nArguments 0 and 2 must be SFNode in doVRMLRoute called from %s(%s): %s\n",
2145 callingFunc, _c_args, callingFunc);
2150 if ((fromNative = (
SFNodeNative *)JS_GetPrivateFw(context, fromNodeObj)) == NULL) {
2151 printf (
"problem getting native props\n");
2154 if ((toNative = (
SFNodeNative *)JS_GetPrivateFw(context, toNodeObj)) == NULL) {
2155 printf (
"problem getting native props\n");
2159 fromNode = X3D_NODE(fromNative->handle);
2160 toNode = X3D_NODE(toNative->handle);
2163 printf (
"routing from a node of type %s to a node of type %s\n",
2164 stringNodeType(fromNode->_nodeType),
2165 stringNodeType(toNode->_nodeType));
2170 myField = findRoutedFieldInFIELDNAMES(fromNode,fromFieldString,0);
2172 myField = findRoutedFieldInFIELDNAMES(fromNode,fromFieldString,1);
2175 findFieldInOFFSETS(fromNode->_nodeType, myField, &fromOfs, &fromtype, &xxx);
2179 myField = findRoutedFieldInFIELDNAMES(toNode,toFieldString,0);
2181 myField = findRoutedFieldInFIELDNAMES(toNode,toFieldString,1);
2184 findFieldInOFFSETS(toNode->_nodeType, myField, &toOfs, &totype, &xxx);
2187 if (fromtype != totype) {
2188 printf (
"Javascript routing problem - can not route from %s to %s\n",
2189 stringNodeType(fromNode->_nodeType),
2190 stringNodeType(toNode->_nodeType));
2194 len = returnRoutingElementLength(totype);
2196 jsRegisterRoute(fromNode, fromOfs, toNode, toOfs, len,callingFunc);
2198 JS_free(context,fromFieldString);
2199 JS_free(context,toFieldString);
2202 printf(
"\nIncorrect argument format for %s(%s).\n",
2203 callingFunc, _c_args);