1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * The Original Code is Mozilla Communicator client code, released
17 * March 31, 1998.
18 *
19 * The Initial Developer of the Original Code is
20 * Netscape Communications Corporation.
21 * Portions created by the Initial Developer are Copyright (C) 1998
22 * the Initial Developer. All Rights Reserved.
23 *
24 * Contributor(s):
25 * John Bandhauer <jband@netscape.com> (original author)
26 *
27 * Alternatively, the contents of this file may be used under the terms of
28 * either of the GNU General Public License Version 2 or later (the "GPL"),
29 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
38 *
39 * ***** END LICENSE BLOCK ***** */
40
41 #include "nsISupports.idl"
42 #include "nsIXPConnect.idl"
43
44 [ptr] native JSTracerPtr(JSTracer);
45
46 %{ C++
47 #define NS_SUCCESS_I_DID_SOMETHING \
48 (NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_XPCONNECT,1))
49 %}
50
51 /**
52 * Note: This is not really an XPCOM interface. For example, callers must
53 * guarantee that they set the *_retval of the various methods that return a
54 * boolean to PR_TRUE before making the call. Implementations may skip writing
55 * to *_retval unless they want to return PR_FALSE.
56 */
57
58 [uuid(1455f6fe-6de9-4b62-a2b3-d1aee82dd829)]
59 interface nsIXPCScriptable : nsISupports
60 {
61 /* bitflags used for 'flags' (only 32 bits available!) */
62
63 const PRUint32 WANT_PRECREATE = 1 << 0;
64 const PRUint32 WANT_CREATE = 1 << 1;
65 const PRUint32 WANT_POSTCREATE = 1 << 2;
66 const PRUint32 WANT_ADDPROPERTY = 1 << 3;
67 const PRUint32 WANT_DELPROPERTY = 1 << 4;
68 const PRUint32 WANT_GETPROPERTY = 1 << 5;
69 const PRUint32 WANT_SETPROPERTY = 1 << 6;
70 const PRUint32 WANT_ENUMERATE = 1 << 7;
71 const PRUint32 WANT_NEWENUMERATE = 1 << 8;
72 const PRUint32 WANT_NEWRESOLVE = 1 << 9;
73 const PRUint32 WANT_CONVERT = 1 << 10;
74 const PRUint32 WANT_FINALIZE = 1 << 11;
75 const PRUint32 WANT_CHECKACCESS = 1 << 12;
76 const PRUint32 WANT_CALL = 1 << 13;
77 const PRUint32 WANT_CONSTRUCT = 1 << 14;
78 const PRUint32 WANT_HASINSTANCE = 1 << 15;
79 const PRUint32 WANT_TRACE = 1 << 16;
80 const PRUint32 USE_JSSTUB_FOR_ADDPROPERTY = 1 << 17;
81 const PRUint32 USE_JSSTUB_FOR_DELPROPERTY = 1 << 18;
82 const PRUint32 USE_JSSTUB_FOR_SETPROPERTY = 1 << 19;
83 const PRUint32 DONT_ENUM_STATIC_PROPS = 1 << 20;
84 const PRUint32 DONT_ENUM_QUERY_INTERFACE = 1 << 21;
85 const PRUint32 DONT_ASK_INSTANCE_FOR_SCRIPTABLE = 1 << 22;
86 const PRUint32 CLASSINFO_INTERFACES_ONLY = 1 << 23;
87 const PRUint32 ALLOW_PROP_MODS_DURING_RESOLVE = 1 << 24;
88 const PRUint32 ALLOW_PROP_MODS_TO_PROTOTYPE = 1 << 25;
89 const PRUint32 DONT_SHARE_PROTOTYPE = 1 << 26;
90 const PRUint32 DONT_REFLECT_INTERFACE_NAMES = 1 << 27;
91 const PRUint32 WANT_EQUALITY = 1 << 28;
92 const PRUint32 WANT_OUTER_OBJECT = 1 << 29;
93 const PRUint32 WANT_INNER_OBJECT = 1 << 30;
94
95 // The high order bit is RESERVED for consumers of these flags.
96 // No implementor of this interface should ever return flags
97 // with this bit set.
98 const PRUint32 RESERVED = 1 << 31;
99
100 readonly attribute string className;
101 readonly attribute PRUint32 scriptableFlags;
102
103 void preCreate(in nsISupports nativeObj, in JSContextPtr cx,
104 in JSObjectPtr globalObj, out JSObjectPtr parentObj);
105
106 void create(in nsIXPConnectWrappedNative wrapper,
107 in JSContextPtr cx, in JSObjectPtr obj);
108
109 void postCreate(in nsIXPConnectWrappedNative wrapper,
110 in JSContextPtr cx, in JSObjectPtr obj);
111
112 PRBool addProperty(in nsIXPConnectWrappedNative wrapper,
113 in JSContextPtr cx, in JSObjectPtr obj, in JSVal id,
114 in JSValPtr vp);
115
116 PRBool delProperty(in nsIXPConnectWrappedNative wrapper,
117 in JSContextPtr cx, in JSObjectPtr obj, in JSVal id,
118 in JSValPtr vp);
119
120 // The returnCode should be set to NS_SUCCESS_I_DID_SOMETHING if
121 // this method does something.
122 PRBool getProperty(in nsIXPConnectWrappedNative wrapper,
123 in JSContextPtr cx, in JSObjectPtr obj, in JSVal id,
124 in JSValPtr vp);
125
126 // The returnCode should be set to NS_SUCCESS_I_DID_SOMETHING if
127 // this method does something.
128 PRBool setProperty(in nsIXPConnectWrappedNative wrapper,
129 in JSContextPtr cx, in JSObjectPtr obj, in JSVal id,
130 in JSValPtr vp);
131
132 PRBool enumerate(in nsIXPConnectWrappedNative wrapper,
133 in JSContextPtr cx, in JSObjectPtr obj);
134
135 PRBool newEnumerate(in nsIXPConnectWrappedNative wrapper,
136 in JSContextPtr cx, in JSObjectPtr obj,
137 in PRUint32 enum_op, in JSValPtr statep, out JSID idp);
138
139 PRBool newResolve(in nsIXPConnectWrappedNative wrapper,
140 in JSContextPtr cx, in JSObjectPtr obj, in JSVal id,
141 in PRUint32 flags, out JSObjectPtr objp);
142
143 PRBool convert(in nsIXPConnectWrappedNative wrapper,
144 in JSContextPtr cx, in JSObjectPtr obj,
145 in PRUint32 type, in JSValPtr vp);
146
147 void finalize(in nsIXPConnectWrappedNative wrapper,
148 in JSContextPtr cx, in JSObjectPtr obj);
149
150 PRBool checkAccess(in nsIXPConnectWrappedNative wrapper,
151 in JSContextPtr cx, in JSObjectPtr obj, in JSVal id,
152 in PRUint32 mode, in JSValPtr vp);
153
154 PRBool call(in nsIXPConnectWrappedNative wrapper,
155 in JSContextPtr cx, in JSObjectPtr obj,
156 in PRUint32 argc, in JSValPtr argv, in JSValPtr vp);
157
158 PRBool construct(in nsIXPConnectWrappedNative wrapper,
159 in JSContextPtr cx, in JSObjectPtr obj,
160 in PRUint32 argc, in JSValPtr argv, in JSValPtr vp);
161
162 PRBool hasInstance(in nsIXPConnectWrappedNative wrapper,
163 in JSContextPtr cx, in JSObjectPtr obj,
164 in JSVal val, out PRBool bp);
165
166 void trace(in nsIXPConnectWrappedNative wrapper,
167 in JSTracerPtr trc, in JSObjectPtr obj);
168
169 PRBool equality(in nsIXPConnectWrappedNative wrapper,
170 in JSContextPtr cx, in JSObjectPtr obj, in JSVal val);
171
172 JSObjectPtr outerObject(in nsIXPConnectWrappedNative wrapper,
173 in JSContextPtr cx, in JSObjectPtr obj);
174
175 JSObjectPtr innerObject(in nsIXPConnectWrappedNative wrapper,
176 in JSContextPtr cx, in JSObjectPtr obj);
177 };