2 Copyright (C) 2000-2003 SKYRIX Software AG
4 This file is part of OGo
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
24 #define LOG_OBJECT_OPS 1
26 extern JS_IMPORT_DATA(JSObjectOps) js_ObjectOps;
34 jop_newMap(JSContext *cx, jsrefcount nrefs,
35 JSObjectOps *ops, JSClass *clasp,
39 The object map stores property information for the object, and is
40 created when the object is created.
46 NSLog(@"new map: cx=0x%p, nrefs=%i, ops=0x%p, class=0x%p, obj=0x%p",
47 cx, nrefs, ops, clasp, obj);
50 map = js_ObjectOps.newObjectMap(cx, nrefs, ops, clasp, obj);
51 emap = calloc(1, sizeof(jso_ObjectMap));
52 memcpy(emap, map, sizeof(JSObjectMap));
54 return (JSObjectMap *)emap;
57 static void jop_delMap(JSContext *cx, JSObjectMap *map) {
58 /* the function that destroys the object map when it is no longer needed. */
59 js_ObjectOps.destroyObjectMap(cx, map);
62 static JSBool jop_lookup(JSContext *cx, JSObject *obj, jsid jid,
63 JSObject **objp, JSProperty **propp
64 #if defined JS_THREADSAFE && defined DEBUG
65 , const char *file, uintN line
69 /* custom property lookup method for the object. */
72 static JSBool jop_define(JSContext *cx, JSObject *obj, jsid jid, jsval value,
73 JSPropertyOp getter, JSPropertyOp setter,
74 uintN attrs, JSProperty **propp)
76 /* custom property creation method for the object. */
79 static JSBool jop_get(JSContext *cx, JSObject *obj, jsid jid, jsval *vp) {
81 static JSBool jop_set(JSContext *cx, JSObject *obj, jsid jid, jsval *vp) {
83 static JSBool jop_del(JSContext *cx, JSObject *obj, jsid jid, jsval *vp) {
86 static JSBool jop_attrsget(JSContext *cx, JSObject *obj, jsid jid,
87 JSProperty *prop, uintN *attrsp)
90 static JSBool jop_attrsset(JSContext *cx, JSObject *obj, jsid jid,
91 JSProperty *prop, uintN *attrsp)
96 jop_defValue(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
100 static JSBool jop_enum(JSContext *cx, JSObject *obj,
102 jsval *statep, jsid *idp)
106 static JSBool jop_chkaccess(JSContext *cx, JSObject *obj, jsid jid,
107 JSAccessMode mode, jsval *vp, uintN *attrsp)
111 struct JSObjectOps NGJavaScriptObjectHandler_JSObjectOps = {
112 /* Mandatory non-null function pointer members. */
113 jop_newMap, /* JSNewObjectMapOp newObjectMap; */
114 jop_delMap, /* JSObjectMapOp destroyObjectMap; */
115 jop_lookup, /* JSLookupPropOp lookupProperty; */
116 jop_define, /* JSDefinePropOp defineProperty; */
117 jop_get, /* JSPropertyIdOp getProperty; */
118 jop_set, /* JSPropertyIdOp setProperty; */
119 jop_attrsget, /* JSAttributesOp getAttributes; */
120 jop_attrsset, /* JSAttributesOp setAttributes; */
121 jop_del, /* JSPropertyIdOp deleteProperty; */
122 jop_defValue, /* JSConvertOp defaultValue; */
123 jop_enum, /* JSNewEnumerateOp enumerate; */
124 jop_chkaccess, /* JSCheckAccessIdOp checkAccess; */
126 /* Optionally non-null members start here. */
127 NULL, /* JSObjectOp thisObject; */
128 NULL, /* JSPropertyRefOp dropProperty; */
129 NULL, /* JSNative call; */
130 NULL, /* JSNative construct; */
131 NULL, /* JSXDRObjectOp xdrObject; */
132 NULL, /* JSHasInstanceOp hasInstance; */
133 NULL, /* JSSetObjectSlotOp setProto; */
134 NULL, /* JSSetObjectSlotOp setParent; */
135 0, /* jsword spare1; */
136 0, /* jsword spare2; */
137 0, /* jsword spare3; */
138 0, /* jsword spare4; */
143 static JSObjectOps *_getObjOps(JSContext *cx, JSClass *clazz) {
144 return &NGJavaScriptObjectHandler_JSObjectOps;
147 static JSBool _convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp) {
151 static void _finalize(JSContext *cx, JSObject *obj) {
154 struct JSClass NGJavaScriptObjectHandler_JSObjectOpsClass = {
157 NULL, NULL, NULL, NULL,
161 /* Optionally non-null members start here. */
162 _getObjOps, //JSGetObjectOps getObjectOps;
163 NULL, //JSCheckAccessOp checkAccess;
164 NULL, //JSNative call;
165 NULL, //JSNative construct;
166 NULL, //JSXDRObjectOp xdrObject;
167 NULL //JSHasInstanceOp hasInstance;