summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-06-12 22:48:37 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-06-12 22:48:37 -0700
commit7a1f2b7c9de07c25046be344ff438048e707a3e3 (patch)
tree73dbd9f77dd40da0276aa04169c85196d5933a46 /lib
parentb6de464bacfc3aac73d84468a074d2860df8c94f (diff)
downloadffi-yajl-7a1f2b7c9de07c25046be344ff438048e707a3e3.tar.gz
fixing state context in the c extension
just pass self through the context and then access state and ruby objects through the instance variables. question? what if the self object is moved by the garbage collector?
Diffstat (limited to 'lib')
-rw-r--r--lib/ffi_yajl/ffi/parser.rb15
-rw-r--r--lib/ffi_yajl/parser.rb16
2 files changed, 16 insertions, 15 deletions
diff --git a/lib/ffi_yajl/ffi/parser.rb b/lib/ffi_yajl/ffi/parser.rb
index 6674952..2e21627 100644
--- a/lib/ffi_yajl/ffi/parser.rb
+++ b/lib/ffi_yajl/ffi/parser.rb
@@ -4,14 +4,6 @@ require 'ffi_yajl/ffi'
module FFI_Yajl
module FFI
module Parser
- attr_accessor :stack, :key_stack, :key, :finished
-
- #
- # stack used to build up our complex object
- #
- def stack
- @stack ||= Array.new
- end
def set_value(val)
case stack.last
@@ -33,13 +25,6 @@ module FFI_Yajl
end
end
- #
- # stack to keep track of keys as we create nested hashes
- #
- def key_stack
- @key_stack ||= Array.new
- end
-
def key_push
key_stack.push(key)
end
diff --git a/lib/ffi_yajl/parser.rb b/lib/ffi_yajl/parser.rb
index ca47ed9..6465106 100644
--- a/lib/ffi_yajl/parser.rb
+++ b/lib/ffi_yajl/parser.rb
@@ -2,8 +2,24 @@
module FFI_Yajl
class ParseError < StandardError; end
class Parser
+ attr_accessor :stack, :key_stack, :key, :finished
+
attr_accessor :opts
+ #
+ # stack used to build up our complex object
+ #
+ def stack
+ @stack ||= Array.new
+ end
+
+ #
+ # stack to keep track of keys as we create nested hashes
+ #
+ def key_stack
+ @key_stack ||= Array.new
+ end
+
def self.parse(obj, *args)
new(*args).parse(obj)
end