swfmill 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/.swfmill +0 -134
  2. data/README.rdoc +28 -8
  3. data/Rakefile +6 -5
  4. data/VERSION +1 -1
  5. data/ext/.gitignore +1 -0
  6. data/ext/buffer.h +95 -0
  7. data/ext/deflate.h +125 -0
  8. data/ext/extconf.rb +77 -43
  9. data/ext/inflate.h +82 -0
  10. data/ext/swfmill/.gitignore +3 -16
  11. data/ext/swfmill/AUTHORS +2 -1
  12. data/ext/swfmill/Makefile.in +2 -1
  13. data/ext/swfmill/NEWS +5 -0
  14. data/ext/swfmill/autogen.sh +7 -1
  15. data/ext/swfmill/configure +361 -275
  16. data/ext/swfmill/configure.ac +28 -20
  17. data/ext/swfmill/src/Makefile.am +93 -20
  18. data/ext/swfmill/src/Makefile.in +454 -170
  19. data/ext/swfmill/src/SWF.h +3 -0
  20. data/ext/swfmill/src/SWFFile.cpp +1 -1
  21. data/ext/swfmill/src/SWFShapeMaker.cpp +4 -3
  22. data/ext/swfmill/src/codegen/basics.xsl +2 -1
  23. data/ext/swfmill/src/codegen/header.xsl +3 -0
  24. data/ext/swfmill/src/codegen/parsexml.xsl +53 -2
  25. data/ext/swfmill/src/codegen/writexml.xsl +54 -1
  26. data/ext/swfmill/src/swfmill.cpp +52 -35
  27. data/ext/swfmill/src/swft/swft_import_jpeg.cpp +62 -16
  28. data/ext/swfmill/src/xslt/simple-elements.xslt +1 -0
  29. data/ext/swfmill/test/Makefile.in +2 -1
  30. data/ext/swfmill/test/xml/Makefile.in +2 -1
  31. data/ext/swfmill_ext.cc +12 -366
  32. data/ext/swfmill_ext_to_swf.cc +260 -0
  33. data/ext/swfmill_ext_to_swf.h +6 -0
  34. data/ext/swfmill_ext_to_xml.cc +262 -0
  35. data/ext/swfmill_ext_to_xml.h +6 -0
  36. data/ext/test/Makefile +16 -0
  37. data/ext/test/buffer_test.cc +84 -0
  38. data/ext/test/deflate_test.cc +61 -0
  39. data/ext/test/inflate_test.cc +84 -0
  40. data/ext/test/test.dat +0 -0
  41. data/lib/swfmill.rb +14 -23
  42. data/spec/swfmill_spec.rb +0 -123
  43. metadata +28 -17
  44. data/ext/swfmill/src/codegen/Makefile.am +0 -15
  45. data/ext/swfmill/src/codegen/Makefile.in +0 -346
  46. data/ext/swfmill/src/swft/Makefile.am +0 -55
  47. data/ext/swfmill/src/swft/Makefile.in +0 -717
  48. data/ext/swfmill/src/xslt/Makefile.am +0 -51
  49. data/ext/swfmill/src/xslt/Makefile.in +0 -536
  50. data/ext/swfmill/src/xslt/README +0 -19
  51. data/ext/swfmill/src/xslt/simple.cpp +0 -1686
data/.swfmill CHANGED
@@ -16,7 +16,6 @@ ext/swfmill/depcomp
16
16
  ext/swfmill/install-sh
17
17
  ext/swfmill/ltmain.sh
18
18
  ext/swfmill/missing
19
- ext/swfmill/src
20
19
  ext/swfmill/src/Geom.cpp
21
20
  ext/swfmill/src/Geom.h
22
21
  ext/swfmill/src/Makefile.am
@@ -50,9 +49,6 @@ ext/swfmill/src/SWFWriter.cpp
50
49
  ext/swfmill/src/SWFWriter.h
51
50
  ext/swfmill/src/base64.c
52
51
  ext/swfmill/src/base64.h
53
- ext/swfmill/src/codegen
54
- ext/swfmill/src/codegen/Makefile.am
55
- ext/swfmill/src/codegen/Makefile.in
56
52
  ext/swfmill/src/codegen/basic.xsl
57
53
  ext/swfmill/src/codegen/basics.xsl
58
54
  ext/swfmill/src/codegen/dumper.xsl
@@ -65,9 +61,6 @@ ext/swfmill/src/codegen/source.xml
65
61
  ext/swfmill/src/codegen/writer.xsl
66
62
  ext/swfmill/src/codegen/writexml.xsl
