Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Hillerson <tony.hillerson@gmail.com>
  • Loading branch information
Jacob Henry authored and thillerson committed Jan 20, 2009
1 parent 39ccebd commit 48cae1d
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 254 deletions.
2 changes: 1 addition & 1 deletion lib/amf.rb
@@ -1,7 +1,7 @@
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
$:.unshift "#{File.expand_path(File.dirname(__FILE__))}/amf/"

require "constants"
require 'amf/common'

module AMF
require 'amf/version'
Expand Down
15 changes: 12 additions & 3 deletions lib/amf/common.rb
Expand Up @@ -14,8 +14,8 @@ def deserializer=(deserializer) # :nodoc:
end

# Deserialize the AMF string _source_ into a Ruby data structure and return it.
def deserialize(source)
AMF.deserializer.new(source).deserialize
def deserialize(source, opts = {})
AMF.deserializer.new(source, opts).deserialize
end

# Returns the AMF serializer modul, that is used by AMF. This might be
Expand All @@ -39,7 +39,12 @@ def serializer=(serializer) # :nodoc:
end

# Serialize the Ruby data structure _obj_ into a single line AMF
def serialize(obj)
def serialize(obj, state = nil)
if state
state = State.from_state(state)
else
state = State.new
end
obj.to_amf()
end

Expand All @@ -58,6 +63,10 @@ def deep_const_get(path) # :nodoc:
end
end

# Returns the JSON generator state class, that is used by JSON. This might
# be either JSON::Ext::Generator::State or JSON::Pure::Generator::State.
attr_accessor :state

# This is create identifier, that is used to decide, if the _amf_create_
# hook of a class should be called. It defaults to 'amf_class'.
attr_accessor :create_id
Expand Down
50 changes: 23 additions & 27 deletions lib/amf/constants.rb
@@ -1,31 +1,27 @@
module AMF
module Constants
# Standard Types Markers
UNDEFINED_MARKER = "\000" #0x00
NULL_MARKER = "\001" #0x01
FALSE_MARKER = "\002" #0x02
TRUE_MARKER = "\003" #0x03
INTEGER_MARKER = "\004" #0x04
DOUBLE_MARKER = "\005" #0x05
STRING_MARKER = "\006" #0x06
XML_DOC_MARKER = "\a" #0x07
DATE_MARKER = "\b" #0x08
ARRAY_MARKER = "\t" #0x09
OBJECT_MARKER = "\n" #0x0A
XML_MARKER = "\v" #0x0B
BYTE_ARRAY_MARKER = "\f" #0x0C

# Standard Types Markers
UNDEFINED_MARKER = 0x00
NULL_MARKER = 0x01
FALSE_MARKER = 0x02
TRUE_MARKER = 0x03
INTEGER_MARKER = 0x04
DOUBLE_MARKER = 0x05
STRING_MARKER = 0x06
XML_DOC_MARKER = 0x07
DATE_MARKER = 0x08
ARRAY_MARKER = 0x09
OBJECT_MARKER = 0x0A
XML_MARKER = 0x0B
BYTE_ARRAY_MARKER = 0x0C

# Other Markers, some reused
EMPTY_STRING = NULL_MARKER
ONE = NULL_MARKER
ANONYMOUS_OBJECT = NULL_MARKER
DYNAMIC_OBJECT = XML_MARKER
CLOSE_DYNAMIC_OBJECT = NULL_MARKER
CLOSE_DYNAMIC_ARRAY = NULL_MARKER
# Other Markers, some reused
EMPTY_STRING = NULL_MARKER
ONE = NULL_MARKER
ANONYMOUS_OBJECT = NULL_MARKER
DYNAMIC_OBJECT = XML_MARKER
CLOSE_DYNAMIC_OBJECT = NULL_MARKER
CLOSE_DYNAMIC_ARRAY = NULL_MARKER

MAX_INTEGER = 268435455
MIN_INTEGER = -268435456

end
MAX_INTEGER = 268435455
MIN_INTEGER = -268435456
end

0 comments on commit 48cae1d

Please sign in to comment.