[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11243: Implement ContextMenuItem.
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11243: Implement ContextMenuItem. |
Date: |
Fri, 10 Jul 2009 11:43:09 +0200 |
User-agent: |
Bazaar (1.13.1) |
------------------------------------------------------------
revno: 11243
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Fri 2009-07-10 11:43:09 +0200
message:
Implement ContextMenuItem.
modified:
libcore/asobj/Global.cpp
libcore/asobj/flash/ui/ContextMenuItem_as.cpp
libcore/namedStrings.cpp
libcore/namedStrings.h
testsuite/actionscript.all/ContextMenu.as
testsuite/swfdec/PASSING
------------------------------------------------------------
revno: 11242.1.1
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Fri 2009-07-10 09:50:32 +0200
message:
Declare ContextMenuItem class for both AS3 and AS2, where it has been
unaccountably missing.
modified:
libcore/asobj/Global.cpp
libcore/namedStrings.cpp
libcore/namedStrings.h
------------------------------------------------------------
revno: 11242.1.2
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Fri 2009-07-10 10:00:45 +0200
message:
Test onSelect property.
modified:
testsuite/actionscript.all/ContextMenu.as
------------------------------------------------------------
revno: 11242.1.3
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Fri 2009-07-10 10:10:23 +0200
message:
Implement ContextMenuItem.
modified:
libcore/asobj/flash/ui/ContextMenuItem_as.cpp
------------------------------------------------------------
revno: 11242.1.4
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Fri 2009-07-10 10:10:32 +0200
message:
Passing tests.
modified:
testsuite/actionscript.all/ContextMenu.as
------------------------------------------------------------
revno: 11242.1.5
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Fri 2009-07-10 10:16:44 +0200
message:
Get more test passes.
modified:
libcore/asobj/flash/ui/ContextMenuItem_as.cpp
testsuite/actionscript.all/ContextMenu.as
------------------------------------------------------------
revno: 11242.1.6
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Fri 2009-07-10 10:27:48 +0200
message:
Implement copy().
modified:
libcore/asobj/flash/ui/ContextMenuItem_as.cpp
------------------------------------------------------------
revno: 11242.1.7
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Fri 2009-07-10 10:27:54 +0200
message:
Passing tests.
modified:
testsuite/actionscript.all/ContextMenu.as
------------------------------------------------------------
revno: 11242.1.8
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Fri 2009-07-10 10:33:22 +0200
message:
Passes in swfdec testsuite.
modified:
testsuite/swfdec/PASSING
=== modified file 'libcore/asobj/Global.cpp'
--- a/libcore/asobj/Global.cpp 2009-07-09 19:46:56 +0000
+++ b/libcore/asobj/Global.cpp 2009-07-10 07:50:32 +0000
@@ -40,6 +40,7 @@
#include "Math_as.h"
#include "flash/accessibility/Accessibility_as.h"
#include "flash/ui/ContextMenu_as.h"
+#include "flash/ui/ContextMenuItem_as.h"
#include "flash/ui/Keyboard_as.h"
#include "flash/ui/Mouse_as.h"
#include "flash/media/Microphone_as.h"
@@ -366,6 +367,8 @@
NS_GLOBAL, 6))
(N(contextmenu_class_init, NSV::CLASS_CONTEXTMENU, NSV::CLASS_OBJECT,
NS_GLOBAL, 5))
+ (N(contextmenuitem_class_init, NSV::CLASS_CONTEXTMENUITEM,
+ NSV::CLASS_OBJECT, NS_GLOBAL, 5))
(N(moviecliploader_class_init, NSV::CLASS_MOVIE_CLIP_LOADER,
NSV::CLASS_OBJECT, NS_GLOBAL, 7))
(N(Error_class_init, NSV::CLASS_ERROR, NSV::CLASS_OBJECT, NS_GLOBAL,
5))
@@ -504,6 +507,8 @@
NSV::NS_FLASH_UI, 5))
(N(contextmenu_class_init, NSV::CLASS_CONTEXTMENU, NSV::CLASS_OBJECT,
NSV::NS_FLASH_UI, 7))
+ (N(contextmenuitem_class_init, NSV::CLASS_CONTEXTMENUITEM,
+ NSV::CLASS_OBJECT, NSV::NS_FLASH_UI, 5))
// Accessibility classes
(N(accessibility_class_init, NSV::CLASS_ACCESSIBILITY,
=== modified file 'libcore/asobj/flash/ui/ContextMenuItem_as.cpp'
--- a/libcore/asobj/flash/ui/ContextMenuItem_as.cpp 2009-05-28 17:11:56
+0000
+++ b/libcore/asobj/flash/ui/ContextMenuItem_as.cpp 2009-07-10 08:27:48
+0000
@@ -1,4 +1,4 @@
-// ContextMenuItem_as.cpp: ActionScript "ContextMenuItem" class, for Gnash.
+// as_object.cpp: ActionScript "ContextMenuItem" class, for Gnash.
//
// Copyright (C) 2009 Free Software Foundation, Inc.
//
@@ -26,38 +26,28 @@
#include "fn_call.h"
#include "smart_ptr.h" // for boost intrusive_ptr
#include "builtin_function.h" // need builtin_function
-#include "GnashException.h" // for ActionException
+#include "Object.h"
namespace gnash {
// Forward declarations
namespace {
as_value contextmenuitem_ctor(const fn_call& fn);
+ as_value contextmenuitem_copy(const fn_call& fn);
void attachContextMenuItemInterface(as_object& o);
- void attachContextMenuItemStaticInterface(as_object& o);
as_object* getContextMenuItemInterface();
}
-class ContextMenuItem_as : public as_object
-{
-
-public:
-
- ContextMenuItem_as()
- :
- as_object(getContextMenuItemInterface())
- {}
-};
-
// extern (used by Global.cpp)
-void contextmenuitem_class_init(as_object& global)
+void
+contextmenuitem_class_init(as_object& global)
{
static boost::intrusive_ptr<builtin_function> cl;
if (!cl) {
- cl = new builtin_function(&contextmenuitem_ctor,
getContextMenuItemInterface());
- attachContextMenuItemStaticInterface(*cl);
+ cl = new builtin_function(&contextmenuitem_ctor,
+ getContextMenuItemInterface());
}
// Register _global.ContextMenuItem
@@ -69,12 +59,11 @@
void
attachContextMenuItemInterface(as_object& o)
{
-}
-
-void
-attachContextMenuItemStaticInterface(as_object& o)
-{
-
+ const int flags = as_prop_flags::dontEnum |
+ as_prop_flags::dontDelete |
+ as_prop_flags::onlySWF7Up;
+
+ o.init_member("copy", new builtin_function(contextmenuitem_copy), flags);
}
as_object*
@@ -82,18 +71,53 @@
{
static boost::intrusive_ptr<as_object> o;
if ( ! o ) {
- o = new as_object();
+ o = new as_object(getObjectInterface());
attachContextMenuItemInterface(*o);
+ VM::get().addStatic(o.get());
}
return o.get();
}
as_value
+contextmenuitem_copy(const fn_call& fn)
+{
+ boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
+
+ as_value caption, separatorBefore, visible, enabled, onSelect;
+ string_table& st = fn.getVM().getStringTable();
+
+ ptr->get_member(st.find("caption"), &caption);
+ ptr->get_member(st.find("separatorBefore"), &separatorBefore);
+ ptr->get_member(st.find("visible"), &visible);
+ ptr->get_member(NSV::PROP_ON_SELECT, &onSelect);
+ ptr->get_member(NSV::PROP_ENABLED, &enabled);
+
+ as_object* c = new as_object(getContextMenuItemInterface());
+ c->set_member(st.find("caption"), caption);
+ c->set_member(st.find("separatorBefore"), separatorBefore);
+ c->set_member(st.find("visible"), visible);
+ c->set_member(NSV::PROP_ON_SELECT, onSelect);
+ c->set_member(NSV::PROP_ENABLED, enabled);
+
+ return as_value(c);
+}
+
+
+as_value
contextmenuitem_ctor(const fn_call& fn)
{
- boost::intrusive_ptr<as_object> obj = new ContextMenuItem_as;
-
- return as_value(obj.get()); // will keep alive
+ as_object* obj = new as_object(getContextMenuItemInterface());
+
+ string_table& st = fn.getVM().getStringTable();
+
+ obj->set_member(st.find("caption"), fn.nargs ? fn.arg(0) : as_value());
+ obj->set_member(NSV::PROP_ON_SELECT, fn.nargs > 1 ? fn.arg(1) :
as_value());
+ obj->set_member(st.find("separatorBefore"), fn.nargs > 2 ?
+ fn.arg(2) : false);
+ obj->set_member(NSV::PROP_ENABLED, fn.nargs > 3 ? fn.arg(3) : true);
+ obj->set_member(st.find("visible"), fn.nargs > 4 ? fn.arg(4) : true);
+
+ return obj;
}
} // anonymous namespace
=== modified file 'libcore/namedStrings.cpp'
--- a/libcore/namedStrings.cpp 2009-07-09 19:46:56 +0000
+++ b/libcore/namedStrings.cpp 2009-07-10 07:50:32 +0000
@@ -209,6 +209,7 @@
string_table::svt( "NetConnection", NSV::CLASS_NET_CONNECTION ),
string_table::svt( "NetStream", NSV::CLASS_NET_STREAM ),
string_table::svt( "ContextMenu", NSV::CLASS_CONTEXTMENU ),
+ string_table::svt( "ContextMenuItem", NSV::CLASS_CONTEXTMENUITEM ),
string_table::svt( "MovieClipLoader", NSV::CLASS_MOVIE_CLIP_LOADER ),
string_table::svt( "Error", NSV::CLASS_ERROR ),
string_table::svt( "Event", NSV::CLASS_EVENT),
=== modified file 'libcore/namedStrings.h'
--- a/libcore/namedStrings.h 2009-07-09 19:46:56 +0000
+++ b/libcore/namedStrings.h 2009-07-10 07:50:32 +0000
@@ -59,6 +59,7 @@
CLASS_CAMERA,
CLASS_COLOR,
CLASS_CONTEXTMENU,
+ CLASS_CONTEXTMENUITEM,
CLASS_CUSTOM_ACTIONS,
CLASS_CSMTEXTSETTINGS,
CLASS_DATE,
=== modified file 'testsuite/actionscript.all/ContextMenu.as'
--- a/testsuite/actionscript.all/ContextMenu.as 2009-07-09 17:58:39 +0000
+++ b/testsuite/actionscript.all/ContextMenu.as 2009-07-10 08:27:54 +0000
@@ -153,9 +153,9 @@
f.customItems.push(cmi);
ff = f.copy();
check_equals(f.customItems.length, 2);
- xcheck_equals(f.customItems[1].caption, "hi");
+ check_equals(f.customItems[1].caption, "hi");
check_equals(ff.customItems.length, 2);
- xcheck_equals(ff.customItems[1].caption, "hi");
+ check_equals(ff.customItems[1].caption, "hi");
c = {};
c.onSelect = h;
@@ -197,9 +197,9 @@
// Test ContextMenuItem
- xcheck_equals(typeof(ContextMenuItem), "function");
+ check_equals(typeof(ContextMenuItem), "function");
- xcheck(ContextMenuItem.prototype.hasOwnProperty("copy"));
+ check(ContextMenuItem.prototype.hasOwnProperty("copy"));
check(!ContextMenuItem.prototype.hasOwnProperty("caption"));
check(!ContextMenuItem.prototype.hasOwnProperty("enabled"));
@@ -207,39 +207,42 @@
check(!ContextMenuItem.prototype.hasOwnProperty("visible"));
it = new ContextMenuItem();
- xcheck_equals(typeof(it), "object");
- xcheck(it instanceof ContextMenuItem);
+ check_equals(typeof(it), "object");
+ check(it instanceof ContextMenuItem);
check(!it.hasOwnProperty("copy"));
- xcheck(it.hasOwnProperty("caption"));
- xcheck(it.hasOwnProperty("enabled"));
- xcheck(it.hasOwnProperty("separatorBefore"));
- xcheck(it.hasOwnProperty("visible"));
+ check(it.hasOwnProperty("caption"));
+ check(it.hasOwnProperty("enabled"));
+ check(it.hasOwnProperty("separatorBefore"));
+ check(it.hasOwnProperty("visible"));
+ check(it.hasOwnProperty("onSelect"));
check_equals(typeof(it.caption), "undefined");
check_equals(it.caption, undefined);
- xcheck_equals(typeof(it.enabled), "boolean");
- xcheck_equals(it.enabled, true);
- xcheck_equals(typeof(it.separatorBefore), "boolean");
- xcheck_equals(it.separatorBefore, false);
- xcheck_equals(typeof(it.visible), "boolean");
- xcheck_equals(it.visible, true);
+ check_equals(typeof(it.onSelect), "undefined");
+ check_equals(it.onSelect, undefined);
+ check_equals(typeof(it.enabled), "boolean");
+ check_equals(it.enabled, true);
+ check_equals(typeof(it.separatorBefore), "boolean");
+ check_equals(it.separatorBefore, false);
+ check_equals(typeof(it.visible), "boolean");
+ check_equals(it.visible, true);
f = function () { trace("f"); return "f"; };
g = function () { trace("g"); return "g"; };
it = new ContextMenuItem("name1", f);
- xcheck_equals(typeof(it.caption), "string");
- xcheck_equals(it.caption, "name1");
- xcheck_equals(typeof(it.onSelect), "function");
- xcheck_equals(it.onSelect(), "f");
- xcheck_equals(typeof(it.enabled), "boolean");
- xcheck_equals(it.enabled, true);
- xcheck_equals(typeof(it.separatorBefore), "boolean");
- xcheck_equals(it.separatorBefore, false);
- xcheck_equals(typeof(it.visible), "boolean");
- xcheck_equals(it.visible, true);
+ check_equals(typeof(it.caption), "string");
+ check_equals(it.caption, "name1");
+ check_equals(typeof(it.onSelect), "function");
+ check_equals(it.onSelect(), "f");
+ check_equals(typeof(it.enabled), "boolean");
+ check_equals(it.enabled, true);
+ check_equals(typeof(it.separatorBefore), "boolean");
+ check_equals(it.separatorBefore, false);
+ check_equals(typeof(it.visible), "boolean");
+ check_equals(it.visible, true);
// Add a test object to the ContextMenu
cm.customItems.push(it);
@@ -265,8 +268,8 @@
// This isn't added because onSelect isn't a function.
o2 = it.copy();
- xcheck_equals(o2.caption, "name1");
- xcheck_equals(o2.onSelect(), "f");
+ check_equals(o2.caption, "name1");
+ check_equals(o2.onSelect(), "f");
o2.onSelect = 6;
o2.caption = "name2";
cm.customItems.push(o2);
@@ -278,7 +281,7 @@
// If two objects have the same caption, only the first is added to the menu.
o4 = it.copy();
- xcheck_equals(o4.caption, "name1");
+ check_equals(o4.caption, "name1");
o4.onSelect = g;
cm.customItems.push(o4);
@@ -301,6 +304,6 @@
contextMenuObj2.onSelect = 4;
check_equals(typeof(contextMenuObj2.onSelect), 'number');
- totals(120);
+ totals(123);
#endif
=== modified file 'testsuite/swfdec/PASSING'
--- a/testsuite/swfdec/PASSING 2009-07-09 19:09:27 +0000
+++ b/testsuite/swfdec/PASSING 2009-07-10 08:33:22 +0000
@@ -197,6 +197,10 @@
context-menu-6.swf:9124c06f1cc4725684717eb3641837bd
context-menu-7.swf:fc22bea201998188714399c2de1ac1f5
context-menu-8.swf:81cec364792b76914943847fe6ec9a1f
+context-menu-item-5.swf:b125dc8033d2337139faccd752edc3cf
+context-menu-item-6.swf:bed4cac31e3e05d22fa5478078e1790a
+context-menu-item-7.swf:e3339c3aa296505f3477d88d2f9033a2
+context-menu-item-8.swf:9d586baebe529587c5b3522f73255810
conversion-functions-6.swf:29f141b5a2d03886c152342fdbea9b25
conversion-functions-7.swf:8bc3951e61b7fefa82d24fb037929350
conversion-functions-8.swf:4a68346aaa982e32b2882a49e34faa07
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11243: Implement ContextMenuItem.,
Benjamin Wolsey <=