3 # Copyright (C) 2009, 2010 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 2 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 # This script generates header file and C++ source file templates
21 # for an ActionScript class. It depends on the doc/C/NOTES file for
22 # data. It takes a single argument, which is the name of the class,
23 # like "./gen-files.sh Camera".
25 # This script is only of use to developers, so it's "as is". Your
28 if test x
"$1" = "x"; then
29 echo "Usage: $0 <classname>" >&2
34 # Add some newlines to make sed;ing and greping easier.
35 nspace
="`basename $PWD`"
36 class
="`basename $1 | sed -e 's:.html::'`"
37 sed -e "s/<tr/\n<tr/g" $1 > tmp.html
39 # extract the properties from the web page
41 grep -v "hideInheritedProperty" tmp.html |
sed -e '/th colspan=.*Property/,/th colspan=.*Method/w props.tmp' > /dev
/null
42 properties
="`grep signatureLink props.tmp | sed -e 's:<div class="summaryTableDescription.
*::' -e 's
:^.
*signatureLink
\">::' -e 's
:<.
*\">:_
:' -e 's
:<.
*::'`"
44 # extract the methods from the web page
46 grep -v "hideInheritedMethod" tmp.html | sed -e '/th colspan
=.
*Method
/,/th colspan
=.
*Event
/w methods.tmp
' > /dev/null
47 allmethods="`grep signatureLink methods.tmp | sed -e 's
:<div class
="summaryTableDescription.*::' -e 's:^.*signatureLink\">::' -e 's:<.*\">:_:' -e 's:<.*::'`"
49 # extract the methods from the web page
50 # events="`sed -e '1,/eventDetail/ d' -e '/(propertyDetail|Property Detail)/,$d' tmp.html | grep "detailHeaderName" | sed -e 's:^.*detailHeaderName">::' -e 's:<.*::' | tr -s '\n' ' '`"
52 # ignore the package-detail files
53 if test x
"${class}" = x
"package-detail" -o x
"${class}" = x
"package"; then
58 # split up the list of data in pairs into an array so we can have a crude
59 # association between the porterty and the data type it returns.
62 for item
in $properties; do
63 name
="`echo $item | cut -d '_' -f 1`"
64 type="`echo $item | cut -d '_' -f 2`"
70 # display what we found
73 props_blanks
=`echo $props | tr -d ' '`
74 echo -n " Properties: "
75 if test x
"$props_blanks" != x
; then
76 for item
in $properties; do
77 echo -n " \"${props[$i]}\" \"${pargs[$i]}\","
86 # split up the list of data in pairs into an array so we can have a crude
87 # association between the porterty and the data type it returns.
90 for item
in $allmethods; do
91 name
="`echo $item | cut -d '_' -f 1`"
92 type="`echo $item | cut -d '_' -f 2`"
98 # display what we found
100 meth_blanks
=`echo $allmethods | tr -d ' '`
102 if test x
"$meth_blanks" != x
; then
103 for item
in $allmethods; do
104 echo -n " \"${methods[$i]}\" \"${margs[$i]}\","
113 # We're done making lists of things, do some real work.
116 lowname
=`echo ${asname} | tr '[A-Z]' '[a-z]'`
117 upname
=`echo ${asname} | tr '[a-z]' '[A-Z]'`
118 outname
=${asname}_as3.hx
120 if test -f ${outname}; then
121 echo ${outname} exists
!
122 mv -f ${outname} ${outname}.orig
126 ###############################################################
127 # Start by generating the header file for this class
132 // ${outname}: ActionScript 3 "${asname}" class, for Gnash.
134 // Generated by gen-as3.sh on: ${now} by "${USER}". Remove this
135 // after any hand editing loosing changes.
137 // Copyright (C) 2009, 2010 Free Software Foundation, Inc.
139 // This program is free software; you can redistribute it and/or modify
140 // it under the terms of the GNU General Public License as published by
141 // the Free Software Foundation; either version 3 of the License, or
142 // (at your option) any later version.
144 // This program is distributed in the hope that it will be useful,
145 // but WITHOUT ANY WARRANTY; without even the implied warranty of
146 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
147 // GNU General Public License for more details.
149 // You should have received a copy of the GNU General Public License
150 // along with this program; if not, write to the Free Software
151 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
154 // This test case must be processed by CPP before compiling to include the
155 // DejaGnu.hx header file for the testing framework support.
158 import flash.${nspace}.${asname};
159 import flash.display.MovieClip;
161 import flash.${asname};
162 import flash.MovieClip;
167 // import our testing API
170 // Class must be named with the _as3 suffix, as that's the same name as the file.
171 class ${asname}_as3 {
172 static function main() {
173 var x1:${asname} = new ${asname}();
175 // Make sure we actually get a valid class
177 DejaGnu.pass("${asname} class exists");
179 DejaGnu.fail("${asname} class doesn't exist");
184 if test x
"$props_blanks" != x
; then
185 cat <<EOF>>${outname}
186 // Tests to see if all the properties exist. All these do is test for
187 // existance of a property, and don't test the functionality at all. This
188 // is primarily useful only to test completeness of the API implementation.
192 # Add tests to see if all the properties exist
195 if test x
"$props_blanks" != x
; then
196 for item
in $properties; do
200 "Number") result
=0 ;;
202 "String") result
="null" ;;
203 "Boolean") result
=false
;;
207 # echo "PROPS[$i]: ${name} : ${type}"
208 lines
[$j]=" if (x1.${name} == $result) {"
210 lines
[$j]=" DejaGnu.pass(\"${asname}.${name} property exists\");"
212 lines
[$j]=" } else {"
214 lines
[$j]=" DejaGnu.fail(\"${asname}.${name} property doesn't exist\");"
226 while test $k -le $j; do
227 echo "${lines[$k]}" >> ${outname}
231 if test x
"$meth_blanks" != x
; then
232 cat <<EOF>>${outname}
233 // Tests to see if all the methods exist. All these do is test for
234 // existance of a method, and don't test the functionality at all. This
235 // is primarily useful only to test completeness of the API implementation.
239 # Add tests to see if all the methods exist
242 if test x
"$props_blanks" != x
; then
243 for item
in $allmethods; do
247 "Number") result
=0 ;;
250 "String") result
="null" ;;
251 "Boolean") result
=false
;;
252 "void") result
=null
;;
256 # echo "PROPS[$i]: ${name} : ${type}"
257 lines
[$j]=" if (x1.${name} == $result) {"
259 lines
[$j]=" DejaGnu.pass(\"${asname}::${name}() method exists\");"
261 lines
[$j]=" } else {"
263 lines
[$j]=" DejaGnu.fail(\"${asname}::${name}() method doesn't exist\");"
275 while test $k -le $j; do
276 echo "${lines[$k]}" >> ${outname}
284 cat <<EOF>>${outname}
285 // Call this after finishing all tests. It prints out the totals.
292 // indent-tabs-mode: t
297 # cleanup after ourselves