swfmill 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/.document +5 -0
  2. data/.gitignore +23 -0
  3. data/.swfmill +240 -0
  4. data/LICENSE +340 -0
  5. data/README.rdoc +37 -0
  6. data/Rakefile +59 -0
  7. data/VERSION +1 -0
  8. data/ext/.gitignore +5 -0
  9. data/ext/extconf.rb +86 -0
  10. data/ext/swfmill/.gitignore +27 -0
  11. data/ext/swfmill/AUTHORS +9 -0
  12. data/ext/swfmill/COPYING +340 -0
  13. data/ext/swfmill/Makefile.am +14 -0
  14. data/ext/swfmill/Makefile.in +635 -0
  15. data/ext/swfmill/NEWS +189 -0
  16. data/ext/swfmill/README +170 -0
  17. data/ext/swfmill/TODO +33 -0
  18. data/ext/swfmill/aclocal.m4 +7712 -0
  19. data/ext/swfmill/autogen.sh +7 -0
  20. data/ext/swfmill/compile +142 -0
  21. data/ext/swfmill/config.guess +1516 -0
  22. data/ext/swfmill/config.sub +1626 -0
  23. data/ext/swfmill/configure +21868 -0
  24. data/ext/swfmill/configure.ac +55 -0
  25. data/ext/swfmill/depcomp +589 -0
  26. data/ext/swfmill/install-sh +519 -0
  27. data/ext/swfmill/ltmain.sh +6964 -0
  28. data/ext/swfmill/missing +367 -0
  29. data/ext/swfmill/src/Geom.cpp +107 -0
  30. data/ext/swfmill/src/Geom.h +100 -0
  31. data/ext/swfmill/src/Makefile.am +86 -0
  32. data/ext/swfmill/src/Makefile.in +1025 -0
  33. data/ext/swfmill/src/SWF.h +11941 -0
  34. data/ext/swfmill/src/SWFAction.cpp +41 -0
  35. data/ext/swfmill/src/SWFAction.h +19 -0
  36. data/ext/swfmill/src/SWFBasic.h +7 -0
  37. data/ext/swfmill/src/SWFFile.cpp +406 -0
  38. data/ext/swfmill/src/SWFFile.h +34 -0
  39. data/ext/swfmill/src/SWFFilter.cpp +25 -0
  40. data/ext/swfmill/src/SWFFilter.h +15 -0
  41. data/ext/swfmill/src/SWFGlyphList.cpp +262 -0
  42. data/ext/swfmill/src/SWFGlyphList.h +34 -0
  43. data/ext/swfmill/src/SWFIdItem.h +85 -0
  44. data/ext/swfmill/src/SWFIdItems.h +16 -0
  45. data/ext/swfmill/src/SWFItem.cpp +235 -0
  46. data/ext/swfmill/src/SWFItem.h +60 -0
  47. data/ext/swfmill/src/SWFList.h +179 -0
  48. data/ext/swfmill/src/SWFReader.cpp +352 -0
  49. data/ext/swfmill/src/SWFReader.h +73 -0
  50. data/ext/swfmill/src/SWFShapeItem.cpp +220 -0
  51. data/ext/swfmill/src/SWFShapeItem.h +45 -0
  52. data/ext/swfmill/src/SWFShapeMaker.cpp +401 -0
  53. data/ext/swfmill/src/SWFShapeMaker.h +128 -0
  54. data/ext/swfmill/src/SWFTag.cpp +49 -0
  55. data/ext/swfmill/src/SWFTag.h +20 -0
  56. data/ext/swfmill/src/SWFTrait.cpp +35 -0
  57. data/ext/swfmill/src/SWFTrait.h +22 -0
  58. data/ext/swfmill/src/SWFWriter.cpp +312 -0
  59. data/ext/swfmill/src/SWFWriter.h +84 -0
  60. data/ext/swfmill/src/base64.c +110 -0
  61. data/ext/swfmill/src/base64.h +15 -0
  62. data/ext/swfmill/src/codegen/Makefile.am +15 -0
  63. data/ext/swfmill/src/codegen/Makefile.in +346 -0
  64. data/ext/swfmill/src/codegen/basic.xsl +45 -0
  65. data/ext/swfmill/src/codegen/basics.xsl +235 -0
  66. data/ext/swfmill/src/codegen/dumper.xsl +109 -0
  67. data/ext/swfmill/src/codegen/header.xsl +131 -0
  68. data/ext/swfmill/src/codegen/mk.xsl +26 -0
  69. data/ext/swfmill/src/codegen/parser.xsl +196 -0
  70. data/ext/swfmill/src/codegen/parsexml.xsl +312 -0
  71. data/ext/swfmill/src/codegen/size.xsl +189 -0
  72. data/ext/swfmill/src/codegen/source.xml +2197 -0
  73. data/ext/swfmill/src/codegen/writer.xsl +190 -0
  74. data/ext/swfmill/src/codegen/writexml.xsl +138 -0
  75. data/ext/swfmill/src/swfmill.cpp +482 -0
  76. data/ext/swfmill/src/swft/Makefile.am +55 -0
  77. data/ext/swfmill/src/swft/Makefile.in +717 -0
  78. data/ext/swfmill/src/swft/Parser.cpp +76 -0
  79. data/ext/swfmill/src/swft/Parser.h +37 -0
  80. data/ext/swfmill/src/swft/SVGAttributeParser.cpp +78 -0
  81. data/ext/swfmill/src/swft/SVGAttributeParser.h +35 -0
  82. data/ext/swfmill/src/swft/SVGColor.cpp +116 -0
  83. data/ext/swfmill/src/swft/SVGColor.h +37 -0
  84. data/ext/swfmill/src/swft/SVGColors.h +167 -0
  85. data/ext/swfmill/src/swft/SVGGradient.cpp +258 -0
  86. data/ext/swfmill/src/swft/SVGGradient.h +81 -0
  87. data/ext/swfmill/src/swft/SVGPathParser.cpp +155 -0
  88. data/ext/swfmill/src/swft/SVGPathParser.h +126 -0
  89. data/ext/swfmill/src/swft/SVGPointsParser.cpp +51 -0
  90. data/ext/swfmill/src/swft/SVGPointsParser.h +25 -0
  91. data/ext/swfmill/src/swft/SVGStyle.cpp +181 -0
  92. data/ext/swfmill/src/swft/SVGStyle.h +80 -0
  93. data/ext/swfmill/src/swft/SVGTransformParser.cpp +72 -0
  94. data/ext/swfmill/src/swft/SVGTransformParser.h +32 -0
  95. data/ext/swfmill/src/swft/readpng.c +305 -0
  96. data/ext/swfmill/src/swft/readpng.h +92 -0
  97. data/ext/swfmill/src/swft/swft.cpp +251 -0
  98. data/ext/swfmill/src/swft/swft.h +64 -0
  99. data/ext/swfmill/src/swft/swft_document.cpp +57 -0
  100. data/ext/swfmill/src/swft/swft_import.cpp +38 -0
  101. data/ext/swfmill/src/swft/swft_import_binary.cpp +82 -0
  102. data/ext/swfmill/src/swft/swft_import_jpeg.cpp +255 -0
  103. data/ext/swfmill/src/swft/swft_import_mp3.cpp +268 -0
  104. data/ext/swfmill/src/swft/swft_import_png.cpp +231 -0
  105. data/ext/swfmill/src/swft/swft_import_ttf.cpp +519 -0
  106. data/ext/swfmill/src/swft/swft_import_wav.cpp +255 -0
  107. data/ext/swfmill/src/swft/swft_path.cpp +178 -0
  108. data/ext/swfmill/src/xslt/Makefile.am +51 -0
  109. data/ext/swfmill/src/xslt/Makefile.in +536 -0
  110. data/ext/swfmill/src/xslt/README +19 -0
  111. data/ext/swfmill/src/xslt/assemble.xsl +38 -0
  112. data/ext/swfmill/src/xslt/simple-deprecated.xslt +62 -0
  113. data/ext/swfmill/src/xslt/simple-elements.xslt +627 -0
  114. data/ext/swfmill/src/xslt/simple-import.xslt +565 -0
  115. data/ext/swfmill/src/xslt/simple-svg.xslt +383 -0
  116. data/ext/swfmill/src/xslt/simple-tools.xslt +255 -0
  117. data/ext/swfmill/src/xslt/simple.cpp +1686 -0
  118. data/ext/swfmill/src/xslt/simple.xml +7 -0
  119. data/ext/swfmill/src/xslt/xslt.h +7 -0
  120. data/ext/swfmill/test/Makefile.am +1 -0
  121. data/ext/swfmill/test/Makefile.in +490 -0
  122. data/ext/swfmill/test/xml/Makefile.am +20 -0
  123. data/ext/swfmill/test/xml/Makefile.in +353 -0
  124. data/ext/swfmill/test/xml/test-xml +21 -0
  125. data/ext/swfmill_ext.cc +375 -0
  126. data/lib/swfmill.rb +30 -0
  127. data/spec/data/swfmill-banner1.swf +0 -0
  128. data/spec/spec.opts +1 -0
  129. data/spec/spec_helper.rb +14 -0
  130. data/spec/swfmill_spec.rb +125 -0
  131. metadata +206 -0
