2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
3 // 2011 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
20 #include "gnashconfig.h"
29 #include "as_object.h"
30 #include "as_function.h"
31 #include "Global_as.h"
38 as_value
dejagnu_pass(const fn_call
& fn
);
39 as_value
dejagnu_fail(const fn_call
& fn
);
40 as_value
dejagnu_totals(const fn_call
& fn
);
42 class DejaGnu
: public Relay
47 const char *pass (const char *msg
);
48 const char *fail (const char *msg
);
49 const char *xpass (const char *msg
);
50 const char *xfail (const char *msg
);
60 attachInterface(as_object
& obj
)
62 Global_as
& gl
= getGlobal(obj
);
64 obj
.init_member("pass", gl
.createFunction(dejagnu_pass
));
65 obj
.init_member("fail", gl
.createFunction(dejagnu_fail
));
66 obj
.init_member("totals", gl
.createFunction(dejagnu_totals
));
70 dejagnu_ctor(const fn_call
& fn
)
72 as_object
* obj
= ensure
<ValidThis
>(fn
);
73 obj
->setRelay(new DejaGnu());
79 : passed(0), failed(0), xpassed(0), xfailed(0)
81 // GNASH_REPORT_FUNCTION;
86 // GNASH_REPORT_FUNCTION;
90 DejaGnu::pass (const char *msg
)
93 log_debug("PASSED: %s\n", msg
);
98 DejaGnu::fail (const char *msg
)
101 log_debug("FAILED: %s\n", msg
);
106 dejagnu_pass(const fn_call
& fn
)
108 // GNASH_REPORT_FUNCTION;
109 DejaGnu
* ptr
= ensure
<ThisIsNative
<DejaGnu
> >(fn
);
112 string text
= fn
.arg(0).to_string();
113 return as_value(ptr
->pass(text
.c_str()));
120 dejagnu_fail(const fn_call
& fn
)
122 // GNASH_REPORT_FUNCTION;
123 DejaGnu
* ptr
= ensure
<ThisIsNative
<DejaGnu
> >(fn
);
126 string text
= fn
.arg(0).to_string();
127 return as_value(ptr
->fail(text
.c_str()));
134 dejagnu_totals(const fn_call
& fn
)
136 DejaGnu
* ptr
= ensure
<ThisIsNative
<DejaGnu
> >(fn
);
139 return as_value(true);
145 dejagnu_class_init(as_object
&obj
)
147 Global_as
& gl
= getGlobal(obj
);
148 as_object
* proto
= createObject(gl
);
149 attachInterface(*proto
);
151 as_object
* cl
= gl
.createClass(&dejagnu_ctor
, proto
);
153 obj
.init_member("DejaGnu", cl
);
158 } // end of gnash namespace
162 // indent-tabs-mode: t