OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 // | |
5 // This implements the scripting interface of the plugin module instance. | |
6 // The interface is used to drive tests and analyze results from JavaScript. | |
7 // | |
8 | |
9 #include <stdio.h> | |
10 #include <string.h> | |
11 #include <unistd.h> | |
12 | |
13 #include "native_client/src/shared/platform/nacl_check.h" | |
14 #include "native_client/tests/ppapi_test_lib/get_browser_interface.h" | |
15 #include "native_client/tests/ppapi_test_lib/internal_utils.h" | |
16 #include "native_client/tests/ppapi_test_lib/test_interface.h" | |
17 | |
18 #include "ppapi/c/dev/ppb_var_deprecated.h" | |
19 #include "ppapi/c/dev/ppp_class_deprecated.h" | |
20 #include "ppapi/c/ppb.h" | |
21 #include "ppapi/c/ppb_core.h" | |
22 #include "ppapi/c/ppb_instance.h" | |
23 #include "ppapi/c/ppb_url_request_info.h" | |
24 #include "ppapi/c/pp_completion_callback.h" | |
25 #include "ppapi/c/pp_instance.h" | |
26 #include "ppapi/c/pp_module.h" | |
27 #include "ppapi/c/pp_var.h" | |
28 | |
29 /////////////////////////////////////////////////////////////////////////////// | |
30 // PPP_Class_Deprecated implementation | |
31 /////////////////////////////////////////////////////////////////////////////// | |
32 | |
33 namespace { | |
34 | |
35 bool HasProperty(void* /*object*/, | |
36 PP_Var /*name*/, | |
37 PP_Var* /*exception*/) { | |
38 return false; | |
39 } | |
40 | |
41 bool HasMethod(void* object, PP_Var name, PP_Var* /*exception*/) { | |
42 // Intercept only the methods that Call() will handle. | |
43 uint32_t len = 0; | |
44 const char* method_name = PPBVarDeprecated()->VarToUtf8(name, &len); | |
45 return HasScriptableTest(method_name); | |
46 } | |
47 | |
48 PP_Var GetProperty(void* /*object*/, | |
49 PP_Var /*name*/, | |
50 PP_Var* /*exception*/) { | |
51 return PP_MakeUndefined(); | |
52 } | |
53 | |
54 void GetAllPropertyNames(void* /*object*/, | |
55 uint32_t* property_count, | |
56 PP_Var** /*properties*/, | |
57 PP_Var* /*exception*/) { | |
58 *property_count = 0; | |
59 } | |
60 | |
61 void SetProperty(void* /*object*/, | |
62 PP_Var /*name*/, | |
63 PP_Var /*value*/, | |
64 PP_Var* /*exception*/) { | |
65 } | |
66 | |
67 void RemoveProperty(void* /*object*/, | |
68 PP_Var /*name*/, | |
69 PP_Var* /*exception*/) { | |
70 } | |
71 | |
72 PP_Var Call(void* object, | |
73 PP_Var method_name, | |
74 uint32_t argc, | |
75 PP_Var* argv, | |
76 PP_Var* exception) { | |
77 uint32_t len; | |
78 const char* name = PPBVarDeprecated()->VarToUtf8(method_name, &len); | |
79 return RunScriptableTest(name); | |
80 } | |
81 | |
82 PP_Var Construct(void* /*object*/, | |
83 uint32_t /*argc*/, | |
84 PP_Var* /*argv*/, | |
85 PP_Var* /*exception*/) { | |
86 return PP_MakeUndefined(); | |
87 } | |
88 | |
89 void Deallocate(void* object) { | |
90 } | |
91 | |
92 const PPP_Class_Deprecated ppp_class_interface = { | |
93 HasProperty, | |
94 HasMethod, | |
95 GetProperty, | |
96 GetAllPropertyNames, | |
97 SetProperty, | |
98 RemoveProperty, | |
99 Call, | |
100 Construct, | |
101 Deallocate | |
102 }; | |
103 | |
104 } // namespace | |
105 | |
106 /////////////////////////////////////////////////////////////////////////////// | |
107 // PPB_Var_Deprecated object creation | |
108 /////////////////////////////////////////////////////////////////////////////// | |
109 | |
110 PP_Var GetScriptableObject(PP_Instance instance) { | |
111 return PPBVarDeprecated()->CreateObject(instance, &ppp_class_interface, NULL); | |
112 } | |
OLD | NEW |