cleanup a few warnings.
[gnash.git] / libcore / ExternalInterface.h
blob944c6877ea74bbe99fc88ef37fc49f1d7a7640d6
1 // ExternalInterface.h: ActionScript "ExternalInterface" support
2 //
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
4 // Foundation, Inc
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef GNASH_EXTERNALINTERFACE_H
22 #define GNASH_EXTERNALINTERFACE_H
24 #include <string>
25 #include <vector>
26 #include <map>
27 #include <boost/shared_ptr.hpp>
29 #include "dsodefs.h" /* For DSOEXPORT */
31 namespace gnash {
33 class as_object;
34 class as_value;
35 struct ObjectURI;
36 class Global_as;
37 class movie_root;
38 class IOChannel;
41 namespace gnash {
43 struct DSOEXPORT ExternalInterface
45 typedef struct DSOLOCAL {
46 std::string name;
47 std::string type;
48 std::vector<as_value> args;
49 } invoke_t;
51 // Some of these appear to be undocumented helper functions of this class
52 // that while probably designed to be used internally, get used
53 // by ActionScript coders.
55 /// Convert an AS object to an XML string.
56 DSOEXPORT static std::string toXML(const as_value &obj);
58 /// Convert an XML string to an AS value.
59 DSOEXPORT static as_value toAS(Global_as& as, const std::string &xml);
61 /// Convert an XML string of properties to a data structure.
62 DSOEXPORT static std::map<std::string, as_value> propertiesToAS(Global_as& gl,
63 std::string &xml);
65 DSOEXPORT static as_value argumentsToXML(std::vector<as_value> &args);
66 // as_value argumentsToAS();
68 DSOEXPORT static std::string objectToXML(as_object *obj);
69 DSOEXPORT static as_value objectToAS(Global_as& gl, const std::string &xml);
70 // std::string objectToJS(as_object &obj);
71 // as_value toJS(const std::string &xml);;
73 DSOEXPORT static std::string arrayToXML(as_object *obj);
75 // static std::string arrayToJS();
76 // static as_value arrayToAS();
78 // static std::string jsQuoteString();
79 // static void initJS();
80 // static bool evalJS();
82 // static callOut"));
83 // static callIn"));
85 static std::string escapeXML(as_object &obj);
86 static std::string unescapeXML(as_object &obj);
88 static as_value parseXML(const std::string &xml);
89 static std::vector<as_value> parseArguments(const std::string &xml);
91 // Parse the XML Invoke message.
92 static boost::shared_ptr<invoke_t> parseInvoke(const std::string &str);
93 // Check for data from the browser and parse it.
94 DSOEXPORT static boost::shared_ptr<invoke_t> ExternalEventCheck(int fd);
96 // These methods are for constructing Invoke messages.
97 // Create an Invoke message for the standalone Gnash
98 DSOEXPORT static std::string makeInvoke (const std::string &method,
99 const std::vector<as_value> &args);
101 static std::string makeNull ();
102 static std::string makeTrue ();
103 static std::string makeFalse ();
104 static std::string makeString (const std::string &str);
105 static std::string makeProperty (const std::string &str, const std::string &data);
106 static std::string makeProperty (const std::string &str, double num);
107 static std::string makeProperty (const std::string &str, int num);
108 static std::string makeNumber (double num);
109 static std::string makeNumber (int num);
110 static std::string makeNumber (unsigned int num);
111 static std::string makeArray (std::vector<std::string> &args);
112 static std::string makeObject (std::map<std::string, std::string> &args);
114 DSOEXPORT static size_t writeBrowser(int fd, const std::string &xml);
115 DSOEXPORT static std::string readBrowser(int fd);
118 } // end of gnash namespace
120 // __GNASH_ASOBJ_EXTERNALINTERFACE_H__
121 #endif
123 // local Variables:
124 // mode: C++
125 // indent-tabs-mode: nil
126 // End: