jat@google.com | 134be54 | 2009-08-03 15:30:11 +0000 | [diff] [blame] | 1 | #ifndef _H_JavaObject |
| 2 | #define _H_JavaObject |
| 3 | /* |
| 4 | * Copyright 2008 Google Inc. |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 7 | * use this file except in compliance with the License. You may obtain a copy of |
| 8 | * the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 15 | * License for the specific language governing permissions and limitations under |
| 16 | * the License. |
| 17 | */ |
| 18 | |
| 19 | #include "mozincludes.h" |
| 20 | #include "jsapi.h" |
| 21 | |
| 22 | class SessionData; |
| 23 | class Value; |
| 24 | |
| 25 | class JavaObject { |
| 26 | public: |
| 27 | static bool isJavaObject(JSContext* ctx, JSObject* obj); |
| 28 | static JSObject* construct(JSContext* ctx, SessionData* data, int objectRef); |
| 29 | static int getObjectId(JSContext* ctx, JSObject* obj); |
| 30 | static JSBool getProperty(JSContext* ctx, JSObject* obj, jsval id, jsval* vp); |
| 31 | static JSBool setProperty(JSContext* ctx, JSObject* obj, jsval id, jsval* vp); |
| 32 | static JSBool resolve(JSContext* ctx, JSObject* obj, jsval id); |
| 33 | static JSBool convert(JSContext* cx, JSObject* obj, JSType type, jsval* vp); |
| 34 | static JSBool enumerate(JSContext* ctx, JSObject* obj, JSIterateOp op, jsval* statep, jsid* idp); |
| 35 | static void finalize(JSContext* ctx, JSObject* obj); |
| 36 | static JSBool toString(JSContext* ctx, JSObject* obj, uintN argc, jsval* argv, jsval* rval); |
| 37 | static JSBool call(JSContext* ctx, JSObject* obj, uintN argc, jsval* argv, jsval* rval); |
| 38 | private: |
| 39 | static SessionData* getSessionData(JSContext* ctx, JSObject* obj); |
| 40 | static JSBool invokeJava(JSContext* ctx, SessionData* data, |
| 41 | const Value& javaThis, int dispId, int numArgs, const jsval* jsargs, |
| 42 | jsval* rval); |
| 43 | }; |
| 44 | |
| 45 | #endif |