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_SCRIPTING_INTERFACE_H_ | |
6 #define C_SALT_SCRIPTING_INTERFACE_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "c_salt/variant_ptrs.h" | |
12 | |
13 namespace c_salt { | |
14 | |
15 // ScriptingInterface represents an interface to any object shared between | |
16 // JavaScript and native code. | |
17 class ScriptingInterface { | |
18 public: | |
19 virtual ~ScriptingInterface() {} | |
20 | |
21 virtual bool HasScriptMethod(const std::string& name) = 0; | |
22 virtual bool InvokeScriptMethod(const std::string& method_name, | |
23 const SharedVariant* params_begin, | |
24 const SharedVariant* params_end, | |
25 SharedVariant* return_value_var) = 0; | |
26 // Support for browser-exposed properties. The browser proxy (which is | |
27 // platform-specific) first calls HasProperty() before getting or setting; | |
28 // the Get or Set is performed only if HasProperty() returns |true|. The | |
29 // brwoser proxy is responsible for all the variant marshaling. | |
30 virtual bool HasScriptProperty(const std::string& name) = 0; | |
31 // Set |return_value| to the value associated with property |name|. If | |
32 // property |name| doesn't exist, then set |return_value| to the null type | |
33 // and return |false|. | |
34 virtual bool GetScriptProperty(const std::string& name, | |
35 SharedVariant* return_value) const = 0; | |
36 // If |name| is associated with a static property, return that value. Else, | |
37 // if there is no property associated with |name|, add it as a dynamic | |
38 // property. See property.h for definitions and more details. | |
39 virtual bool SetScriptProperty(const std::string& name, | |
40 const SharedVariant& value) = 0; | |
41 // This succeeds only if |name| is associated with a dynamic property. | |
42 virtual bool RemoveScriptProperty(const std::string& name) = 0; | |
43 | |
44 // Return the names of all enumerable properties in to the provided vector. | |
45 virtual void GetAllPropertyNames( | |
46 std::vector<std::string>* prop_names) const = 0; | |
47 | |
48 // Return true iff this object is implemented by a native object (as opposed | |
49 // to a JavaScript object in the browser). | |
50 virtual bool IsNative() const = 0; | |
51 | |
52 // This is called by some browser proxies when all references to a proxy | |
53 // object have been deallocated, but the proxy's ref count has not gone to 0. | |
54 // It's kind of an anti-leak clean-up mechanism. | |
55 virtual void Invalidate() = 0; | |
56 }; | |
57 | |
58 } // namespace c_salt | |
59 | |
60 #endif // C_SALT_SCRIPTING_INTERFACE_H_ | |
OLD | NEW |