Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: webkit/tools/npapi_layout_test_plugin/TestObject.cpp

Issue 113823: Added support for constructor calls in the NPAPI (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/tools/layout_tests/test_expectations.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 16 matching lines...) Expand all
27 #include "PluginObject.h" 27 #include "PluginObject.h"
28 28
29 #include <stdlib.h> 29 #include <stdlib.h>
30 30
31 static bool testEnumerate(NPObject *npobj, NPIdentifier **value, uint32_t *count ); 31 static bool testEnumerate(NPObject *npobj, NPIdentifier **value, uint32_t *count );
32 static bool testInvokeDefault(NPObject *obj, const NPVariant *args, uint32_t arg Count, NPVariant *result); 32 static bool testInvokeDefault(NPObject *obj, const NPVariant *args, uint32_t arg Count, NPVariant *result);
33 static bool testHasProperty(NPObject *obj, NPIdentifier name); 33 static bool testHasProperty(NPObject *obj, NPIdentifier name);
34 static bool testGetProperty(NPObject *obj, NPIdentifier name, NPVariant *variant ); 34 static bool testGetProperty(NPObject *obj, NPIdentifier name, NPVariant *variant );
35 static NPObject *testAllocate(NPP npp, NPClass *theClass); 35 static NPObject *testAllocate(NPP npp, NPClass *theClass);
36 static void testDeallocate(NPObject *obj); 36 static void testDeallocate(NPObject *obj);
37 static bool testConstruct(NPObject* obj, const NPVariant* args, uint32_t argCoun t, NPVariant* result);
38
37 39
38 static NPClass testClass = { 40 static NPClass testClass = {
39 NP_CLASS_STRUCT_VERSION, 41 NP_CLASS_STRUCT_VERSION,
40 testAllocate, 42 testAllocate,
41 testDeallocate, 43 testDeallocate,
42 0, 44 0,
43 0, 45 0,
44 0, 46 0,
45 testInvokeDefault, 47 testInvokeDefault,
46 testHasProperty, 48 testHasProperty,
47 testGetProperty, 49 testGetProperty,
48 0, 50 0,
49 0, 51 0,
50 testEnumerate 52 testEnumerate,
53 testConstruct
51 }; 54 };
52 55
53 NPClass *getTestClass(void) 56 NPClass *getTestClass(void)
54 { 57 {
55 return &testClass; 58 return &testClass;
56 } 59 }
57 60
58 int testObjectCount = 0; 61 int testObjectCount = 0;
59 62
60 int getTestObjectCount(void) { 63 int getTestObjectCount(void) {
61 return testObjectCount; 64 return testObjectCount;
62 } 65 }
63 66
64 static bool identifiersInitialized = false; 67 static bool identifiersInitialized = false;
65 68
66 #define NUM_TEST_IDENTIFIERS 4 69 #define NUM_ENUMERABLE_TEST_IDENTIFIERS 4
67 #define ID_PROPERTY_FOO 0 70 #define NUM_TEST_IDENTIFIERS 5
68 #define ID_PROPERTY_BAR 1 71
69 #define ID_PROPERTY_TEST_OBJECT 2 72 #define ID_PROPERTY_FOO 0
70 #define ID_PROPERTY_REF_COUNT 3 73 #define ID_PROPERTY_BAR 1
74 #define ID_PROPERTY_TEST_OBJECT 2
75 #define ID_PROPERTY_REF_COUNT 3
76 #define ID_PROPERTY_OBJECT_POINTER 4
71 77
72 static NPIdentifier testIdentifiers[NUM_TEST_IDENTIFIERS]; 78 static NPIdentifier testIdentifiers[NUM_TEST_IDENTIFIERS];
73 static const NPUTF8 *testIdentifierNames[NUM_TEST_IDENTIFIERS] = { 79 static const NPUTF8 *testIdentifierNames[NUM_TEST_IDENTIFIERS] = {
74 "foo", 80 "foo",
75 "bar", 81 "bar",
76 "testObject", 82 "testObject",
77 "refCount", 83 "refCount",
84 "objectPointer",
78 }; 85 };
79 86
80 static void initializeIdentifiers(void) 87 static void initializeIdentifiers(void)
81 { 88 {
82 browser->getstringidentifiers(testIdentifierNames, NUM_TEST_IDENTIFIERS, tes tIdentifiers); 89 browser->getstringidentifiers(testIdentifierNames, NUM_TEST_IDENTIFIERS, tes tIdentifiers);
83 } 90 }
84 91
85 static NPObject *testAllocate(NPP npp, NPClass *theClass) 92 static NPObject *testAllocate(NPP npp, NPClass *theClass)
86 { 93 {
87 TestObject *newInstance = 94 TestObject *newInstance =
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } else if (name == testIdentifiers[ID_PROPERTY_TEST_OBJECT]) { 144 } else if (name == testIdentifiers[ID_PROPERTY_TEST_OBJECT]) {
138 TestObject* testObject = reinterpret_cast<TestObject*>(obj); 145 TestObject* testObject = reinterpret_cast<TestObject*>(obj);
139 if (testObject->testObject == NULL) 146 if (testObject->testObject == NULL)
140 testObject->testObject = browser->createobject(NULL, &testClass); 147 testObject->testObject = browser->createobject(NULL, &testClass);
141 browser->retainobject(testObject->testObject); 148 browser->retainobject(testObject->testObject);
142 OBJECT_TO_NPVARIANT(testObject->testObject, *variant); 149 OBJECT_TO_NPVARIANT(testObject->testObject, *variant);
143 return true; 150 return true;
144 } else if (name == testIdentifiers[ID_PROPERTY_REF_COUNT]) { 151 } else if (name == testIdentifiers[ID_PROPERTY_REF_COUNT]) {
145 INT32_TO_NPVARIANT(obj->referenceCount, *variant); 152 INT32_TO_NPVARIANT(obj->referenceCount, *variant);
146 return true; 153 return true;
154 } else if (name == testIdentifiers[ID_PROPERTY_OBJECT_POINTER]) {
155 int32_t objectPointer = static_cast<int32_t>(reinterpret_cast<long long> (obj));
156 INT32_TO_NPVARIANT(objectPointer, *variant);
157 return true;
147 } 158 }
148 return false; 159 return false;
149 } 160 }
150 161
151 static bool testEnumerate(NPObject *npobj, NPIdentifier **value, uint32_t *count ) 162 static bool testEnumerate(NPObject *npobj, NPIdentifier **value, uint32_t *count )
152 { 163 {
153 *count = NUM_TEST_IDENTIFIERS; 164 *count = NUM_ENUMERABLE_TEST_IDENTIFIERS;
154 165
155 *value = (NPIdentifier*)browser->memalloc(NUM_TEST_IDENTIFIERS * sizeof(NPId entifier)); 166 *value = (NPIdentifier*)browser->memalloc(NUM_ENUMERABLE_TEST_IDENTIFIERS * sizeof(NPIdentifier));
156 memcpy(*value, testIdentifiers, sizeof(NPIdentifier) * NUM_TEST_IDENTIFIERS) ; 167 memcpy(*value, testIdentifiers, sizeof(NPIdentifier) * NUM_ENUMERABLE_TEST_I DENTIFIERS);
157 168
158 return true; 169 return true;
159 } 170 }
160 171
172 static bool testConstruct(NPObject* npobj, const NPVariant* args, uint32_t argCo unt, NPVariant* result)
173 {
174 browser->retainobject(npobj);
161 175
176 // Just return the same object.
177 OBJECT_TO_NPVARIANT(npobj, *result);
178 return true;
179 }
180
181
OLDNEW
« no previous file with comments | « webkit/tools/layout_tests/test_expectations.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698