Don't create thread at start
[nativeclient.git] / tests / npapi_pi / base_object.cc
blob6b99786e42962d4743aa6cc3fcb79556eeea0672
1 /*
2 * Copyright 2008, Google Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include "native_client/tests/npapi_pi/plugin.h"
35 namespace {
37 void Deallocate(NPObject* object) {
38 delete static_cast<BaseObject*>(object);
41 void Invalidate(NPObject* object) {
42 return static_cast<BaseObject*>(object)->Invalidate();
45 bool HasMethod(NPObject* object, NPIdentifier name) {
46 return static_cast<BaseObject*>(object)->HasMethod(name);
49 bool Invoke(NPObject* object, NPIdentifier name,
50 const NPVariant* args, uint32_t arg_count,
51 NPVariant* result) {
52 return static_cast<BaseObject*>(object)->Invoke(
53 name, args, arg_count, result);
56 bool InvokeDefault(NPObject* object, const NPVariant* args, uint32_t arg_count,
57 NPVariant* result) {
58 return static_cast<BaseObject*>(object)->InvokeDefault(
59 args, arg_count, result);
62 bool HasProperty(NPObject* object, NPIdentifier name) {
63 return static_cast<BaseObject*>(object)->HasProperty(name);
66 bool GetProperty(NPObject* object, NPIdentifier name, NPVariant* result) {
67 return static_cast<BaseObject*>(object)->GetProperty(name, result);
70 bool SetProperty(NPObject* object, NPIdentifier name, const NPVariant* value) {
71 return static_cast<BaseObject*>(object)->SetProperty(name, value);
74 bool RemoveProperty(NPObject* object, NPIdentifier name) {
75 return static_cast<BaseObject*>(object)->RemoveProperty(name);
78 NPObject* AllocateScriptablePluginObject(NPP npp, NPClass* npclass) {
79 return new ScriptablePluginObject(npp);
82 } // namespace
84 NPClass ScriptablePluginObject::np_class = {
85 NP_CLASS_STRUCT_VERSION,
86 ::AllocateScriptablePluginObject,
87 ::Deallocate,
88 ::Invalidate,
89 ::HasMethod,
90 ::Invoke,
91 ::InvokeDefault,
92 ::HasProperty,
93 ::GetProperty,
94 ::SetProperty,
95 ::RemoveProperty