67
63
  ext/swfmill/src/swfmill.cpp
68
- ext/swfmill/src/swft
69
- ext/swfmill/src/swft/Makefile.am
70
- ext/swfmill/src/swft/Makefile.in
71
64
  ext/swfmill/src/swft/Parser.cpp
72
65
  ext/swfmill/src/swft/Parser.h
73
66
  ext/swfmill/src/swft/SVGAttributeParser.cpp
@@ -98,143 +91,16 @@ ext/swfmill/src/swft/swft_import_png.cpp
98
91
  ext/swfmill/src/swft/swft_import_ttf.cpp
99
92
  ext/swfmill/src/swft/swft_import_wav.cpp
100
93
  ext/swfmill/src/swft/swft_path.cpp
101
- ext/swfmill/src/xslt
102
- ext/swfmill/src/xslt/Makefile.am
103
- ext/swfmill/src/xslt/Makefile.in
104
- ext/swfmill/src/xslt/README
105
94
  ext/swfmill/src/xslt/assemble.xsl
106
95
  ext/swfmill/src/xslt/simple-deprecated.xslt
107
96
  ext/swfmill/src/xslt/simple-elements.xslt
108
97
  ext/swfmill/src/xslt/simple-import.xslt
109
98
  ext/swfmill/src/xslt/simple-svg.xslt
110
99
  ext/swfmill/src/xslt/simple-tools.xslt
111
- ext/swfmill/src/xslt/simple.cpp
112
100
  ext/swfmill/src/xslt/simple.xml
113
101
  ext/swfmill/src/xslt/xslt.h
114
- ext/swfmill/test
115
102
  ext/swfmill/test/Makefile.am
116
103
  ext/swfmill/test/Makefile.in
117
- ext/swfmill/test/xml
118
- ext/swfmill/test/xml/Makefile.am
119
- ext/swfmill/test/xml/Makefile.in
120
- ext/swfmill/test/xml/test-xml
121
- ext/swfmill/AUTHORS
122
- ext/swfmill/COPYING
123
- ext/swfmill/Makefile.am
124
- ext/swfmill/Makefile.in
125
- ext/swfmill/NEWS
126
- ext/swfmill/README
127
- ext/swfmill/TODO
128
- ext/swfmill/aclocal.m4
129
- ext/swfmill/autogen.sh
130
- ext/swfmill/compile
131
- ext/swfmill/config.guess
132
- ext/swfmill/config.sub
133
- ext/swfmill/configure
134
- ext/swfmill/configure.ac
135
- ext/swfmill/depcomp
136
- ext/swfmill/install-sh
137
- ext/swfmill/ltmain.sh
138
- ext/swfmill/missing
139
- ext/swfmill/src
140
- ext/swfmill/src/Geom.cpp
141
- ext/swfmill/src/Geom.h
142
- ext/swfmill/src/Makefile.am
143
- ext/swfmill/src/Makefile.in
144
- ext/swfmill/src/SWF.h
145
- ext/swfmill/src/SWFAction.cpp
146
- ext/swfmill/src/SWFAction.h
147
- ext/swfmill/src/SWFBasic.h
148
- ext/swfmill/src/SWFFile.cpp
149
- ext/swfmill/src/SWFFile.h
150
- ext/swfmill/src/SWFFilter.cpp
151
- ext/swfmill/src/SWFFilter.h
152
- ext/swfmill/src/SWFGlyphList.cpp
153
- ext/swfmill/src/SWFGlyphList.h
154
- ext/swfmill/src/SWFIdItem.h
155
- ext/swfmill/src/SWFIdItems.h
156
- ext/swfmill/src/SWFItem.cpp
157
- ext/swfmill/src/SWFItem.h
158
- ext/swfmill/src/SWFList.h
159
- ext/swfmill/src/SWFReader.cpp
160
- ext/swfmill/src/SWFReader.h
161
- ext/swfmill/src/SWFShapeItem.cpp
162
- ext/swfmill/src/SWFShapeItem.h
163
- ext/swfmill/src/SWFShapeMaker.cpp
164
- ext/swfmill/src/SWFShapeMaker.h
165
- ext/swfmill/src/SWFTag.cpp
166
- ext/swfmill/src/SWFTag.h
167
- ext/swfmill/src/SWFTrait.cpp
168
- ext/swfmill/src/SWFTrait.h
169
- ext/swfmill/src/SWFWriter.cpp
170
- ext/swfmill/src/SWFWriter.h
171
- ext/swfmill/src/base64.c
172
- ext/swfmill/src/base64.h
173
- ext/swfmill/src/codegen
174
- ext/swfmill/src/codegen/Makefile.am
175
- ext/swfmill/src/codegen/Makefile.in
176
- ext/swfmill/src/codegen/basic.xsl
177
- ext/swfmill/src/codegen/basics.xsl
178
- ext/swfmill/src/codegen/dumper.xsl
179
- ext/swfmill/src/codegen/header.xsl
180
- ext/swfmill/src/codegen/mk.xsl
181
- ext/swfmill/src/codegen/parser.xsl
182
- ext/swfmill/src/codegen/parsexml.xsl
183
- ext/swfmill/src/codegen/size.xsl
184
- ext/swfmill/src/codegen/source.xml
185
- ext/swfmill/src/codegen/writer.xsl
186
- ext/swfmill/src/codegen/writexml.xsl
187
- ext/swfmill/src/swfmill.cpp
188
- ext/swfmill/src/swft
189
- ext/swfmill/src/swft/Makefile.am
190
- ext/swfmill/src/swft/Makefile.in
191
- ext/swfmill/src/swft/Parser.cpp
192
- ext/swfmill/src/swft/Parser.h
193
- ext/swfmill/src/swft/SVGAttributeParser.cpp
194
- ext/swfmill/src/swft/SVGAttributeParser.h
195
- ext/swfmill/src/swft/SVGColor.cpp
196
- ext/swfmill/src/swft/SVGColor.h
197
- ext/swfmill/src/swft/SVGColors.h
198
- ext/swfmill/src/swft/SVGGradient.cpp
199
- ext/swfmill/src/swft/SVGGradient.h
200
- ext/swfmill/src/swft/SVGPathParser.cpp
201
- ext/swfmill/src/swft/SVGPathParser.h
202
- ext/swfmill/src/swft/SVGPointsParser.cpp
203
- ext/swfmill/src/swft/SVGPointsParser.h
204
- ext/swfmill/src/swft/SVGStyle.cpp
205
- ext/swfmill/src/swft/SVGStyle.h
206
- ext/swfmill/src/swft/SVGTransformParser.cpp
207
- ext/swfmill/src/swft/SVGTransformParser.h
208
- ext/swfmill/src/swft/readpng.c
209
- ext/swfmill/src/swft/readpng.h
210
- ext/swfmill/src/swft/swft.cpp
211
- ext/swfmill/src/swft/swft.h
212
- ext/swfmill/src/swft/swft_document.cpp
213
- ext/swfmill/src/swft/swft_import.cpp
214
- ext/swfmill/src/swft/swft_import_binary.cpp
215
- ext/swfmill/src/swft/swft_import_jpeg.cpp
216
- ext/swfmill/src/swft/swft_import_mp3.cpp
217
- ext/swfmill/src/swft/swft_import_png.cpp
218
- ext/swfmill/src/swft/swft_import_ttf.cpp
219
- ext/swfmill/src/swft/swft_import_wav.cpp
220
- ext/swfmill/src/swft/swft_path.cpp
221
- ext/swfmill/src/xslt
222
- ext/swfmill/src/xslt/Makefile.am
223
- ext/swfmill/src/xslt/Makefile.in
224
- ext/swfmill/src/xslt/README
225
- ext/swfmill/src/xslt/assemble.xsl
226
- ext/swfmill/src/xslt/simple-deprecated.xslt
227
- ext/swfmill/src/xslt/simple-elements.xslt
228
- ext/swfmill/src/xslt/simple-import.xslt
229
- ext/swfmill/src/xslt/simple-svg.xslt
230
- ext/swfmill/src/xslt/simple-tools.xslt
231
- ext/swfmill/src/xslt/simple.cpp
232
- ext/swfmill/src/xslt/simple.xml
233
- ext/swfmill/src/xslt/xslt.h
234
- ext/swfmill/test
235
- ext/swfmill/test/Makefile.am
236
- ext/swfmill/test/Makefile.in
237
- ext/swfmill/test/xml
238
104
  ext/swfmill/test/xml/Makefile.am
239
105
  ext/swfmill/test/xml/Makefile.in
240
106
  ext/swfmill/test/xml/test-xml
@@ -8,22 +8,42 @@
8
8
 
9
9
  from stream
10
10
 
11
- xmlstr = Swfmill.load_stream(st) if st.responde_to?(:read)
11
+ xml = Swfmill.swf2xml(io) if io.responde_to?(:read)
12
12
 
13
- from file path
13
+ from String
14
14
 
15
- xmlstr = Swfmill.load_file("path/to/swf_file")
15
+ string = File.open("path/to/swf_file"){|st| st.read }
16
+ xml = Swfmill.swf2xml(string)
16
17
 
17
- from String
18
+ with encoding
19
+
20
+ xml = Swfmill.swf2xml(string, :e => "CP932")
21
+
22
+ or
18
23
 
19
- xmlstr = Swfmill.parse(File.open("path/to/swf_file"){|st| st.read })
24
+ xml = Swfmill.swf2xml(string, :encoding => "CP932")
20
25
 
21
26
  === to SWF Data(String)
22
27
 
23
- swf = Swfmill.publish(xmlstr)
28
+ from stream
29
+
30
+ swf = Swfmill.xml2swf(io) if io.responde_to?(:read)
31
+
32
+ from String
33
+
34
+ string = File.open("path/to/xml_file"){|st| st.read }
35
+ swf = Swfmill.xml2swf(string)
36
+
37
+ with encoding
38
+
39
+ xml = Swfmill.xml2swf(string, :e => "CP932")
40
+
41
+ or
42
+
43
+ xml = Swfmill.xml2swf(string, :encoding => "CP932")
24
44
 
25
45
  == Note on Patches/Pull Requests
26
-
46
+
27
47
  * Fork the project.
28
48
  * Make your feature addition or bug fix.
29
49
  * Add tests for it. This is important so I don't break it in a
@@ -34,4 +54,4 @@ from String
34
54
 
35
55
  == Copyright
36
56
 
37
- Copyright (c) 2010 fistfvck. See LICENSE for details.
57
+ Copyright (c) 2010 miyucy. See LICENSE for details.
data/Rakefile CHANGED
@@ -5,11 +5,11 @@ begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "swfmill"
8
- gem.summary = %Q{Ruby bindings for swfmill}
9
- gem.description = %Q{Ruby bindings for swfmill}
10
- gem.email = "fistfvck@gmail.com"
11
- gem.homepage = "http://github.com/fistfvck/swfmill"
12
- gem.authors = ["fistfvck"]
8
+ gem.summary = %Q{swfmill bindings for Ruby}
9
+ gem.description = %Q{swfmill bindings for Ruby}
10
+ gem.email = "miyucy@gmail.com"
11
+ gem.homepage = "http://github.com/miyucy/swfmill"
12
+ gem.authors = ["miyucy"]
13
13
  gem.add_development_dependency "rspec", ">= 1.2.9"
14
14
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
15
  gem.files << File.readlines(".swfmill").map{ |fn| fn.chomp }
@@ -51,6 +51,7 @@ file 'lib/swfmill_ext.so' => FileList['ext/extconf.rb', 'ext/Makefile', 'ext/*.c
51
51
  sh 'make'
52
52
  end
53
53
  sh 'mv ext/swfmill_ext.so lib/swfmill_ext.so'
54
+ sh 'strip lib/swfmill_ext.so'
54
55
  end
55
56
  file 'ext/Makefile' => 'ext/extconf.rb' do
56
57
  Dir.chdir('ext') do
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -3,3 +3,4 @@ mkmf.log
3
3
 
4
4
  *.o
5
5
  *.so
6
+ !test/Makefile
@@ -0,0 +1,95 @@
1
+ #ifndef _BUFFER_H_
2
+ #define _BUFFER_H_
3
+ #include <cstring>
4
+ #include <algorithm>
5
+
6
+ template <class T>
7
+ class buffer
8
+ {
9
+ public:
10
+
11
+ buffer(size_t init=INITIAL_SIZE)
12
+ : _data(NULL), _size(0), _capacity(init)
13
+ {
14
+ _data = new T[init];
15
+ }
16
+
17
+ buffer(const buffer<T>& other)
18
+ : _data(NULL), _size(0), _capacity(0)
19
+ {
20
+ _data = new T[other.size()];
21
+ _capacity = other.size();
22
+ append(other.ptr(), other.size());
23
+ }
24
+
25
+ virtual ~buffer()
26
+ {
27
+ delete[] _data;
28
+ }
29
+
30
+ const T* ptr() const
31
+ {
32
+ return _data;
33
+ }
34
+
35
+ const size_t size() const
36
+ {
37
+ return _size;
38
+ }
39
+
40
+ const size_t capacity() const
41
+ {
42
+ return _capacity;
43
+ }
44
+
45
+ const size_t reserve(const size_t length)
46
+ {
47
+ T* temp;
48
+
49
+ _capacity = length;
50
+ _size = std::min<size_t>(_size, length);
51
+
52
+ temp = new T[_capacity];
53
+ std::memcpy(temp, _data, _size);
54
+ delete[] _data;
55
+
56
+ _data = temp;
57
+ return _capacity;
58
+ }
59
+
60
+ const size_t resize(const size_t length)
61
+ {
62
+ expand(length - _size);
63
+ return _size = length;
64
+ }
65
+
66
+ size_t append(const T* const source, const size_t length)
67
+ {
68
+ expand(length);
69
+ std::memcpy(_data + _size, source, length);
70
+ return _size += length;
71
+ }
72
+
73
+ private:
74
+
75
+ void expand(size_t length)
76
+ {
77
+ if(need_reserve(length))
78
+ {
79
+ reserve(_capacity + length + length / 2);
80
+ }
81
+ }
82
+
83
+ bool need_reserve(size_t length) const
84
+ {
85
+ return _size + length >= _capacity;
86
+ }
87
+
88
+ static const size_t INITIAL_SIZE = 255;
89
+ T* _data;
90
+ size_t _size;
91
+ size_t _capacity;
92
+
93
+ };
94
+
95
+ #endif /* _BUFFER_H_ */
@@ -0,0 +1,125 @@
1
+ #ifndef _DEFLATE_H_
2
+ #define _DEFLATE_H_
3
+ #include <zlib.h>
4
+ #include "buffer.h"
5
+
6
+ class Deflate
7
+ {
8
+ public:
9
+
10
+ Deflate(const unsigned char* data, const size_t size, int compress_level=Z_BEST_COMPRESSION)
11
+ : _initialized(false), _temp(NULL), _compress_level(compress_level)
12
+ {
13
+ _data = const_cast<unsigned char*>(data);
14
+ _data_size = size;
15
+ _temp = new Bytef[size];
16
+ _temp_size = size;
17
+ }
18
+
19
+ ~Deflate()
20
+ {
21
+ finish();
22
+ delete[] _temp;
23
+ }
24
+
25
+ bool compress()
26
+ {
27
+ if(!init())
28
+ {
29
+ return false;
30
+ }
31
+
32
+ for(;;)
33
+ {
34
+ if(stream.avail_in == 0)
35
+ {
36
+ break;
37
+ }
38
+
39
+ if(deflate(&stream, Z_NO_FLUSH) != Z_OK)
40
+ {
41
+ return false;
42
+ }
43
+
44
+ size_t count = _temp_size - stream.avail_out;
45
+ if(count > 0)
46
+ {
47
+ _buff.append(_temp, count);
48
+ }
49
+
50
+ stream.next_out = _temp;
51
+ stream.avail_out = _temp_size;
52
+ }
53
+
54
+ int status;
55
+ do
56
+ {
57
+ status = deflate(&stream, Z_FINISH);
58
+
59
+ size_t count = _temp_size - stream.avail_out;
60
+ if(count > 0)
61
+ {
62
+ _buff.append(_temp, count);
63
+ }
64
+
65
+ stream.next_out = _temp;
66
+ stream.avail_out = _temp_size;
67
+ } while(status == Z_OK);
68
+
69
+ return status == Z_STREAM_END;
70
+ }
71
+
72
+ const char* error() const
73
+ {
74
+ return stream.msg;
75
+ }
76
+
77
+ const Bytef* data() const
78
+ {
79
+ return _buff.ptr();
80
+ }
81
+
82
+ const size_t size() const
83
+ {
84
+ return _buff.size();
85
+ }
86
+
87
+ private:
88
+
89
+ bool init()
90
+ {
91
+ if(_initialized)
92
+ {
93
+ return true;
94
+ }
95
+ stream.zalloc = Z_NULL;
96
+ stream.zfree = Z_NULL;
97
+ stream.opaque = Z_NULL;
98
+ stream.next_in = _data;
99
+ stream.avail_in = _data_size;
100
+ stream.next_out = _temp;
101
+ stream.avail_out = _temp_size;
102
+ return _initialized = deflateInit(&stream, _compress_level) == Z_OK;
103
+ }
104
+
105
+ bool finish()
106
+ {
107
+ if(_initialized)
108
+ {
109
+ return deflateEnd(&stream) == Z_OK;
110
+ }
111
+ return false;
112
+ }
113
+
114
+ z_stream stream;
115
+ buffer<Bytef> _buff;
116
+ unsigned char* _data;
117
+ size_t _data_size;
118
+ Bytef* _temp;
119
+ size_t _temp_size;
120
+ bool _initialized;
121
+ int _compress_level;
122
+
123
+ };
124
+
125
+ #endif /* _DEFLATE_H_ */