@@ -0,0 +1,20 @@
1
+
2
+
3
+ .PHONY: test run-tests
4
+
5
+ check-local: test
6
+
7
+ test: run-tests
8
+
9
+ EXTRA_DIST = \
10
+ test-xml \
11
+ $(NULL)
12
+
13
+ check_SCRIPTS = \
14
+ run-xml-tests \
15
+ $(NULL)
16
+
17
+ run-tests:
18
+ sh $(srcdir)/run-xml-tests $(srcdir)
19
+
20
+ CLEANFILES = *.swf *.xml.swf
@@ -0,0 +1,353 @@
1
+ # Makefile.in generated by automake 1.10.1 from Makefile.am.
2
+ # @configure_input@
3
+
4
+ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5
+ # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
6
+ # This Makefile.in is free software; the Free Software Foundation
7
+ # gives unlimited permission to copy and/or distribute it,
8
+ # with or without modifications, as long as this notice is preserved.
9
+
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
12
+ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13
+ # PARTICULAR PURPOSE.
14
+
15
+ @SET_MAKE@
16
+ VPATH = @srcdir@
17
+ pkgdatadir = $(datadir)/@PACKAGE@
18
+ pkglibdir = $(libdir)/@PACKAGE@
19
+ pkgincludedir = $(includedir)/@PACKAGE@
20
+ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
21
+ install_sh_DATA = $(install_sh) -c -m 644
22
+ install_sh_PROGRAM = $(install_sh) -c
23
+ install_sh_SCRIPT = $(install_sh) -c
24
+ INSTALL_HEADER = $(INSTALL_DATA)
25
+ transform = $(program_transform_name)
26
+ NORMAL_INSTALL = :
27
+ PRE_INSTALL = :
28
+ POST_INSTALL = :
29
+ NORMAL_UNINSTALL = :
30
+ PRE_UNINSTALL = :
31
+ POST_UNINSTALL = :
32
+ build_triplet = @build@
33
+ host_triplet = @host@
34
+ subdir = test/xml
35
+ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
36
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
37
+ am__aclocal_m4_deps = $(top_srcdir)/configure.ac
38
+ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
39
+ $(ACLOCAL_M4)
40
+ mkinstalldirs = $(install_sh) -d
41
+ CONFIG_CLEAN_FILES =
42
+ SOURCES =
43
+ DIST_SOURCES =
44
+ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
45
+ ACLOCAL = @ACLOCAL@
46
+ AMTAR = @AMTAR@
47
+ AR = @AR@
48
+ AUTOCONF = @AUTOCONF@
49
+ AUTOHEADER = @AUTOHEADER@
50
+ AUTOMAKE = @AUTOMAKE@
51
+ AWK = @AWK@
52
+ CC = @CC@
53
+ CCDEPMODE = @CCDEPMODE@
54
+ CFLAGS = @CFLAGS@
55
+ CPP = @CPP@
56
+ CPPFLAGS = @CPPFLAGS@
57
+ CXX = @CXX@
58
+ CXXCPP = @CXXCPP@
59
+ CXXDEPMODE = @CXXDEPMODE@
60
+ CXXFLAGS = @CXXFLAGS@
61
+ CYGPATH_W = @CYGPATH_W@
62
+ DEFS = @DEFS@
63
+ DEPDIR = @DEPDIR@
64
+ DSYMUTIL = @DSYMUTIL@
65
+ ECHO = @ECHO@
66
+ ECHO_C = @ECHO_C@
67
+ ECHO_N = @ECHO_N@
68
+ ECHO_T = @ECHO_T@
69
+ EGREP = @EGREP@
70
+ EXEEXT = @EXEEXT@
71
+ F77 = @F77@
72
+ FFLAGS = @FFLAGS@
73
+ FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
74
+ FREETYPE_LIBS = @FREETYPE_LIBS@
75
+ GREP = @GREP@
76
+ HAVE_PKGCONFIG = @HAVE_PKGCONFIG@
77
+ INSTALL = @INSTALL@
78
+ INSTALL_DATA = @INSTALL_DATA@
79
+ INSTALL_PROGRAM = @INSTALL_PROGRAM@
80
+ INSTALL_SCRIPT = @INSTALL_SCRIPT@
81
+ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
82
+ LDFLAGS = @LDFLAGS@
83
+ LIBOBJS = @LIBOBJS@
84
+ LIBS = @LIBS@
85
+ LIBTOOL = @LIBTOOL@
86
+ LN_S = @LN_S@
87
+ LTLIBOBJS = @LTLIBOBJS@
88
+ MAKEINFO = @MAKEINFO@
89
+ MKDIR_P = @MKDIR_P@
90
+ NMEDIT = @NMEDIT@
91
+ OBJEXT = @OBJEXT@
92
+ PACKAGE = @PACKAGE@
93
+ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
94
+ PACKAGE_NAME = @PACKAGE_NAME@
95
+ PACKAGE_STRING = @PACKAGE_STRING@
96
+ PACKAGE_TARNAME = @PACKAGE_TARNAME@
97
+ PACKAGE_VERSION = @PACKAGE_VERSION@
98
+ PATH_SEPARATOR = @PATH_SEPARATOR@
99
+ PKG_CONFIG = @PKG_CONFIG@
100
+ PNG_CFLAGS = @PNG_CFLAGS@
101
+ PNG_LIBS = @PNG_LIBS@
102
+ RANLIB = @RANLIB@
103
+ SED = @SED@
104
+ SET_MAKE = @SET_MAKE@
105
+ SHELL = @SHELL@
106
+ STRIP = @STRIP@
107
+ VERSION = @VERSION@
108
+ XML_CFLAGS = @XML_CFLAGS@
109
+ XML_LIBS = @XML_LIBS@
110
+ XSLT_CFLAGS = @XSLT_CFLAGS@
111
+ XSLT_LIBS = @XSLT_LIBS@
112
+ abs_builddir = @abs_builddir@
113
+ abs_srcdir = @abs_srcdir@
114
+ abs_top_builddir = @abs_top_builddir@
115
+ abs_top_srcdir = @abs_top_srcdir@
116
+ ac_ct_CC = @ac_ct_CC@
117
+ ac_ct_CXX = @ac_ct_CXX@
118
+ ac_ct_F77 = @ac_ct_F77@
119
+ am__include = @am__include@
120
+ am__leading_dot = @am__leading_dot@
121
+ am__quote = @am__quote@
122
+ am__tar = @am__tar@
123
+ am__untar = @am__untar@
124
+ bindir = @bindir@
125
+ build = @build@
126
+ build_alias = @build_alias@
127
+ build_cpu = @build_cpu@
128
+ build_os = @build_os@
129
+ build_vendor = @build_vendor@
130
+ builddir = @builddir@
131
+ datadir = @datadir@
132
+ datarootdir = @datarootdir@
133
+ docdir = @docdir@
134
+ dvidir = @dvidir@
135
+ exec_prefix = @exec_prefix@
136
+ host = @host@
137
+ host_alias = @host_alias@
138
+ host_cpu = @host_cpu@
139
+ host_os = @host_os@
140
+ host_vendor = @host_vendor@
141
+ htmldir = @htmldir@
142
+ includedir = @includedir@
143
+ infodir = @infodir@
144
+ install_sh = @install_sh@
145
+ libdir = @libdir@
146
+ libexecdir = @libexecdir@
147
+ localedir = @localedir@
148
+ localstatedir = @localstatedir@
149
+ mandir = @mandir@
150
+ mkdir_p = @mkdir_p@
151
+ oldincludedir = @oldincludedir@
152
+ pdfdir = @pdfdir@
153
+ prefix = @prefix@
154
+ program_transform_name = @program_transform_name@
155
+ psdir = @psdir@
156
+ sbindir = @sbindir@
157
+ sharedstatedir = @sharedstatedir@
158
+ srcdir = @srcdir@
159
+ sysconfdir = @sysconfdir@
160
+ target_alias = @target_alias@
161
+ top_builddir = @top_builddir@
162
+ top_srcdir = @top_srcdir@
163
+ EXTRA_DIST = \
164
+ test-xml \
165
+ $(NULL)
166
+
167
+ check_SCRIPTS = \
168
+ run-xml-tests \
169
+ $(NULL)
170
+
171
+ CLEANFILES = *.swf *.xml.swf
172
+ all: all-am
173
+
174
+ .SUFFIXES:
175
+ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
176
+ @for dep in $?; do \
177
+ case '$(am__configure_deps)' in \
178
+ *$$dep*) \
179
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
180
+ && exit 0; \
181
+ exit 1;; \
182
+ esac; \
183
+ done; \
184
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign test/xml/Makefile'; \
185
+ cd $(top_srcdir) && \
186
+ $(AUTOMAKE) --foreign test/xml/Makefile
187
+ .PRECIOUS: Makefile
188
+ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
189
+ @case '$?' in \
190
+ *config.status*) \
191
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
192
+ *) \
193
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
194
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
195
+ esac;
196
+
197
+ $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
198
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
199
+
200
+ $(top_srcdir)/configure: $(am__configure_deps)
201
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
202
+ $(ACLOCAL_M4): $(am__aclocal_m4_deps)
203
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
204
+
205
+ mostlyclean-libtool:
206
+ -rm -f *.lo
207
+
208
+ clean-libtool:
209
+ -rm -rf .libs _libs
210
+ tags: TAGS
211
+ TAGS:
212
+
213
+ ctags: CTAGS
214
+ CTAGS:
215
+
216
+
217
+ distdir: $(DISTFILES)
218
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
219
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
220
+ list='$(DISTFILES)'; \
221
+ dist_files=`for file in $$list; do echo $$file; done | \
222
+ sed -e "s|^$$srcdirstrip/||;t" \
223
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
224
+ case $$dist_files in \
225
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
226
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
227
+ sort -u` ;; \
228
+ esac; \
229
+ for file in $$dist_files; do \
230
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
231
+ if test -d $$d/$$file; then \
232
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
233
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
234
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
235
+ fi; \
236
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
237
+ else \
238
+ test -f $(distdir)/$$file \
239
+ || cp -p $$d/$$file $(distdir)/$$file \
240
+ || exit 1; \
241
+ fi; \
242
+ done
243
+ check-am: all-am
244
+ $(MAKE) $(AM_MAKEFLAGS) $(check_SCRIPTS)
245
+ $(MAKE) $(AM_MAKEFLAGS) check-local
246
+ check: check-am
247
+ all-am: Makefile
248
+ installdirs:
249
+ install: install-am
250
+ install-exec: install-exec-am
251
+ install-data: install-data-am
252
+ uninstall: uninstall-am
253
+
254
+ install-am: all-am
255
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
256
+
257
+ installcheck: installcheck-am
258
+ install-strip:
259
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
260
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
261
+ `test -z '$(STRIP)' || \
262
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
263
+ mostlyclean-generic:
264
+
265
+ clean-generic:
266
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
267
+
268
+ distclean-generic:
269
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
270
+
271
+ maintainer-clean-generic:
272
+ @echo "This command is intended for maintainers to use"
273
+ @echo "it deletes files that may require special tools to rebuild."
274
+ clean: clean-am
275
+
276
+ clean-am: clean-generic clean-libtool mostlyclean-am
277
+
278
+ distclean: distclean-am
279
+ -rm -f Makefile
280
+ distclean-am: clean-am distclean-generic
281
+
282
+ dvi: dvi-am
283
+
284
+ dvi-am:
285
+
286
+ html: html-am
287
+
288
+ info: info-am
289
+
290
+ info-am:
291
+
292
+ install-data-am:
293
+
294
+ install-dvi: install-dvi-am
295
+
296
+ install-exec-am:
297
+
298
+ install-html: install-html-am
299
+
300
+ install-info: install-info-am
301
+
302
+ install-man:
303
+
304
+ install-pdf: install-pdf-am
305
+
306
+ install-ps: install-ps-am
307
+
308
+ installcheck-am:
309
+
310
+ maintainer-clean: maintainer-clean-am
311
+ -rm -f Makefile
312
+ maintainer-clean-am: distclean-am maintainer-clean-generic
313
+
314
+ mostlyclean: mostlyclean-am
315
+
316
+ mostlyclean-am: mostlyclean-generic mostlyclean-libtool
317
+
318
+ pdf: pdf-am
319
+
320
+ pdf-am:
321
+
322
+ ps: ps-am
323
+
324
+ ps-am:
325
+
326
+ uninstall-am:
327
+
328
+ .MAKE: install-am install-strip
329
+
330
+ .PHONY: all all-am check check-am check-local clean clean-generic \
331
+ clean-libtool distclean distclean-generic distclean-libtool \
332
+ distdir dvi dvi-am html html-am info info-am install \
333
+ install-am install-data install-data-am install-dvi \
334
+ install-dvi-am install-exec install-exec-am install-html \
335
+ install-html-am install-info install-info-am install-man \
336
+ install-pdf install-pdf-am install-ps install-ps-am \
337
+ install-strip installcheck installcheck-am installdirs \
338
+ maintainer-clean maintainer-clean-generic mostlyclean \
339
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
340
+ uninstall uninstall-am
341
+
342
+
343
+ .PHONY: test run-tests
344
+
345
+ check-local: test
346
+
347
+ test: run-tests
348
+
349
+ run-tests:
350
+ sh $(srcdir)/run-xml-tests $(srcdir)
351
+ # Tell versions [3.59,3.63) of GNU make to not export all variables.
352
+ # Otherwise a system limit (for SysV at least) may be exceeded.
353
+ .NOEXPORT:
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+
3
+ SWFMILL=../../src/swfmill
4
+
5
+ file=$1
6
+ swf=`basename ${file}`.swf
7
+ target=${swf}.xml
8
+
9
+ $SWFMILL xml2swf ${file} ${swf}
10
+ $SWFMILL swf2xml ${swf} ${target}
11
+
12
+ if [ ! -e ${swf} -o ! -e ${target} ]; then
13
+ exit 1
14
+ fi
15
+
16
+ diff -q ${file} ${target}
17
+ ret=$?
18
+
19
+ if [ ${ret} -ne 0 ]; then
20
+ exit 1
21
+ fi
@@ -0,0 +1,375 @@
1
+ #include <zlib.h>
2
+ #include "ruby.h"
3
+ #include "SWF.h"
4
+ #include "SWFReader.h"
5
+ #include "SWFWriter.h"
6
+
7
+ static VALUE rb_mSwfmill;
8
+ static VALUE rb_eSwfmill_Error;
9
+ static VALUE rb_eSwfmill_EOFError;
10
+
11
+ /*
12
+ call-seq:
13
+ Swfmill.to_xmlstr(str [, params]) -> String
14
+
15
+ +params+
16
+ {
17
+ :version => Fixnum,
18
+ :compressed => Boolean,
19
+ }
20
+ */
21
+ VALUE swfmill_ext_to_xmlstr(int argc, VALUE *argv, VALUE self)
22
+ {
23
+ VALUE arg_str, arg_param;
24
+ int arg_num = rb_scan_args(argc, argv, "11", &arg_str, &arg_param);
25
+
26
+ unsigned char version = 7;
27
+ bool compressed = false;
28
+
29
+ Check_Type(arg_str, T_STRING);
30
+ if(arg_num == 2)
31
+ {
32
+ Check_Type(arg_param, T_HASH);
33
+
34
+ VALUE ver = rb_hash_aref(arg_param, ID2SYM(rb_intern("version")));
35
+ if(!NIL_P(ver))
36
+ {
37
+ version = (unsigned char)NUM2INT(ver);
38
+ }
39
+
40
+ VALUE cmp = rb_hash_aref(arg_param, ID2SYM(rb_intern("compressed")));
41
+ if(!NIL_P(cmp))
42
+ {
43
+ compressed = cmp == Qtrue;
44
+ }
45
+ }
46
+
47
+ unsigned char* data = (unsigned char*)StringValuePtr(arg_str);
48
+ size_t size = RSTRING_LEN(arg_str);
49
+
50
+ SWF::Header header;
51
+ {
52
+ SWF::Context context;
53
+ SWF::Reader reader(data, size);
54
+ header.parse(&reader, size, &context);
55
+ switch(reader.getError())
56
+ {
57
+ case SWFR_ERROR:
58
+ rb_raise(rb_eSwfmill_Error, "unknown error while reading SWF");
59
+ break;
60
+ case SWFR_EOF:
61
+ rb_raise(rb_eSwfmill_EOFError, "reached EOF while reading SWF");
62
+ break;
63
+ }
64
+ }
65
+
66
+ VALUE xml = Qnil;
67
+ {
68
+ SWF::Context context;
69
+ xmlDocPtr doc = xmlNewDoc((const xmlChar*)"1.0");
70
+ xmlNodePtr root = doc->xmlRootNode = xmlNewDocNode(doc, NULL, (const xmlChar *)"swf", NULL);
71
+ char tmp[4];
72
+
73
+ snprintf(tmp, sizeof(tmp), "%i", version);
74
+ xmlSetProp(root, (const xmlChar*)"version", (const xmlChar*)tmp);
75
+
76
+ snprintf(tmp, sizeof(tmp), "%i", compressed?1:0);
77
+ xmlSetProp(root, (const xmlChar*)"compressed", (const xmlChar*)tmp);
78
+
79
+ context.swfVersion = version;
80
+ header.writeXML(root, &context);
81
+
82
+ char* xml_data = NULL;
83
+ int xml_size;
84
+ xmlDocDumpFormatMemory(doc, (xmlChar **)&xml_data, &xml_size, 1);
85
+
86
+ if(xml_size > 0)
87
+ {
88
+ xml = rb_str_new(xml_data, xml_size);
89
+ }
90
+
91
+ if(xml_data != NULL)
92
+ {
93
+ xmlFree(xml_data);
94
+ }
95
+
96
+ xmlFreeDoc(doc);
97
+ }
98
+
99
+ return xml;
100
+ }
101
+
102
+ /*
103
+ call-seq:
104
+ Swfmill.to_swf(str [, params]) -> Array
105
+
106
+ +params+
107
+ {
108
+ :compress => Boolean,
109
+ :level => Symbol,
110
+ }
111
+
112
+ :compress
113
+ true
114
+ false
115
+ nil
116
+
117
+ :level
118
+ :best
119
+ :speed
120
+ :none
121
+ */
122
+ VALUE swfmill_ext_to_swf(int argc, VALUE *argv, VALUE self)
123
+ {
124
+ VALUE arg_str, arg_param;
125
+ int arg_num = rb_scan_args(argc, argv, "11", &arg_str, &arg_param);
126
+
127
+ unsigned char version = 7;
128
+ bool compressed = false;
129
+ int compress = 0;
130
+ int compress_level = Z_BEST_COMPRESSION;
131
+
132
+ Check_Type(arg_str, T_STRING);
133
+ if(arg_num == 2)
134
+ {
135
+ Check_Type(arg_param, T_HASH);
136
+
137
+ VALUE lvl = rb_hash_aref(arg_param, ID2SYM(rb_intern("level")));
138
+ if(!NIL_P(lvl))
139
+ {
140
+ if(lvl == ID2SYM(rb_intern("speed")))
141
+ {
142
+ compress_level = Z_BEST_SPEED;
143
+ }
144
+ if(lvl == ID2SYM(rb_intern("none")))
145
+ {
146
+ compress_level = Z_NO_COMPRESSION;
147
+ }
148
+ }
149
+
150
+ VALUE cmp = rb_hash_aref(arg_param, ID2SYM(rb_intern("compressed")));
151
+ if(!NIL_P(cmp))
152
+ {
153
+ compress = cmp == Qtrue ? 1 : 2;
154
+ }
155
+ }
156
+
157
+ char* data = StringValuePtr(arg_str);
158
+ int size = RSTRING_LEN(arg_str);
159
+ xmlDocPtr doc = xmlParseMemory(data, size);
160
+
161
+ if(doc == NULL)
162
+ {
163
+ rb_raise(rb_eSwfmill_Error, "XML parser error");
164
+ }
165
+
166
+ xmlNodePtr root = doc->xmlRootNode;
167
+ if(strcmp((const char*)root->name, "swf") != 0)
168
+ {
169
+ xmlFreeDoc(doc);
170
+ rb_raise(rb_eSwfmill_Error, "doesn't seem to be a swfml file");
171
+ }
172
+
173
+ xmlNodePtr headerNode = root->children;
174
+ while((headerNode != NULL) &&
175
+ (headerNode->name == NULL || strcmp((const char*)headerNode->name, "Header") != 0))
176
+ {
177
+ headerNode = headerNode->next;
178
+ }
179
+ if(headerNode == NULL)
180
+ {
181
+ xmlFreeDoc(doc);
182
+ rb_raise(rb_eSwfmill_Error, "swfml file is empty");
183
+ }
184
+
185
+ {
186
+ xmlChar *tmp;
187
+ tmp = xmlGetProp(root, (const xmlChar*)"version");
188
+ if(tmp != NULL)
189
+ {
190
+ int i;
191
+ sscanf((char*)tmp, "%i", &i);
192
+ version = i;
193
+ xmlFree(tmp);
194
+ }
195
+
196
+ tmp = xmlGetProp(root, (const xmlChar*)"compressed");
197
+ if(tmp != NULL)
198
+ {
199
+ int i;
200
+ sscanf((char*)tmp, "%i", &i);
201
+ compressed = i > 0;
202
+ xmlFree(tmp);
203
+ }
204
+ }
205
+ if(compress > 0)
206
+ {
207
+ compressed = compress == 1;
208
+ }
209
+
210
+ SWF::Header header;
211
+ size_t swf_size;
212
+ {
213
+ SWF::Context context;
214
+ context.swfVersion = version;
215
+ header.parseXML(headerNode, &context);
216
+ swf_size = header.getSize(&context, 0) / 8;
217
+ }
218
+
219
+ char swf_head[8+1];
220
+ {
221
+ swf_size += 8;
222
+ snprintf(swf_head, 8, "%s%c%c%c%c%c",
223
+ compressed ? "CWS" : "FWS",
224
+ version,
225
+ ((swf_size>> 0) & 0xFF),
226
+ ((swf_size>> 8) & 0xFF),
227
+ ((swf_size>>16) & 0xFF),
228
+ ((swf_size>>24) & 0xFF));
229
+ swf_size -= 8;
230
+ }
231
+
232
+ unsigned char* swf_buff = (unsigned char*)ruby_xmalloc(swf_size);
233
+ {
234
+ SWF::Context context;
235
+ SWF::Writer writer(swf_buff, swf_size);
236
+ context.swfVersion = version;
237
+ header.write(&writer, &context);
238
+ switch(writer.getError())
239
+ {
240
+ case SWFW_ERROR:
241
+ ruby_xfree(swf_buff);
242
+ xmlFreeDoc(doc);
243
+ rb_raise(rb_eSwfmill_Error, "unknown write error");
244
+ break;
245
+ case SWFW_FULL:
246
+ ruby_xfree(swf_buff);
247
+ xmlFreeDoc(doc);
248
+ rb_raise(rb_eSwfmill_Error, "write buffer full");
249
+ break;
250
+ }
251
+ }
252
+
253
+ if(compressed)
254
+ {
255
+ unsigned char temp[BUFSIZ];
256
+ z_stream stream={Z_NULL};
257
+ int status, count;
258
+
259
+ unsigned char* out_buff = (unsigned char*)ruby_xmalloc(swf_size);
260
+ int out_offset = 0, out_size = swf_size;
261
+
262
+ stream.next_in = swf_buff;
263
+ stream.avail_in = swf_size;
264
+ stream.next_out = temp;
265
+ stream.avail_out = BUFSIZ;
266
+
267
+ status = deflateInit(&stream, compress_level);
268
+ if(status != Z_OK)
269
+ {
270
+ ruby_xfree(swf_buff);
271
+ xmlFreeDoc(doc);
272
+ rb_raise(rb_eSwfmill_Error, "Error compressing SWF: %s", stream.msg);
273
+ }
274
+
275
+ for(;;)
276
+ {
277
+ if(stream.avail_in == 0)
278
+ {
279
+ break;
280
+ }
281
+
282
+ status = deflate(&stream, Z_NO_FLUSH);
283
+ if(status != Z_OK)
284
+ {
285
+ ruby_xfree(swf_buff);
286
+ xmlFreeDoc(doc);
287
+ rb_raise(rb_eSwfmill_Error, "Error compressing SWF: %s", stream.msg);
288
+ }
289
+
290
+ count = BUFSIZ - stream.avail_out;
291
+ if(count > 0)
292
+ {
293
+ if(out_offset + count >= out_size)
294
+ {
295
+ int tmp_size = out_size + out_size / 2;
296
+ unsigned char* tmp_buff = (unsigned char*)ruby_xmalloc(tmp_size);
297
+ memcpy(tmp_buff, out_buff, out_size);
298
+ ruby_xfree(out_buff);
299
+ out_buff = tmp_buff;
300
+ out_size = tmp_size;
301
+ }
302
+ memcpy(out_buff + out_offset, temp, count);
303
+ out_offset += count;
304
+ }
305
+
306
+ stream.next_out = temp;
307
+ stream.avail_out = BUFSIZ;
308
+ }
309
+
310
+ do
311
+ {
312
+ status = deflate(&stream, Z_FINISH);
313
+
314
+ count = BUFSIZ - stream.avail_out;
315
+ if(count > 0)
316
+ {
317
+ if(out_offset + count >= out_size)
318
+ {
319
+ int tmp_size = out_size + out_size / 2;
320
+ unsigned char* tmp_buff = (unsigned char*)ruby_xmalloc(tmp_size);
321
+ memcpy(tmp_buff, out_buff, out_size);
322
+ ruby_xfree(out_buff);
323
+ out_buff = tmp_buff;
324
+ out_size = tmp_size;
325
+ }
326
+ memcpy(out_buff + out_offset, temp, count);
327
+ out_offset += count;
328
+ }
329
+
330
+ stream.next_out = temp;
331
+ stream.avail_out = BUFSIZ;
332
+ } while(status == Z_OK);
333
+
334
+ if(status != Z_STREAM_END)
335
+ {
336
+ ruby_xfree(swf_buff);
337
+ xmlFreeDoc(doc);
338
+ rb_raise(rb_eSwfmill_Error, "Error compressing SWF: %s", stream.msg);
339
+ }
340
+
341
+ status = deflateEnd(&stream);
342
+ if(status != Z_OK)
343
+ {
344
+ ruby_xfree(swf_buff);
345
+ xmlFreeDoc(doc);
346
+ rb_raise(rb_eSwfmill_Error, "Error compressing SWF: %s", stream.msg);
347
+ }
348
+
349
+ ruby_xfree(swf_buff);
350
+ swf_size = out_offset;
351
+ swf_buff = (unsigned char*)ruby_xmalloc(swf_size);
352
+ memcpy(swf_buff, out_buff, swf_size);
353
+ ruby_xfree(out_buff);
354
+ }
355
+
356
+ VALUE swf;
357
+ swf = rb_str_new(swf_head, 8);
358
+ rb_str_cat(swf, (const char*)swf_buff, swf_size);
359
+
360
+ ruby_xfree(swf_buff);
361
+ xmlFreeDoc(doc);
362
+ return swf;
363
+ }
364
+
365
+ extern "C" {
366
+ void Init_swfmill_ext(void)
367
+ {
368
+ rb_mSwfmill = rb_define_module("Swfmill");
369
+ rb_define_singleton_method(rb_mSwfmill, "to_xmlstr", (VALUE(*)(...))swfmill_ext_to_xmlstr, -1);
370
+ rb_define_singleton_method(rb_mSwfmill, "to_swf", (VALUE(*)(...))swfmill_ext_to_swf, -1);
371
+
372
+ rb_eSwfmill_Error = rb_define_class_under(rb_mSwfmill, "Error", rb_eStandardError);
373
+ rb_eSwfmill_EOFError = rb_define_class_under(rb_mSwfmill, "EOFError", rb_eStandardError);
374
+ }
375
+ }