Annotation of Amaya/amaya/javascript.h, revision 1.4
1.1 vatton 1: /*
2: *
3: * (c) COPYRIGHT INRIA and W3C, 2007
4: * Please first read the full copyright statement in file COPYRIGHT.
5: *
6: */
7:
8: #ifndef __AMAYA_JAVASCRIPT_H__
9: #define __AMAYA_JAVASCRIPT_H__
10:
11: /* javascript.h : defines functions, properties and classes
12: * used by the javascript interpreter
13: *
14: * Author: F. Wang
15: *
16: */
17:
18: /*----------------------------------------------------------------------
19: Instructions to complete the javascript/DOM support
20:
21: * Properties
22:
23: - Add a C identifier for your property in the enum list
24: properties_names.
25:
26: - Complete or create a JSPropertySpec to integrate your new property.
27: If your property must not be modified by the user, then add a
28: JSPROP_READONLY flag in its definition.
29:
30: - In javascript.c, complete the functions that manipulate your property:
31: getProperty, setProperty (if your property is not readonly)...
32:
1.2 vatton 33: - If your property does not belong to a class already declared, you
1.1 vatton 34: have to create one first (see the instructions for Classes). Then
35: apply JS_DefineProperties to all the object of the classes that
36: have the property.
37:
38: * Methods (functions)
39:
40: - Add a declaration of a C function representing the method.
41:
42: - Complete or create a JSFunctionSpec to integrate your new method.
43:
44: - In javascript.c, create the C function representing the method.
45:
1.2 vatton 46: - If your method does not belong to a class already declared, you
1.1 vatton 47: have to create one first (see the instructions for Classes). Then
48: apply JS_DefineFunctions to all the object of the classes that
49: have the method.
50:
51: * Classes (in DOM specification, they correspond to "Object" in the
52: pages ECMA Script Language Binding)
53:
54: - Add a JSClass definition (see all the possible configurations
55: at http://www.mozilla.org/js/spidermonkey/):
56:
57: > The first element is the name of your class
58:
1.2 vatton 59: > It is often useful to have private data for an object (for
60: instance to find which Thot Element it represents) so
1.1 vatton 61: JSCLASS_HAS_PRIVATE flag to the second element.
62:
63: > The next four elements indicate the name of the C functions
64: (for instance getProperty) that manipulate properties of an
1.2 vatton 65: object, respectively to add, delete, get or set a property.
1.1 vatton 66: If they are not used, then put JS_PropertyStub.
67:
68: > The last elements indicate other manipulations, that normally
69: are not used, so you can let them to JS_EnumerateStub,
70: JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
71:
72: - Define Properties and Methods to use with your class. See the
1.2 vatton 73: instructions above.
1.1 vatton 74:
75: - In javascript.c, make Amaya apply your class (and the corresponding
76: property and methods) to a certain kind of objects:
77:
78: > If they are childs of the global object (such as Navigator,
79: Screen...), then only one object is created for this class and
80: this must directly be done in the function InitJavascript.
81:
82: > Otherwise, you have to analyse the type of Thot's Document/Node
1.2 vatton 83: in the function Element_to_jsval in order to apply the class to
1.1 vatton 84: each object of the expected type.
85:
86: > To create an object with a given class use the function
87: JS_NewObject. If the object is actually a property, you have to
88: use JS_DefineObject. Note that in this case, it is not mandatory
89: to define the property in javascript.h
90:
1.2 vatton 91: * Properties/Methods that need a specific treatment
92:
93: For some kinds of properties/methods, the instructions above are not
94: enough. For example if X is an element, consider:
95:
96: X.getElementsByTagName("div").item(2) [1]
97: X.getElementsByTagName("div") [2]
98:
99: [1] returns the second "div" in the element X.
100: [2] returns a NodeList of all the "div" in X. The problem is that the
101: list is modified at the same time as the DOM tree, so you have to
102: return an object that describes the way you obtain this list.
103:
1.3 vatton 104: This is done by using private data. See the function ObjectWithInfo.
1.2 vatton 105:
1.1 vatton 106: -----------------------------------------------------------------------*/
107:
108: /*----------------------------------------------------------------------
109: Functions used to manipulate property values
110: -----------------------------------------------------------------------*/
1.3 vatton 111: static void finalizeObjectWithInfo(JSContext *cx, JSObject *obj);
1.1 vatton 112: static JSBool getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
113: static JSBool setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
114:
115: /*----------------------------------------------------------------------
116: Name of all properties used in getProperty, setProperty...
117: -----------------------------------------------------------------------*/
118: enum properties_names
119: {
120: WINDOW,
121: WINDOW_CLOSED, WINDOW_FRAMES, WINDOW_LENGTH, WINDOW_OPENER,
122: WINDOW_PARENT, WINDOW_SELF, WINDOW_TOP, WINDOW_NAME,
123:
124: NAVIGATOR_APPNAME, NAVIGATOR_APPCODENAME, NAVIGATOR_APPVERSION,
125: NAVIGATOR_USERAGENT, NAVIGATOR_COOKIESENABLED, NAVIGATOR_PLATFORM,
126: NAVIGATOR_BROWSERLANGUAGE, /*NAVIGATOR_PLUGINS, */
127:
128: SCREEN_PIXELDEPTH, SCREEN_COLORDEPTH,
129: SCREEN_AVAILHEIGHT, SCREEN_AVAILWIDTH, SCREEN_HEIGHT, SCREEN_WIDTH,
130:
131: HISTORY_LENGTH,
132:
133: LOCATION_HREF, LOCATION_PATHNAME, LOCATION_HASH,
134: /*, LOCATION_HOST, LOCATION_HOSTNAME,
135: LOCATION_PORT, LOCATION_PROTOCOL, LOCATION_SEARCH, */
136:
137: DOCUMENT_IMPLEMENTATION, DOCUMENT_DOCTYPE, DOCUMENT_DOCUMENTELEMENT,
138:
139: DOCUMENTTYPE_NAME, DOCUMENTTYPE_ENTITIES, DOCUMENTTYPE_NOTATIONS,
140:
1.2 vatton 141: ATTR_NAME, ATTR_SPECIFIED, ATTR_VALUE,
142:
143: ELEMENT_TAGNAME,
144:
1.1 vatton 145: NODE_NODENAME, NODE_NODEVALUE, NODE_NODETYPE, NODE_PARENTNODE, NODE_CHILDNODES, NODE_FIRSTCHILD,
146: NODE_LASTCHILD, NODE_PREVIOUSSIBLING, NODE_NEXTSIBLING, NODE_ATTRIBUTES, NODE_OWNERDOCUMENT,
147:
148: NODELIST_LENGTH
1.2 vatton 149:
1.3 vatton 150: /* Put here methods that use the ObjectWithInfo function to create their PrivateData */
1.4 ! vatton 151: , GETELEMENTSBYTAGNAME,
1.1 vatton 152: };
153:
154: /*----------------------------------------------------------------------
155: Global Object Window
156: -----------------------------------------------------------------------*/
157: static JSBool window_alert(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
158: static JSBool window_confirm(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
159: static JSBool window_prompt(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
160: static JSBool window_close(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
161: static JSBool window_blur(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
162: static JSBool window_print(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
163:
164: /*
165: static JSBool window_clearInterval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
166: static JSBool window_clearTimeout(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
167: static JSBool window_focus(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
168: static JSBool window_moveBy(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
169: static JSBool window_moveTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
170: static JSBool window_open(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
171: static JSBool window_resizeBy(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
172: static JSBool window_resizeTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
173: static JSBool window_scrollBy(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
174: static JSBool window_scrollTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
175: static JSBool window_setInterval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
176: static JSBool window_setTimeout(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
177: */
178:
179: static JSFunctionSpec window_functions[] =
180: {
181: /* name of javascript function name of C function number of arguments */
182: {"alert" , window_alert , 1},
183: {"confirm" , window_confirm , 1},
184: {"prompt" , window_prompt , 2},
185: {"close" , window_close , 0},
186: {"blur" , window_blur , 0},
187: {"print" , window_print , 0},
188:
189: /*
190: {"clearInterval" , window_clearInterval , 1},
191: {"clearTimeout" , window_clearTimeout , 1},
192: {"focus" , window_focus , 0},
193: {"moveBy" , window_moveBy , 2},
194: {"moveTo" , window_moveTo , 2},
195: {"open" , window_open , 4},
196: {"resizeBy" , window_resizeBy , 2},
197: {"resizeTo" , window_resizeTo , 2},
198: {"scrollBy" , window_scrollBy , 2},
199: {"scrollTo" , window_scrollTo , 2},
200: {"setInterval" , window_setInterval , 3},
201: {"setTimeout" , window_setTimeout , 3},
202: */
203: {0}
204: };
205:
206: static JSPropertySpec window_properties[] =
207: {
208: {"window" , WINDOW, JSPROP_READONLY},
209: {"closed" , WINDOW_CLOSED, JSPROP_READONLY},
210: {"frames" , WINDOW_FRAMES, JSPROP_INDEX & JSPROP_READONLY},
211: {"length" , WINDOW_LENGTH, JSPROP_READONLY},
212: {"opener" , WINDOW_OPENER, JSPROP_READONLY},
213: {"parent" , WINDOW_PARENT, JSPROP_READONLY},
214: {"self" , WINDOW_SELF , JSPROP_READONLY},
215: {"top" , WINDOW_TOP , JSPROP_READONLY},
216: {0}
217: };
218:
219: static JSClass window_class =
220: {
221: "Window",0,
222: JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
223: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
224: };
225:
226: /*----------------------------------------------------------------------
227: Object Navigator
228: -----------------------------------------------------------------------*/
229:
230: static JSBool navigator_javaEnabled(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
231: static JSBool navigator_taintEnabled(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
232:
233: static JSFunctionSpec navigator_functions[] =
234: {
235: /* name of javascript function name of C function number of arguments */
236: {"javaEnabled" , navigator_javaEnabled , 0},
237: {"taintEnabled" , navigator_taintEnabled , 0},
238: {0}
239: };
240:
241: static JSPropertySpec navigator_properties[] =
242: {
243: /* {"plugins" , NAVIGATOR_PLUGINS , JSPROP_INDEX & JSPROP_READONLY},*/
244: {"appCodeName" , NAVIGATOR_APPCODENAME , JSPROP_READONLY},
245: {"appName" , NAVIGATOR_APPNAME , JSPROP_READONLY},
246: {"appVersion" , NAVIGATOR_APPVERSION , JSPROP_READONLY},
247: {"browserLanguage" , NAVIGATOR_BROWSERLANGUAGE , JSPROP_READONLY},
248: {"cookieEnabled" , NAVIGATOR_COOKIESENABLED , JSPROP_READONLY},
249: {"platform" , NAVIGATOR_PLATFORM , JSPROP_READONLY},
250: {"userAgent" , NAVIGATOR_USERAGENT , JSPROP_READONLY},
251: {0}
252: };
253:
254: static JSClass navigator_class =
255: {
256: "Navigator",0,
257: JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
258: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
259: };
260:
261:
262: /*----------------------------------------------------------------------
263: Object Screen
264: -----------------------------------------------------------------------*/
265:
266: static JSPropertySpec screen_properties[] =
267: {
268: {"availHeight", SCREEN_AVAILHEIGHT , JSPROP_READONLY},
269: {"availWidth" , SCREEN_AVAILWIDTH , JSPROP_READONLY},
270: {"colorDepth" , SCREEN_COLORDEPTH , JSPROP_READONLY},
271: {"pixelDepth" , SCREEN_PIXELDEPTH , JSPROP_READONLY},
272: {"height" , SCREEN_HEIGHT , JSPROP_READONLY},
273: {"width" , SCREEN_WIDTH , JSPROP_READONLY},
274: {0}
275: };
276:
277: static JSClass screen_class =
278: {
279: "Screen",0,
280: JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
281: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
282: };
283:
284: /*----------------------------------------------------------------------
285: Object History
286: -----------------------------------------------------------------------*/
287:
288: static JSBool history_back(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
289: static JSBool history_forward(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
290: /*static JSBool history_go(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);*/
291:
292: static JSFunctionSpec history_functions[] =
293: {
294: /* name of javascript function name of C function number of arguments */
295: {"back" , history_back , 0},
296: {"forward" , history_forward , 0},
297: /* {"go" , history_go , 1},*/
298: {0}
299: };
300:
301: static JSPropertySpec history_properties[] =
302: {
303: {"length" , HISTORY_LENGTH , JSPROP_READONLY},
304: {0}
305: };
306:
307: static JSClass history_class =
308: {
309: "History",0,
310: JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
311: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
312: };
313:
314: /*----------------------------------------------------------------------
315: Object Location
316: -----------------------------------------------------------------------*/
317:
318: static JSBool location_replace(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
319: static JSBool location_assign(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
320: static JSBool location_reload(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
321:
322: static JSFunctionSpec location_functions[] =
323: {
324: /* name of javascript function name of C function number of arguments */
325: {"reload" , location_reload , 0},
326: {"assign" , location_assign , 1},
327: {"replace" , location_replace , 1},
328: {0}
329: };
330:
331:
332: static JSPropertySpec location_properties[] =
333: {
334: {"href" , LOCATION_HREF , 0},
335: {"pathname" , LOCATION_PATHNAME , JSPROP_READONLY},
336: {"hash" , LOCATION_HASH , JSPROP_READONLY},
337: /* {"host" , LOCATION_HOST , 0},
338: {"hostname" , LOCATION_HOSTNAME , 0},
339: {"port" , LOCATION_PORT , 0},
340: {"protocol" , LOCATION_PROTOCOL , 0},
341: {"search" , LOCATION_SEARCH , 0},*/
342: {0}
343: };
344:
345:
346: static JSClass location_class =
347: {
348: "Location",0,
349: JS_PropertyStub,JS_PropertyStub,getProperty,setProperty,
350: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
351: };
352:
353: /*----------------------------------------------------------------------
354: Object DOMException
355: -----------------------------------------------------------------------*/
356: /*
357: static JSClass DOMException_class =
358: {
359: "DOMException",0,
360: JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
361: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
362: };*/
363:
364: /*----------------------------------------------------------------------
365: Object ExceptionCode
366: -----------------------------------------------------------------------*/
367: /*
368: static JSClass ExceptionCode_class =
369: {
370: "ExceptionCode",0,
371: JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
372: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
373: };
374: */
375:
376: /* Definition ExceptionCode */
377: #define INDEX_SIZE_ERR 1
378: #define DOMSTRING_SIZE_ERR 2
379: #define HIERARCHY_REQUEST_ERR 3
380: #define WRONG_DOCUMENT_ERR 4
381: #define INVALID_CHARACTER_ERR 5
382: #define NO_DATA_ALLOWED_ERR 6
383: #define NO_MODIFICATION_ALLOWED_ERR 7
384: #define NOT_FOUND_ERR 8
385: #define NOT_SUPPORTED_ERR 9
386: #define INUSE_ATTRIBUTE_ERR 10
387:
388: /*----------------------------------------------------------------------
389: Object DOMImplementation
390: -----------------------------------------------------------------------*/
391: static JSBool DOMImplementation_hasFeature(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
392:
393: static JSFunctionSpec DOMImplementation_functions[] =
394: {
395: /* name of javascript function name of C function number of arguments */
396: {"hasFeature" , DOMImplementation_hasFeature , 2},
397: {0}
398: };
399:
400: static JSClass DOMImplementation_class =
401: {
402: "DOMImplementation",0,
403: JS_PropertyStub,JS_PropertyStub,JS_PropertyStub,JS_PropertyStub,
404: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
405: };
406:
407:
408: /*----------------------------------------------------------------------
409: Object DocumentFragment
410: -----------------------------------------------------------------------*/
411: static JSClass DocumentFragment_class =
412: {
413: "DocumentFragment",0,
414: JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
415: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
416: };
417:
418: /*----------------------------------------------------------------------
419: Object Document
420: -----------------------------------------------------------------------*/
1.2 vatton 421: static JSBool _getElementsByTagName(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
422:
1.1 vatton 423: /*
424:
425: static JSBool Document_createElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
426: static JSBool Document_createDocumentFragment(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
427: static JSBool Document_createCDATASection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
428: static JSBool Document_createProcessingInstruction(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
429: static JSBool Document_createAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
430: static JSBool Document_createEntityReference(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
1.2 vatton 431: */
1.1 vatton 432:
433: static JSFunctionSpec Document_functions[] =
434: {
1.2 vatton 435: /* name of javascript function name of C function number of arguments */
436: /* {"createElement" , Document_createElement , 1},
1.1 vatton 437: {"createDocumentFragment" , Document_createDocumentFragment , 0},
438: {"createCDATASection" , Document_createCDATASection , 1},
439: {"createProcessingInstruction" , Document_createProcessingInstruction , 2},
440: {"createAttribute" , Document_createAttribute , 1},
1.2 vatton 441: {"createEntityReference" , Document_createEntityReference , 1},*/
442: {"getElementsByTagName" , _getElementsByTagName , 1},
1.1 vatton 443: {0}
444: };
445:
446: static JSPropertySpec Document_properties[] =
447: {
448: {"doctype" , DOCUMENT_DOCTYPE , JSPROP_READONLY},
449: {"implementation" , DOCUMENT_IMPLEMENTATION , JSPROP_READONLY},
450: {"documentElement" , DOCUMENT_DOCUMENTELEMENT , JSPROP_READONLY},
451: {0}
452: };
453:
454: static JSClass Document_class =
455: {
456: "Document", JSCLASS_HAS_PRIVATE,
457: JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
458: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
459: };
460:
461:
462: /*----------------------------------------------------------------------
463: Object Node
464: -----------------------------------------------------------------------*/
465: /*
466: static JSBool Node_createElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
467: static JSBool Node_replaceChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
468: static JSBool Node_removeChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
469: static JSBool Node_appendChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);*/
470: static JSBool Node_hasChildNodes(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
471: //static JSBool Node_cloneNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);*/
472:
473: static JSFunctionSpec Node_functions[] =
474: {
475: /* {"insertBefore" , Node_createElement , 2},
476: {"replaceChild" , Node_replaceChild , 1},
477: {"removeChild" , Node_removeChild , 0},
478: {"appendChild" , Node_appendChild , 1},*/
479: {"hasChildNodes" , Node_hasChildNodes , 0},
480: /* {"cloneNode" , Node_cloneNode , 1},*/
481: {0}
482: };
483:
484: static JSPropertySpec Node_properties[] =
485: {
486: {"nodeName" , NODE_NODENAME , JSPROP_READONLY},
487: {"nodeValue" , NODE_NODEVALUE , JSPROP_READONLY},
488: {"nodeType" , NODE_NODETYPE , JSPROP_READONLY},
489: {"parentNode" , NODE_PARENTNODE , JSPROP_READONLY},
490: {"childNodes" , NODE_CHILDNODES , JSPROP_READONLY},
491: {"firstChild" , NODE_FIRSTCHILD , JSPROP_READONLY},
492: {"lastChild" , NODE_LASTCHILD , JSPROP_READONLY},
493: {"previousSibling" , NODE_PREVIOUSSIBLING , JSPROP_READONLY},
494: {"nextSibling" , NODE_NEXTSIBLING , JSPROP_READONLY},
495: {"attributes" , NODE_ATTRIBUTES , JSPROP_READONLY},
496: {"ownerDocument" , NODE_OWNERDOCUMENT , JSPROP_READONLY},
497: {0}
498: };
499:
500: /*static JSClass Node_class =
501: {
502: "Node", JSCLASS_HAS_PRIVATE,
503: JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
504: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
505: };*/
506:
507: /* Definition NodeType */
508: #define ELEMENT_NODE 1
509: #define ATTRIBUTE_NODE 2
510: #define TEXT_NODE 3
511: #define CDATA_SECTION_NODE 4
512: #define ENTITY_REFERENCE_NODE 5
513: #define ENTITY_NODE 6
514: #define PROCESSING_INSTRUCTION_NODE 7
515: #define COMMENT_NODE 8
516: #define DOCUMENT_NODE 9
517: #define DOCUMENT_TYPE_NODE 10
518: #define DOCUMENT_FRAGMENT_NODE 11
519: #define NOTATION_NODE 12
520:
521: /*----------------------------------------------------------------------
522: Object NodeList
523: -----------------------------------------------------------------------*/
524: static JSBool NodeList_item(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
525:
526: static JSFunctionSpec NodeList_functions[] =
527: {
528: {"item" , NodeList_item , 1},
529: {0}
530: };
531:
532: static JSPropertySpec NodeList_properties[] =
533: {
534: {"length" , NODELIST_LENGTH , JSPROP_READONLY},
535: {0}
536: };
537:
538: static JSClass NodeList_class =
539: {
540: "NodeList", JSCLASS_HAS_PRIVATE,
541: JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
1.3 vatton 542: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,finalizeObjectWithInfo
1.1 vatton 543: };
544:
545: /*----------------------------------------------------------------------
546: Object NamedNodeMap
547: -----------------------------------------------------------------------*/
1.2 vatton 548: static JSBool NamedNodeMap_getNamedItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
1.3 vatton 549: static JSBool NamedNodeMap_setNamedItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
1.1 vatton 550: /*
551: static JSBool NamedNodeMap_removeNamedItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
552: static JSBool NamedNodeMap_item(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
1.2 vatton 553: */
1.1 vatton 554:
555: static JSFunctionSpec NamedNodeMap_functions[] =
556: {
557: {"getNamedItem" , NamedNodeMap_getNamedItem , 1},
1.4 ! vatton 558: {"setNamedItem" , NamedNodeMap_setNamedItem , 2},
1.3 vatton 559: /* {"removeNamedItem" , NamedNodeMap_removeNamedItem , 1},
1.2 vatton 560: {"item" , NamedNodeMap_item , 1},*/
1.1 vatton 561: {0}
562: };
563:
564: static JSPropertySpec NamedNodeMap_properties[] =
565: {
1.2 vatton 566: /* {"length" , NAMEDNODEMAP_LENGTH , JSPROP_READONLY},*/
1.1 vatton 567: {0}
568: };
569:
570: static JSClass NamedNodeMap_class =
571: {
572: "NamedNodeMap", JSCLASS_HAS_PRIVATE,
573: JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
1.3 vatton 574: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,finalizeObjectWithInfo
1.1 vatton 575: };
576:
577: /*----------------------------------------------------------------------
578: Object CharacterData
579: -----------------------------------------------------------------------*/
580: /*
581: static JSBool CharacterData_substringData(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
582: static JSBool CharacterData_appendData(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
583: static JSBool CharacterData_insertData(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
584: static JSBool CharacterData_deleteData(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
585: static JSBool CharacterData_replaceData(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
586:
587: static JSFunctionSpec CharacterData_functions[] =
588: {
589: {"substringData" , CharacterData_createElement , 2},
590: {"appendData" , CharacterData_createElement , 1},
591: {"insertData" , CharacterData_createElement , 2},
592: {"deleteData" , CharacterData_createElement , 2},
593: {"replaceData" , CharacterData_createElement , 3},
594: {0}
595: };
596:
597: static JSPropertySpec CharacterData_properties[] =
598: {
599: {"data" , CHARACTERDATA_DATA , JSPROP_READONLY},
600: {"length" , CHARACTERDATA_LENGTH , JSPROP_READONLY},
601: {0}
602: };
603:
604: static JSClass CharacterData_class =
605: {
606: "CharacterData", JSCLASS_HAS_PRIVATE,
607: JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
608: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
609: };
610: */
611:
612: /*----------------------------------------------------------------------
613: Object Attr
614: -----------------------------------------------------------------------*/
615: static JSPropertySpec Attr_properties[] =
616: {
617: {"name" , ATTR_NAME , JSPROP_READONLY},
618: {"specified" , ATTR_SPECIFIED , JSPROP_READONLY},
619: {"value" , ATTR_VALUE , JSPROP_READONLY},
620: {0}
621: };
622:
623: static JSClass Attr_class =
624: {
625: "Attr", JSCLASS_HAS_PRIVATE,
626: JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
627: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
628: };
629:
630:
631: /*----------------------------------------------------------------------
632: Object Element
633: -----------------------------------------------------------------------*/
634: /*
635: static JSBool Element_getAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
636: static JSBool Element_setAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
637: static JSBool Element_removeAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
638: static JSBool Element_getAttributeNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
639: static JSBool Element_setAttributeNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
1.2 vatton 640: static JSBool Element_removeAttributeNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);*/
641: /*static JSBool Element_normalize(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);*/
1.1 vatton 642:
643: static JSFunctionSpec Element_functions[] =
644: {
1.2 vatton 645: /* {"getAttribute" , Element_getAttribute , 1},
1.1 vatton 646: {"setAttribute" , Element_setAttribute , 1},
647: {"removeAttribute" , Element_removeAttribute , 1},
648: {"getAttributeNode" , Element_getAttributeNode , 1},
649: {"setAttributeNode" , Element_setAttributeNode , 1},
1.2 vatton 650: {"removeAttributeNode" , Element_removeAttributeNode , 1},*/
651: {"getElementsByTagName" , _getElementsByTagName , 1},
652: /* {"normalize" , Element_normalize , 0},*/
1.1 vatton 653: {0}
654: };
655:
656: static JSPropertySpec Element_properties[] =
657: {
658: {"tagName" , ELEMENT_TAGNAME , JSPROP_READONLY},
659: {0}
660: };
661:
662: static JSClass Element_class =
663: {
664: "Element", JSCLASS_HAS_PRIVATE,
665: JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
666: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
667: };
668:
669: /*----------------------------------------------------------------------
670: Object Text
671: -----------------------------------------------------------------------*/
672: /*
673: static JSBool Element_splitText(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
674:
675: static JSFunctionSpec Text_functions[] =
676: {
677: {"splitText" , Text_splitText , 1},
678: {0}
679: };*/
680:
681: static JSClass Text_class =
682: {
683: "Text", JSCLASS_HAS_PRIVATE,
684: JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
685: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
686: };
687:
688: /*----------------------------------------------------------------------
689: Object Comment
690: -----------------------------------------------------------------------*/
691: static JSClass Comment_class =
692: {
693: "Comment", JSCLASS_HAS_PRIVATE,
694: JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
695: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
696: };
697:
698: /*----------------------------------------------------------------------
699: Object CDATASection
700: -----------------------------------------------------------------------*/
701: static JSClass CDATASection_class =
702: {
703: "CDATASection", JSCLASS_HAS_PRIVATE,
704: JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
705: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
706: };
707:
708: /*----------------------------------------------------------------------
709: Object DocumentType
710: -----------------------------------------------------------------------*/
711:
712: static JSPropertySpec DocumentType_properties[] =
713: {
714: {"name" , DOCUMENTTYPE_NAME , JSPROP_READONLY},
715: {"entities" , DOCUMENTTYPE_ENTITIES , JSPROP_READONLY},
716: {"notations" , DOCUMENTTYPE_NOTATIONS , JSPROP_READONLY},
717: {0}
718: };
719:
720: static JSClass DocumentType_class =
721: {
722: "DocumentType", JSCLASS_HAS_PRIVATE,
723: JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
724: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
725: };
726:
727: /*----------------------------------------------------------------------
728: Object Notation
729: -----------------------------------------------------------------------*/
730: /*
731: static JSPropertySpec Notation_properties[] =
732: {
733: {"publicId" , NOTATION_PUBLICID , JSPROP_READONLY},
734: {"systemId" , NOTATION_SYSTEMID , JSPROP_READONLY},
735: {0}
736: };
737: */
738: static JSClass Notation_class =
739: {
740: "Notation", JSCLASS_HAS_PRIVATE,
741: JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
742: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
743: };
744:
745: /*----------------------------------------------------------------------
746: Object Entity
747: -----------------------------------------------------------------------*/
748: /*
749: static JSPropertySpec Entity_properties[] =
750: {
751: {"publicId" , ENTITY_PUBLICID , JSPROP_READONLY},
752: {"systemId" , ENTITY_SYSTEMID , JSPROP_READONLY},
753: {"notationName" , ENTITY_NOTATIONNAME , JSPROP_READONLY},
754: {0}
755: };
756: */
757: static JSClass Entity_class =
758: {
759: "Entity_properties", JSCLASS_HAS_PRIVATE,
760: JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
761: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
762: };
763:
764: /*----------------------------------------------------------------------
765: Object EntityReference
766: -----------------------------------------------------------------------*/
767: static JSClass EntityReference_class =
768: {
769: "EntityReference", JSCLASS_HAS_PRIVATE,
770: JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
771: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
772: };
773:
774: /*----------------------------------------------------------------------
775: Object ProcessingInstruction
776: -----------------------------------------------------------------------*/
777: /*
778: static JSPropertySpec ProcessingInstruction_properties[] =
779: {
780: {"target" , PROCESSINGINSTRUCTION_TARGET , JSPROP_READONLY},
781: {"data" , PROCESSINGINSTRUCTION_DATA , JSPROP_READONLY},
782: {0}
783: };
784: */
785: static JSClass ProcessingInstruction_class =
786: {
787: "ProcessingInstruction", JSCLASS_HAS_PRIVATE,
788: JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
789: JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
790: };
791:
792: #endif /* __AMAYA_JAVASCRIPT_H__ */
Webmaster