From 9b6db26fcc22a7a4ec0510a93733b2e190d9e649 Mon Sep 17 00:00:00 2001 From: "brettw@chromium.org" Date: Mon, 11 Apr 2011 04:27:47 +0000 Subject: Create a VarPrivate interface to contain the scripting helper functions of Var. Currently, the old functions are left in Var. When people have a chance to move to this new API, we can delete them from Var. This also adds new enums for ARRAY and DICTIONARY vars, and makes the var C++ wrapper forward-compatible with them by refcounting any enums that it doesn't know about. Review URL: http://codereview.chromium.org/6823016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81068 0039d316-1c4b-4281-b951-d872f2087c98 --- ppapi/example/example.cc | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'ppapi/example') diff --git a/ppapi/example/example.cc b/ppapi/example/example.cc index e8c3995..1eef073 100644 --- a/ppapi/example/example.cc +++ b/ppapi/example/example.cc @@ -25,6 +25,7 @@ #include "ppapi/cpp/image_data.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" +#include "ppapi/cpp/private/var_private.h" #include "ppapi/cpp/rect.h" #include "ppapi/cpp/url_loader.h" #include "ppapi/cpp/url_request_info.h" @@ -61,7 +62,7 @@ class MyScriptableObject : public pp::deprecated::ScriptableObject { virtual pp::Var GetProperty(const pp::Var& name, pp::Var* exception) { if (name.is_string() && name.AsString() == "blah") - return pp::Var(instance_, new MyScriptableObject(instance_)); + return pp::VarPrivate(instance_, new MyScriptableObject(instance_)); return pp::Var(); } @@ -203,9 +204,9 @@ class MyInstance : public pp::Instance, public MyFetcherClient { << " usb=" << std::hex << key_event.usb_key_code; // Locate the field to update in the page DOM - pp::Var window = GetWindowObject(); - pp::Var doc = window.GetProperty("document"); - pp::Var last_key_down = doc.Call("getElementById", "lastKeyDown"); + pp::VarPrivate window = GetWindowObject(); + pp::VarPrivate doc = window.GetProperty("document"); + pp::VarPrivate last_key_down = doc.Call("getElementById", "lastKeyDown"); last_key_down.SetProperty("innerHTML", last_key_down_text.str()); } @@ -226,7 +227,7 @@ class MyInstance : public pp::Instance, public MyFetcherClient { } virtual pp::Var GetInstanceObject() { - return pp::Var(this, new MyScriptableObject(this)); + return pp::VarPrivate(this, new MyScriptableObject(this)); } pp::ImageData PaintImage(int width, int height) { @@ -294,9 +295,9 @@ class MyInstance : public pp::Instance, public MyFetcherClient { void UpdateFps() { // Time code doesn't currently compile on Windows, just skip FPS for now. #ifndef _WIN32 - pp::Var window = GetWindowObject(); - pp::Var doc = window.GetProperty("document"); - pp::Var fps = doc.Call("getElementById", "fps"); + pp::VarPrivate window = GetWindowObject(); + pp::VarPrivate doc = window.GetProperty("document"); + pp::VarPrivate fps = doc.Call("getElementById", "fps"); struct timeval tv; struct timezone tz = {0, 0}; @@ -374,11 +375,11 @@ class MyInstance : public pp::Instance, public MyFetcherClient { private: void SayHello() { - pp::Var window = GetWindowObject(); - pp::Var doc = window.GetProperty("document"); - pp::Var body = doc.GetProperty("body"); + pp::VarPrivate window = GetWindowObject(); + pp::VarPrivate doc = window.GetProperty("document"); + pp::VarPrivate body = doc.GetProperty("body"); - pp::Var obj(this, new MyScriptableObject(this)); + pp::VarPrivate obj(this, new MyScriptableObject(this)); // Our object should have its toString method called. Log(PP_LOGLEVEL_LOG, "Testing MyScriptableObject::toString():"); -- cgit v1.1