OLD | NEW |
| (Empty) |
1 // Copyright 2010 The Ginsu Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can | |
3 // be found in the LICENSE file. | |
4 | |
5 #ifndef C_SALT_SCRIPTABLE_NATIVE_OBJECT_H_ | |
6 #define C_SALT_SCRIPTABLE_NATIVE_OBJECT_H_ | |
7 | |
8 #include "c_salt/scripting_bridge_ptrs.h" | |
9 | |
10 namespace c_salt { | |
11 | |
12 // The base class for C++ classes which are Scriptable, where Scriptable means | |
13 // they can be accessed from JavaScript. Scriptable C++ classes expose their | |
14 // methods and properties to JavaScript via ScriptingBridge. | |
15 class ScriptableNativeObject { | |
16 public: | |
17 ScriptableNativeObject() {} | |
18 virtual ~ScriptableNativeObject() {} | |
19 | |
20 // Initialize the ScriptableNativeObject. This invokes appropriate virtual | |
21 // functions on the child class to give it an opportunity to register methods | |
22 // and properties with the ScriptingBridge. | |
23 void Initialize(SharedScriptingBridge bridge); | |
24 | |
25 // Return the ScriptingBridge which is associated with this object. | |
26 WeakScriptingBridge GetScriptingBridge(); | |
27 | |
28 | |
29 private: | |
30 // Called during initialization to publish the module's method names that | |
31 // can be called from JavaScript. | |
32 virtual void InitializeMethods(ScriptingBridge* bridge) = 0; | |
33 | |
34 // Called during initialization to publish the module's properties that can | |
35 // be called from JavaScript. | |
36 virtual void InitializeProperties(ScriptingBridge* bridge) = 0; | |
37 | |
38 private: | |
39 // Copy and assign are unsupported and therefore not implemented. | |
40 ScriptableNativeObject(const ScriptableNativeObject&); | |
41 ScriptableNativeObject& operator=(const ScriptableNativeObject&); | |
42 WeakScriptingBridge scripting_bridge_; | |
43 }; | |
44 | |
45 } // namespace c_salt | |
46 | |
47 #endif // C_SALT_SCRIPTABLE_NATIVE_OBJECT_H_ | |
OLD | NEW |