1
// CustomActions.cpp: ActionScript CustomActions class, for Gnash.
3
// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
5
// This program is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation; either version 3 of the License, or
8
// (at your option) any later version.
10
// This program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
15
// You should have received a copy of the GNU General Public License
16
// along with this program; if not, write to the Free Software
17
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#include "gnashconfig.h"
24
#include "CustomActions.h"
25
#include "as_object.h" // for inheritance
28
#include "smart_ptr.h" // for boost intrusive_ptr
29
#include "builtin_function.h" // need builtin_function
30
#include "Object.h" // for getObjectInterface
34
as_value customactions_get(const fn_call& fn);
35
as_value customactions_install(const fn_call& fn);
36
as_value customactions_list(const fn_call& fn);
37
as_value customactions_uninstall(const fn_call& fn);
38
as_value customactions_ctor(const fn_call& fn);
41
attachCustomActionsInterface(as_object& o)
43
o.init_member("get", new builtin_function(customactions_get));
44
o.init_member("install", new builtin_function(customactions_install));
45
o.init_member("list", new builtin_function(customactions_list));
46
o.init_member("uninstall", new builtin_function(customactions_uninstall));
50
getCustomActionsInterface()
52
static boost::intrusive_ptr<as_object> o;
55
o = new as_object(getObjectInterface());
56
attachCustomActionsInterface(*o);
61
class customactions_as_object: public as_object
66
customactions_as_object()
68
as_object(getCustomActionsInterface())
71
// override from as_object ?
72
//std::string get_text_value() const { return "CustomActions"; }
74
// override from as_object ?
75
//double get_numeric_value() const { return 0; }
78
as_value customactions_get(const fn_call& /*fn*/) {
79
log_unimpl (__FUNCTION__);
82
as_value customactions_install(const fn_call& /*fn*/) {
83
log_unimpl (__FUNCTION__);
86
as_value customactions_list(const fn_call& /*fn*/) {
87
log_unimpl (__FUNCTION__);
90
as_value customactions_uninstall(const fn_call& /*fn*/) {
91
log_unimpl (__FUNCTION__);
96
customactions_ctor(const fn_call& /* fn */)
98
boost::intrusive_ptr<as_object> obj = new customactions_as_object;
100
return as_value(obj.get()); // will keep alive
103
// extern (used by Global.cpp)
104
void customactions_class_init(as_object& global)
106
// This is going to be the global CustomActions "class"/"function"
107
static boost::intrusive_ptr<builtin_function> cl;
111
cl=new builtin_function(&customactions_ctor, getCustomActionsInterface());
112
// replicate all interface to class, to be able to access
113
// all methods as static functions
114
attachCustomActionsInterface(*cl);
118
// Register _global.CustomActions
119
global.init_member("CustomActions", cl.get());
124
} // end of gnash namespace