Make automated FSCommand invocation tests show player-side output.
[gnash.git] / libcore / ExternalInterface.h
blob6a1089b78b580e431cac5e94a4fb081a52696888
1 // ExternalInterface.h: ActionScript "ExternalInterface" support
2 //
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software 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 <memory>
25 #include <string>
26 #include <vector>
27 #include <set>
29 #include "dsodefs.h" /* For DSOEXPORT */
31 namespace gnash {
32 class as_object;
33 class as_value;
34 struct ObjectURI;
35 class Global_as;
36 class movie_root;
37 class IOChannel;
40 namespace gnash {
42 struct DSOEXPORT ExternalInterface
44 struct DSOLOCAL invoke_t {
45 std::string name;
46 std::string type;
47 std::vector<as_value> args;
50 /// Convert an AS object to an XML string.
51 static std::string toXML(const as_value &obj) {
52 ExternalInterface ei;
53 return ei._toXML(obj);
56 static as_value parseXML(const std::string &xml);
57 static std::vector<as_value> parseArguments(const std::string &xml);
59 // Parse the XML Invoke message.
60 static std::unique_ptr<invoke_t> parseInvoke(const std::string &str);
61 // Check for data from the browser and parse it.
62 DSOEXPORT static std::unique_ptr<invoke_t> ExternalEventCheck(int fd);
64 // These methods are for constructing Invoke messages.
65 // Create an Invoke message for the standalone Gnash
66 DSOEXPORT static std::string makeInvoke (const std::string &method,
67 const std::vector<as_value> &args);
69 static std::string makeString (const std::string &str) {
70 return "<string>" + str + "</string>";
73 DSOEXPORT static size_t writeBrowser(int fd, const std::string &xml);
74 DSOEXPORT static std::string readBrowser(int fd);
76 private:
78 DSOEXPORT std::string _toXML(const as_value &obj);
79 DSOEXPORT std::string _objectToXML(as_object* obj);
80 DSOEXPORT std::string _arrayToXML(as_object *obj);
82 std::set<as_object*> _visited;
85 } // end of gnash namespace
87 #endif
89 // local Variables:
90 // mode: C++
91 // indent-tabs-mode: nil
92 // End: