Skip to content

Commit

Permalink
hacked around the byte alignment. prints out labels in symbol class (…
Browse files Browse the repository at this point in the history
…code 76) tag
  • Loading branch information
Eric Chu committed Feb 13, 2010
1 parent 6e9cd84 commit 6bd92a8
Show file tree
Hide file tree
Showing 10 changed files with 747 additions and 1,810 deletions.
4 changes: 2 additions & 2 deletions advanced_file_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def eof?
end

def skip_to_next_byte
raise "Skipping more than a byte (#{buffer.size}) or buffer is nonzero (#{buffer}). " unless (@buffer.size < 8 && @buffer.to_i(2) == 0)
#puts "Skipping to next byte. Buffer size: #{buffer.size} #{buffer}"
raise "Skipping more than a byte (#{buffer.size}) or buffer is nonzero (#{buffer}). Bytes read so far: #{total_bytes_read}" unless (@buffer.size < 8 && @buffer.to_i(2) == 0)
puts "Skipping to next byte. Buffer size: #{buffer.size} #{buffer}"
@buffer = ''
end

Expand Down
8 changes: 4 additions & 4 deletions models/generic_records.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def initialize( f )
@blue_add_term = SwfMath.parse_signed_int( f.next_n_bits(nbits) )
end

f.skip_to_next_byte
#f.skip_to_next_byte
end

def to_xml
Expand Down Expand Up @@ -92,7 +92,7 @@ def to_xml
</color_transform>"
end

f.skip_to_next_byte
#f.skip_to_next_byte
end

def to_txt
Expand Down Expand Up @@ -140,7 +140,7 @@ def initialize( f )
@translate_y = SwfMath.parse_signed_int( f.next_n_bits(n_translate_bits) )
end

f.skip_to_next_byte
#f.skip_to_next_byte
end

def to_txt
Expand Down Expand Up @@ -172,7 +172,7 @@ def initialize( f )
@ymax = SwfMath.parse_signed_int( f.next_n_bits( num_bits ) )

# byte alignment
f.skip_to_next_byte
#f.skip_to_next_byte
end

def to_xml
Expand Down
12 changes: 12 additions & 0 deletions models/shape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,32 @@ def to_xml
end

def line_styles_xml
if(@line_styles)
return_val = "<line_styles>"
return_val += line_styles.map{ |line_style| line_style.to_xml }.join('')
return_val += "</line_styles>"
else
""
end
end

def fill_styles_xml
if(@fill_styles)
return_val = "<fill_styles>"
return_val += self.fill_styles.map{ |fill_style| fill_style.to_xml }.join('')
return_val += "</fill_styles>"
else
""
end
end

def shape_records_xml
if(@shape_records)
return_val = "<shape_records>"
return_val += self.shape_records.map{ |shape_record| shape_record.to_xml }.join('')
return_val += "</shape_records>"
else
""
end
end
end
13 changes: 13 additions & 0 deletions models/symbol_class_tag.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class SymbolClassTag
attr_accessor :num_symbols, :tag_ids, :tag_names

def to_xml
"<symbols num='#{num_symbols}'>
#{tags_to_xml}
</symbols>"
end
private
def tags_to_xml
return_val = tag_ids.each_with_index.map{ |id, i| "<symbol tag_id='#{id}' name='#{tag_names[i]}'/>" }.join("\n")
end
end
Loading

0 comments on commit 6bd92a8

Please sign in to comment.