diff options
author | neb@chromium.org <neb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-23 17:06:31 +0000 |
---|---|---|
committer | neb@chromium.org <neb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-23 17:06:31 +0000 |
commit | b574626479d71344d5190155026873a57cf0d5a3 (patch) | |
tree | 4e4bc0b2e3f24d1985460c1a4d8b125836647823 /ppapi | |
parent | 7cdf00c22466989309283d9d0e7f8a766a81195a (diff) | |
download | chromium_src-b574626479d71344d5190155026873a57cf0d5a3.zip chromium_src-b574626479d71344d5190155026873a57cf0d5a3.tar.gz chromium_src-b574626479d71344d5190155026873a57cf0d5a3.tar.bz2 |
Remove PPB_Var interface's scripting functionality.
PPB_Var now only deals with the PPB_Var datatype. PPB_Var_Deprecated provides scripting for legacy users, post message API will be the replacement in the future.
BUG=76453
TEST=none
Review URL: http://codereview.chromium.org/6673098
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79139 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/c/ppb_class.h | 154 | ||||
-rw-r--r-- | ppapi/c/ppb_var.h | 261 | ||||
-rw-r--r-- | ppapi/ppapi_cpp.gypi | 1 | ||||
-rw-r--r-- | ppapi/ppapi_tests.gypi | 4 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 15 | ||||
-rw-r--r-- | ppapi/tests/all_c_includes.h | 4 | ||||
-rw-r--r-- | ppapi/tests/arch_dependent_sizes_32.h | 5 | ||||
-rw-r--r-- | ppapi/tests/arch_dependent_sizes_64.h | 5 | ||||
-rw-r--r-- | ppapi/tests/test_class.cc | 50 | ||||
-rw-r--r-- | ppapi/tests/test_class.h | 32 | ||||
-rw-r--r-- | ppapi/tests/test_var.cc | 168 | ||||
-rw-r--r-- | ppapi/tests/test_var.h | 30 |
12 files changed, 5 insertions, 724 deletions
diff --git a/ppapi/c/ppb_class.h b/ppapi/c/ppb_class.h deleted file mode 100644 index 64c215b..0000000 --- a/ppapi/c/ppb_class.h +++ /dev/null @@ -1,154 +0,0 @@ -/* Copyright (c) 2010 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#ifndef PPAPI_C_PPB_CLASS_H_ -#define PPAPI_C_PPB_CLASS_H_ - -#include "ppapi/c/pp_module.h" -#include "ppapi/c/pp_resource.h" -#include "ppapi/c/pp_stdint.h" -#include "ppapi/c/pp_var.h" -#include "ppapi/c/ppb_var.h" - -#define PPB_CLASS_INTERFACE "PPB_Class;0.4" - -/** - * @file - * This file defines the PPB_Class struct which is an interface for - * implementing JavaScript-accessible objects. - * - */ - -/** - * @addtogroup Typedefs - * @{ - */ - -/** - * Function callback. - * - * native_ptr will always be the native_ptr used to create this_object. If - * this object was not created in this module, native_ptr will be NULL. There - * is no other type protection - if your module contains two objects with - * different native_ptr information, make sure you can handle the case of - * JS calling one object's function with another object set as this. - * - */ -typedef struct PP_Var (*PP_ClassFunction)(void* native_ptr, - struct PP_Var this_object, /*NOLINT*/ - struct PP_Var* args, - uint32_t argc, - struct PP_Var* exception); -/** - * @} - */ - -/** - * @addtogroup Typedefs - * @{ - */ -typedef void (*PP_ClassDestructor)(void* native_ptr); -/** - * @} - */ - -/** - * @addtogroup Structs - * @{ - */ - -/** - * One property of a class. - * - * It can be either a value property, in which case it need to have getter - * and/or setter fields set, and method NULL, or a function, in which case it - * needs to have method set, and getter/setter set to NULL. It is an error to - * have method and either getter or setter set, as it is an error to not provide - * any of them. - * - * Not providing a getter will be equivalent to having a getter which returns - * undefined. Not providing a setter will be equivalent to providing a setter - * which doesn't do anything. - * - */ -struct PP_ClassProperty { - const char* name; - PP_ClassFunction method; - PP_ClassFunction getter; - PP_ClassFunction setter; - uint32_t modifiers; -}; -/** - * @} - */ - -/** - * @addtogroup Interfaces - * @{ - */ - -/** Interface for implementing JavaScript-accessible objects. - * - * - * Example usage: - * - * struct PP_ClassProperty properties[] = { - * { "method", methodFunc }, - * { "hiddenMethod", hiddenMethodFunc, NULL, NULL, - * PP_OBJECTPROPERTY_MODIFIER_DONTENUM }, - * { "property", NULL, propertyGetter, propertySetter }, - * { "readonlyProperty", NULL, propertyGetter, NULL, - * PP_OBJECTPROPERTY_MODIFIER_READONLY }, - * { NULL } - * }; - * - * PP_Resource object_template = - * Create(module, &operator delete, NULL, properties); - * - * ... - * - * struct NativeData { int blah; ... }; // Can be anything. - * NativeData* native_data = new NativeData; - * native_data->blah = 123; // Initialize native data. - * - * PP_Var object = Instantiate(object_template, native_data); - * - * Please also see: - * http://code.google.com/p/ppapi/wiki/InterfacingWithJavaScript - * for general information on using and implementing vars. - */ -struct PPB_Class { - /** - * Creates a class containing given methods and properties. - * - * Properties list is terminated with a NULL-named property. New instances are - * created using Instantiate(). Each instance carries one void* of native - * state, which is passed to Instantiate(). When the instance is finalized, - * the destructor function is called to destruct the native state. - * - * If invoke handler is specified, then the instances can be used as - * functions. - */ - PP_Resource (*Create)(PP_Module module, - PP_ClassDestructor destruct, - PP_ClassFunction invoke, - struct PP_ClassProperty* properties); - - /** - * Creates an instance of the given class, and attaches given native pointer - * to it. - * - * If the class_object is invalid, throws an exception. - */ - struct PP_Var (*Instantiate)(PP_Resource class_object, - void* native_ptr, - struct PP_Var* exception); -}; -/** - * @} - */ - - -#endif /* PPAPI_C_PPP_CLASS_H_ */ - diff --git a/ppapi/c/ppb_var.h b/ppapi/c/ppb_var.h index 47096c6..56280b3 100644 --- a/ppapi/c/ppb_var.h +++ b/ppapi/c/ppb_var.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2010 The Chromium Authors. All rights reserved. +/* Copyright (c) 2011 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -13,7 +13,7 @@ #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" -#define PPB_VAR_INTERFACE "PPB_Var;0.4" +#define PPB_VAR_INTERFACE "PPB_Var;0.5" /** * @file @@ -21,89 +21,13 @@ */ /** - * - * @addtogroup Enums - * @{ - */ - -/** - * See http://code.google.com/p/ppapi/wiki/InterfacingWithJavaScript - * for general information on using this interface. - */ -// PENDING: Should the generated doc really be pointing to methods? -enum PP_ObjectProperty_Modifier { - PP_OBJECTPROPERTY_MODIFIER_NONE = 0, - PP_OBJECTPROPERTY_MODIFIER_READONLY = 1 << 0, - PP_OBJECTPROPERTY_MODIFIER_DONTENUM = 1 << 1, - PP_OBJECTPROPERTY_MODIFIER_DONTDELETE = 1 << 2, - PP_OBJECTPROPERTY_MODIFIER_HASVALUE = 1 << 3 -}; -PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_ObjectProperty_Modifier, 4); -/** - * @} - */ - -/** - * @addtogroup Structs - * @{ - */ -struct PP_ObjectProperty { - struct PP_Var name; - struct PP_Var value; - struct PP_Var getter; - struct PP_Var setter; - uint32_t modifiers; - - /** Ensure that this struct is 72 bytes wide by padding the end. In some - * compilers, PP_Var is 8-byte aligned, so those compilers align this struct - * on 8-byte boundaries as well and pad it to 72 bytes even without this - * padding attribute. This padding makes its size consistent across - * compilers. - */ - int32_t padding; -}; -PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_ObjectProperty, 72); -/** - * @} - */ - -/** * @addtogroup Interfaces * @{ */ /** * PPB_Var API - * - * JavaScript specification: - * - * When referencing JS specification, we will refer to ECMAScript, 5th edition, - * and we will put section numbers in square brackets. - * - * Exception handling: - * - * If an exception parameter is NULL, then any exceptions that happen during the - * execution of the function will be ignored. If it is non-NULL, and has a type - * of PP_VARTYPE_UNDEFINED, then if an exception is thrown it will be stored in - * the exception variable. It it is non-NULL and not PP_VARTYPE_UNDEFINED, then - * the function is a no-op, and, if it returns a value, it will return - * PP_VARTYPE_UNDEFINED. This can be used to chain together multiple calls and - * only check the exception at the end. - * - * Make sure not to intermix non-JS with JS calls when relying on this behavior - * to catch JS exceptions, as non-JS functions will still execute! - - * JS engine's exceptions will always be of type PP_VARTYPE_OBJECT. However, - * PP_Var interface can also throw PP_VARTYPE_STRING exceptions, in situations - * where there's no JS execution context defined. These are usually invalid - * parameter errors - passing an invalid PP_Var value, for example, will always - * result in an PP_VARTYPE_STRING exception. Exceptions will not be of any other - * type. - * */ - -// TODO(neb): Specify the exception for ill-formed PP_Vars, invalid module, -// instance, resource, string and object ids. struct PPB_Var { /** * Adds a reference to the given var. If this is not a refcounted object, @@ -153,191 +77,10 @@ struct PPB_Var { * will be to random memory. */ const char* (*VarToUtf8)(struct PP_Var var, uint32_t* len); - - /** - * Convert a variable to a different type using rules from ECMAScript - * specification, section [9]. - * - * For conversions from/to PP_VARTYPE_OBJECT, the instance must be specified, - * or an exception of type PP_VARTYPE_STRING will be thrown. - */ - struct PP_Var (*ConvertType)(PP_Instance instance, - struct PP_Var var, - PP_VarType new_type, - struct PP_Var* exception); - - /** - * Sets a property on the object, similar to Object.prototype.defineProperty. - * - * First, if object is not PP_VARTYPE_OBJECT, throw an exception. - * Then, the property's 'name' field is converted to string using - * ConvertType (ToString [9.8]). - * After that, defineOwnProperty [8.12.9, 15.4.5.1] is called with the - * property. - * To set a simple property, set the value and set modifiers to default - * (Writable|Enumerable|Configurable|HasValue), see [8.12.15] and - * function PPB_MakeSimpleProperty. - */ - -// TODO(neb): Specify the exception. Ideally, it would be a TypeError, but -// don't have the JS context to create new objects, we might throw a string. - void (*DefineProperty)(struct PP_Var object, - struct PP_ObjectProperty property, - struct PP_Var* exception); - - /** - * Tests whether an object has a property with a given name. - * - * First, if object is not PP_VARTYPE_OBJECT, throw an exception. - * Then, convert 'property' to string using ConvertType (ToString [9.8]). - * Then return true if the given property exists on the object [8.12.6]. - */ - -// TODO(neb): Specify the exception. Ideally, it would be a TypeError, but -// don't have the JS context to create new objects, we might throw a string. - PP_Bool (*HasProperty)(struct PP_Var object, - struct PP_Var property, - struct PP_Var* exception); - - /** - * Returns a given property of the object. - * - * First, if object is not PP_VARTYPE_OBJECT, throw an exception. - * Then, convert 'property' to string using ConvertType (ToString [9.8]). - * Then return the given property of the object [8.12.2]. - */ - -// TODO(neb): Specify the exception. Ideally, it would be a TypeError, but -// don't have the JS context to create new objects, we might throw a string. - struct PP_Var (*GetProperty)(struct PP_Var object, - struct PP_Var property, - struct PP_Var* exception); - - /** - * Delete a property from the object, return true if succeeded. - * - * True is returned if the property didn't exist in the first place. - * - * First, if object is not PP_VARTYPE_OBJECT, throw an exception. - * Then, convert 'property' to string using ConvertType (ToString [9.8]). - * Then delete the given property of the object [8.12.7]. - */ - -// TODO(neb): Specify the exception. Ideally, it would be a TypeError, but -// don't have the JS context to create new objects, we might throw a string. - PP_Bool (*DeleteProperty)(struct PP_Var object, - struct PP_Var property, - struct PP_Var* exception); - - /** - * Retrieves all property names on the given object. Property names include - * methods. - * - * If object is not PP_VARTYPE_OBJECT, throw an exception. - * - * If there is a failure, the given exception will be set (if it is non-NULL). - * On failure, |*properties| will be set to NULL and |*property_count| will be - * set to 0. - * - * A pointer to the array of property names will be placed in |*properties|. - * The caller is responsible for calling Release() on each of these properties - * (as per normal refcounted memory management) as well as freeing the array - * pointer with PPB_Core.MemFree(). - * - * This function returns all "enumerable" properties. Some JavaScript - * properties are "hidden" and these properties won't be retrieved by this - * function, yet you can still set and get them. You can use JS - * Object.getOwnPropertyNames() to access these properties. - * - * Example: - * <pre> uint32_t count; - * PP_Var* properties; - * ppb_var.EnumerateProperties(object, &count, &properties); - * - * ...use the properties here... - * - * for (uint32_t i = 0; i < count; i++) - * ppb_var.Release(properties[i]); - * ppb_core.MemFree(properties); </pre> - */ - -// TODO(neb): Specify the exception. Ideally, it would be a TypeError, but -// don't have the JS context to create new objects, we might throw a string. - void (*EnumerateProperties)(struct PP_Var object, - uint32_t* property_count, - struct PP_Var** properties, - struct PP_Var* exception); - - /** - * Check if an object is a JS Function [9.11]. - */ - PP_Bool (*IsCallable)(struct PP_Var object); - - /** - * Call the functions. - * - * Similar to Function.prototype.call [15.3.4.4]. It will throw a TypeError - * and return undefined if object is not PP_VARTYPE_OBJECT, or is not - * callable. - * - * Pass the arguments to the function in order in the |argv| array, and the - * number of arguments in the |argc| parameter. |argv| can be NULL if |argc| - * is zero. - * - * Example: - * Call(obj.GetProperty("DoIt"), obj, 0, NULL, NULL) - * Equivalent to obj.DoIt() in JavaScript. - * - * Call(obj, PP_MakeUndefined(), 0, NULL, NULL) - * Equivalent to obj() in JavaScript. - */ - struct PP_Var (*Call)(struct PP_Var object, - struct PP_Var this_object, - uint32_t argc, - struct PP_Var* argv, - struct PP_Var* exception); - - /** - * Invoke the object as a constructor. It will throw a |TypeError| and return - * |undefined| if |object| is not PP_VARTYPE_OBJECT, or cannot be used as a - * constructor. - * - * Pass the arguments to the function in order in the |argv| array, and the - * number of arguments in the |argc| parameter. |argv| can be NULL if |argc| - * is zero. - * - * For example, if |object| is |String|, this is like saying |new String| in - * JavaScript. Similar to the [[Construct]] internal method [13.2.2]. - * - * For examples, to construct an empty object, do: - * GetWindow().GetProperty("Object").Construct(0, NULL); - */ - struct PP_Var (*Construct)(struct PP_Var object, - uint32_t argc, - struct PP_Var* argv, - struct PP_Var* exception); }; /** * @} */ -/** - * @addtogroup Functions - * @{ - */ -PP_INLINE struct PP_ObjectProperty PP_MakeSimpleProperty(struct PP_Var name, - struct PP_Var value) { - struct PP_ObjectProperty result; - result.name = name; - result.value = value; - result.getter = PP_MakeUndefined(); - result.setter = PP_MakeUndefined(); - result.modifiers = PP_OBJECTPROPERTY_MODIFIER_HASVALUE; - return result; -} -/** - * @} - */ - #endif /* PPAPI_C_PPB_VAR_H_ */ diff --git a/ppapi/ppapi_cpp.gypi b/ppapi/ppapi_cpp.gypi index 784bf0e..12c199e 100644 --- a/ppapi/ppapi_cpp.gypi +++ b/ppapi/ppapi_cpp.gypi @@ -31,7 +31,6 @@ 'c/ppb_audio.h', 'c/ppb_audio_config.h', 'c/ppb_core.h', - 'c/ppb_class.h', 'c/ppb_graphics_2d.h', 'c/ppb_image_data.h', 'c/ppb_instance.h', diff --git a/ppapi/ppapi_tests.gypi b/ppapi/ppapi_tests.gypi index a3de9bb..1003446 100644 --- a/ppapi/ppapi_tests.gypi +++ b/ppapi/ppapi_tests.gypi @@ -181,8 +181,6 @@ 'tests/test_c_includes.c', 'tests/test_char_set.cc', 'tests/test_char_set.h', - 'tests/test_class.cc', - 'tests/test_class.h', 'tests/test_cpp_includes.cc', 'tests/test_directory_reader.cc', 'tests/test_directory_reader.h', @@ -209,8 +207,6 @@ 'tests/test_url_util.h', 'tests/test_utils.cc', 'tests/test_utils.h', - 'tests/test_var.cc', - 'tests/test_var.h', # Deprecated test cases. 'tests/test_instance_deprecated.cc', diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 2ecc03a..3681d1e 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -23,7 +23,6 @@ #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" -#include "ppapi/c/ppb_var.h" #include "ppapi/proxy/ppapi_param_traits.h" #include "ppapi/proxy/serialized_flash_menu.h" #include "ppapi/proxy/serialized_structs.h" @@ -678,10 +677,6 @@ IPC_SYNC_MESSAGE_ROUTED3_2(PpapiHostMsg_PPBVar_ConvertType, int /* new_type */, pp::proxy::SerializedVar /* exception */, pp::proxy::SerializedVar /* result */) -IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBVar_DefineProperty, - pp::proxy::SerializedVar /* object */, - PP_ObjectProperty /* property */, - pp::proxy::SerializedVar /* out_exception */) IPC_SYNC_MESSAGE_ROUTED2_2(PpapiHostMsg_PPBVar_HasProperty, pp::proxy::SerializedVar /* object */, pp::proxy::SerializedVar /* property */, @@ -711,16 +706,6 @@ IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBVar_SetPropertyDeprecated, pp::proxy::SerializedVar /* name */, pp::proxy::SerializedVar /* value */, pp::proxy::SerializedVar /* out_exception */) -IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBVar_IsCallable, - pp::proxy::SerializedVar /* object */, - PP_Bool /* result */) -IPC_SYNC_MESSAGE_ROUTED4_2(PpapiHostMsg_PPBVar_Call, - pp::proxy::SerializedVar /* object */, - pp::proxy::SerializedVar /* this_object */, - pp::proxy::SerializedVar /* method_name */, - std::vector<pp::proxy::SerializedVar> /* args */, - pp::proxy::SerializedVar /* out_exception */, - pp::proxy::SerializedVar /* result */) IPC_SYNC_MESSAGE_ROUTED3_2(PpapiHostMsg_PPBVar_CallDeprecated, pp::proxy::SerializedVar /* object */, pp::proxy::SerializedVar /* method_name */, diff --git a/ppapi/tests/all_c_includes.h b/ppapi/tests/all_c_includes.h index bbac836..b181fc6 100644 --- a/ppapi/tests/all_c_includes.h +++ b/ppapi/tests/all_c_includes.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2010 The Chromium Authors. All rights reserved. +/* Copyright (c) 2011 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * @@ -66,7 +66,6 @@ #include "ppapi/c/ppb.h" #include "ppapi/c/ppb_audio.h" #include "ppapi/c/ppb_audio_config.h" -#include "ppapi/c/ppb_class.h" #include "ppapi/c/ppb_core.h" #include "ppapi/c/ppb_graphics_2d.h" #include "ppapi/c/ppb_image_data.h" @@ -74,7 +73,6 @@ #include "ppapi/c/ppb_url_loader.h" #include "ppapi/c/ppb_url_request_info.h" #include "ppapi/c/ppb_url_response_info.h" -#include "ppapi/c/ppb_var.h" #include "ppapi/c/ppp.h" #include "ppapi/c/ppp_instance.h" #include "ppapi/c/private/ppb_flash.h" diff --git a/ppapi/tests/arch_dependent_sizes_32.h b/ppapi/tests/arch_dependent_sizes_32.h index fb18237..8ae7a50 100644 --- a/ppapi/tests/arch_dependent_sizes_32.h +++ b/ppapi/tests/arch_dependent_sizes_32.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2010 The Chromium Authors. All rights reserved. +/* Copyright (c) 2011 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * @@ -13,15 +13,12 @@ PP_COMPILE_ASSERT_SIZE_IN_BYTES(GLintptr, 4); PP_COMPILE_ASSERT_SIZE_IN_BYTES(GLsizeiptr, 4); -PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_ClassDestructor, 4); -PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_ClassFunction, 4); PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_CompletionCallback_Func, 4); PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_URLLoaderTrusted_StatusCallback, 4); PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VideoConfig_Dev, 4); PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VideoDecodeEventHandler_Func_Dev, 4); PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VideoDecodeInputCallback_Func_Dev, 4); PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VideoDecodeOutputCallback_Func_Dev, 4); -PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_ClassProperty, 20); PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_CompletionCallback, 8); PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FileChooserOptions_Dev, 8); PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoDecoderConfig_Dev, 20); diff --git a/ppapi/tests/arch_dependent_sizes_64.h b/ppapi/tests/arch_dependent_sizes_64.h index 3a63ab2..dd419d1 100644 --- a/ppapi/tests/arch_dependent_sizes_64.h +++ b/ppapi/tests/arch_dependent_sizes_64.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2010 The Chromium Authors. All rights reserved. +/* Copyright (c) 2011 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * @@ -13,15 +13,12 @@ PP_COMPILE_ASSERT_SIZE_IN_BYTES(GLintptr, 8); PP_COMPILE_ASSERT_SIZE_IN_BYTES(GLsizeiptr, 8); -PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_ClassDestructor, 8); -PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_ClassFunction, 8); PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_CompletionCallback_Func, 8); PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_URLLoaderTrusted_StatusCallback, 8); PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VideoConfig_Dev, 8); PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VideoDecodeEventHandler_Func_Dev, 8); PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VideoDecodeInputCallback_Func_Dev, 8); PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VideoDecodeOutputCallback_Func_Dev, 8); -PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_ClassProperty, 40); PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_CompletionCallback, 16); PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FileChooserOptions_Dev, 16); PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoDecoderConfig_Dev, 40); diff --git a/ppapi/tests/test_class.cc b/ppapi/tests/test_class.cc deleted file mode 100644 index e27e8fc..0000000 --- a/ppapi/tests/test_class.cc +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/tests/test_class.h" - -#include <limits> - -#include "ppapi/c/dev/ppb_testing_dev.h" -#include "ppapi/c/pp_var.h" -#include "ppapi/c/ppb_class.h" -#include "ppapi/c/ppb_var.h" -#include "ppapi/cpp/instance.h" -#include "ppapi/cpp/module.h" -#include "ppapi/cpp/var.h" -#include "ppapi/tests/testing_instance.h" - -REGISTER_TEST_CASE(Class); - -bool TestClass::Init() { - class_interface_ = reinterpret_cast<const PPB_Class*>( - pp::Module::Get()->GetBrowserInterface(PPB_CLASS_INTERFACE)); - testing_interface_ = reinterpret_cast<const PPB_Testing_Dev*>( - pp::Module::Get()->GetBrowserInterface(PPB_TESTING_DEV_INTERFACE)); - if (!testing_interface_) { - // Give a more helpful error message for the testing interface being gone - // since that needs special enabling in Chrome. - instance_->AppendError("This test needs the testing interface, which is " - "not currently available. In Chrome, use --enable-pepper-testing when " - "launching."); - } - return class_interface_ && testing_interface_; -} - -void TestClass::RunTest() { - RUN_TEST(ConstructEmptyObject); -} - -std::string TestClass::TestConstructEmptyObject() { - PP_ClassProperty properties[] = { { NULL } }; - PP_Resource object_class = class_interface_->Create( - pp::Module::Get()->pp_module(), NULL, NULL, properties); - ASSERT_TRUE(object_class != 0); - - pp::Var instance(pp::Var::PassRef(), - class_interface_->Instantiate(object_class, NULL, NULL)); - ASSERT_TRUE(instance.is_object()); - return std::string(); -} - diff --git a/ppapi/tests/test_class.h b/ppapi/tests/test_class.h deleted file mode 100644 index df38e479..0000000 --- a/ppapi/tests/test_class.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef PPAPI_TESTS_TEST_CLASS_H_ -#define PPAPI_TESTS_TEST_CLASS_H_ - -#include <string> - -#include "ppapi/tests/test_case.h" - -struct PPB_Class; -struct PPB_Testing_Dev; - -class TestClass : public TestCase { - public: - explicit TestClass(TestingInstance* instance) : TestCase(instance) {} - - // TestCase implementation. - virtual bool Init(); - virtual void RunTest(); - - private: - std::string TestConstructEmptyObject(); - - // Used by the tests that access the C API directly. - const PPB_Class* class_interface_; - const PPB_Testing_Dev* testing_interface_; -}; - -#endif // PPAPI_TESTS_TEST_VAR_H_ - diff --git a/ppapi/tests/test_var.cc b/ppapi/tests/test_var.cc deleted file mode 100644 index c9a1339..0000000 --- a/ppapi/tests/test_var.cc +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/tests/test_var.h" - -#include <limits> - -#include "ppapi/c/pp_var.h" -#include "ppapi/c/ppb_var.h" -#include "ppapi/cpp/module.h" -#include "ppapi/cpp/var.h" -#include "ppapi/tests/test_utils.h" -#include "ppapi/tests/testing_instance.h" - -REGISTER_TEST_CASE(Var); - -namespace { -pp::Var adoptVar(PP_Var var) { - return pp::Var(pp::Var::PassRef(), var); -} -} // namespace - -bool TestVar::Init() { - var_interface_ = reinterpret_cast<PPB_Var const*>( - pp::Module::Get()->GetBrowserInterface(PPB_VAR_INTERFACE)); - return var_interface_ && InitTestingInterface(); -} - -void TestVar::RunTest() { - RUN_TEST(ConvertType); - RUN_TEST(DefineProperty); -} - -std::string TestVar::TestConvertType() { - pp::Var result; - PP_Var exception = PP_MakeUndefined(); - double NaN = std::numeric_limits<double>::quiet_NaN(); - - // Int to string - result = adoptVar(var_interface_->ConvertType(instance_->pp_instance(), - pp::Var(100).pp_var(), - PP_VARTYPE_STRING, - &exception)); - ASSERT_EQ(pp::Var("100"), result); - ASSERT_TRUE(adoptVar(exception).is_undefined()); - - // Int to double - result = adoptVar(var_interface_->ConvertType(instance_->pp_instance(), - pp::Var(100).pp_var(), - PP_VARTYPE_DOUBLE, - &exception)); - ASSERT_EQ(pp::Var(100.0), result); - ASSERT_TRUE(adoptVar(exception).is_undefined()); - - // Double to int - result = adoptVar(var_interface_->ConvertType(instance_->pp_instance(), - pp::Var(100.0).pp_var(), - PP_VARTYPE_INT32, - &exception)); - ASSERT_EQ(pp::Var(100), result); - ASSERT_TRUE(adoptVar(exception).is_undefined()); - - // Double(NaN) to int - result = adoptVar(var_interface_->ConvertType(instance_->pp_instance(), - pp::Var(NaN).pp_var(), - PP_VARTYPE_INT32, - &exception)); - ASSERT_EQ(pp::Var(0), result); - ASSERT_TRUE(adoptVar(exception).is_undefined()); - - // Double to string - result = adoptVar(var_interface_->ConvertType(instance_->pp_instance(), - pp::Var(100.0).pp_var(), - PP_VARTYPE_STRING, - &exception)); - ASSERT_EQ(pp::Var("100"), result); - ASSERT_TRUE(adoptVar(exception).is_undefined()); - - // Double(NaN) to string - result = adoptVar(var_interface_->ConvertType(instance_->pp_instance(), - pp::Var(NaN).pp_var(), - PP_VARTYPE_STRING, - &exception)); - ASSERT_EQ(pp::Var("NaN"), result); - ASSERT_TRUE(adoptVar(exception).is_undefined()); - - // String to int, valid string - result = adoptVar(var_interface_->ConvertType(instance_->pp_instance(), - pp::Var("100").pp_var(), - PP_VARTYPE_INT32, - &exception)); - ASSERT_EQ(pp::Var(100), result); - ASSERT_TRUE(adoptVar(exception).is_undefined()); - - // String to int, invalid string - result = adoptVar(var_interface_->ConvertType(instance_->pp_instance(), - pp::Var("jockey").pp_var(), - PP_VARTYPE_INT32, - &exception)); - ASSERT_EQ(pp::Var(0), result); - ASSERT_TRUE(adoptVar(exception).is_undefined()); - - PASS(); -} - -std::string TestVar::TestDefineProperty() { - pp::Var exception; - pp::Var property; - pp::Var value; - PP_Var unmanaged_exception = PP_MakeUndefined(); - - // Create an empty object. - pp::Var test_obj = instance_->ExecuteScript("({})", &exception); - ASSERT_TRUE(exception.is_undefined()); - ASSERT_TRUE(test_obj.is_object()); - - // Define a simple property. - property = "x"; - value = 1001; - var_interface_->DefineProperty(test_obj.pp_var(), - PP_MakeSimpleProperty(property.pp_var(), - value.pp_var()), - &unmanaged_exception); - ASSERT_TRUE(adoptVar(unmanaged_exception).is_undefined()); - - ASSERT_EQ(value, test_obj.GetProperty(property, &exception)); - ASSERT_TRUE(exception.is_undefined()); - - // Define a property with a getter that always returns 123 and setter that - // sets another property to the given value. - property = "y"; - pp::Var getter = instance_->ExecuteScript( - "(function(){return 'okey';})", &exception); - ASSERT_TRUE(getter.is_object()); - ASSERT_TRUE(exception.is_undefined()); - pp::Var setter = instance_->ExecuteScript( - "(function(x){this['another']=x;})", &exception); - ASSERT_TRUE(setter.is_object()); - ASSERT_TRUE(exception.is_undefined()); - - struct PP_ObjectProperty property_attributes = { - property.pp_var(), - PP_MakeUndefined(), - getter.pp_var(), - setter.pp_var(), - PP_OBJECTPROPERTY_MODIFIER_NONE - }; - var_interface_->DefineProperty(test_obj.pp_var(), property_attributes, - &unmanaged_exception); - ASSERT_TRUE(adoptVar(unmanaged_exception).is_undefined()); - - value = test_obj.GetProperty(property, &exception); - ASSERT_EQ(pp::Var("okey"), value); - ASSERT_TRUE(exception.is_undefined()); - - value = test_obj.GetProperty("another", &exception); - ASSERT_TRUE(value.is_undefined()); - ASSERT_TRUE(exception.is_undefined()); - - test_obj.SetProperty("another", "dokey", &exception); - ASSERT_TRUE(exception.is_undefined()); - - ASSERT_EQ(pp::Var("dokey"), test_obj.GetProperty("another", &exception)); - ASSERT_TRUE(exception.is_undefined()); - - PASS(); -} diff --git a/ppapi/tests/test_var.h b/ppapi/tests/test_var.h deleted file mode 100644 index 3a0229b..0000000 --- a/ppapi/tests/test_var.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef PPAPI_TEST_TEST_VAR_H_ -#define PPAPI_TEST_TEST_VAR_H_ - -#include <string> - -#include "ppapi/tests/test_case.h" - -struct PPB_Var; - -class TestVar : public TestCase { - public: - explicit TestVar(TestingInstance* instance) : TestCase(instance) {} - - // TestCase implementation. - virtual bool Init(); - virtual void RunTest(); - - private: - std::string TestConvertType(); - std::string TestDefineProperty(); - - // Used by the tests that access the C API directly. - const PPB_Var* var_interface_; -}; - -#endif // PPAPI_TEST_TEST_VAR_H_ |