Annotation of Amaya/amaya/javascript.h, revision 1.2

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: 
        !           104:        Use ObjectWithInfo
        !           105: 
        !           106:             ***!!!! TODO: Currently the returned value is a typed object
        !           107:                      with a private data that points to a jsArray. But
        !           108:                       this has to be improved...
        !           109:                                                                      !!!!***
        !           110: 
1.1       vatton    111:   -----------------------------------------------------------------------*/
                    112: 
                    113: /*----------------------------------------------------------------------
                    114:   Functions used to manipulate property values
                    115:   -----------------------------------------------------------------------*/
                    116: static JSBool getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
                    117: static JSBool setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
                    118: 
                    119: /*----------------------------------------------------------------------
                    120:   Name of all properties used in getProperty, setProperty...
                    121:   -----------------------------------------------------------------------*/
                    122: enum properties_names
                    123: {
                    124:  WINDOW,
                    125:  WINDOW_CLOSED, WINDOW_FRAMES, WINDOW_LENGTH, WINDOW_OPENER,
                    126:  WINDOW_PARENT, WINDOW_SELF, WINDOW_TOP, WINDOW_NAME,
                    127: 
                    128:  NAVIGATOR_APPNAME, NAVIGATOR_APPCODENAME, NAVIGATOR_APPVERSION, 
                    129:  NAVIGATOR_USERAGENT, NAVIGATOR_COOKIESENABLED, NAVIGATOR_PLATFORM,
                    130:  NAVIGATOR_BROWSERLANGUAGE, /*NAVIGATOR_PLUGINS, */
                    131: 
                    132:  SCREEN_PIXELDEPTH, SCREEN_COLORDEPTH,
                    133:  SCREEN_AVAILHEIGHT, SCREEN_AVAILWIDTH,  SCREEN_HEIGHT, SCREEN_WIDTH,
                    134:  
                    135:  HISTORY_LENGTH,
                    136: 
                    137:  LOCATION_HREF, LOCATION_PATHNAME, LOCATION_HASH,
                    138:  /*, LOCATION_HOST, LOCATION_HOSTNAME, 
                    139:  LOCATION_PORT, LOCATION_PROTOCOL, LOCATION_SEARCH, */
                    140: 
                    141:  DOCUMENT_IMPLEMENTATION, DOCUMENT_DOCTYPE, DOCUMENT_DOCUMENTELEMENT,
                    142: 
                    143:  DOCUMENTTYPE_NAME, DOCUMENTTYPE_ENTITIES, DOCUMENTTYPE_NOTATIONS,
                    144: 
1.2     ! vatton    145:  ATTR_NAME, ATTR_SPECIFIED, ATTR_VALUE,
        !           146: 
        !           147:  ELEMENT_TAGNAME,
        !           148: 
1.1       vatton    149:  NODE_NODENAME, NODE_NODEVALUE, NODE_NODETYPE, NODE_PARENTNODE, NODE_CHILDNODES, NODE_FIRSTCHILD,
                    150:  NODE_LASTCHILD, NODE_PREVIOUSSIBLING, NODE_NEXTSIBLING, NODE_ATTRIBUTES, NODE_OWNERDOCUMENT,
                    151: 
                    152:  NODELIST_LENGTH
1.2     ! vatton    153: 
        !           154:  /* Put here methods that need CreateTemporary */
        !           155:  , GETELEMENTSBYTAGNAME,
1.1       vatton    156: };
                    157: 
                    158: /*----------------------------------------------------------------------
                    159:   Global Object Window
                    160:   -----------------------------------------------------------------------*/
                    161: static JSBool window_alert(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    162: static JSBool window_confirm(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    163: static JSBool window_prompt(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    164: static JSBool window_close(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    165: static JSBool window_blur(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    166: static JSBool window_print(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    167: 
                    168: /*
                    169: static JSBool window_clearInterval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    170: static JSBool window_clearTimeout(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    171: static JSBool window_focus(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    172: static JSBool window_moveBy(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    173: static JSBool window_moveTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    174: static JSBool window_open(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    175: static JSBool window_resizeBy(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    176: static JSBool window_resizeTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    177: static JSBool window_scrollBy(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    178: static JSBool window_scrollTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    179: static JSBool window_setInterval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    180: static JSBool window_setTimeout(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    181: */
                    182: 
                    183: static JSFunctionSpec window_functions[] =
                    184: {
                    185:   /* name of javascript function     name of C function       number of arguments  */
                    186:   {"alert"                        , window_alert          ,        1},
                    187:   {"confirm"                      , window_confirm        ,        1},
                    188:   {"prompt"                       , window_prompt         ,        2},
                    189:   {"close"                        , window_close          ,        0},
                    190:   {"blur"                         , window_blur           ,        0},
                    191:   {"print"                        , window_print          ,        0},
                    192: 
                    193: /*
                    194:   {"clearInterval"                , window_clearInterval  ,        1},
                    195:   {"clearTimeout"                 , window_clearTimeout   ,        1},
                    196:   {"focus"                        , window_focus          ,        0},
                    197:   {"moveBy"                       , window_moveBy         ,        2},
                    198:   {"moveTo"                       , window_moveTo         ,        2},
                    199:   {"open"                         , window_open           ,        4},
                    200:   {"resizeBy"                     , window_resizeBy       ,        2},
                    201:   {"resizeTo"                     , window_resizeTo       ,        2},
                    202:   {"scrollBy"                     , window_scrollBy       ,        2},
                    203:   {"scrollTo"                     , window_scrollTo       ,        2},
                    204:   {"setInterval"                  , window_setInterval    ,        3},
                    205:   {"setTimeout"                   , window_setTimeout     ,        3},
                    206: */
                    207:   {0}
                    208: };
                    209: 
                    210: static JSPropertySpec window_properties[] =
                    211: {
                    212:   {"window"     ,      WINDOW,             JSPROP_READONLY},
                    213:   {"closed"     ,      WINDOW_CLOSED,      JSPROP_READONLY},
                    214:   {"frames"     ,      WINDOW_FRAMES,      JSPROP_INDEX & JSPROP_READONLY},
                    215:   {"length"     ,      WINDOW_LENGTH,      JSPROP_READONLY},
                    216:   {"opener"     ,      WINDOW_OPENER,      JSPROP_READONLY},
                    217:   {"parent"     ,      WINDOW_PARENT,      JSPROP_READONLY},
                    218:   {"self"       ,      WINDOW_SELF  ,      JSPROP_READONLY},
                    219:   {"top"        ,      WINDOW_TOP   ,      JSPROP_READONLY},
                    220:   {0}
                    221: };
                    222: 
                    223: static JSClass window_class =
                    224: {
                    225:   "Window",0,
                    226:   JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
                    227:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    228: };
                    229: 
                    230: /*----------------------------------------------------------------------
                    231:   Object Navigator
                    232:   -----------------------------------------------------------------------*/
                    233: 
                    234: static JSBool navigator_javaEnabled(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    235: static JSBool navigator_taintEnabled(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    236: 
                    237: static JSFunctionSpec navigator_functions[] =
                    238: {
                    239:   /* name of javascript function     name of C function       number of arguments  */
                    240:   {"javaEnabled"                  , navigator_javaEnabled  ,        0},
                    241:   {"taintEnabled"                 , navigator_taintEnabled ,        0},
                    242:   {0}
                    243: };
                    244: 
                    245: static JSPropertySpec navigator_properties[] =
                    246: {
                    247: /*  {"plugins"         ,      NAVIGATOR_PLUGINS          , JSPROP_INDEX & JSPROP_READONLY},*/
                    248:   {"appCodeName"     ,      NAVIGATOR_APPCODENAME      , JSPROP_READONLY},
                    249:   {"appName"         ,      NAVIGATOR_APPNAME          , JSPROP_READONLY},
                    250:   {"appVersion"      ,      NAVIGATOR_APPVERSION       , JSPROP_READONLY},
                    251:   {"browserLanguage" ,      NAVIGATOR_BROWSERLANGUAGE  , JSPROP_READONLY},
                    252:   {"cookieEnabled"   ,      NAVIGATOR_COOKIESENABLED   , JSPROP_READONLY},
                    253:   {"platform"        ,      NAVIGATOR_PLATFORM         , JSPROP_READONLY},
                    254:   {"userAgent"       ,      NAVIGATOR_USERAGENT        , JSPROP_READONLY},
                    255:   {0}
                    256: };
                    257: 
                    258: static JSClass navigator_class =
                    259: {
                    260:   "Navigator",0,
                    261:   JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
                    262:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    263: };
                    264: 
                    265: 
                    266: /*----------------------------------------------------------------------
                    267:   Object Screen
                    268:   -----------------------------------------------------------------------*/
                    269: 
                    270: static JSPropertySpec screen_properties[] =
                    271: {
                    272:   {"availHeight",      SCREEN_AVAILHEIGHT      , JSPROP_READONLY},
                    273:   {"availWidth" ,      SCREEN_AVAILWIDTH       , JSPROP_READONLY},
                    274:   {"colorDepth" ,      SCREEN_COLORDEPTH       , JSPROP_READONLY},
                    275:   {"pixelDepth" ,      SCREEN_PIXELDEPTH       , JSPROP_READONLY},
                    276:   {"height"     ,      SCREEN_HEIGHT           , JSPROP_READONLY},
                    277:   {"width"      ,      SCREEN_WIDTH            , JSPROP_READONLY},
                    278:   {0}
                    279: };
                    280: 
                    281: static JSClass screen_class =
                    282: {
                    283:   "Screen",0,
                    284:   JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
                    285:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    286: };
                    287: 
                    288: /*----------------------------------------------------------------------
                    289:   Object History
                    290:   -----------------------------------------------------------------------*/
                    291: 
                    292: static JSBool history_back(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    293: static JSBool history_forward(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    294: /*static JSBool history_go(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);*/
                    295: 
                    296: static JSFunctionSpec history_functions[] =
                    297: {
                    298:   /* name of javascript function     name of C function       number of arguments  */
                    299:   {"back"                            , history_back          ,        0},
                    300:   {"forward"                         , history_forward       ,        0},
                    301: /*  {"go"                              , history_go            ,        1},*/
                    302:   {0}
                    303: };
                    304: 
                    305: static JSPropertySpec history_properties[] =
                    306: {
                    307:   {"length"      ,      HISTORY_LENGTH            , JSPROP_READONLY},
                    308:   {0}
                    309: };
                    310: 
                    311: static JSClass history_class =
                    312: {
                    313:   "History",0,
                    314:   JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
                    315:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    316: };
                    317: 
                    318: /*----------------------------------------------------------------------
                    319:   Object Location
                    320:   -----------------------------------------------------------------------*/
                    321: 
                    322: static JSBool location_replace(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    323: static JSBool location_assign(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    324: static JSBool location_reload(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    325: 
                    326: static JSFunctionSpec location_functions[] =
                    327: {
                    328:   /* name of javascript function     name of C function       number of arguments  */
                    329:   {"reload"                         , location_reload          ,        0},
                    330:   {"assign"                         , location_assign          ,        1},
                    331:   {"replace"                        , location_replace         ,        1},
                    332:   {0}
                    333: };
                    334: 
                    335: 
                    336: static JSPropertySpec location_properties[] =
                    337: {
                    338:   {"href"            ,      LOCATION_HREF               , 0},
                    339:   {"pathname"        ,      LOCATION_PATHNAME           , JSPROP_READONLY},
                    340:   {"hash"            ,      LOCATION_HASH               , JSPROP_READONLY},
                    341: /*   {"host"            ,      LOCATION_HOST               , 0},
                    342:   {"hostname"        ,      LOCATION_HOSTNAME           , 0},
                    343:   {"port"            ,      LOCATION_PORT               , 0},
                    344:   {"protocol"        ,      LOCATION_PROTOCOL           , 0},
                    345:   {"search"          ,      LOCATION_SEARCH             , 0},*/
                    346:   {0}
                    347: };
                    348: 
                    349: 
                    350: static JSClass location_class =
                    351: {
                    352:   "Location",0,
                    353:   JS_PropertyStub,JS_PropertyStub,getProperty,setProperty,
                    354:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    355: };
                    356: 
                    357: /*----------------------------------------------------------------------
                    358:   Object DOMException
                    359:   -----------------------------------------------------------------------*/
                    360: /*
                    361: static JSClass DOMException_class =
                    362: {
                    363:   "DOMException",0,
                    364:   JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
                    365:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    366: };*/
                    367: 
                    368: /*----------------------------------------------------------------------
                    369:   Object ExceptionCode
                    370:   -----------------------------------------------------------------------*/
                    371: /*
                    372: static JSClass ExceptionCode_class =
                    373: {
                    374:   "ExceptionCode",0,
                    375:   JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
                    376:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    377: };
                    378: */
                    379: 
                    380: /* Definition ExceptionCode */
                    381: #define INDEX_SIZE_ERR                   1
                    382: #define DOMSTRING_SIZE_ERR               2
                    383: #define HIERARCHY_REQUEST_ERR            3
                    384: #define WRONG_DOCUMENT_ERR               4
                    385: #define INVALID_CHARACTER_ERR            5
                    386: #define NO_DATA_ALLOWED_ERR              6
                    387: #define NO_MODIFICATION_ALLOWED_ERR      7
                    388: #define NOT_FOUND_ERR                    8
                    389: #define NOT_SUPPORTED_ERR                9
                    390: #define INUSE_ATTRIBUTE_ERR             10 
                    391: 
                    392: /*----------------------------------------------------------------------
                    393:   Object DOMImplementation
                    394:   -----------------------------------------------------------------------*/
                    395: static JSBool DOMImplementation_hasFeature(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    396: 
                    397: static JSFunctionSpec DOMImplementation_functions[] =
                    398: {
                    399:   /* name of javascript function     name of C function             number of arguments  */
                    400:   {"hasFeature"                   , DOMImplementation_hasFeature   ,        2},
                    401:   {0}
                    402: };
                    403: 
                    404: static JSClass DOMImplementation_class =
                    405: {
                    406:   "DOMImplementation",0,
                    407:   JS_PropertyStub,JS_PropertyStub,JS_PropertyStub,JS_PropertyStub,
                    408:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    409: };
                    410: 
                    411: 
                    412: /*----------------------------------------------------------------------
                    413:   Object DocumentFragment
                    414:   -----------------------------------------------------------------------*/
                    415: static JSClass DocumentFragment_class =
                    416: {
                    417:   "DocumentFragment",0,
                    418:   JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
                    419:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    420: };
                    421: 
                    422: /*----------------------------------------------------------------------
                    423:   Object Document
                    424:   -----------------------------------------------------------------------*/
1.2     ! vatton    425: static JSBool _getElementsByTagName(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
        !           426: 
1.1       vatton    427: /*
                    428: 
                    429: static JSBool Document_createElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    430: static JSBool Document_createDocumentFragment(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    431: static JSBool Document_createCDATASection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    432: static JSBool Document_createProcessingInstruction(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    433: static JSBool Document_createAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    434: static JSBool Document_createEntityReference(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
1.2     ! vatton    435: */
1.1       vatton    436: 
                    437: static JSFunctionSpec Document_functions[] =
                    438: {
1.2     ! vatton    439:   /* name of javascript function     name of C function                   number of arguments  */
        !           440: /*  {"createElement"                , Document_createElement               ,        1},
1.1       vatton    441:   {"createDocumentFragment"       , Document_createDocumentFragment      ,        0},
                    442:   {"createCDATASection"           , Document_createCDATASection          ,        1},
                    443:   {"createProcessingInstruction"  , Document_createProcessingInstruction ,        2},
                    444:   {"createAttribute"              , Document_createAttribute             ,        1},
1.2     ! vatton    445:   {"createEntityReference"        , Document_createEntityReference       ,        1},*/
        !           446:   {"getElementsByTagName"         , _getElementsByTagName        ,        1},
1.1       vatton    447:   {0}
                    448: };
                    449: 
                    450: static JSPropertySpec Document_properties[] =
                    451: {
                    452:   {"doctype"            ,    DOCUMENT_DOCTYPE          , JSPROP_READONLY},
                    453:   {"implementation"     ,    DOCUMENT_IMPLEMENTATION   , JSPROP_READONLY},
                    454:   {"documentElement"    ,    DOCUMENT_DOCUMENTELEMENT  , JSPROP_READONLY},
                    455:   {0}
                    456: };
                    457: 
                    458: static JSClass Document_class =
                    459: {
                    460:   "Document", JSCLASS_HAS_PRIVATE,
                    461:   JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
                    462:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    463: };
                    464: 
                    465: 
                    466: /*----------------------------------------------------------------------
                    467:   Object Node
                    468:   -----------------------------------------------------------------------*/
                    469: /*
                    470: static JSBool Node_createElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    471: static JSBool Node_replaceChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    472: static JSBool Node_removeChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    473: static JSBool Node_appendChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);*/
                    474: static JSBool Node_hasChildNodes(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    475: //static JSBool Node_cloneNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);*/
                    476: 
                    477: static JSFunctionSpec Node_functions[] =
                    478: {
                    479: /*  {"insertBefore"                 , Node_createElement                   ,        2},
                    480:   {"replaceChild"                 , Node_replaceChild                    ,        1},
                    481:   {"removeChild"                  , Node_removeChild                     ,        0},
                    482:   {"appendChild"                  , Node_appendChild                     ,        1},*/
                    483:   {"hasChildNodes"                , Node_hasChildNodes                   ,        0},
                    484: /*  {"cloneNode"                    , Node_cloneNode                       ,        1},*/
                    485:   {0}
                    486: };
                    487: 
                    488: static JSPropertySpec Node_properties[] =
                    489: {
                    490:   {"nodeName"            ,      NODE_NODENAME               , JSPROP_READONLY},
                    491:   {"nodeValue"           ,      NODE_NODEVALUE              , JSPROP_READONLY},
                    492:   {"nodeType"            ,      NODE_NODETYPE               , JSPROP_READONLY},
                    493:   {"parentNode"          ,      NODE_PARENTNODE             , JSPROP_READONLY},
                    494:   {"childNodes"          ,      NODE_CHILDNODES             , JSPROP_READONLY},
                    495:   {"firstChild"          ,      NODE_FIRSTCHILD             , JSPROP_READONLY},
                    496:   {"lastChild"           ,      NODE_LASTCHILD              , JSPROP_READONLY},
                    497:   {"previousSibling"     ,      NODE_PREVIOUSSIBLING        , JSPROP_READONLY},
                    498:   {"nextSibling"         ,      NODE_NEXTSIBLING            , JSPROP_READONLY},
                    499:   {"attributes"          ,      NODE_ATTRIBUTES             , JSPROP_READONLY},
                    500:   {"ownerDocument"       ,      NODE_OWNERDOCUMENT          , JSPROP_READONLY},
                    501:   {0}
                    502: };
                    503: 
                    504: /*static JSClass Node_class =
                    505: {
                    506:   "Node", JSCLASS_HAS_PRIVATE,
                    507:   JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
                    508:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    509: };*/
                    510: 
                    511: /* Definition NodeType */
                    512: #define ELEMENT_NODE                    1
                    513: #define ATTRIBUTE_NODE                  2
                    514: #define TEXT_NODE                       3
                    515: #define CDATA_SECTION_NODE              4
                    516: #define ENTITY_REFERENCE_NODE           5
                    517: #define ENTITY_NODE                     6
                    518: #define PROCESSING_INSTRUCTION_NODE     7
                    519: #define COMMENT_NODE                    8
                    520: #define DOCUMENT_NODE                   9
                    521: #define DOCUMENT_TYPE_NODE             10
                    522: #define DOCUMENT_FRAGMENT_NODE         11
                    523: #define NOTATION_NODE                  12
                    524: 
                    525: /*----------------------------------------------------------------------
                    526:   Object NodeList
                    527:   -----------------------------------------------------------------------*/
                    528: static JSBool NodeList_item(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    529: 
                    530: static JSFunctionSpec NodeList_functions[] =
                    531: {
                    532:   {"item"                 , NodeList_item                   ,        1},
                    533:   {0}
                    534: };
                    535: 
                    536: static JSPropertySpec NodeList_properties[] =
                    537: {
                    538:   {"length"            ,      NODELIST_LENGTH               , JSPROP_READONLY},
                    539:   {0}
                    540: };
                    541: 
                    542: static JSClass NodeList_class =
                    543: {
                    544:   "NodeList", JSCLASS_HAS_PRIVATE,
                    545:   JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
                    546:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    547: };
                    548: 
                    549: /*----------------------------------------------------------------------
                    550:   Object NamedNodeMap
                    551:   -----------------------------------------------------------------------*/
1.2     ! vatton    552: static JSBool NamedNodeMap_getNamedItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
1.1       vatton    553: /*
                    554: static JSBool NamedNodeMap_setNamedItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    555: static JSBool NamedNodeMap_removeNamedItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    556: static JSBool NamedNodeMap_item(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
1.2     ! vatton    557: */
1.1       vatton    558: 
                    559: static JSFunctionSpec NamedNodeMap_functions[] =
                    560: {
                    561:   {"getNamedItem"                 , NamedNodeMap_getNamedItem           ,        1},
1.2     ! vatton    562: /*  {"setNamedItem"                 , NamedNodeMap_setNamedItem           ,        1},
1.1       vatton    563:   {"removeNamedItem"              , NamedNodeMap_removeNamedItem        ,        1},
1.2     ! vatton    564:   {"item"                         , NamedNodeMap_item                   ,        1},*/
1.1       vatton    565:   {0}
                    566: };
                    567: 
                    568: static JSPropertySpec NamedNodeMap_properties[] =
                    569: {
1.2     ! vatton    570: /*  {"length"            ,      NAMEDNODEMAP_LENGTH               , JSPROP_READONLY},*/
1.1       vatton    571:   {0}
                    572: };
                    573: 
                    574: static JSClass NamedNodeMap_class =
                    575: {
                    576:   "NamedNodeMap", JSCLASS_HAS_PRIVATE,
                    577:   JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
                    578:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    579: };
                    580: 
                    581: /*----------------------------------------------------------------------
                    582:   Object CharacterData
                    583:   -----------------------------------------------------------------------*/
                    584: /*
                    585: static JSBool CharacterData_substringData(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    586: static JSBool CharacterData_appendData(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    587: static JSBool CharacterData_insertData(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    588: static JSBool CharacterData_deleteData(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    589: static JSBool CharacterData_replaceData(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    590: 
                    591: static JSFunctionSpec CharacterData_functions[] =
                    592: {
                    593:   {"substringData"              , CharacterData_createElement                   ,        2},
                    594:   {"appendData"                 , CharacterData_createElement                   ,        1},
                    595:   {"insertData"                 , CharacterData_createElement                   ,        2},
                    596:   {"deleteData"                 , CharacterData_createElement                   ,        2},
                    597:   {"replaceData"                , CharacterData_createElement                   ,        3},
                    598:   {0}
                    599: };
                    600: 
                    601: static JSPropertySpec CharacterData_properties[] =
                    602: {
                    603:   {"data"                ,      CHARACTERDATA_DATA               , JSPROP_READONLY},
                    604:   {"length"              ,      CHARACTERDATA_LENGTH             , JSPROP_READONLY},
                    605:   {0}
                    606: };
                    607: 
                    608: static JSClass CharacterData_class =
                    609: {
                    610:   "CharacterData", JSCLASS_HAS_PRIVATE,
                    611:   JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
                    612:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    613: };
                    614: */
                    615: 
                    616: /*----------------------------------------------------------------------
                    617:   Object Attr
                    618:   -----------------------------------------------------------------------*/
                    619: static JSPropertySpec Attr_properties[] =
                    620: {
                    621:   {"name"            ,      ATTR_NAME                   , JSPROP_READONLY},
                    622:   {"specified"       ,      ATTR_SPECIFIED              , JSPROP_READONLY},
                    623:   {"value"           ,      ATTR_VALUE                  , JSPROP_READONLY},
                    624:   {0}
                    625: };
                    626: 
                    627: static JSClass Attr_class =
                    628: {
                    629:   "Attr", JSCLASS_HAS_PRIVATE,
                    630:   JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
                    631:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    632: };
                    633: 
                    634: 
                    635: /*----------------------------------------------------------------------
                    636:   Object Element
                    637:   -----------------------------------------------------------------------*/
                    638: /*
                    639: static JSBool Element_getAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    640: static JSBool Element_setAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    641: static JSBool Element_removeAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    642: static JSBool Element_getAttributeNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    643: static JSBool Element_setAttributeNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
1.2     ! vatton    644: static JSBool Element_removeAttributeNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);*/
        !           645: /*static JSBool Element_normalize(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);*/
1.1       vatton    646: 
                    647: static JSFunctionSpec Element_functions[] =
                    648: {
1.2     ! vatton    649: /*  {"getAttribute"                 , Element_getAttribute                ,        1},
1.1       vatton    650:   {"setAttribute"                 , Element_setAttribute                ,        1},
                    651:   {"removeAttribute"              , Element_removeAttribute             ,        1},
                    652:   {"getAttributeNode"             , Element_getAttributeNode            ,        1},
                    653:   {"setAttributeNode"             , Element_setAttributeNode            ,        1},
1.2     ! vatton    654:   {"removeAttributeNode"          , Element_removeAttributeNode         ,        1},*/
        !           655:   {"getElementsByTagName"         , _getElementsByTagName        ,        1},
        !           656: /*  {"normalize"                    , Element_normalize                   ,        0},*/
1.1       vatton    657:   {0}
                    658: };
                    659: 
                    660: static JSPropertySpec Element_properties[] =
                    661: {
                    662:   {"tagName"            ,      ELEMENT_TAGNAME               , JSPROP_READONLY},
                    663:   {0}
                    664: };
                    665: 
                    666: static JSClass Element_class =
                    667: {
                    668:   "Element", JSCLASS_HAS_PRIVATE,
                    669:   JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
                    670:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    671: };
                    672: 
                    673: /*----------------------------------------------------------------------
                    674:   Object Text
                    675:   -----------------------------------------------------------------------*/
                    676: /*
                    677: static JSBool Element_splitText(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
                    678: 
                    679: static JSFunctionSpec Text_functions[] =
                    680: {
                    681:   {"splitText"                 , Text_splitText                   ,        1},
                    682:   {0}
                    683: };*/
                    684: 
                    685: static JSClass Text_class =
                    686: {
                    687:   "Text", JSCLASS_HAS_PRIVATE,
                    688:   JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
                    689:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    690: };
                    691: 
                    692: /*----------------------------------------------------------------------
                    693:   Object Comment
                    694:   -----------------------------------------------------------------------*/
                    695: static JSClass Comment_class =
                    696: {
                    697:   "Comment", JSCLASS_HAS_PRIVATE,
                    698:   JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
                    699:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    700: };
                    701: 
                    702: /*----------------------------------------------------------------------
                    703:   Object CDATASection
                    704:   -----------------------------------------------------------------------*/
                    705: static JSClass CDATASection_class =
                    706: {
                    707:   "CDATASection", JSCLASS_HAS_PRIVATE,
                    708:   JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
                    709:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    710: };
                    711: 
                    712: /*----------------------------------------------------------------------
                    713:   Object DocumentType
                    714:   -----------------------------------------------------------------------*/
                    715: 
                    716: static JSPropertySpec DocumentType_properties[] =
                    717: {
                    718:   {"name"                ,      DOCUMENTTYPE_NAME           , JSPROP_READONLY},
                    719:   {"entities"            ,      DOCUMENTTYPE_ENTITIES       , JSPROP_READONLY},
                    720:   {"notations"           ,      DOCUMENTTYPE_NOTATIONS      , JSPROP_READONLY},
                    721:   {0}
                    722: };
                    723: 
                    724: static JSClass DocumentType_class =
                    725: {
                    726:   "DocumentType", JSCLASS_HAS_PRIVATE,
                    727:   JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
                    728:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    729: };
                    730: 
                    731: /*----------------------------------------------------------------------
                    732:   Object Notation
                    733:   -----------------------------------------------------------------------*/
                    734: /*
                    735: static JSPropertySpec Notation_properties[] =
                    736: {
                    737:   {"publicId"            ,      NOTATION_PUBLICID            , JSPROP_READONLY},
                    738:   {"systemId"            ,      NOTATION_SYSTEMID            , JSPROP_READONLY},
                    739:   {0}
                    740: };
                    741: */
                    742: static JSClass Notation_class =
                    743: {
                    744:   "Notation", JSCLASS_HAS_PRIVATE,
                    745:   JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
                    746:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    747: };
                    748: 
                    749: /*----------------------------------------------------------------------
                    750:   Object Entity
                    751:   -----------------------------------------------------------------------*/
                    752: /*
                    753: static JSPropertySpec Entity_properties[] =
                    754: {
                    755:   {"publicId"            ,      ENTITY_PUBLICID               , JSPROP_READONLY},
                    756:   {"systemId"            ,      ENTITY_SYSTEMID               , JSPROP_READONLY},
                    757:   {"notationName"        ,      ENTITY_NOTATIONNAME           , JSPROP_READONLY},
                    758:   {0}
                    759: };
                    760: */
                    761: static JSClass Entity_class =
                    762: {
                    763:   "Entity_properties", JSCLASS_HAS_PRIVATE,
                    764:   JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
                    765:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    766: };
                    767: 
                    768: /*----------------------------------------------------------------------
                    769:   Object EntityReference
                    770:   -----------------------------------------------------------------------*/
                    771: static JSClass EntityReference_class =
                    772: {
                    773:   "EntityReference", JSCLASS_HAS_PRIVATE,
                    774:   JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
                    775:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    776: };
                    777: 
                    778: /*----------------------------------------------------------------------
                    779:   Object ProcessingInstruction
                    780:   -----------------------------------------------------------------------*/
                    781: /*
                    782: static JSPropertySpec ProcessingInstruction_properties[] =
                    783: {
                    784:   {"target"            , PROCESSINGINSTRUCTION_TARGET     , JSPROP_READONLY},
                    785:   {"data"              , PROCESSINGINSTRUCTION_DATA       , JSPROP_READONLY},
                    786:   {0}
                    787: };
                    788: */
                    789: static JSClass ProcessingInstruction_class =
                    790: {
                    791:   "ProcessingInstruction", JSCLASS_HAS_PRIVATE,
                    792:   JS_PropertyStub,JS_PropertyStub,getProperty,JS_PropertyStub,
                    793:   JS_EnumerateStub,JS_ResolveStub,JS_ConvertStub,JS_FinalizeStub
                    794: };
                    795: 
                    796: #endif /* __AMAYA_JAVASCRIPT_H__ */

Webmaster