FreeWRL/FreeX3D  3.0.0
jsUtils.c
1 /*
2 
3 
4 A substantial amount of code has been adapted from js/src/js.c,
5 which is the sample application included with the javascript engine.
6 
7 */
8 
9 /****************************************************************************
10  This file is part of the FreeWRL/FreeX3D Distribution.
11 
12  Copyright 2009 CRC Canada. (http://www.crc.gc.ca)
13 
14  FreeWRL/FreeX3D is free software: you can redistribute it and/or modify
15  it under the terms of the GNU Lesser Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  FreeWRL/FreeX3D is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  GNU General Public License for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with FreeWRL/FreeX3D. If not, see <http://www.gnu.org/licenses/>.
26 ****************************************************************************/
27 
28 
29 #include <config.h>
30 #include <system.h>
31 #if !(defined(JAVASCRIPT_STUB) || defined(JAVASCRIPT_DUK))
32 #include <display.h>
33 #include <internal.h>
34 
35 #include <libFreeWRL.h>
36 
37 #include "../vrml_parser/Structs.h"
38 #include "../main/headers.h"
39 #include "../vrml_parser/CParseGeneral.h"
40 #include "../main/Snapshot.h"
41 #include "../scenegraph/Collision.h"
42 #include "../scenegraph/quaternion.h"
43 #include "../scenegraph/Viewer.h"
44 #include "../input/EAIHelpers.h"
45 #include "../input/SensInterps.h"
46 #include "../x3d_parser/Bindable.h"
47 
48 #include "JScript.h"
49 #include "CScripts.h"
50 #include "jsUtils.h"
51 #include "jsNative.h"
52 #include "jsVRMLClasses.h"
53 #include "fieldSet.h"
54 #ifdef _MSC_VER
55 #include <pthread.h> // win32 needs the strtok_r
56 #endif
57 
58 
59 
60 #ifdef WANT_OSC
61  #include "../scenegraph/ringbuf.h"
62  #define USE_OSC 1
63  #define TRACK_FIFO_MSG 0
64 #else
65  #define USE_OSC 0
66  #define TRACK_FIFO_MSG 0
67 #endif
68 
69 extern void dump_scene (FILE *fp, int level, struct X3D_Node* node); // in GeneratedCode.c
70 extern char *parser_getNameFromNode(struct X3D_Node *ptr) ; /* vi +/dump_scene src/lib/scenegraph/GeneratedCode.c */
71 
72 /********************** Javascript to X3D Scenegraph ****************************/
73 
74 
75 /* a SF value has changed in an MF; eg, xx[10] = new SFVec3f(...); */
76 /* These values were created below; new SF values to this MF are not accessed here, but in
77  the MFVec3fSetProperty (or equivalent). Note that we do NOT use something like JS_SetElement
78  on these because it would be a recursive call; thus we set the private data */
79 
80 
81 //static int insetSFStr = FALSE;
82 //static JSBool reportWarnings = JS_TRUE;
83 typedef struct pjsUtils{
84  int insetSFStr;// = FALSE;
85  JSBool reportWarnings;// = JS_TRUE;
86 
87 }* ppjsUtils;
88 void *jsUtils_constructor(){
89  void *v = MALLOCV(sizeof(struct pjsUtils));
90  memset(v,0,sizeof(struct pjsUtils));
91  return v;
92 }
93 void jsUtils_init(struct tjsUtils *t){
94  //public
95  //private
96  t->prv = jsUtils_constructor();
97  {
98  ppjsUtils p = (ppjsUtils)t->prv;
99  p->insetSFStr = FALSE;
100  p->reportWarnings = JS_TRUE;
101 
102  }
103 }
104 // ppjsUtils p = (ppjsUtils)gglobal()->jsUtils.prv;
105 #if JS_VERSION < 185
106 static JSBool setSF_in_MF (JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
107 #else
108 static JSBool setSF_in_MF (JSContext *cx, JSObject *obj, jsid iid, JSBool strict, jsval *vp) {
109 #endif
110  int num;
111  jsval pf;
112  jsval nf;
113  JSObject *me;
114  JSObject *par;
115  jsval ele;
116  ppjsUtils p = (ppjsUtils)gglobal()->jsUtils.prv;
117  jsid oid;
118 #if JS_VERSION >= 185
119  char *tmp;
120  jsval id;
121 
122  UNUSED(tmp); // compiler warning mitigation
123 
124  if (!JS_IdToValue(cx,iid,&id)) {
125  printf("setSF_in_MF: JS_IdToValue failed.\n");
126  return JS_FALSE;
127  }
128 #endif
129 
130  /* when we save the value, we will be called again, so we make sure that we
131  know if we are being called from within, or from without */
132  if (p->insetSFStr) {
133  #ifdef JSVRMLCLASSESVERBOSE
134  printf ("setSF_in_MF: already caught this value; this is our JS_SetElement call\n");
135  #endif
136  return JS_TRUE;
137  }
138 
139  /* ok, we are really called to replace an existing SFNode MF value assignment */
140  p->insetSFStr = TRUE;
141 
142  if (JSVAL_IS_INT(id)) {
143  if (!JS_ValueToInt32(cx,id,&num)) {
144  printf ("setSF_in_MF: error converting to number...\n");
145  return JS_FALSE;
146  }
147  /* get a pointer to the object at the index in the parent */
148  if (!JS_GetElement(cx, obj, num, &ele)) {
149  printf ("error getting child %d in setSF_in_MF\n",num);
150  return JS_FALSE;
151  }
152  /* THIS is the touching that will cause us to be called recursively,
153  which is why insetSFStr is TRUE right here */
154  if (!JS_SetElement(cx,obj,num,vp)) {
155  printf ("can not set element %d in MFString\n",num);
156  return JS_FALSE;
157  }
158  } else {
159  printf ("expect an integer id in setSF_in_MF\n");
160  return JS_FALSE;
161  }
162 
163 
164  /* copy this value out to the X3D scene graph */
165  me = obj;
166  par = JS_GetParent(cx, me);
167  while (par != NULL) {
168  #ifdef JSVRMLCLASSESVERBOSE
169  printf ("for obj %u: ",me);
170  printJSNodeType(cx,me);
171  printf ("... parent %u\n",par);
172  printJSNodeType(cx,par);
173  #endif
174 
175  if (JS_InstanceOf (cx, par, &SFNodeClass, NULL)) {
176  #ifdef JSVRMLCLASSESVERBOSE
177  printf (" the parent IS AN SFNODE - it is %u\n",par);
178  #endif
179 
180 
181  if (!JS_GetProperty(cx, obj, "_parentField", &pf)) {
182  printf ("doMFSetProperty, can not get parent field from this object\n");
183  return JS_FALSE;
184  }
185 
186  nf = OBJECT_TO_JSVAL(me);
187 
188  #ifdef JSVRMLCLASSESVERBOSE
189  #if JS_VERSION < 185
190  printf ("parentField is %u \"%s\"\n", pf, JS_GetStringBytes(JSVAL_TO_STRING(pf)));
191  #else
192  tmp=JS_EncodeString(cx,JSVAL_TO_STRING(pf));
193  printf ("parentField is %u \"%s\"\n", pf, tmp);
194  JS_free(cx,tmp);
195  #endif
196  #endif
197 
198  if (!JS_ValueToId(cx,pf,&oid)) {
199  printf("setSF_in_MF: JS_ValueToId failed.\n");
200  return JS_FALSE;
201  }
202 
203  if (!setSFNodeField (cx, par, oid,
204 #if JS_VERSION >= 185
205  JS_FALSE,
206 #endif
207  &nf)) {
208  printf ("could not set field of SFNode\n");
209  }
210 
211  }
212  me = par;
213  par = JS_GetParent(cx, me);
214  }
215  p->insetSFStr = FALSE;
216  return JS_TRUE;
217 }
218 
219 /* take an ECMA value in the X3D Scenegraph, and return a jsval with it in */
220 /* This is FAST as w deal just with pointers */
221 static void JS_ECMA_TO_X3D(JSContext *cx, void *Data, unsigned datalen, int dataType, jsval *newval) {
222  float fl;
223  double dl;
224  int il;
225 
226  #ifdef JSVRMLCLASSESVERBOSE
227  printf ("calling JS_ECMA_TO_X3D on type %s\n",FIELDTYPES[dataType]);
228  #endif
229 
230  switch (dataType) {
231 
232  case FIELDTYPE_SFFloat: {
233  if (!JS_ValueToNumber(cx,*newval,&dl)) {
234  printf ("problems converting Javascript val to number\n");
235  return;
236  }
237  fl = (float) dl;
238  memcpy (Data, (void *) &fl, datalen);
239  break;
240  }
241  case FIELDTYPE_SFDouble:
242  case FIELDTYPE_SFTime: {
243  if (!JS_ValueToNumber(cx,*newval,&dl)) {
244  printf ("problems converting Javascript val to number\n");
245  return;
246  }
247  memcpy (Data, (void *) &dl, datalen);
248  break;
249  }
250  case FIELDTYPE_SFBool: {
251  il = JSVAL_TO_BOOLEAN (*newval);
252  memcpy (Data, (void *) &il, datalen);
253  break;
254  }
255 
256  case FIELDTYPE_SFInt32: {
257  il = JSVAL_TO_INT (*newval);
258  memcpy (Data, (void *) &il, datalen);
259  break;
260  }
261 
262  case FIELDTYPE_SFString: {
263  struct Uni_String *oldS;
264  JSString *_idStr;
265  char *_id_c;
266 
267  _idStr = JS_ValueToString(cx, *newval);
268 #if JS_VERSION < 185
269  _id_c = JS_GetStringBytes(_idStr);
270 #else
271  _id_c = JS_EncodeString(cx,_idStr);
272 #endif
273 
274  oldS = (struct Uni_String *) *((intptr_t *)Data);
275 
276  #ifdef JSVRMLCLASSESVERBOSE
277  printf ("JS_ECMA_TO_X3D, replacing \"%s\" with \"%s\" \n", oldS->strptr, _id_c);
278  #endif
279 
280  /* replace the C string if it needs to be replaced. */
281  verify_Uni_String (oldS,_id_c);
282 #if JS_VERSION >= 185
283  JS_free(cx,_id_c);
284 #endif
285  break;
286  }
287  default: { printf("WARNING: SHOULD NOT BE HERE in JS_ECMA_TO_X3D! %d\n",dataType); }
288  }
289 }
290 
291 
292 /* take a Javascript ECMA value and put it in the X3D Scenegraph. */
293 static void JS_SF_TO_X3D(JSContext *cx, void *Data, unsigned datalen, int dataType, jsval *newval) {
294  SFColorNative *Cptr;
295  SFVec3fNative *V3ptr;
296  SFVec3dNative *V3dptr;
297  SFVec2fNative *V2ptr;
298  SFRotationNative *VRptr;
299  SFNodeNative *VNptr;
300 
301  void *VPtr;
302 
303  #ifdef JSVRMLCLASSESVERBOSE
304  printf ("calling JS_SF_TO_X3D on type %s\n",FIELDTYPES[dataType]);
305  #endif
306 
307  /* get a pointer to the internal private data */
308  if ((VPtr = JS_GetPrivate(cx, JSVAL_TO_OBJECT(*newval))) == NULL) {
309  printf( "JS_GetPrivate failed in JS_SF_TO_X3D.\n");
310  return;
311  }
312 
313  /* copy over the data from the X3D node to this new Javascript object */
314  switch (dataType) {
315  case FIELDTYPE_SFColor:
316  Cptr = (SFColorNative *)VPtr;
317  memcpy (Data, (void *)((Cptr->v).c), datalen);
318  break;
319  case FIELDTYPE_SFVec3d:
320  V3dptr = (SFVec3dNative *)VPtr;
321  memcpy (Data, (void *)((V3dptr->v).c), datalen);
322  break;
323  case FIELDTYPE_SFVec3f:
324  V3ptr = (SFVec3fNative *)VPtr;
325  memcpy (Data, (void *)((V3ptr->v).c), datalen);
326  break;
327  case FIELDTYPE_SFVec2f:
328  V2ptr = (SFVec2fNative *)VPtr;
329  memcpy (Data, (void *)((V2ptr->v).c), datalen);
330  break;
331  case FIELDTYPE_SFRotation:
332  VRptr = (SFRotationNative *)VPtr;
333  memcpy (Data,(void *)((VRptr->v).c), datalen);
334  break;
335  case FIELDTYPE_SFNode:
336  VNptr = (SFNodeNative *)VPtr;
337  memcpy (Data, (void *)(VNptr->handle), datalen);
338  break;
339 
340  default: { printf("WARNING: SHOULD NOT BE HERE! %d\n",dataType); }
341  }
342 }
343 
344 void getJSMultiNumType(JSContext *, struct Multi_Vec3f *, int);
345 
346 /* make an MF type from the X3D node. This can be fairly slow... */
347 static void JS_MF_TO_X3D(JSContext *cx, JSObject * obj, void *Data, int dataType, jsval *newval) {
348  ttglobal tg = gglobal();
349  #ifdef JSVRMLCLASSESVERBOSE
350  printf ("calling JS_MF_TO_X3D on type %s\n",FIELDTYPES[dataType]);
351  printf ("JS_MF_TO_X3D, we have object %u, newval %u\n",obj,*newval);
352  printf ("JS_MF_TO_X3D, obj is an:\n");
353  if (JSVAL_IS_OBJECT(OBJECT_TO_JSVAL(obj))) { printf ("JS_MF_TO_X3D - obj is an OBJECT\n"); }
354  if (JSVAL_IS_PRIMITIVE(OBJECT_TO_JSVAL(obj))) { printf ("JS_MF_TO_X3D - obj is an PRIMITIVE\n"); }
355  printf ("JS_MF_TO_X3D, obj is a "); printJSNodeType(cx,obj);
356  printf ("JS_MF_TO_X3D, vp is an:\n");
357  if (JSVAL_IS_OBJECT(*newval)) { printf ("JS_MF_TO_X3D - vp is an OBJECT\n"); }
358  if (JSVAL_IS_PRIMITIVE(*newval)) { printf ("JS_MF_TO_X3D - vp is an PRIMITIVE\n"); }
359  printf ("JS_MF_TO_X3D, vp is a "); printJSNodeType(cx,JSVAL_TO_OBJECT(*newval));
360  #endif
361 
362  *(jsval *)tg->JScript.JSglobal_return_val = *newval;
363  getJSMultiNumType (cx, (struct Multi_Vec3f*) Data, convertToSFType(dataType));
364 
365 }
366 
367 /********************** X3D Scenegraph to Javascript ****************************/
368 
369 /* take an ECMA value in the X3D Scenegraph, and return a jsval with it in */
370 /* This is FAST as w deal just with pointers */
371 void X3D_ECMA_TO_JS(JSContext *cx, void *Data, int datalen, int dataType, jsval *newval) {
372  float fl;
373  double dl;
374  int il;
375 
376  /* NOTE - caller of this function has already defined a BeginRequest */
377 
378  #ifdef JSVRMLCLASSESVERBOSE
379  printf ("calling X3D_ECMA_TO_JS on type %s\n",FIELDTYPES[dataType]);
380  #endif
381 
382  switch (dataType) {
383 
384  case FIELDTYPE_SFFloat: {
385  memcpy ((void *) &fl, Data, datalen);
386  JS_NewNumberValue(cx,(double)fl,newval);
387  break;
388  }
389  case FIELDTYPE_SFDouble:
390  case FIELDTYPE_SFTime: {
391  memcpy ((void *) &dl, Data, datalen);
392  JS_NewNumberValue(cx,dl,newval);
393  break;
394  }
395  case FIELDTYPE_SFBool:
396  case FIELDTYPE_SFInt32: {
397  memcpy ((void *) &il,Data, datalen);
398  *newval = INT_TO_JSVAL(il);
399  break;
400  }
401 
402  case FIELDTYPE_SFString: {
403  struct Uni_String *ms;
404 
405  /* datalen will be ROUTING_SFSTRING here; or at least should be! We
406  copy over the data, which is a UniString pointer, and use the pointer
407  value here */
408  memcpy((void *) &ms,Data, sizeof(void *));
409  *newval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx,ms->strptr));
410  break;
411  }
412  default: { printf("WARNING: SHOULD NOT BE HERE in X3D_ECMA_TO_JS! %d\n",dataType); }
413  }
414 }
415 
416 /* take an ECMA value in the X3D Scenegraph, and return a jsval with it in */
417 /* this is not so fast; we call a script to make a default type, then we fill it in */
418 static void X3D_SF_TO_JS(JSContext *cx, JSObject *obj, void *Data, unsigned datalen, int dataType, jsval *newval) {
419  SFColorNative *Cptr;
420  SFVec3fNative *V3ptr;
421  SFVec3dNative *V3dptr;
422  SFVec2fNative *V2ptr;
423  SFRotationNative *VRptr;
424  SFNodeNative *VNptr;
425 
426  void *VPtr;
427  jsval rval;
428  char *script = NULL;
429 
430  /* NOTE - caller is (eventually) a class constructor, no need to BeginRequest */
431 
432  #ifdef JSVRMLCLASSESVERBOSE
433  printf ("calling X3D_SF_TO_JS on type %s, newval %u\n",FIELDTYPES[dataType],*newval);
434  #endif
435 
436  if (!JSVAL_IS_OBJECT(*newval)) {
437  /* find a script to create the correct object */
438  switch (dataType) {
439  case FIELDTYPE_SFVec3f: script = "new SFVec3f()"; break;
440  case FIELDTYPE_SFVec3d: script = "new SFVec3d()"; break;
441  case FIELDTYPE_SFColor: script = "new SFColor()"; break;
442  case FIELDTYPE_SFNode: script = "new SFNode()"; break;
443  case FIELDTYPE_SFVec2f: script = "new SFVec2f()"; break;
444  case FIELDTYPE_SFRotation: script = "new SFRotation()"; break;
445  default: printf ("invalid type in X3D_SF_TO_JS\n"); return;
446  }
447 
448  /* create the object */
449 
450 
451  #ifdef JSVRMLCLASSESVERBOSE
452  printf ("X3D_SF_TO_JS, have to run script to make new object: \"%s\"\n",script);
453  #endif
454 
455  if (!JS_EvaluateScript(cx, obj, script, (int) strlen(script), FNAME_STUB, LINENO_STUB, &rval)) {
456  printf ("error creating the new object in X3D_SF_TO_JS, script :%s:\n",script);
457  return;
458  }
459 
460  /* this is the return pointer, lets save it right now */
461  *newval = rval;
462 
463  #ifdef JSVRMLCLASSESVERBOSE
464  printf ("X3D_SF_TO_JS, so, newval now is %u\n",*newval);
465  #endif
466 
467  }
468  /* get a pointer to the internal private data */
469  if ((VPtr = JS_GetPrivate(cx, JSVAL_TO_OBJECT(*newval))) == NULL) {
470  printf( "JS_GetPrivate failed in X3D_SF_TO_JS.\n");
471  return;
472  }
473 
474 
475  /* copy over the data from the X3D node to this new Javascript object */
476  switch (dataType) {
477  case FIELDTYPE_SFColor:
478  Cptr = (SFColorNative *)VPtr;
479  memcpy ((void *)((Cptr->v).c), Data, datalen);
480  Cptr->valueChanged = 1;
481  break;
482  case FIELDTYPE_SFVec3f:
483  V3ptr = (SFVec3fNative *)VPtr;
484  memcpy ((void *)((V3ptr->v).c), Data, datalen);
485  V3ptr->valueChanged = 1;
486  break;
487  case FIELDTYPE_SFVec3d:
488  V3dptr = (SFVec3dNative *)VPtr;
489  memcpy ((void *)((V3dptr->v).c), Data, datalen);
490  V3dptr->valueChanged = 1;
491  break;
492  case FIELDTYPE_SFVec2f:
493  V2ptr = (SFVec2fNative *)VPtr;
494  memcpy ((void *)((V2ptr->v).c), Data, datalen);
495  V2ptr->valueChanged = 1;
496  break;
497  case FIELDTYPE_SFRotation:
498  VRptr = (SFRotationNative *)VPtr;
499  memcpy ((void *)((VRptr->v).c), Data, datalen);
500  VRptr->valueChanged = 1;
501  break;
502  case FIELDTYPE_SFNode:
503  VNptr = (SFNodeNative *)VPtr;
504  memcpy ((void *)(&(VNptr->handle)), Data, datalen);
505  VNptr->valueChanged = 1;
506  break;
507 
508  default: { printf("WARNING: SHOULD NOT BE HERE! %d\n",dataType); }
509  }
510 }
511 
512 /* make an MF type from the X3D node. This can be fairly slow... */
513 static void X3D_MF_TO_JS(JSContext *cx, JSObject *obj, void *Data, int dataType, jsval *newval, char *fieldName) {
514  int i;
515  jsval rval;
516  char *script = NULL;
517  struct Multi_Int32 *MIptr;
518  struct Multi_Float *MFptr;
519  struct Multi_Time *MTptr;
520  jsval fieldNameAsJSVAL;
521 
522  /* NOTE - caller is (eventually) a JS class constructor, no need to BeginRequest */
523 
524  /* so, obj should be an __SFNode_proto, and newval should be a __MFString_proto (or whatever) */
525 
526  #ifdef JSVRMLCLASSESVERBOSE
527  printf ("calling X3D_MF_TO_JS on type %s\n",FIELDTYPES[dataType]);
528  printf ("X3D_MF_TO_JS, we have object %u, newval %u\n",obj,*newval);
529  printf ("X3D_MF_TO_JS, obj is an:\n");
530  if (JSVAL_IS_OBJECT(OBJECT_TO_JSVAL(obj))) { printf ("X3D_MF_TO_JS - obj is an OBJECT\n");
531  printf ("X3D_MF_TO_JS, obj is a "); printJSNodeType(cx,obj);
532  }
533  if (JSVAL_IS_PRIMITIVE(OBJECT_TO_JSVAL(obj))) { printf ("X3D_MF_TO_JS - obj is an PRIMITIVE\n"); }
534  printf ("X3D_MF_TO_JS, vp is an:\n");
535  if (JSVAL_IS_OBJECT(*newval)) { printf ("X3D_MF_TO_JS - newval is an OBJECT\n");
536  printf ("X3D_MF_TO_JS, newval is a "); printJSNodeType(cx,JSVAL_TO_OBJECT(*newval));
537  }
538  if (JSVAL_IS_PRIMITIVE(*newval)) { printf ("X3D_MF_TO_JS - newval is an PRIMITIVE\n"); }
539  #endif
540 
541 
542 #ifdef JSVRMLCLASSESVERBOSE
543  printf ("X3D_MF_TO_JS - is this already expanded? \n");
544  {
545  SFNodeNative *VNptr;
546 
547  /* get a pointer to the internal private data */
548  if ((VNptr = JS_GetPrivate(cx, obj)) == NULL) {
549  printf( "JS_GetPrivate failed in X3D_MF_TO_JS.\n");
550  return;
551  }
552  if (VNptr->fieldsExpanded) printf ("FIELDS EXPANDED\n");
553  else printf ("FIELDS NOT EXPANDED\n");
554  }
555 #endif
556 
557 
558  if (!JSVAL_IS_OBJECT(*newval)) {
559  #ifdef JSVRMLCLASSESVERBOSE
560  printf ("X3D_MF_TO_JS - have to create empty MF type \n");
561  #endif
562 
563  /* find a script to create the correct object */
564  switch (dataType) {
565  case FIELDTYPE_MFString: script = "new MFString()"; break;
566  case FIELDTYPE_MFFloat: script = "new MFFloat()"; break;
567  case FIELDTYPE_MFTime: script = "new MFTime()"; break;
568  case FIELDTYPE_MFInt32: script = "new MFInt32()"; break;
569  case FIELDTYPE_SFImage: script = "new SFImage()"; break;
570  case FIELDTYPE_MFVec3f: script = "new MFVec3f()"; break;
571  case FIELDTYPE_MFColor: script = "new MFColor()"; break;
572  case FIELDTYPE_MFNode: script = "new MFNode()"; break;
573  case FIELDTYPE_MFVec2f: script = "new MFVec2f()"; break;
574  case FIELDTYPE_MFRotation: script = "new MFRotation()"; break;
575  default: printf ("invalid type in X3D_MF_TO_JS\n"); return;
576  }
577 
578  if (!JS_EvaluateScript(cx, obj, script, (int) strlen(script), FNAME_STUB, LINENO_STUB, &rval)) {
579  printf ("error creating the new object in X3D_MF_TO_JS\n");
580  return;
581  }
582 
583  /* this is the return pointer, lets save it right now */
584  *newval = rval;
585  }
586 
587  #ifdef JSVRMLCLASSESVERBOSE
588  printf ("setting parent for %u to %u\n", *newval, obj);
589  #endif
590 
591  /* ok - if we are setting an MF* field by a thing like myField[10] = new String(); the
592  set method does not really get called. So, we go up the parental chain until we get
593  either no parent, or a SFNode. If we get a SFNode, we call the "save this" function
594  so that the X3D scene graph gets the updated array value. To make a long story short,
595  here's the call to set the parent for the above. */
596  if (!JS_SetParent (cx, JSVAL_TO_OBJECT(*newval), obj)) {
597  printf ("X3D_MF_TO_JS - can not set parent!\n");
598  }
599 
600  #ifdef JSVRMLCLASSESVERBOSE
601  printf ("telling %u that it is a child \"%s\" of parent %u\n",*newval, fieldName, obj);
602  #endif
603 
604  fieldNameAsJSVAL = STRING_TO_JSVAL(JS_NewStringCopyZ(cx,fieldName));
605 
606  if (!JS_DefineProperty(cx, JSVAL_TO_OBJECT(*newval), "_parentField", fieldNameAsJSVAL,
607  JS_GET_PROPERTY_STUB, JS_SET_PROPERTY_STUB5, JSPROP_READONLY)) {
608  printf("JS_DefineProperty failed for \"%s\" in X3D_MF_TO_JS.\n", fieldName);
609  return;
610  }
611 
612 
613  #ifdef JSVRMLCLASSESVERBOSE
614  printf ("X3D_MF_TO_JS - object is %u, copying over data\n",*newval);
615  #endif
616 
617 
618  /* copy over the data from the X3D node to this new Javascript object */
619  switch (dataType) {
620  case FIELDTYPE_MFInt32:
621  MIptr = (struct Multi_Int32*) Data;
622  for (i=0; i<MIptr->n; i++) {
623  if (!JS_DefineElement(cx, JSVAL_TO_OBJECT(*newval), (jsint) i, INT_TO_JSVAL(MIptr->p[i]),
624  JS_GET_PROPERTY_STUB, setSF_in_MF, JSPROP_ENUMERATE)) {
625  printf( "JS_DefineElement failed for arg %u in MFInt32Constr.\n", i);
626  return;
627  }
628  }
629  break;
630  case FIELDTYPE_MFFloat:
631  MFptr = (struct Multi_Float*) Data;
632  for (i=0; i<MFptr->n; i++) {
633  if (!JS_DefineElement(cx, JSVAL_TO_OBJECT(*newval), (jsint) i, INT_TO_JSVAL(MFptr->p[i]),
634  JS_GET_PROPERTY_STUB, setSF_in_MF, JSPROP_ENUMERATE)) {
635  printf( "JS_DefineElement failed for arg %u in MFFloatConstr.\n", i);
636  return;
637  }
638  }
639  break;
640  case FIELDTYPE_MFTime:
641  MTptr = (struct Multi_Time*) Data;
642  for (i=0; i<MTptr->n; i++) {
643  if (!JS_DefineElement(cx, JSVAL_TO_OBJECT(*newval), (jsint) i, INT_TO_JSVAL(MTptr->p[i]),
644  JS_GET_PROPERTY_STUB, setSF_in_MF, JSPROP_ENUMERATE)) {
645  printf( "JS_DefineElement failed for arg %u in MFTimeConstr.\n", i);
646  return;
647  }
648  }
649  break;
650  case FIELDTYPE_MFColor:
651  case FIELDTYPE_MFVec3f: {
652  struct Multi_Vec3f* MCptr;
653  char newline[100];
654  jsval xf;
655 
656  MCptr = (struct Multi_Vec3f *) Data;
657  for (i=0; i<MCptr->n; i++) {
658  if (dataType == FIELDTYPE_MFColor)
659  sprintf (newline,"new SFColor(%f, %f, %f)", MCptr->p[i].c[0], MCptr->p[i].c[1], MCptr->p[i].c[2]);
660  else
661  sprintf (newline,"new SFColor(%f, %f, %f)", MCptr->p[i].c[0], MCptr->p[i].c[1], MCptr->p[i].c[2]);
662  if (!JS_EvaluateScript(cx, JSVAL_TO_OBJECT(*newval), newline, (int) strlen(newline), FNAME_STUB, LINENO_STUB, &xf)) {
663  printf ("error creating the new object in X3D_MF_TO_JS string :%s:\n",newline);
664  return;
665  }
666  if (!JS_DefineElement(cx, JSVAL_TO_OBJECT(*newval), (jsint) i, xf,
667  JS_GET_PROPERTY_STUB, setSF_in_MF, JSPROP_ENUMERATE)) {
668  printf( "JS_DefineElement failed for arg %u .\n", i);
669  return;
670  }
671  }
672  } break;
673 
674  case FIELDTYPE_MFVec2f: {
675  struct Multi_Vec2f* MCptr;
676  char newline[100];
677  jsval xf;
678 
679  MCptr = (struct Multi_Vec2f *) Data;
680  for (i=0; i<MCptr->n; i++) {
681  sprintf (newline,"new SFVec2f(%f, %f)", MCptr->p[i].c[0], MCptr->p[i].c[1]);
682  if (!JS_EvaluateScript(cx, JSVAL_TO_OBJECT(*newval), newline, (int) strlen(newline), FNAME_STUB, LINENO_STUB, &xf)) {
683  printf ("error creating the new object in X3D_MF_TO_JS string :%s:\n",newline);
684  return;
685  }
686  if (!JS_DefineElement(cx, JSVAL_TO_OBJECT(*newval), (jsint) i, xf,
687  JS_GET_PROPERTY_STUB, setSF_in_MF, JSPROP_ENUMERATE)) {
688  printf( "JS_DefineElement failed for arg %u .\n", i);
689  return;
690  }
691  }
692  } break;
693  case FIELDTYPE_MFRotation: {
694  struct Multi_Rotation* MCptr;
695  char newline[100];
696  jsval xf;
697 
698  MCptr = (struct Multi_Rotation*) Data;
699  for (i=0; i<MCptr->n; i++) {
700  sprintf (newline,"new SFRotation(%f, %f, %f, %f)", MCptr->p[i].c[0], MCptr->p[i].c[1], MCptr->p[i].c[2], MCptr->p[i].c[3]);
701  if (!JS_EvaluateScript(cx, JSVAL_TO_OBJECT(*newval), newline, (int) strlen(newline), FNAME_STUB, LINENO_STUB, &xf)) {
702  printf ("error creating the new object in X3D_MF_TO_JS string :%s:\n",newline);
703  return;
704  }
705  if (!JS_DefineElement(cx, JSVAL_TO_OBJECT(*newval), (jsint) i, xf,
706  JS_GET_PROPERTY_STUB, setSF_in_MF, JSPROP_ENUMERATE)) {
707  printf( "JS_DefineElement failed for arg %u .\n", i);
708  return;
709  }
710  }
711  } break;
712 
713  case FIELDTYPE_MFNode: {
714  struct Multi_Node* MCptr;
715  char newline[100];
716  jsval xf;
717 
718  MCptr = (struct Multi_Node *) Data;
719 
720  for (i=0; i<MCptr->n; i++) {
721  /* purge out null nodes */
722  if (MCptr->p[i] != NULL) {
723  sprintf (newline,"new SFNode(\"%p\")", MCptr->p[i]);
724 
725  if (!JS_EvaluateScript(cx, JSVAL_TO_OBJECT(*newval), newline, (int) strlen(newline), FNAME_STUB, LINENO_STUB, &xf)) {
726  printf ("error creating the new object in X3D_MF_TO_JS string :%s:\n",newline);
727  return;
728  }
729  if (!JS_DefineElement(cx, JSVAL_TO_OBJECT(*newval), (jsint) i, xf,
730  JS_GET_PROPERTY_STUB, setSF_in_MF, JSPROP_ENUMERATE)) {
731  printf( "JS_DefineElement failed for arg %u .\n", i);
732  return;
733  }
734  } else {
735  /* printf ("X3DMF, ignoring NULL node here \n"); */
736  }
737  }
738  } break;
739 
740 
741  case FIELDTYPE_MFString: {
742  struct Multi_String* MCptr;
743  char newline[100];
744  jsval xf;
745 
746  MCptr = (struct Multi_String *) Data;
747  for (i=0; i<MCptr->n; i++) {
748  #ifdef JSVRMLCLASSESVERBOSE
749  printf ("X3D_MF_TO_JS, working on %d of %d, p %u\n",i, MCptr->n, MCptr->p[i]);
750  #endif
751 
752  if (((struct Uni_String *)MCptr->p[i])->strptr != NULL)
753  sprintf (newline,"new String('%s')", ((struct Uni_String *)MCptr->p[i])->strptr);
754  else sprintf (newline,"new String('(NULL)')");
755 
756  #ifdef JSVRMLCLASSESVERBOSE
757  printf ("X3D_MF_TO_JS, we have a new script to evaluate: \"%s\"\n",newline);
758  #endif
759 
760  if (!JS_EvaluateScript(cx, JSVAL_TO_OBJECT(*newval), newline, (int) strlen(newline), FNAME_STUB, LINENO_STUB, &xf)) {
761  printf ("error creating the new object in X3D_MF_TO_JS string :%s:\n",newline);
762  return;
763  }
764  if (!JS_DefineElement(cx, JSVAL_TO_OBJECT(*newval), (jsint) i, xf,
765  JS_GET_PROPERTY_STUB, setSF_in_MF, JSPROP_ENUMERATE)) {
766  printf( "JS_DefineElement failed for arg %u .\n", i);
767  return;
768  }
769  }
770  } break;
771 
772  case FIELDTYPE_SFImage: {
773  struct Multi_Int32* MCptr;
774  char newline[10000];
775  jsval xf;
776 
777  /* look at the PixelTexture internals, an image is just a bunch of Int32s */
778  MCptr = (struct Multi_Int32 *) Data;
779  sprintf (newline, "new SFImage(");
780 
781  for (i=0; i<MCptr->n; i++) {
782  char sl[20];
783  sprintf (sl,"0x%x ", MCptr->p[i]);
784  strcat (newline,sl);
785 
786  if (i != ((MCptr->n)-1)) strcat (newline,",");
787  if (i == 2) strcat (newline, " new MFInt32(");
788 
789  }
790  strcat (newline, "))");
791 
792  if (!JS_EvaluateScript(cx, JSVAL_TO_OBJECT(*newval), newline, (int) strlen(newline), FNAME_STUB, LINENO_STUB, &xf)) {
793  printf ("error creating the new object in X3D_MF_TO_JS string :%s:\n",newline);
794  return;
795  }
796  *newval = xf; /* save this version */
797  } break;
798  default: { printf("WARNING: SHOULD NOT BE HERE! %d\n",dataType); }
799  }
800 
801  #ifdef JSVRMLCLASSESVERBOSE
802  printf ("returning from X3D_MF_TO_JS\n");
803  #endif
804 }
805 
806 void
807 reportWarningsOn() {
808  ppjsUtils p = (ppjsUtils)gglobal()->jsUtils.prv;
809  p->reportWarnings = JS_TRUE;
810 }
811 
812 
813 void
814 reportWarningsOff() {
815  ppjsUtils p = (ppjsUtils)gglobal()->jsUtils.prv;
816  p->reportWarnings = JS_FALSE;
817 }
818 
819 
820 void
821 errorReporter(JSContext *context, const char *message, JSErrorReport *report)
822 {
823  char *errorReport = 0;
824  int len = 0, charPtrSize = (int) sizeof(char *);
825  ppjsUtils p = (ppjsUtils)gglobal()->jsUtils.prv;
826 
827 //printf ("*** errorReporter ***\n");
828 
829  if (!report) {
830  fprintf(stderr, "%s\n", message);
831  return;
832  }
833 
834  /* Conditionally ignore reported warnings. */
835  if (JSREPORT_IS_WARNING(report->flags) && !p->reportWarnings) {
836  return;
837  }
838 
839  if (report->filename == NULL) {
840  len = (int) (strlen(message) + 1);
841  } else {
842  len = (int) ((strlen(report->filename) + 1) + (strlen(message) + 1));
843  }
844 
845  errorReport = (char *) JS_malloc(context, (len + STRING) * charPtrSize);
846  if (!errorReport) {
847  return;
848  }
849 
850 
851  if (JSREPORT_IS_WARNING(report->flags)) {
852  sprintf(errorReport,
853  "%swarning in %s at line %u:\n\t%s\n",
854  JSREPORT_IS_STRICT(report->flags) ? "strict " : "",
855  report->filename ? report->filename : "",
856  report->lineno ? report->lineno : 0,
857  message ? message : "No message.");
858  } else {
859  sprintf(errorReport,
860  "error in %s at line %u:\n\t%s\n",
861  report->filename ? report->filename : "",
862  report->lineno ? report->lineno : 0,
863  message ? message : "No message.");
864  }
865 
866  fprintf(stderr, "Javascript -- %s", errorReport);
867 
868  JS_free(context, errorReport);
869 }
870 
871 
872 /* SFNode - find the fieldOffset pointer for this field within this node */
873 static int *getFOP (struct X3D_Node *node, const char *str) {
874  int *fieldOffsetsPtr;
875 
876 
877  if (node != NULL) {
878  #ifdef JSVRMLCLASSESVERBOSE
879  printf ("...getFOP... it is a %s\n",stringNodeType(node->_nodeType));
880  #endif
881 
882  fieldOffsetsPtr = (int *) NODE_OFFSETS[node->_nodeType];
883  /*go thru all field*/
884  /* what we have is a list of 4 numbers, representing:
885  FIELDNAMES__parentResource, offsetof (struct X3D_Anchor, __parenturl), FIELDTYPE_SFString, KW_initializeOnly,
886  */
887 
888  while (*fieldOffsetsPtr != -1) {
889  #ifdef JSVRMLCLASSESVERBOSE
890  printf ("getFOP, looking at field %s type %s to match %s\n",FIELDNAMES[*fieldOffsetsPtr],FIELDTYPES[*(fieldOffsetsPtr+2)],str);
891  #endif
892 
893  /* skip any fieldNames starting with an underscore, as these are "internal" ones */
894  /* There is in fact nothing in this function that actually enforces this, which is good!! */
895  if (strcmp(str,FIELDNAMES[*fieldOffsetsPtr]) == 0) {
896  #ifdef JSVRMLCLASSESVERBOSE
897  printf ("getFOP, found entry for %s, it is %u (%p)\n",str,fieldOffsetsPtr,fieldOffsetsPtr);
898  #endif
899  return fieldOffsetsPtr;
900  }
901  fieldOffsetsPtr += 5;
902  }
903 
904  /* failed to find field?? */
905  #if TRACK_FIFO_MSG
906  printf ("getFOP, could not find field \"%s\" in nodeType \"%s\"\n", str, stringNodeType(node->_nodeType));
907  #endif
908  } else {
909  printf ("getFOP, passed in X3D node was NULL!\n");
910  }
911  return NULL;
912 }
913 
914 
915 /* getter for SFNode accesses */
916 static JSBool getSFNodeField (JSContext *context, JSObject *obj, jsid id, jsval *vp) {
917  //JSString *_idStr;
918  char *_id_c;
919  SFNodeNative *ptr;
920  int *fieldOffsetsPtr;
921  struct X3D_Node *node;
922 
923  /* NOTE - caller is (eventually) a JS class constructor, no need to BeginRequest */
924 
925  /* _idStr = JS_ValueToString(context, id); */
926 /* #if JS_VERSION < 185 */
927  /* _id_c = JS_GetStringBytes(_idStr); */
928 /* #else */
929  /* _id_c = JS_EncodeString(context,_idStr); */
930 /* #endif */
931 #if JS_VERSION < 185
932  _id_c = JS_GetStringBytes(JSVAL_TO_STRING(id));
933 #else
934  _id_c = JS_EncodeString(context,JSID_TO_STRING(id));
935 #endif
936 
937 
938  #ifdef JSVRMLCLASSESVERBOSE
939  printf ("\ngetSFNodeField called on name %s object %u\n",_id_c, obj);
940  #endif
941 
942  if ((ptr = (SFNodeNative *)JS_GetPrivate(context, obj)) == NULL) {
943  printf( "JS_GetPrivate failed in getSFNodeField.\n");
944 #if JS_VERSION >= 185
945  JS_free(context,_id_c);
946 #endif
947  return JS_FALSE;
948  }
949  node = X3D_NODE(ptr->handle);
950 
951  #ifdef JSVRMLCLASSESVERBOSE
952  printf ("getSFNodeField, got node %u for field %s object %u\n",node,_id_c, obj);
953  printf ("getSFNodeField, got node %p for field %s object %p\n",node,_id_c, obj);
954  #endif
955 
956  if (node == NULL) {
957  printf ("getSFNodeField, can not set field \"%s\", NODE is NULL!\n",_id_c);
958 #if JS_VERSION >= 185
959  JS_free(context,_id_c);
960 #endif
961  return JS_FALSE;
962  }
963 #if USE_OSC
964  /* Is this a ring buffer item? */
965  fieldOffsetsPtr = getFOP(ptr->handle,"FIFOsize");
966  if (fieldOffsetsPtr == NULL) {
967  #if TRACK_FIFO_MSG
968  printf("getSFNodeField : This is not a ringBuffer type\n");
969  #endif
970  } else {
971  struct X3D_OSC_Sensor *OSCnode ;
972  OSCnode = (struct X3D_OSC_Sensor *) X3D_NODE(ptr->handle);
973  char *_id_buffer_c = NULL ;
974  RingBuffer * buffer ;
975 
976  int iVal ;
977  float fVal ;
978  char * strPtr ;
979 
980  #if TRACK_FIFO_MSG
981  printf("getSFNodeField : This could be a ringBuffer type (found FIFOsize)\n");
982  #endif
983 
984  if (0 == strcmp(_id_c,"int32Inp")) {
985  #if TRACK_FIFO_MSG
986  printf("getSFNodeField %d : ptr->handle=%p (which corresponds to realnode in scenegraph/Component_Networking.c,314) node=%p see X3D_NODE(ptr->handle)\n",__LINE__,ptr->handle , node);
987  #endif
988  /* fieldOffsetsPtr = getFOP(ptr->handle,_id_buffer_c); */
989  buffer = (RingBuffer *) OSCnode->_int32InpFIFO ;
990  #if TRACK_FIFO_MSG
991  printf("getSFNodeField %d : buffer=%p\n",__LINE__,buffer) ;
992  #endif
993 
994  if (!RingBuffer_testEmpty(buffer)) {
995  _id_buffer_c = "_int32InpFIFO" ;
996  iVal = RingBuffer_pullUnion(buffer)->i ;
997  #if TRACK_FIFO_MSG
998  printf("getSFNodeField %d : iVal=%d\n",__LINE__,iVal);
999  #endif
1000 
1001  *vp = INT_TO_JSVAL(iVal) ;
1002  return JS_TRUE;
1003  } else {
1004  #if TRACK_FIFO_MSG
1005  printf("but the buffer is empty\n") ;
1006  #endif
1007  }
1008  } else if (0 == strcmp(_id_c,"floatInp")) {
1009  #if TRACK_FIFO_MSG
1010  printf("getSFNodeField %d : ptr->handle=%p (which corresponds to realnode in scenegraph/Component_Networking.c,314) node=%p see X3D_NODE(ptr->handle)\n",__LINE__,ptr->handle , node);
1011  #endif
1012  buffer = (RingBuffer *) OSCnode->_floatInpFIFO ;
1013  #if TRACK_FIFO_MSG
1014  printf("getSFNodeField %d : buffer=%p\n",__LINE__,buffer) ;
1015  #endif
1016 
1017  if (!RingBuffer_testEmpty(buffer)) {
1018  _id_buffer_c = "_floatInpFIFO" ;
1019  fVal = RingBuffer_pullUnion(buffer)->f ;
1020  #if TRACK_FIFO_MSG
1021  printf("getSFNodeField %d : fVal=%d\n",__LINE__,fVal);
1022  #endif
1023 
1024  JS_NewNumberValue(context,(double)fVal,vp);
1025  return JS_TRUE;
1026  } else {
1027  #if TRACK_FIFO_MSG
1028  printf("but the buffer is empty\n") ;
1029  #endif
1030  }
1031  } else if (0 == strcmp(_id_c,"stringInp")) {
1032  #if TRACK_FIFO_MSG
1033  printf("getSFNodeField %d : ptr->handle=%p (which corresponds to realnode in scenegraph/Component_Networking.c,314) node=%p see X3D_NODE(ptr->handle)\n",__LINE__,ptr->handle , node);
1034  #endif
1035  buffer = (RingBuffer *) OSCnode->_stringInpFIFO ;
1036  #if TRACK_FIFO_MSG
1037  printf("getSFNodeField %d : buffer=%p\n",__LINE__,buffer) ;
1038  #endif
1039 
1040  if (!RingBuffer_testEmpty(buffer)) {
1041  _id_buffer_c = "_stringInpFIFO" ;
1042  strPtr = (char *) RingBuffer_pullUnion(buffer)->p ;
1043  #if TRACK_FIFO_MSG
1044  printf("getSFNodeField %d : strPtr=%s\n",__LINE__,strPtr);
1045  #endif
1046 
1047  *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(context,strPtr));
1048  return JS_TRUE;
1049  } else {
1050  #if TRACK_FIFO_MSG
1051  printf("but the buffer is empty\n") ;
1052  #endif
1053  }
1054  } else {
1055  #if TRACK_FIFO_MSG
1056  printf("but this variable itself (%s) is not a ring buffer item\n",_id_c) ;
1057  #endif
1058  }
1059  }
1060 #endif
1061 
1062  /* get the table entry giving the type, offset, etc. of this field in this node */
1063  fieldOffsetsPtr = getFOP(ptr->handle,_id_c);
1064  if (fieldOffsetsPtr == NULL) {
1065 #if JS_VERSION >= 185
1066  JS_free(context,_id_c);
1067 #endif
1068  return JS_FALSE;
1069  }
1070  #ifdef JSVRMLCLASSESVERBOSE
1071  printf ("ptr=%p _id_c=%s node=%p node->_nodeType=%d stringNodeType=%s\n",ptr,_id_c,node,node->_nodeType,stringNodeType(node->_nodeType)) ;
1072  printf ("getSFNodeField, fieldOffsetsPtr is %d for node %u, field %s\n",fieldOffsetsPtr, ptr->handle, _id_c);
1073  #endif
1074 #if JS_VERSION >= 185
1075  JS_free(context,_id_c); /* _id_c is not used beyond this point in this fn */
1076 #endif
1077 
1078 
1079  /* now, we have an X3D node, offset, type, etc. Just get the value from memory, and move
1080  it to javascript. Kind of like: void getField_ToJavascript (int num, int fromoffset)
1081  for Routing. */
1082 
1083  /* fieldOffsetsPtr points to a 4-number line like:
1084  FIELDNAMES__parentResource, offsetof (struct X3D_Anchor, __parenturl), FIELDTYPE_SFString, KW_initializeOnly */
1085  switch (*(fieldOffsetsPtr+2)) {
1086  case FIELDTYPE_SFBool:
1087  case FIELDTYPE_SFFloat:
1088  case FIELDTYPE_SFTime:
1089  case FIELDTYPE_SFDouble:
1090  case FIELDTYPE_SFInt32:
1091  case FIELDTYPE_SFString:
1092  X3D_ECMA_TO_JS(context, offsetPointer_deref (void *, node, *(fieldOffsetsPtr+1)),
1093  returnElementLength(*(fieldOffsetsPtr+2)), *(fieldOffsetsPtr+2), vp);
1094  break;
1095  case FIELDTYPE_SFColor:
1096  case FIELDTYPE_SFNode:
1097  case FIELDTYPE_SFVec2f:
1098  case FIELDTYPE_SFVec3f:
1099  case FIELDTYPE_SFVec3d:
1100  case FIELDTYPE_SFRotation:
1101  X3D_SF_TO_JS(context, obj, offsetPointer_deref (void *, node, *(fieldOffsetsPtr+1)),
1102  returnElementLength(*(fieldOffsetsPtr+2)) * returnElementRowSize(*(fieldOffsetsPtr+2)) , *(fieldOffsetsPtr+2), vp);
1103  break;
1104  case FIELDTYPE_MFColor:
1105  case FIELDTYPE_MFVec3f:
1106  case FIELDTYPE_MFVec2f:
1107  case FIELDTYPE_MFFloat:
1108  case FIELDTYPE_MFTime:
1109  case FIELDTYPE_MFInt32:
1110  case FIELDTYPE_MFString:
1111  case FIELDTYPE_MFNode:
1112  case FIELDTYPE_MFRotation:
1113  case FIELDTYPE_SFImage:
1114  X3D_MF_TO_JS(context, obj, offsetPointer_deref (void *, node, *(fieldOffsetsPtr+1)), *(fieldOffsetsPtr+2), vp,
1115  (char *)FIELDNAMES[*(fieldOffsetsPtr+0)]);
1116  break;
1117  default: printf ("unhandled type FIELDTYPE_ %d in getSFNodeField\n", *(fieldOffsetsPtr+2)) ;
1118  return JS_FALSE;
1119  }
1120 
1121  #ifdef JSVRMLCLASSESVERBOSE
1122  printf ("end of getSFNodeField\n");
1123  #endif
1124 
1125  return JS_TRUE;
1126 }
1127 
1128 /* setter for SFNode accesses */
1129 #if JS_VERSION < 185
1130 JSBool setSFNodeField (JSContext *context, JSObject *obj, jsid id, jsval *vp) {
1131 #else
1132 JSBool setSFNodeField (JSContext *context, JSObject *obj, jsid id, JSBool strict, jsval *vp) {
1133 #endif
1134  char *_id_c;
1135  SFNodeNative *ptr;
1136  int *fieldOffsetsPtr;
1137  struct X3D_Node *node;
1138 
1139  /* get the id field... */
1140 
1141 #if JS_VERSION < 185
1142  _id_c = JS_GetStringBytes(JSVAL_TO_STRING(id));
1143 #else
1144  _id_c = JS_EncodeString(context,JSID_TO_STRING(id));
1145 #endif
1146 
1147  #ifdef JSVRMLCLASSESVERBOSE
1148  printf ("\nsetSFNodeField called on name %s object %u, jsval %u\n",_id_c, obj, *vp);
1149  #endif
1150 
1151  /* get the private data. This will contain a pointer into the FreeWRL scenegraph */
1152  if ((ptr = (SFNodeNative *)JS_GetPrivate(context, obj)) == NULL) {
1153  printf( "JS_GetPrivate failed in setSFNodeField.\n");
1154 #if JS_VERSION >= 185
1155  JS_free(context,_id_c);
1156 #endif
1157  return JS_FALSE;
1158  }
1159 
1160  /* get the X3D Scenegraph node pointer from this Javascript SFNode node */
1161  node = (struct X3D_Node *) ptr->handle;
1162 
1163  if (node == NULL) {
1164  printf ("setSFNodeField, can not set field \"%s\", NODE is NULL!\n",_id_c);
1165 #if JS_VERSION >= 185
1166  JS_free(context,_id_c);
1167 #endif
1168  return JS_FALSE;
1169  }
1170 
1171  #ifdef JSVRMLCLASSESVERBOSE
1172  printf ("so then, we have a node of type %s\n",stringNodeType(node->_nodeType));
1173  #endif
1174 
1175  #if USE_OSC
1176  #ifdef JSVRMLCLASSESVERBOSE
1177  /* Is this a ring buffer item? */
1178  fieldOffsetsPtr = getFOP(ptr->handle,"FIFOsize");
1179  #if TRACK_FIFO_MSG
1180  if (fieldOffsetsPtr == NULL) {
1181  printf("setSFNodeField : This is not a ringBuffer type\n");
1182  } else {
1183  printf("setSFNodeField : This is a ringBuffer type\n");
1184  }
1185  #endif
1186  #endif
1187  #endif
1188 
1189  /* get the table entry giving the type, offset, etc. of this field in this node */
1190  fieldOffsetsPtr = getFOP(ptr->handle,_id_c);
1191 #if JS_VERSION >= 185
1192  JS_free(context,_id_c); /* _id_c is not used beyond this point in this fn */
1193 #endif
1194  if (fieldOffsetsPtr == NULL) {
1195  return JS_FALSE;
1196  }
1197 
1198  /* now, we have an X3D node, offset, type, etc. Just get the value from Javascript, and move
1199  it to the X3D Scenegraph. */
1200 
1201  /* fieldOffsetsPtr points to a 4-number line like:
1202  FIELDNAMES__parentResource, offsetof (struct X3D_Anchor, __parenturl), FIELDTYPE_SFString, KW_initializeOnly */
1203  #ifdef JSVRMLCLASSESVERBOSE
1204  printf ("and a field type of %s\n",FIELDTYPES[*(fieldOffsetsPtr+2)]);
1205  #endif
1206 
1207  switch (*(fieldOffsetsPtr+2)) {
1208  case FIELDTYPE_SFBool:
1209  case FIELDTYPE_SFFloat:
1210  case FIELDTYPE_SFTime:
1211  case FIELDTYPE_SFDouble:
1212  case FIELDTYPE_SFInt32:
1213  case FIELDTYPE_SFString:
1214  JS_ECMA_TO_X3D(context, ((void *)( ((unsigned char *) node) + *(fieldOffsetsPtr+1))),
1215  returnElementLength(*(fieldOffsetsPtr+2)), *(fieldOffsetsPtr+2), vp);
1216  break;
1217  case FIELDTYPE_SFColor:
1218  case FIELDTYPE_SFNode:
1219  case FIELDTYPE_SFVec2f:
1220  case FIELDTYPE_SFVec3f:
1221  case FIELDTYPE_SFVec3d:
1222  case FIELDTYPE_SFRotation:
1223  JS_SF_TO_X3D(context, ((void *)( ((unsigned char *) node) + *(fieldOffsetsPtr+1))),
1224  returnElementLength(*(fieldOffsetsPtr+2)) * returnElementRowSize(*(fieldOffsetsPtr+2)) , *(fieldOffsetsPtr+2), vp);
1225  break;
1226  case FIELDTYPE_MFColor:
1227  case FIELDTYPE_MFVec3f:
1228  case FIELDTYPE_MFVec2f:
1229  case FIELDTYPE_MFFloat:
1230  case FIELDTYPE_MFTime:
1231  case FIELDTYPE_MFInt32:
1232  case FIELDTYPE_MFString:
1233  case FIELDTYPE_MFNode:
1234  case FIELDTYPE_MFRotation:
1235  case FIELDTYPE_SFImage:
1236  JS_MF_TO_X3D(context, obj, ((void *)( ((unsigned char *) node) + *(fieldOffsetsPtr+1))), *(fieldOffsetsPtr+2), vp);
1237  break;
1238  default: printf ("unhandled type in setSFNodeField\n");
1239  return JS_FALSE;
1240  }
1241 
1242  /* tell the X3D Scenegraph that something has changed in Kansas */
1243  update_node(node);
1244 
1245  #ifdef JSVRMLCLASSESVERBOSE
1246  printf ("end of setSFNodeField\n");
1247  #endif
1248 
1249 
1250  return JS_TRUE;
1251 }
1252 
1253 /* for SFNodes, go through and insure that all properties are defined for the specific node type */
1254 int JS_DefineSFNodeSpecificProperties (JSContext *context, JSObject *object, struct X3D_Node * ptr) {
1255  int *fieldOffsetsPtr;
1256  jsval rval = INT_TO_JSVAL(0);
1257  uintN attrs = JSPROP_PERMANENT
1258  | JSPROP_ENUMERATE
1259 #ifdef JSPROP_EXPORTED
1260  | JSPROP_EXPORTED
1261 #endif
1262  /* | JSPROP_INDEX */
1263  ;
1264  char *name;
1265  SFNodeNative *nodeNative;
1266  #ifdef JSVRMLCLASSESVERBOSE
1267  char *nodeName;
1268  struct X3D_Node *confirmNode;
1269  #endif
1270 
1271  /* NOTE - caller of this function is a class constructor, no need to worry about Requests */
1272 
1273 
1274  #ifdef JSVRMLCLASSESVERBOSE
1275  nodeName = parser_getNameFromNode(ptr) ; /* vi +/dump_scene src/lib/scenegraph/GeneratedCode.c */
1276  if (nodeName == NULL) {
1277  printf ("\nStart of JS_DefineSFNodeSpecificProperties for '---' ... working on node %u object %u (%p,%p)\n",ptr,object,ptr,object);
1278  } else {
1279  printf ("\nStart of JS_DefineSFNodeSpecificProperties for '%s' ... working on node %u object %u (%p,%p)\n",nodeName,ptr,object,ptr,object);
1280  confirmNode = parser_getNodeFromName(nodeName);
1281  if (confirmNode == NULL) {
1282  printf("RoundTrip failed : ptr (%p) -> nodeName (%s) -----\n",ptr,nodeName) ;
1283  } else {
1284  printf("RoundTrip OK : ptr (%p) -> nodeName (%s) -> confirmNode (%p)\n",ptr,nodeName,confirmNode) ;
1285  }
1286  }
1287  #endif
1288 
1289  if (ptr != NULL) {
1290  #ifdef JSVRMLCLASSESVERBOSE
1291  printf ("...JS_DefineSFNodeSpecificProperties... it is a %s\n",stringNodeType(ptr->_nodeType));
1292  #endif
1293 
1294  /* have we already done this for this node? We really do not want to do this again */
1295  if ((nodeNative = (SFNodeNative *)JS_GetPrivate(context,object)) == NULL) {
1296  printf ("JS_DefineSFNodeSpecificProperties, can not get private for a SFNode!\n");
1297  return JS_FALSE;
1298  }
1299  if (nodeNative->fieldsExpanded) {
1300  #ifdef JSVRMLCLASSESVERBOSE
1301  printf ("JS_DefineSFNodeSpecificProperties, already done for node\n");
1302  #endif
1303 
1304  return JS_TRUE;
1305  }
1306 
1307  fieldOffsetsPtr = (int *) NODE_OFFSETS[ptr->_nodeType];
1308  /*go thru all field*/
1309  /* what we have is a list of 4 numbers, representing:
1310  FIELDNAMES__parentResource, offsetof (struct X3D_Anchor, __parenturl), FIELDTYPE_SFString, KW_initializeOnly,
1311  */
1312 
1313  while (*fieldOffsetsPtr != -1) {
1314  /* fieldPtr=(char*)structptr+(*(fieldOffsetsPtr+1)); */
1315  #ifdef JSVRMLCLASSESVERBOSE
1316  printf ("looking at field %s type %s\n",FIELDNAMES[*fieldOffsetsPtr],FIELDTYPES[*(fieldOffsetsPtr+2)]);
1317  #endif
1318 
1319 #if USE_OSC
1320  if( 0 == strcmp("FreeWRL_PROTOInterfaceNodes",FIELDNAMES[*fieldOffsetsPtr])) {
1321 
1322  #ifdef JSVRMLCLASSESVERBOSE
1323  printf ("%s:%d Mangle %s before calling JS_DefineProperty ....\n",__FILE__,__LINE__,FIELDNAMES[*fieldOffsetsPtr]);
1324  #endif
1325  int i ;
1326  char *str1, *token;
1327  char *saveptr1 = NULL;
1328 
1329  UNUSED(token); // compiler warning mitigation
1330 
1331  for (i=0; i < X3D_GROUP(ptr)->FreeWRL_PROTOInterfaceNodes.n; i++) {
1332  rval = INT_TO_JSVAL(*fieldOffsetsPtr);
1333  name = parser_getNameFromNode(X3D_GROUP(ptr)->FreeWRL_PROTOInterfaceNodes.p[i]);
1334 
1335  #ifdef JSVRMLCLASSESVERBOSE
1336  dump_scene(stdout,0,X3D_GROUP(ptr)->FreeWRL_PROTOInterfaceNodes.p[i]);
1337  printf ("%s:%d dummy name=%s\n",__FILE__,__LINE__,name);
1338  #endif
1339 
1340  str1 = MALLOC(void *, 1+strlen(name));
1341  strcpy(str1,name) ;
1342  /* discard Proto_0xnnnnn_*/
1343  token = strtok_r(str1, "_", &saveptr1);
1344  str1 = NULL;
1345  token = strtok_r(str1, "_", &saveptr1);
1346  name = saveptr1 ;
1347 
1348  #ifdef JSVRMLCLASSESVERBOSE
1349  printf ("%s:%d would call JS_DefineProperty on (context=%p, object=%p, name=%s, rval=%p), setting getSFNodeField, setSFNodeField\n",__FILE__,__LINE__,context,object,name,rval);
1350  #endif
1351  if (!JS_DefineProperty(context, object, name, rval, getSFNodeField, setSFNodeField, attrs)) {
1352  printf("JS_DefineProperty failed for \"%s\" in JS_DefineSFNodeSpecificProperties.\n", name);
1353  return JS_FALSE;
1354  }
1355  }
1356  } else if (FIELDNAMES[*fieldOffsetsPtr][0] != '_') {
1357 #else
1358  if (FIELDNAMES[*fieldOffsetsPtr][0] != '_') {
1359 #endif
1360  /* skip any fieldNames starting with an underscore, as these are "internal" ones */
1361  name = (char *)FIELDNAMES[*fieldOffsetsPtr];
1362  rval = INT_TO_JSVAL(*fieldOffsetsPtr);
1363 
1364  /* is this an initializeOnly property? */
1365  /* lets not do this, ok?
1366  if ((*(fieldOffsetsPtr+3)) == KW_initializeOnly) attrs |= JSPROP_READONLY;
1367  */
1368 
1369  #ifdef JSVRMLCLASSESVERBOSE
1370  printf ("calling JS_DefineProperty on (context=%p, object=%p, name=%s, rval=%p), setting getSFNodeField, setSFNodeField\n",context,object,name,rval);
1371  #endif
1372 
1373  if (!JS_DefineProperty(context, object, name, rval, getSFNodeField, setSFNodeField, attrs)) {
1374  printf("JS_DefineProperty failed for \"%s\" in JS_DefineSFNodeSpecificProperties.\n", name);
1375  return JS_FALSE;
1376  }
1377  }
1378  fieldOffsetsPtr += 5;
1379  }
1380 
1381  /* set a flag indicating that we have been here already */
1382  nodeNative->fieldsExpanded = TRUE;
1383  }
1384  #ifdef JSVRMLCLASSESVERBOSE
1385  printf ("JS_DefineSFNodeSpecificProperties, returning TRUE\n");
1386  #endif
1387 
1388  return TRUE;
1389 }
1390 
1391 
1392 /********************************************************************************************/
1393 /* new addition April 2009. It was noted that the following code would not send an event to
1394  FreeWRL:
1395 #VRML V2.0 utf8
1396  DEF DisplayScript Script {
1397  eventOut MFString display_string
1398 
1399  url [ "javascript:
1400  function eventsProcessed () {
1401  display_string[7] = ' ';
1402  }
1403  "]
1404  }
1405 
1406 
1407 Shape {geometry DEF Display Text {}}
1408  ROUTE DisplayScript.display_string TO Display.set_string
1409 
1410 (it would if the assignment was display_string = new MFString(...) )
1411 
1412 But, this property check gets called on the equals. Lets figure out how to indicate that the
1413 holding object needs to route to FreeWRL... */
1414 
1415 
1416 #define SET_TOUCHED_TYPE_MF_A(thisMFtype,thisSFtype) \
1417  else if (JS_InstanceOf (cx, obj, &thisMFtype##Class, NULL)) {\
1418  jsval mainElement;\
1419  thisSFtype##Native *ptr; \
1420 \
1421  if (!JS_GetElement(cx, obj, num, &mainElement)) { \
1422  printf ("JS_GetElement failed for %d in get_valueChanged_flag\n",num); \
1423  return JS_FALSE; \
1424  } \
1425 \
1426  if ((ptr = (thisSFtype##Native *)JS_GetPrivate(cx, JSVAL_TO_OBJECT(mainElement))) == NULL) {\
1427  printf( "JS_GetPrivate failed in assignCheck.\n"); \
1428  return JS_FALSE; \
1429  } else { \
1430  /* printf ("got private for MFVec3f, doing it...\n"); */ \
1431  ptr->valueChanged++; \
1432  } \
1433  return JS_TRUE; \
1434  }
1435 
1436 
1437 #if JS_VERSION < 185
1438 JSBool js_SetPropertyCheck (JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
1439 #else
1440 JSBool js_SetPropertyCheck(JSContext *cx, JSObject *obj, jsid iid, JSBool strict, jsval *vp) {
1441 #endif
1442  int num=0;
1443 #if JS_VERSION >= 185
1444  jsval id;
1445  if (!JS_IdToValue(cx,iid,&id)) {
1446  printf("js_SetPropertyCheck: JS_IdToValue failed.\n");
1447  return JS_FALSE;
1448  }
1449 #endif
1450 
1451 #ifdef JAVASCRIPTVERBOSE
1452  char *_id_c = "(no value in string)";
1453  /* get the id field... */
1454  if (JSVAL_IS_STRING(id)) {
1455 /*
1456 #if JS_VERSION < 185
1457  _id_c = JS_GetStringBytes(JSVAL_TO_STRING(id));
1458 #else
1459  _id_c = JS_EncodeString(cx,JSVAL_TO_STRING(id));
1460 #endif
1461  printf ("hmmm...js_SetPropertyCheck called on string \"%s\" object %u, jsval %u\n",_id_c, obj, *vp); */
1462  } else if (JSVAL_IS_DOUBLE(id)) {
1463 #if JS_VERSION < 185
1464  _id_c = JS_GetStringBytes(JSVAL_TO_STRING(id));
1465 #else
1466  _id_c = JS_EncodeString(cx,JSVAL_TO_STRING(id));
1467 #endif
1468  printf ("\n...js_SetPropertyCheck called on double %s object %u, jsval %u\n",_id_c, obj, *vp);
1469 #if JS_VERSION >= 185
1470  JS_free(cx,_id_c);
1471 #endif
1472  } else if (JSVAL_IS_INT(id)) {
1473  num = JSVAL_TO_INT(id);
1474  printf ("\n...js_SetPropertyCheck called on number %d object %u, jsval %u\n",num, obj, *vp);
1475  } else {
1476  printf ("hmmm...js_SetPropertyCheck called on unknown type of object %u, jsval %u\n", obj, *vp);
1477  }
1478 #endif
1479 
1480  /* lets worry about the MFs containing ECMAs here - MFFloat MFInt32 MFTime MFString MFBool */
1481 
1482  if (JS_InstanceOf (cx, obj, &MFStringClass, NULL)) {
1483  SET_MF_ECMA_HAS_CHANGED;
1484  return JS_TRUE;
1485  }
1486  else if (JS_InstanceOf (cx, obj, &MFFloatClass, NULL)) {
1487  SET_MF_ECMA_HAS_CHANGED;
1488  return JS_TRUE;
1489  }
1490  else if (JS_InstanceOf (cx, obj, &MFInt32Class, NULL)) {
1491  SET_MF_ECMA_HAS_CHANGED;
1492  return JS_TRUE;
1493  }
1494 
1495 #ifdef NEWCLASSES
1496  else if (JS_InstanceOf (cx, obj, &MFBoolClass, NULL)) {
1497  SET_MF_ECMA_HAS_CHANGED;
1498  return JS_TRUE;
1499  }
1500 #endif
1501 
1502  SET_TOUCHED_TYPE_MF_A(MFRotation,SFRotation)
1503  SET_TOUCHED_TYPE_MF_A(MFNode,SFNode)
1504  SET_TOUCHED_TYPE_MF_A(MFVec2f,SFVec2f)
1505  SET_TOUCHED_TYPE_MF_A(MFVec3f,SFVec3f)
1506  /* SET_TOUCHED_TYPE_MF_A(MFImage,SFImage) */
1507  SET_TOUCHED_TYPE_MF_A(MFColor,SFColor)
1508  /* SET_TOUCHED_TYPE_MF_A(MFColorRGBA,SFColorRGBA) */
1509 
1510 
1511  #ifdef JSVRMLCLASSESVERBOSE
1512  printf ("this is a class of "); printJSNodeType (cx,obj);
1513  #endif
1514 
1515  return JS_TRUE;
1516 
1517 }
1518 
1519 /****************************************************************************/
1520 
1521 #if JS_VERSION < 185
1522 JSBool js_GetPropertyDebug (JSContext *context, JSObject *obj, jsval id, jsval *vp) {
1523 #else
1524 JSBool js_GetPropertyDebug (JSContext *context, JSObject *obj, jsid iid, jsval *vp) {
1525 #endif
1526  #ifdef JSVRMLCLASSESVERBOSE
1527  char *_id_c = "(no value in string)";
1528  int num;
1529  /* get the id field... */
1530 #if JS_VERSION >= 185
1531  jsval id;
1532  if (!JS_IdToValue(context,iid,&id)) {
1533  printf("js_GetPropertyDebug: JS_IdToValue failed -- NOT returning false\n");
1534  }
1535 #endif
1536 
1537  if (JSVAL_IS_STRING(id)) {
1538 #if JS_VERSION < 185
1539  _id_c = JS_GetStringBytes(JSVAL_TO_STRING(id));
1540 #else
1541  _id_c = JS_EncodeString(context,JSVAL_TO_STRING(id));
1542 #endif
1543  printf ("\n...js_GetPropertyDebug called on string \"%s\" object %u, jsval %lu\n",_id_c, (unsigned int) obj, *vp);
1544 #if JS_VERSION >= 185
1545  JS_free(context,_id_c);
1546 #endif
1547  } else if (JSVAL_IS_INT(id)) {
1548  num = JSVAL_TO_INT(id);
1549  printf ("\n...js_GetPropertyDebug called on number %d object %u, jsval %lu\n",num, (unsigned int) obj, *vp);
1550  } else {
1551  printf ("\n...js_GetPropertyDebug called on unknown type of object %u, jsval %lu\n", (unsigned int) obj, *vp);
1552  }
1553  #endif
1554  return JS_TRUE;
1555 }
1556 
1557 #ifdef JSVRMLCLASSESVERBOSE
1558 #if JS_VERSION < 185
1559 void js_SetPropertyDebugWrapped (JSContext *context, JSObject *obj, jsval id, jsval *vp,char *debugString) {
1560 #else
1561 void js_SetPropertyDebugWrapped (JSContext *context, JSObject *obj, jsid iid, jsval *vp,char *debugString) {
1562 #endif
1563  char *_id_c = "(no value in string)";
1564  int num;
1565 #if JS_VERSION >= 185
1566  jsval id;
1567  if (!JS_IdToValue(context,iid,&id)) {
1568  printf("js_GetPropertyDebug: JS_IdToValue failed\n");
1569  }
1570 #endif
1571 
1572  /* get the id field... */
1573  if (JSVAL_IS_STRING(id)) {
1574 #if JS_VERSION < 185
1575  _id_c = JS_GetStringBytes(JSVAL_TO_STRING(id));
1576 #else
1577  _id_c = JS_EncodeString(context,JSVAL_TO_STRING(id));
1578 #endif
1579  printf ("\n...js_SetPropertyDebug%s called on string \"%s\" object %p, jsval %lu\n",debugString,_id_c, obj, *vp);
1580 #if JS_VERSION >= 185
1581  JS_free(context,_id_c);
1582 #endif
1583  } else if (JSVAL_IS_INT(id)) {
1584  num = JSVAL_TO_INT(id);
1585  printf ("\n...js_SetPropertyDebug%s called on number %d object %p, jsval %lu\n",debugString,num, obj, *vp);
1586  } else {
1587  printf ("\n...js_SetPropertyDebug%s called on unknown type of object %p, jsval %lu\n",debugString, obj, *vp);
1588  }
1589 }
1590 #endif
1591 
1592 #if JS_VERSION < 185
1593 JSBool js_SetPropertyDebug (JSContext *context, JSObject *obj, jsval id, jsval *vp) {
1594 #else
1595 JSBool js_SetPropertyDebug (JSContext *context, JSObject *obj, jsid id, JSBool strict, jsval *vp) {
1596 #endif
1597  #ifdef JSVRMLCLASSESVERBOSE
1598  js_SetPropertyDebugWrapped(context,obj,id,vp,"");
1599  #endif
1600  return JS_TRUE;
1601 }
1602 
1603 #if JS_VERSION < 185
1604 JSBool js_SetPropertyDebug1 (JSContext *context, JSObject *obj, jsval id, jsval *vp) {
1605 #else
1606 JSBool js_SetPropertyDebug1 (JSContext *context, JSObject *obj, jsid id, JSBool strict, jsval *vp) {
1607 #endif
1608  #ifdef JSVRMLCLASSESVERBOSE
1609  js_SetPropertyDebugWrapped(context,obj,id,vp,"1");
1610  #endif
1611  return JS_TRUE;
1612 }
1613 #if JS_VERSION < 185
1614 JSBool js_SetPropertyDebug2 (JSContext *context, JSObject *obj, jsval id, jsval *vp) {
1615 #else
1616 JSBool js_SetPropertyDebug2 (JSContext *context, JSObject *obj, jsid id, JSBool strict, jsval *vp) {
1617 #endif
1618  #ifdef JSVRMLCLASSESVERBOSE
1619  js_SetPropertyDebugWrapped(context,obj,id,vp,"2");
1620  #endif
1621  return JS_TRUE;
1622 }
1623 #if JS_VERSION < 185
1624 JSBool js_SetPropertyDebug3 (JSContext *context, JSObject *obj, jsval id, jsval *vp) {
1625 #else
1626 JSBool js_SetPropertyDebug3 (JSContext *context, JSObject *obj, jsid id, JSBool strict, jsval *vp) {
1627 #endif
1628  #ifdef JSVRMLCLASSESVERBOSE
1629  js_SetPropertyDebugWrapped(context,obj,id,vp,"3");
1630  #endif
1631  return JS_TRUE;
1632 }
1633 #if JS_VERSION < 185
1634 JSBool js_SetPropertyDebug4 (JSContext *context, JSObject *obj, jsval id, jsval *vp) {
1635 #else
1636 JSBool js_SetPropertyDebug4 (JSContext *context, JSObject *obj, jsid id, JSBool strict, jsval *vp) {
1637 #endif
1638  #ifdef JSVRMLCLASSESVERBOSE
1639  js_SetPropertyDebugWrapped(context,obj,id,vp,"4");
1640  #endif
1641  return JS_TRUE;
1642 }
1643 #if JS_VERSION < 185
1644 JSBool js_SetPropertyDebug5 (JSContext *context, JSObject *obj, jsval id, jsval *vp) {
1645 #else
1646 JSBool js_SetPropertyDebug5 (JSContext *context, JSObject *obj, jsid id, JSBool strict, jsval *vp) {
1647 #endif
1648  #ifdef JSVRMLCLASSESVERBOSE
1649  js_SetPropertyDebugWrapped(context,obj,id,vp,"5");
1650  #endif
1651  return JS_TRUE;
1652 }
1653 #if JS_VERSION < 185
1654 JSBool js_SetPropertyDebug6 (JSContext *context, JSObject *obj, jsval id, jsval *vp) {
1655 #else
1656 JSBool js_SetPropertyDebug6 (JSContext *context, JSObject *obj, jsid id, JSBool strict, jsval *vp) {
1657 #endif
1658  #ifdef JSVRMLCLASSESVERBOSE
1659  js_SetPropertyDebugWrapped(context,obj,id,vp,"6");
1660  #endif
1661  return JS_TRUE;
1662 }
1663 #if JS_VERSION < 185
1664 JSBool js_SetPropertyDebug7 (JSContext *context, JSObject *obj, jsval id, jsval *vp) {
1665 #else
1666 JSBool js_SetPropertyDebug7 (JSContext *context, JSObject *obj, jsid id, JSBool strict, jsval *vp) {
1667 #endif
1668  #ifdef JSVRMLCLASSESVERBOSE
1669  js_SetPropertyDebugWrapped(context,obj,id,vp,"7");
1670  #endif
1671  return JS_TRUE;
1672 }
1673 #if JS_VERSION < 185
1674 JSBool js_SetPropertyDebug8 (JSContext *context, JSObject *obj, jsval id, jsval *vp) {
1675 #else
1676 JSBool js_SetPropertyDebug8 (JSContext *context, JSObject *obj, jsid id, JSBool strict, jsval *vp) {
1677 #endif
1678  #ifdef JSVRMLCLASSESVERBOSE
1679  js_SetPropertyDebugWrapped(context,obj,id,vp,"8");
1680  #endif
1681  return JS_TRUE;
1682 }
1683 #if JS_VERSION < 185
1684 JSBool js_SetPropertyDebug9 (JSContext *context, JSObject *obj, jsval id, jsval *vp) {
1685 #else
1686 JSBool js_SetPropertyDebug9 (JSContext *context, JSObject *obj, jsid id, JSBool strict, jsval *vp) {
1687 #endif
1688  #ifdef JSVRMLCLASSESVERBOSE
1689  js_SetPropertyDebugWrapped(context,obj,id,vp,"9");
1690  #endif
1691  return JS_TRUE;
1692 }
1693 
1694 
1695 #endif /* !(defined(JAVASCRIPT_STUB) || defined(JAVASCRIPT_DUK) */
Definition: ringbuf.h:8