
# fileIn("s8/library/sharing/Objectifier.st")
smalltalk.addClass("Objectifier",smalltalk.Object,["origin","objects","names","transforms","natives","useJSON"],"Objectifier")

smalltalk.bind(smalltalk.Objectifier.__class__,"constructEventsTriggered",0
,smalltalk.__f__("""(self):
	#Objectifier class>>#constructEventsTriggered
	return smalltalk.object_comma_(smalltalk.superReceiver(smalltalk.Objectifier.__class__,self).constructEventsTriggered(),smalltalk.newArray(["needsParser","getNames:from:","getTransforms:","adapt:shape:"])) 
""","Objectifier_class_constructEventsTriggered")
,"events","""constructEventsTriggered
	" Private - Return the events managed by instances of the receiver. "

	^super constructEventsTriggered
	,#(	#needsParser
		#getNames:from:
		#getTransforms:
		#adapt:shape:
	)""",nil)

smalltalk.bind(smalltalk.Objectifier.__class__,"@","_at"
,smalltalk.__f__("""(self,aLiteral):
	#Objectifier class>>#@
	return self.new().objectFrom_(aLiteral) 
""","Objectifier_class__at")
,"converting","""@ aLiteral
	" Returns a copy of an object sent from a remote system stringified into aLiteral. "

	^self new objectFrom: aLiteral""",nil)

smalltalk.bind(smalltalk.Objectifier.__class__,"from:",0
,smalltalk.__f__("""(self,source):
	#Objectifier class>>#from:
	def __blk1__(_s8_rec):
		_s8_rec.origin_(source) 
		return _s8_rec.yourself() 
	return __blk1__(self.new()) 
""","Objectifier_class_from_")
,"instantiation","""from: source
	" Returns an instance of the receiver. "

	^self new
		origin: source;
		yourself""",nil)

smalltalk.bind(smalltalk.Objectifier,"natives",0
,smalltalk.__f__("""(self):
	#Objectifier>>#natives
	if smalltalk.b(smalltalk.isNil_(getattr(self,"@natives",nil))):
		self.initializeNatives() 
	 
	return getattr(self,"@natives",nil) 
""","Objectifier_natives")
,"accessing","""natives
	" Private - Returns the natives of the receiver. "

	natives isNil ifTrue: [ self initializeNatives ].
	^natives""",nil)

smalltalk.bind(smalltalk.Objectifier,"platform",0
,smalltalk.__f__("""(self):
	#Objectifier>>#platform
	if smalltalk.b(smalltalk.Smalltalk.includesKey_(smalltalk.String("OrderedCollection"))):
		return smalltalk.String("VSE") 
	 
	return smalltalk.String("S8") 
""","Objectifier_platform")
,"constants","""platform
	" Private - Returns the platform selector. "

	(Smalltalk includesKey: #OrderedCollection) ifTrue: [ ^#VSE ].
	^#S8""",nil)

smalltalk.bind(smalltalk.Objectifier,"tagStart",0
,smalltalk.__f__("""(self):
	#Objectifier>>#tagStart
	return smalltalk.String(" ") 
""","Objectifier_tagStart")
,"constants","""tagStart
	" Private - Returns the tag start mask. "

	^' '""",nil)

smalltalk.bind(smalltalk.Objectifier,"objectFrom:",0
,smalltalk.__f__("""(self,aString):
	#Objectifier>>#objectFrom:
	return self.unMap_(self.mapFrom_(aString)) 
""","Objectifier_objectFrom_")
,"reading","""objectFrom: aString
	" Returns the next object read from aString literal. "

	^self unMap: (self mapFrom: aString)""",nil)

smalltalk.bind(smalltalk.Objectifier,"mapFrom:",0
,smalltalk.__f__("""(self,aString):
	_s8Ret_=smalltalk.newContext()
	try:
		#Objectifier>>#mapFrom:
		__0__=smalltalk.newContext()
		def __blk1__():
			def __blk2__(result):
				return smalltalk.raise_result_(_s8Ret_,result) 
			self.tryJSON_onSuccess_(aString,smalltalk.blk(__blk2__,1)) 
			return self 
		__0__.parser=nil
		smalltalk.basic_at_put(self,"@useJSON",smalltalk.false) 
		__0__.parser=self.triggerEvent_ifNotHandled_(smalltalk.String("needsParser"),smalltalk.blk(__blk1__,0)) 
		smalltalk.raise_result_(_s8Ret_,__0__.parser.parse_(aString)) 
	except Exception as __ex:
		if smalltalk.exception_at(__ex,_s8Ret_):
			return smalltalk.exceptionResult_(__ex)
		raise __ex
	
""","Objectifier_mapFrom_")
,"parsing","""mapFrom: aString
	" Private - Returns the map read from aString literal. "

	| parser |
	useJSON := false.
	parser := self triggerEvent: #needsParser ifNotHandled: [
		self tryJSON: aString onSuccess: [:result| ^result ].
		self
	].
	^parser parse: aString""",nil)

smalltalk.bind(smalltalk.Objectifier,"initializeNatives",0
,smalltalk.__f__("""(self):
	#Objectifier>>#initializeNatives
	smalltalk.basic_at_put(self,"@natives",smalltalk.PoolDictionary.new()) 
	if smalltalk.b(smalltalk.isObject_equalTo_(self.platform(),smalltalk.String("VSE"))):
		self.initializeVSEAccess() 
	else:
		self.initializeS8Access() 
	 
	return self 
""","Objectifier_initializeNatives")
,"initialize","""initializeNatives
	" Private - Initialize the native accessors. "

	natives := PoolDictionary new.
	self platform = #VSE
		ifTrue: [ self initializeVSEAccess ]
		ifFalse: [ self initializeS8Access ]""",nil)

smalltalk.bind(smalltalk.Objectifier,"poolIsObject",0
,smalltalk.__f__("""(self):
	#Objectifier>>#poolIsObject
	def __blk1__(obj):
		def __blk2__():
			def __blk3__():
				nil 
			return smalltalk.isObject_equalTo_(obj.at_ifAbsent_(smalltalk.String("objectifier_isObject"),smalltalk.blk(__blk3__,0)),self)._8not() 
		return smalltalk.boolean_or_(smalltalk.booleanNot_(obj.isMemberOf_(smalltalk.PoolDictionary)),smalltalk.blk(__blk2__,0)) 
	return smalltalk.blk(__blk1__,1) 
""","Objectifier_poolIsObject")
,"natives","""poolIsObject
	" Private - Returns the native accessor for isObject when using PoolDictionaries. "

	^[:obj|
		(obj isMemberOf: PoolDictionary) not or: [
			(obj at: #objectifier_isObject ifAbsent: []) ~= self
		]
	]""",nil)

smalltalk.bind(smalltalk.Objectifier,"s8IsObject",0
,smalltalk.__f__("""(self):
	#Objectifier>>#s8IsObject
	def __blk1__(obj):
		def __blk2__():
			getattr(self,"@natives",nil).removeKey_(smalltalk.String("isObject")) 
			return smalltalk.true 
		def __blk3__():
			getattr(self,"@natives",nil).at_put_(smalltalk.String("isObject"),self.poolIsObject()) 
			return self.poolIsObject().value_(obj) 
		return smalltalk.if_true_false_(smalltalk.booleanNot_(smalltalk.superReceiver(smalltalk.Objectifier,self).isObject_(obj)),smalltalk.blk(__blk2__,0),smalltalk.blk(__blk3__,0)) 
	return smalltalk.blk(__blk1__,1) 
""","Objectifier_s8IsObject")
,"natives","""s8IsObject
	" Private - Returns the native accessor for isObject. "

	^[:obj|
		(super isObject: obj) not ifTrue: [
			natives removeKey: #isObject.
			true
		] ifFalse: [
			natives at: #isObject put: self poolIsObject.
			self poolIsObject value: obj
		]
	]""",nil)

smalltalk.bind(smalltalk.Objectifier,"initializeVSEAccess",0
,smalltalk.__f__("""(self):
	#Objectifier>>#initializeVSEAccess
	def __blk1__(_s8_rec):
		def __blk2__(obj,key):
			def __blk3__():
				return smalltalk.basic_at_(obj,key) 
			def __blk4__():
				def __blk5__():
					return nil 
				return obj.at_ifAbsent_(key,smalltalk.blk(__blk5__,0)) 
			return smalltalk.if_true_false_(getattr(self,"@useJSON",nil),smalltalk.blk(__blk3__,0),smalltalk.blk(__blk4__,0)) 
		def __blk6__(obj,key):
			def __blk7__():
				return smalltalk.isObject_equalTo_(obj.copyFrom_to_(smalltalk.Number(1),key.size()),key) 
			return smalltalk.boolean_and_(obj.size()._gt_eq(key.size()),smalltalk.blk(__blk7__,0)) 
		_s8_rec.at_put_(smalltalk.String("get"),smalltalk.blk(__blk2__,2)) 
		_s8_rec.at_put_(smalltalk.String("isObject"),self.poolIsObject()) 
		_s8_rec.at_put_(smalltalk.String("startsWith"),smalltalk.blk(__blk6__,2)) 
		return _s8_rec.yourself() 
	__blk1__(getattr(self,"@natives",nil)) 
	return self 
""","Objectifier_initializeVSEAccess")
,"initialize","""initializeVSEAccess
	" Private - Initialize the native accessors. "

	natives
		at: #get put: [:obj :key|
			useJSON
			ifTrue:  [ obj basicAt: key ]
			ifFalse: [ obj at: key ifAbsent: [nil] ]
		];
		at: #isObject put: self poolIsObject;
		at: #startsWith put: [:obj :key|
			obj size >= key size and: [
				(obj copyFrom: 1 to: key size) = key
			]
		];
		yourself""",nil)

smalltalk.bind(smalltalk.Objectifier,"initializeS8Access",0
,smalltalk.__f__("""(self):
	#Objectifier>>#initializeS8Access
	def __blk1__(_s8_rec):
		def __blk2__(obj,key):
			def __blk3__():
				return smalltalk.basic_at_(obj,key) 
			def __blk4__():
				def __blk5__():
					return nil 
				return obj.at_ifAbsent_(key,smalltalk.blk(__blk5__,0)) 
			return smalltalk.if_true_false_(getattr(self,"@useJSON",nil),smalltalk.blk(__blk3__,0),smalltalk.blk(__blk4__,0)) 
		_s8_rec.at_put_(smalltalk.String("get"),smalltalk.blk(__blk2__,2)) 
		_s8_rec.at_put_(smalltalk.String("isObject"),self.s8IsObject()) 
		return _s8_rec.yourself() 
	__blk1__(getattr(self,"@natives",nil)) 
	return self 
""","Objectifier_initializeS8Access")
,"initialize","""initializeS8Access
	" Private - Initialize the native accessors. "

	natives
		at: #get put: [:obj :key|
			useJSON
			ifTrue:  [ obj basicAt: key ]
			ifFalse: [ obj at: key ifAbsent: [nil] ]
		];
		at: #isObject put: self s8IsObject;
		yourself""",nil)

smalltalk.bind(smalltalk.Objectifier,"value:for:with:",0
,smalltalk.__f__("""(self,access,object,argument):
	#Objectifier>>#value:for:with:
	return self.natives().at_(access).value_value_(object,argument) 
""","Objectifier_value_for_with_")
,"natives","""value: access for: object with: argument
	" Private - Returns the value of access the (native)object with argument. "

	^(self natives at: access) value: object value: argument""",nil)

smalltalk.bind(smalltalk.Objectifier,"readStream:",0
,smalltalk.__f__("""(self,source):
	_s8Ret_=smalltalk.newContext()
	try:
		#Objectifier>>#readStream:
		__0__=smalltalk.newContext()
		def __blk1__():
			return smalltalk.raise_result_(_s8Ret_,source.stream()) 
		__0__.support=nil
		__0__.support=smalltalk.Smalltalk.at_ifAbsent_(smalltalk.String("ReadStream"),smalltalk.blk(__blk1__,0)) 
		smalltalk.raise_result_(_s8Ret_,__0__.support.on_(source)) 
	except Exception as __ex:
		if smalltalk.exception_at(__ex,_s8Ret_):
			return smalltalk.exceptionResult_(__ex)
		raise __ex
	
""","Objectifier_readStream_")
,"natives","""readStream: source
	" Private - Returns a read stream on source. "

	| support |
	support := Smalltalk at: #ReadStream ifAbsent: [ ^source stream ].
	^support on: source""",nil)

smalltalk.bind(smalltalk.Objectifier,"writeStreamOn:",0
,smalltalk.__f__("""(self,container):
	_s8Ret_=smalltalk.newContext()
	try:
		#Objectifier>>#writeStreamOn:
		__0__=smalltalk.newContext()
		def __blk1__():
			return smalltalk.raise_result_(_s8Ret_,container.writeStream()) 
		__0__.support=nil
		__0__.support=smalltalk.Smalltalk.at_ifAbsent_(smalltalk.String("WriteStream"),smalltalk.blk(__blk1__,0)) 
		smalltalk.raise_result_(_s8Ret_,__0__.support.on_(container)) 
	except Exception as __ex:
		if smalltalk.exception_at(__ex,_s8Ret_):
			return smalltalk.exceptionResult_(__ex)
		raise __ex
	
""","Objectifier_writeStreamOn_")
,"natives","""writeStreamOn: container
	" Private - Returns a write stream on container. "

	| support |
	support := Smalltalk at: #WriteStream ifAbsent: [ ^container writeStream ].
	^support on: container""",nil)

smalltalk.bind(smalltalk.Objectifier,"isObject:",0
,smalltalk.__f__("""(self,object):
	_s8Ret_=smalltalk.newContext()
	try:
		#Objectifier>>#isObject:
		__0__=smalltalk.newContext()
		def __blk1__():
			return smalltalk.raise_result_(_s8Ret_,smalltalk.superReceiver(smalltalk.Objectifier,self).isObject_(object)) 
		__0__.block=nil
		__0__.block=self.natives().at_ifAbsent_(smalltalk.String("isObject"),smalltalk.blk(__blk1__,0)) 
		smalltalk.raise_result_(_s8Ret_,__0__.block.value_(object)) 
	except Exception as __ex:
		if smalltalk.exception_at(__ex,_s8Ret_):
			return smalltalk.exceptionResult_(__ex)
		raise __ex
	
""","Objectifier_isObject_")
,"natives","""isObject: object
	" Private - Returns true if object is a (non-native)object. "

	| block |
	block := self natives at: #isObject ifAbsent: [ ^super isObject: object ].
	^block value: object""",nil)

smalltalk.bind(smalltalk.Objectifier,"starts:with:",0
,smalltalk.__f__("""(self,string,key):
	_s8Ret_=smalltalk.newContext()
	try:
		#Objectifier>>#starts:with:
		__0__=smalltalk.newContext()
		def __blk1__():
			return smalltalk.raise_result_(_s8Ret_,string.startsWith_(key)) 
		__0__.block=nil
		__0__.block=self.natives().at_ifAbsent_(smalltalk.String("startsWith"),smalltalk.blk(__blk1__,0)) 
		smalltalk.raise_result_(_s8Ret_,__0__.block.value_value_(string,key)) 
	except Exception as __ex:
		if smalltalk.exception_at(__ex,_s8Ret_):
			return smalltalk.exceptionResult_(__ex)
		raise __ex
	
""","Objectifier_starts_with_")
,"natives","""starts: string with: key
	" Private - Returns true if string starts with key. "

	| block |
	block := self natives at: #startsWith ifAbsent: [ ^string startsWith: key ].
	^block value: string value: key""",nil)

smalltalk.bind(smalltalk.Objectifier,"basic:at:",0
,smalltalk.__f__("""(self,object,key):
	#Objectifier>>#basic:at:
	return self.value_for_with_(smalltalk.String("get"),object,key) 
""","Objectifier_basic_at_")
,"natives","""basic: object at: key
	" Private - Returns the result of indexing the (native)object with a key. "

	^self value: #get for: object with: key""",nil)

smalltalk.bind(smalltalk.Objectifier,"tryJSON:onSuccess:",0
,smalltalk.__f__("""(self,aString,aBlock):
	#Objectifier>>#tryJSON:onSuccess:
	__0__=smalltalk.newContext()
	__0__.json=nil
	__0__.result=nil
	if smalltalk.b(smalltalk.responds_to_(smalltalk.Smalltalk,(smalltalk.String("nativeObjectAt:ifAbsent:")))):
		def __blk1__():
			nil 
		__0__.json=smalltalk.Smalltalk.nativeObjectAt_ifAbsent_(smalltalk.String("JSON"),smalltalk.blk(__blk1__,0)) 
	 
	if smalltalk.b(smalltalk.notNil_(__0__.json)):
		smalltalk.basic_at_put(self,"@useJSON",smalltalk.true) 
		__0__.result=self.basic_at_(__0__.json,smalltalk.String("parse")).value_(aString) 
		return aBlock.value_(__0__.result) 
	 
	return nil 
""","Objectifier_tryJSON_onSuccess_")
,"parsing","""tryJSON: aString onSuccess: aBlock
	" Private - Try to read a map from aString literal using JSON support.
	Evaluates aBlock on success.
	"

	| json result |
	(Smalltalk respondsTo: #nativeObjectAt:ifAbsent:) ifTrue: [
		json := Smalltalk nativeObjectAt: #JSON ifAbsent: []
	].
	json notNil ifTrue: [
		useJSON := true.
		result := (self basic: json at: #parse) value: aString.
		^aBlock value: result
	].
	^nil""",nil)

smalltalk.bind(smalltalk.Objectifier,"names",0
,smalltalk.__f__("""(self):
	#Objectifier>>#names
	if smalltalk.b(smalltalk.notNil_(getattr(self,"@names",nil))):
		return getattr(self,"@names",nil) 
	 
	smalltalk.basic_at_put(self,"@names",smalltalk.PoolDictionary.new()) 
	if smalltalk.b(smalltalk.isObject_equalTo_(self.platform(),smalltalk.String("VSE"))):
		self.setDefaultVSENames() 
	else:
		self.setDefaultS8Names() 
	 
	self.triggerEvent_withArguments_(smalltalk.String("getNames:from:"),smalltalk.Array.with_with_(getattr(self,"@names",nil),getattr(self,"@origin",nil))) 
	return getattr(self,"@names",nil) 
""","Objectifier_names")
,"names","""names
	" Private - Returns the well known names map. "

	names notNil ifTrue: [ ^names ].
	names := PoolDictionary new.
	self platform = #VSE
		ifTrue: [ self setDefaultVSENames ]
		ifFalse: [ self setDefaultS8Names ].
	self	triggerEvent: #getNames:from:
		withArguments: (Array with: names with: origin).
	^names""",nil)

smalltalk.bind(smalltalk.Objectifier,"setDefaultS8Names",0
,smalltalk.__f__("""(self):
	#Objectifier>>#setDefaultS8Names
	def __blk1__(_s8_rec):
		def __blk2__(json):
			return self.instantiateCharacter_(json) 
		_s8_rec.at_put_(smalltalk.String("OrderedCollection"),smalltalk.String("Array")) 
		_s8_rec.at_put_(smalltalk.String("Set"),smalltalk.String("HashedSet")) 
		_s8_rec.at_put_(smalltalk.String("Character"),smalltalk.blk(__blk2__,1)) 
		_s8_rec.at_put_(smalltalk.String("TimeStamp"),smalltalk.String("DateTime")) 
		return _s8_rec.yourself() 
	__blk1__(getattr(self,"@names",nil)) 
	return self 
""","Objectifier_setDefaultS8Names")
,"initialize","""setDefaultS8Names
	" Private - Register well known names used for instantiation mappings. "

	names	at: #OrderedCollection put: #Array;
		at: #Set put: #HashedSet;
		at: #Character put: [:json| self instantiateCharacter: json ];
		at: #TimeStamp put: #DateTime;
		yourself""",nil)

smalltalk.bind(smalltalk.Objectifier,"setDefaultVSENames",0
,smalltalk.__f__("""(self):
	#Objectifier>>#setDefaultVSENames
	def __blk1__(_s8_rec):
		_s8_rec.at_put_(smalltalk.String("DateTime"),smalltalk.String("TimeStamp")) 
		return _s8_rec.yourself() 
	__blk1__(getattr(self,"@names",nil)) 
	return self 
""","Objectifier_setDefaultVSENames")
,"initialize","""setDefaultVSENames
	" Private - Register well known names used for instantiation mappings. "

	names	at: #DateTime put: #TimeStamp;
		yourself""",nil)

smalltalk.bind(smalltalk.Objectifier,"transforms",0
,smalltalk.__f__("""(self):
	#Objectifier>>#transforms
	if smalltalk.b(smalltalk.notNil_(getattr(self,"@transforms",nil))):
		return getattr(self,"@transforms",nil) 
	 
	smalltalk.basic_at_put(self,"@transforms",smalltalk.PoolDictionary.new()) 
	if smalltalk.b(smalltalk.isObject_equalTo_(self.platform(),smalltalk.String("VSE"))):
		self.setDefaultVSETransforms() 
	else:
		self.setDefaultS8Transforms() 
	 
	self.triggerEvent_(smalltalk.String("getTransforms")) 
	return getattr(self,"@transforms",nil) 
""","Objectifier_transforms")
,"transforms","""transforms
	" Private - Returns the transforms used to fill concrete instances from structure. "

	transforms notNil ifTrue: [ ^transforms ].
	transforms := PoolDictionary new.
	self platform = #VSE
		ifTrue: [ self setDefaultVSETransforms ]
		ifFalse: [ self setDefaultS8Transforms ].
	self triggerEvent: #getTransforms.
	^transforms""",nil)

smalltalk.bind(smalltalk.Objectifier,"setDefaultS8Transforms",0
,smalltalk.__f__("""(self):
	#Objectifier>>#setDefaultS8Transforms
	__0__=smalltalk.newContext()
	def __blk1__(_s8_rec):
		def __blk2__(oid,object,json,varNames):
			__2__=smalltalk.newContext()
			def __blk3__(i):
				return object.at_put_(i,self.object_(__2__.contents.at_(i))) 
			__2__.contents=nil
			__2__.contents=self.basic_at_(json,smalltalk.String("contents")) 
			if smalltalk.b(smalltalk.isNil_(__2__.contents)):
				self.error_(smalltalk.String("Missing Array contents")) 
			 
			return smalltalk.Number(1).to_do_(__2__.contents.size(),smalltalk.blk(__blk3__,1)) 
		def __blk4__(oid,object,json,varNames):
			nil 
		def __blk5__(oid,object,json,varNames):
			return object.initialize_(self.object_(self.basic_at_(json,smalltalk.String("contents")))) 
		def __blk6__(oid,object,json,varNames):
			return self.id_is_(oid,__0__.dateTimeSupport.fromString_(self.basic_at_(json,smalltalk.String("contents")))) 
		_s8_rec.at_put_(smalltalk.String("Array"),smalltalk.blk(__blk2__,4)) 
		_s8_rec.at_put_(smalltalk.String("String"),smalltalk.blk(__blk4__,4)) 
		_s8_rec.at_put_(smalltalk.String("HashedSet"),smalltalk.blk(__blk5__,4)) 
		_s8_rec.at_put_(smalltalk.String("DateTime"),smalltalk.blk(__blk6__,4)) 
		return _s8_rec.yourself() 
	__0__.dateTimeSupport=nil
	__0__.dateTimeSupport=smalltalk.Smalltalk.at_(smalltalk.String("DateTime")) 
	__blk1__(getattr(self,"@transforms",nil)) 
	return self 
""","Objectifier_setDefaultS8Transforms")
,"initialize","""setDefaultS8Transforms
	" Private - Register default transforms to fill instances from structures. "

	| dateTimeSupport |
	dateTimeSupport := Smalltalk at: #DateTime.
	transforms
		at: #Array put: [:oid :object :json :varNames | | contents |
			contents := self basic: json at: #contents.
			contents isNil ifTrue: [ self error: 'Missing Array contents' ].
			1 to: contents size do: [:i|
				object at: i put: (self object: (contents at: i))
			].
		];
		at: #String put: [:oid :object :json :varNames | "nothing to do" ];
		at: #HashedSet put: [:oid :object :json :varNames |
			object initialize: (self object: (self basic: json at: #contents))
		];
		at: #DateTime put: [:oid :object :json :varNames |
			self id: oid is: (dateTimeSupport fromString: (self basic: json at: #contents))
		];
		yourself""",nil)

smalltalk.bind(smalltalk.Objectifier,"setDefaultVSETransforms",0
,smalltalk.__f__("""(self):
	#Objectifier>>#setDefaultVSETransforms
	def __blk1__(_s8_rec):
		def __blk2__(oid,proto,json,varNames):
			__2__=smalltalk.newContext()
			def __blk3__(i):
				return __2__.object.at_put_(i,self.object_(__2__.contents.at_(i))) 
			__2__.object=nil
			__2__.contents=nil
			__2__.contents=self.basic_at_(json,smalltalk.String("contents")) 
			if smalltalk.b(smalltalk.isNil_(__2__.contents)):
				self.error_(smalltalk.String("Missing Array contents")) 
			 
			__2__.object=smalltalk.Array.new_(__2__.contents.size()) 
			self.id_is_(oid,__2__.object) 
			return smalltalk.Number(1).to_do_(__2__.contents.size(),smalltalk.blk(__blk3__,1)) 
		def __blk4__(oid,object,json,varNames):
			return object.addAll_(self.object_(self.basic_at_(json,smalltalk.String("contents")))) 
		def __blk5__(oid,object,json,varNames):
			def __blk6__(assoc):
				return object.at_put_(assoc.key(),assoc.value()) 
			return self.object_(self.basic_at_(json,smalltalk.String("associations"))).do_(smalltalk.blk(__blk6__,1)) 
		def __blk7__(oid,object,json,varNames):
			return self.timeStamp_from_(object,self.basic_at_(json,smalltalk.String("contents"))) 
		_s8_rec.at_put_(smalltalk.String("Array"),smalltalk.blk(__blk2__,4)) 
		_s8_rec.at_put_(smalltalk.String("Set"),smalltalk.blk(__blk4__,4)) 
		_s8_rec.at_put_(smalltalk.String("PoolDictionary"),smalltalk.blk(__blk5__,4)) 
		_s8_rec.at_put_(smalltalk.String("TimeStamp"),smalltalk.blk(__blk7__,4)) 
		return _s8_rec.yourself() 
	__blk1__(getattr(self,"@transforms",nil)) 
	return self 
""","Objectifier_setDefaultVSETransforms")
,"initialize","""setDefaultVSETransforms
	" Private - Register default transforms to fill instances from structures. "

	transforms
		at: #Array put: [:oid :proto :json :varNames | | object contents |
			contents := self basic: json at: #contents.
			contents isNil ifTrue: [ self error: 'Missing Array contents' ].
			object := Array new: contents size.
			self id: oid is: object.
			1 to: contents size do: [:i|
				object at: i put: (self object: (contents at: i))
			].
		];
		at: #Set put: [:oid :object :json :varNames |
			object addAll: (self object: (self basic: json at: #contents))
		];
		at: #PoolDictionary put: [:oid :object :json :varNames |
			(self object: (self basic: json at: #associations)) do: [:assoc|
				object at: assoc key put: assoc value
			]
		];
		at: #TimeStamp put: [:oid :object :json :varNames |
			self timeStamp: object from: (self basic: json at: #contents)
		];
		yourself""",nil)

smalltalk.bind(smalltalk.Objectifier,"timeStamp:from:",0
,smalltalk.__f__("""(self,ts,contents):
	#Objectifier>>#timeStamp:from:
	__0__=smalltalk.newContext()
	__0__.aStream=nil
	__0__.yyyy=nil
	__0__.mm=nil
	__0__.dd=nil
	__0__.hh=nil
	__0__.ss=nil
	__0__.aStream=contents.asStream() 
	__0__.yyyy=__0__.aStream.upTo_(smalltalk.String("/")) 
	__0__.mm=__0__.aStream.upTo_(smalltalk.String("/")) 
	__0__.dd=__0__.aStream.upTo_(smalltalk.String(" ")) 
	ts.date_(smalltalk.Date.fromString_(smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.object_comma_(__0__.dd,smalltalk.String("-")),__0__.mm),smalltalk.String("-")),__0__.yyyy))) 
	__0__.hh=__0__.aStream.upTo_(smalltalk.String(":")).asInteger() 
	__0__.mm=__0__.aStream.upTo_(smalltalk.String(":")).asInteger() 
	__0__.ss=__0__.aStream.upTo_(nil).asInteger() 
	ts.time_(smalltalk.Time.hours_minutes_seconds_(__0__.hh,__0__.mm,__0__.ss)) 
	return self 
""","Objectifier_timeStamp_from_")
,"converting","""timeStamp: ts from: contents
	" Private - Read a TimeStamp instance from contents. "

	| aStream yyyy mm dd hh ss |
	aStream := contents asStream.
	yyyy := aStream upTo: $/.
	mm := aStream upTo: $/.
	dd := aStream upTo: $ .
	ts date: (Date fromString: dd ,'-' ,mm ,'-' ,yyyy).
	hh := (aStream upTo: $:) asInteger.
	mm := (aStream upTo: $:) asInteger.
	ss := (aStream upTo: nil) asInteger.
	ts time: (Time hours: hh minutes: mm seconds: ss)""",nil)

smalltalk.bind(smalltalk.Objectifier,"shapeValidatingTransform",0
,smalltalk.__f__("""(self):
	#Objectifier>>#shapeValidatingTransform
	def __blk1__(oid,object,json,varNames):
		__1__=smalltalk.newContext()
		def __blk2__():
			return self.error_(smalltalk.String("Invalid shape")) 
		__1__.transform=nil
		self.validateClass_shape_((object).__class__,varNames) 
		__1__.transform=getattr(self,"@transforms",nil).at_ifAbsent_((object).__class__.name(),smalltalk.blk(__blk2__,0)) 
		return __1__.transform.valueWithArguments_(smalltalk.Array.with_with_with_with_(oid,object,json,varNames)) 
	return smalltalk.blk(__blk1__,4) 
""","Objectifier_shapeValidatingTransform")
,"transforms","""shapeValidatingTransform
	" Private - Returns the transform to apply to fill instances from structures, validating class shape. "

	^[:oid :object :json :varNames | | transform |
		self validateClass: object class shape: varNames.
		transform := transforms at: object class name ifAbsent: [
			self error: 'Invalid shape'
		].
		transform valueWithArguments: (Array
			with: oid with: object
			with: json with: varNames)
	]""",nil)

smalltalk.bind(smalltalk.Objectifier,"copyTransform",0
,smalltalk.__f__("""(self):
	#Objectifier>>#copyTransform
	if smalltalk.b(smalltalk.isObject_equalTo_(self.platform(),smalltalk.String("VSE"))):
		return self.copyTransformVSE() 
	 
	return self.copyTransformS8() 
""","Objectifier_copyTransform")
,"transforms","""copyTransform
	" Private - Returns the transform to apply to fill instances from structures. "

	self platform = #VSE ifTrue: [ ^self copyTransformVSE ].
	^self copyTransformS8""",nil)

smalltalk.bind(smalltalk.Objectifier,"copyTransformS8",0
,smalltalk.__f__("""(self):
	#Objectifier>>#copyTransformS8
	def __blk1__(oid,object,json,varNames):
		def __blk2__(i):
			__2__=smalltalk.newContext()
			__2__.key=nil
			__2__.value=nil
			__2__.key=varNames.at_(i) 
			__2__.value=self.object_(self.basic_at_(json,smalltalk.to_String(i))) 
			return object.instVarAt_put_(__2__.key,__2__.value) 
		return smalltalk.Number(1).to_do_(varNames.size(),smalltalk.blk(__blk2__,1)) 
	return smalltalk.blk(__blk1__,4) 
""","Objectifier_copyTransformS8")
,"transforms","""copyTransformS8
	" Private - Returns the transform to apply to fill instances from structures. "

	^[:oid :object :json :varNames |
		1 to: varNames size do: [:i| | key value |
			key := varNames at: i.
			value := self object: (self basic: json at: i toString).
			object instVarAt: key put: value
		]
	]""",nil)

smalltalk.bind(smalltalk.Objectifier,"copyTransformVSE",0
,smalltalk.__f__("""(self):
	#Objectifier>>#copyTransformVSE
	def __blk1__(oid,object,json,varNames):
		__1__=smalltalk.newContext()
		def __blk2__(i):
			__2__=smalltalk.newContext()
			def __blk3__():
				__2__.value=self.object_(self.basic_at_(json,__2__.index)) 
				return object.instVarAt_put_(i,__2__.value) 
			__2__.key=nil
			__2__.index=nil
			__2__.value=nil
			__2__.key=__1__.all.at_(i) 
			__2__.index=varNames.indexOf_(__2__.key) 
			return smalltalk.if_true_false_(__2__.index._gt(smalltalk.Number(0)),smalltalk.blk(__blk3__,0),nil) 
		__1__.all=nil
		__1__.all=(object).__class__.allInstVarNames() 
		return smalltalk.Number(1).to_do_(__1__.all.size(),smalltalk.blk(__blk2__,1)) 
	return smalltalk.blk(__blk1__,4) 
""","Objectifier_copyTransformVSE")
,"transforms","""copyTransformVSE
	" Private - Returns the transform to apply to fill instances from structures. "

	^[:oid :object :json :varNames | | all |
		all := object class allInstVarNames.
		1 to: all size do: [:i| | key index value |
			key := all at: i.
			index := varNames indexOf: key.
			index > 0 ifTrue: [
				value := self object: (self basic: json at: index).
				object instVarAt: i put: value
			].
		].
	]""",nil)

smalltalk.bind(smalltalk.Objectifier,"validateClass:shape:",0
,smalltalk.__f__("""(self,aClass,varNames):
	#Objectifier>>#validateClass:shape:
	__0__=smalltalk.newContext()
	__0__.all=nil
	__0__.missing=nil
	if smalltalk.b(smalltalk.notNil_(varNames)):
		def __blk1__():
			return varNames.size()._gt(smalltalk.Number(0)) 
		def __blk2__():
			def __blk3__(each):
				return varNames.includes_(each) 
			def __blk4__(each):
				return __0__.all.includes_(each) 
			def __blk5__():
				def __blk6__():
					return self.error_(smalltalk.object_comma_(smalltalk.String("Missing structure variables "),smalltalk.asString_(__0__.missing))) 
				return self.triggerEvent_withArguments_ifNotHandled_(smalltalk.String("adapt:shape:"),smalltalk.Array.with_with_(aClass,varNames),smalltalk.blk(__blk6__,0)) 
			__0__.missing=__0__.all.reject_(smalltalk.blk(__blk3__,1)) 
			if smalltalk.b(__0__.missing.notEmpty()):
				def __blk7__():
					return self.error_(smalltalk.object_comma_(smalltalk.String("Missing class variables "),smalltalk.asString_(__0__.missing))) 
				self.triggerEvent_withArguments_ifNotHandled_(smalltalk.String("adapt:shape:"),smalltalk.Array.with_with_(aClass,varNames),smalltalk.blk(__blk7__,0)) 
			 
			__0__.missing=varNames.reject_(smalltalk.blk(__blk4__,1)) 
			return smalltalk.if_true_false_(__0__.missing.notEmpty(),smalltalk.blk(__blk5__,0),nil) 
		__0__.all=aClass.allInstVarNames() 
		smalltalk.if_true_false_(smalltalk.boolean_or_(__0__.all.notEmpty(),smalltalk.blk(__blk1__,0)),smalltalk.blk(__blk2__,0),nil) 
	 
	getattr(self,"@transforms",nil).at_put_(aClass.name(),self.copyTransform()) 
	return self 
""","Objectifier_validateClass_shape_")
,"validation","""validateClass: aClass shape: varNames
	" Private - Validate shape of aClass to be mapped to varNames. "

	| all missing |
	varNames notNil ifTrue: [
		all := aClass allInstVarNames.
		(all notEmpty or: [varNames size > 0]) ifTrue: [
			missing := all reject: [:each| varNames includes: each ].
			missing notEmpty ifTrue: [
				self	triggerEvent: #adapt:shape:
					withArguments: (Array with: aClass with: varNames)
					ifNotHandled: [ self error: 'Missing class variables ' ,missing asString ]
			].
			missing := varNames reject: [:each| all includes: each ].
			missing notEmpty ifTrue: [
				self	triggerEvent: #adapt:shape:
					withArguments: (Array with: aClass with: varNames)
					ifNotHandled: [ self error: 'Missing structure variables ' ,missing asString ]
			].
		].
	].
	transforms at: aClass name put: self copyTransform""",nil)

smalltalk.bind(smalltalk.Objectifier,"unMap:",0
,smalltalk.__f__("""(self,aMap):
	#Objectifier>>#unMap:
	__0__=smalltalk.newContext()
	__0__.sender=nil
	__0__.sender=self.basic_at_(aMap,smalltalk.String("origin")) 
	if smalltalk.b(smalltalk.notNil_(__0__.sender)):
		__0__.sender=__0__.sender.asSymbol() 
	 
	if smalltalk.b(smalltalk.notNil_(getattr(self,"@origin",nil))):
		def __blk1__():
			return self.error_(smalltalk.String("Invalid origin")) 
		smalltalk.if_true_false_(smalltalk.isObject_equalTo_(getattr(self,"@origin",nil),__0__.sender),nil,smalltalk.blk(__blk1__,0)) 
	else:
		smalltalk.basic_at_put(self,"@origin",__0__.sender) 
	 
	if smalltalk.b(smalltalk.isNil_(getattr(self,"@objects",nil))):
		__1__=smalltalk.newContext()
		__1__.count=nil
		__1__.count=self.basic_at_(aMap,smalltalk.String("id")) 
		smalltalk.basic_at_put(self,"@objects",smalltalk.Array.new_(__1__.count)) 
		getattr(self,"@objects",nil).atAllPut_(smalltalk.String("missing")) 
	 
	return self.object_(self.basic_at_(aMap,smalltalk.String("contents"))) 
""","Objectifier_unMap_")
,"converting","""unMap: aMap
	" Private - Returns the object instantiated from aMap. "

	| sender |
	sender := self basic: aMap at: #origin.
	sender notNil ifTrue: [ sender := sender asSymbol ].
	origin notNil ifTrue: [
		origin = sender ifFalse: [ self error: 'Invalid origin' ]
	] ifFalse: [ origin := sender ].
	objects isNil ifTrue: [ | count |
		count := self basic: aMap at: #id.
		objects := Array new: count.
		objects atAllPut: #missing.
	].
	^self object: (self basic: aMap at: #contents)""",nil)

smalltalk.bind(smalltalk.Objectifier,"withRef:do:",0
,smalltalk.__f__("""(self,json,aBlock):
	_s8Ret_=smalltalk.newContext()
	try:
		#Objectifier>>#withRef:do:
		def __blk1__():
			return json.isString() 
		if smalltalk.b(smalltalk.boolean_and_(self.isObject_(json),smalltalk.blk(__blk1__,0))):
			def __blk2__():
				__2__=smalltalk.newContext()
				__2__.refID=nil
				__2__.refID=json.copyFrom_to_(self.tagStart().size()._plus(smalltalk.Number(1)),json.size()) 
				return smalltalk.raise_result_(_s8Ret_,aBlock.value_(self.ref_(__2__.refID))) 
			smalltalk.if_true_false_(self.starts_with_(json,self.tagStart()),smalltalk.blk(__blk2__,0),nil) 
		 
		smalltalk.raise_result_(_s8Ret_,json) 
	except Exception as __ex:
		if smalltalk.exception_at(__ex,_s8Ret_):
			return smalltalk.exceptionResult_(__ex)
		raise __ex
	
""","Objectifier_withRef_do_")
,"references","""withRef: json do: aBlock
	" Private - Returns the result of evaluating aBlock with reference to known object (or json). "

	((self isObject: json) and: [json isString]) ifTrue: [
		(self starts: json with: self tagStart) ifTrue: [ | refID |
			refID := json copyFrom: self tagStart size + 1 to: json size.
			^aBlock value: (self ref: refID)
		].
	].
	^json""",nil)

smalltalk.bind(smalltalk.Objectifier,"object:",0
,smalltalk.__f__("""(self,json):
	#Objectifier>>#object:
	def __blk1__(anObject):
		return anObject 
	if smalltalk.b(smalltalk.isNil_(json)):
		return nil 
	 
	if not smalltalk.b(self.isObject_(json)):
		return self.newObject_(json) 
	 
	if smalltalk.b(json.isArray()):
		def __blk2__(each):
			return self.object_(each) 
		return json.collect_(smalltalk.blk(__blk2__,1)) 
	 
	return self.withRef_do_(json,smalltalk.blk(__blk1__,1)) 
""","Objectifier_object_")
,"converting","""object: json
	" Private - Returns the object instantiated from json. "

	json isNil ifTrue: [ ^nil ].
	(self isObject: json) ifFalse: [ ^self newObject: json ].
	json isArray ifTrue: [ ^json collect: [:each| self object: each ] ].
	^self withRef: json do: [:anObject| anObject ]""",nil)

smalltalk.bind(smalltalk.Objectifier,"instantiate:with:allInstVarNames:",0
,smalltalk.__f__("""(self,instantiator,json,varNames):
	#Objectifier>>#instantiate:with:allInstVarNames:
	if not smalltalk.b(smalltalk.is_kindOf_(instantiator,(smalltalk.Behavior))):
		return instantiator.value_(json) 
	 
	if smalltalk.b(instantiator.inheritsFrom_(smalltalk.Collection)):
		return instantiator.new() 
	 
	if not smalltalk.b(instantiator.isClass()):
		return self.error_(smalltalk.String("Must be a class")) 
	 
	return instantiator.basicNew() 
""","Objectifier_instantiate_with_allInstVarNames_")
,"instantiating","""instantiate: instantiator with: json allInstVarNames: varNames
	" Private - Returns a new instance from json. "

	(instantiator isKindOf: Behavior) ifFalse: [ ^instantiator value: json ].
	(instantiator inheritsFrom: Collection) ifTrue: [ ^instantiator new ].
	instantiator isClass ifFalse: [ ^self error: 'Must be a class' ].
	^instantiator basicNew """,nil)

smalltalk.bind(smalltalk.Objectifier,"fill:object:with:allInstVarNames:",0
,smalltalk.__f__("""(self,oid,anObject,contents,varNames):
	#Objectifier>>#fill:object:with:allInstVarNames:
	def __blk1__():
		return self.shapeValidatingTransform() 
	self.transforms().at_ifAbsent_((anObject).__class__.name(),smalltalk.blk(__blk1__,0)).valueWithArguments_(smalltalk.Array.with_with_with_with_(oid,anObject,contents,varNames)) 
	return self 
""","Objectifier_fill_object_with_allInstVarNames_")
,"instantiating","""fill: oid object: anObject with: contents allInstVarNames: varNames
	" Private - Fill contents of anObject with contents. "

	(self transforms
		at: anObject class name
		ifAbsent: [ self shapeValidatingTransform ])
		valueWithArguments: (Array
			with: oid with: anObject
			with: contents with: varNames)""",nil)

smalltalk.bind(smalltalk.Objectifier,"instantiateCharacter:",0
,smalltalk.__f__("""(self,json):
	#Objectifier>>#instantiateCharacter:
	__0__=smalltalk.newContext()
	def __blk1__():
		return smalltalk.booleanNot_(__0__.ascii.isNumber()) 
	__0__.ascii=nil
	__0__.ascii=self.basic_at_(json,smalltalk.Number(1)) 
	if smalltalk.b(smalltalk.isNil_(__0__.ascii)):
		__0__.ascii=self.basic_at_(json,smalltalk.String("1")) 
	 
	if smalltalk.b(smalltalk.boolean_or_(smalltalk.isNil_(__0__.ascii),smalltalk.blk(__blk1__,0))):
		return self.error_(smalltalk.String("Invalid ascii code")) 
	 
	return smalltalk.String.fromCharCode_(__0__.ascii) 
""","Objectifier_instantiateCharacter_")
,"instantiating","""instantiateCharacter: json
	" Private - Instantiate a character(String) literal from json structure. "

	| ascii |
	ascii := self basic: json at: 1.
	ascii isNil ifTrue: [ ascii := self basic: json at: '1' ].
	(ascii isNil or: [ ascii isNumber not ]) ifTrue: [
		^self error: 'Invalid ascii code'
	].
	^String fromCharCode: ascii""",nil)

smalltalk.bind(smalltalk.Objectifier,"newObject:",0
,smalltalk.__f__("""(self,json):
	#Objectifier>>#newObject:
	__0__=smalltalk.newContext()
	def __blk1__():
		return self.basic_at_(__0__.jsClass,smalltalk.String("allInstVarNames")) 
	__0__.jsClass=nil
	__0__.cls=nil
	__0__.object=nil
	__0__.varNames=nil
	__0__.oid=nil
	__0__.jsClass=self.basic_at_(json,smalltalk.String("class")) 
	if smalltalk.b(smalltalk.isNil_(__0__.jsClass)):
		return self.global_(json) 
	 
	__0__.cls=self.global_(__0__.jsClass) 
	if smalltalk.b(smalltalk.isNil_(__0__.cls)):
		self.error_(smalltalk.String("Missing class")) 
	 
	__0__.varNames=smalltalk.if_true_false_(self.isObject_(__0__.jsClass),nil,smalltalk.blk(__blk1__,0)) 
	__0__.oid=self.basic_at_(json,smalltalk.String("id")) 
	__0__.object=self.instantiate_with_allInstVarNames_(__0__.cls,json,__0__.varNames) 
	self.id_is_(__0__.oid,__0__.object) 
	self.fill_object_with_allInstVarNames_(__0__.oid,__0__.object,json,__0__.varNames) 
	return getattr(self,"@objects",nil).at_(__0__.oid) 
""","Objectifier_newObject_")
,"converting","""newObject: json
	" Private - Returns a new instance from json. "

	| jsClass cls object varNames oid |
	jsClass := self basic: json at: #class.
	jsClass isNil ifTrue: [ ^self global: json ].

	cls := self global: jsClass.
	cls isNil ifTrue: [ self error: 'Missing class' ].
	varNames := (self isObject: jsClass) ifFalse: [ self basic: jsClass at: #allInstVarNames ].
	oid := self basic: json at: #id.

	object := self instantiate: cls with: json allInstVarNames: varNames.
	self id: oid is: object.
	self fill: oid object: object with: json allInstVarNames: varNames.
	^objects at: oid""",nil)

smalltalk.bind(smalltalk.Objectifier,"name:",0
,smalltalk.__f__("""(self,aName):
	#Objectifier>>#name:
	def __blk1__():
		return aName 
	return self.names().at_ifAbsent_(aName,smalltalk.blk(__blk1__,0)) 
""","Objectifier_name_")
,"lookup","""name: aName
	" Private - Returns the (global) name to use for reference to aName. "

	^self names at: aName ifAbsent: [ aName ]""",nil)

smalltalk.bind(smalltalk.Objectifier,"globalAt:",0
,smalltalk.__f__("""(self,key):
	#Objectifier>>#globalAt:
	__0__=smalltalk.newContext()
	def __blk1__():
		return self.error_(smalltalk.object_comma_(smalltalk.String("Missing global #"),key)) 
	__0__.binding=nil
	if smalltalk.b(smalltalk.isNil_(key)):
		return self.error_(smalltalk.String("Missing global name")) 
	 
	if not smalltalk.b(key.isString()):
		def __blk2__(result,selector):
			def __blk3__():
				return self.globalAt_(selector) 
			def __blk4__():
				return result.perform_(selector.asSymbol()) 
			return smalltalk.if_true_false_(smalltalk.isNil_(result),smalltalk.blk(__blk3__,0),smalltalk.blk(__blk4__,0)) 
		return key.inject_into_(nil,smalltalk.blk(__blk2__,2)) 
	 
	__0__.binding=self.name_(key) 
	if not smalltalk.b(__0__.binding.isString()):
		return __0__.binding 
	 
	return smalltalk.Smalltalk.at_ifAbsent_(__0__.binding.asSymbol(),smalltalk.blk(__blk1__,0)) 
""","Objectifier_globalAt_")
,"lookup","""globalAt: key
	" Private - Returns the global object references by key. "

	| binding |
	key isNil ifTrue: [ ^self error: 'Missing global name' ].
	key isString ifFalse: [ "path from global reference"
		^key inject: nil into: [:result :selector|
			result isNil ifTrue: [ self globalAt: selector ]
			ifFalse: [ result perform: selector asSymbol ]
		]
	].
	binding := self name: key.
	binding isString ifFalse: [ ^binding ].
	^Smalltalk at: binding asSymbol ifAbsent: [
		self error: 'Missing global #' ,key
	]""",nil)

smalltalk.bind(smalltalk.Objectifier,"id:is:",0
,smalltalk.__f__("""(self,id,anObject):
	#Objectifier>>#id:is:
	if smalltalk.b(smalltalk.isNil_(id)):
		return anObject 
	 
	return getattr(self,"@objects",nil).at_put_(id,anObject) 
""","Objectifier_id_is_")
,"registration","""id: id is: anObject
	" Private - Register anObject as object at id. "

	id isNil ifTrue: [ ^anObject ].
	^objects at: id put: anObject""",nil)

smalltalk.bind(smalltalk.Objectifier,"global:",0
,smalltalk.__f__("""(self,json):
	_s8Ret_=smalltalk.newContext()
	try:
		#Objectifier>>#global:
		__0__=smalltalk.newContext()
		def __blk1__(anObject):
			return smalltalk.raise_result_(_s8Ret_,anObject) 
		__0__.result=nil
		self.withRef_do_(json,smalltalk.blk(__blk1__,1)) 
		__0__.result=self.globalAt_(self.basic_at_(json,smalltalk.String("global"))) 
		smalltalk.raise_result_(_s8Ret_,self.id_is_(self.basic_at_(json,smalltalk.String("id")),__0__.result)) 
	except Exception as __ex:
		if smalltalk.exception_at(__ex,_s8Ret_):
			return smalltalk.exceptionResult_(__ex)
		raise __ex
	
""","Objectifier_global_")
,"references","""global: json
	" Private - Returns a global from json. "

	| result |
	self withRef: json do: [:anObject| ^anObject ].
	result := self globalAt: (self basic: json at: #global).
	^self id: (self basic: json at: #id) is: result""",nil)

smalltalk.bind(smalltalk.Objectifier,"ref:",0
,smalltalk.__f__("""(self,ref):
	#Objectifier>>#ref:
	__0__=smalltalk.newContext()
	__0__.value=nil
	if smalltalk.b(self.starts_with_(ref,self.tagStart())):
		return ref 
	 
	__0__.value=getattr(self,"@objects",nil).at_(ref.asNumber()) 
	if smalltalk.b(smalltalk.isObject_equalTo_(__0__.value,smalltalk.String("missing"))):
		return self.error_(smalltalk.object_comma_(smalltalk.String("Missing value at #"),ref)) 
	 
	return __0__.value 
""","Objectifier_ref_")
,"references","""ref: ref
	" Private - Returns the object pointed at reference. "

	| value |
	(self starts: ref with: self tagStart) ifTrue: [ ^ref ].
	value := objects at: ref asNumber.
	value = #missing ifTrue: [ ^self error: 'Missing value at #' ,ref ].
	^value""",nil)

smalltalk.bind(smalltalk.Objectifier,"parse:",0
,smalltalk.__f__("""(self,aString):
	#Objectifier>>#parse:
	return self.jsonObject_(self.readStream_(aString)) 
""","Objectifier_parse_")
,"parsing","""parse: aString
	" Private - Returns the map read from aString literal.
	See https://www.json.org/
	"

	^self jsonObject: (self readStream: aString)""",nil)

smalltalk.bind(smalltalk.Objectifier,"skipSeparators:",0
,smalltalk.__f__("""(self,stream):
	_s8Ret_=smalltalk.newContext()
	try:
		#Objectifier>>#skipSeparators:
		def __blk1__():
			if smalltalk.b(stream.atEnd()):
				smalltalk.raise_result_(_s8Ret_,smalltalk.false) 
			 
			return stream.peek().isSeparator() 
		while smalltalk.b(smalltalk.blk(__blk1__,0)()):
			stream.next() 
		 
		smalltalk.raise_result_(_s8Ret_,smalltalk.true) 
	except Exception as __ex:
		if smalltalk.exception_at(__ex,_s8Ret_):
			return smalltalk.exceptionResult_(__ex)
		raise __ex
	
""","Objectifier_skipSeparators_")
,"parsing","""skipSeparators: stream
	" Advance the stream upto a non-separator (or end).
	Return true  if a non-separator contents is found,
	return false if run upto end of stream.
	"

	[ stream atEnd ifTrue: [ ^false ].
	  stream peek isSeparator
	] whileTrue: [ stream next ].
	^true""",nil)

smalltalk.bind(smalltalk.Objectifier,"mustRead:in:",0
,smalltalk.__f__("""(self,char,stream):
	_s8Ret_=smalltalk.newContext()
	try:
		#Objectifier>>#mustRead:in:
		if smalltalk.b(smalltalk.isObject_equalTo_(stream.peek(),char)):
			return stream.next() 
		 
		if smalltalk.b(self.skipSeparators_(stream)):
			def __blk1__():
				return smalltalk.raise_result_(_s8Ret_,stream.next()) 
			smalltalk.if_true_false_(smalltalk.isObject_equalTo_(stream.peek(),char),smalltalk.blk(__blk1__,0),nil) 
		 
		smalltalk.raise_result_(_s8Ret_,self.error_(smalltalk.object_comma_(smalltalk.String("Invalid contents at "),smalltalk.asString_(stream.position()._plus(smalltalk.Number(1)))))) 
	except Exception as __ex:
		if smalltalk.exception_at(__ex,_s8Ret_):
			return smalltalk.exceptionResult_(__ex)
		raise __ex
	
""","Objectifier_mustRead_in_")
,"parsing","""mustRead: char in: stream
	" Private - Ensure char is the next character to read from stream. "

	stream peek = char ifTrue: [ ^stream next ].
	(self skipSeparators: stream) ifTrue: [
		stream peek = char ifTrue: [ ^stream next ].
	].
	^self error: 'Invalid contents at ' ,(stream position + 1) asString""",nil)

smalltalk.bind(smalltalk.Objectifier,"mustReadToken:in:",0
,smalltalk.__f__("""(self,token,stream):
	#Objectifier>>#mustReadToken:in:
	__0__=smalltalk.newContext()
	__0__.start=nil
	__0__.start=stream.position()._plus(smalltalk.Number(1)) 
	if not smalltalk.b(smalltalk.isObject_equalTo_(token,stream.next_(token.size()))):
		return self.error_(smalltalk.object_comma_(smalltalk.object_comma_(token,smalltalk.String(" expected at ")),smalltalk.asString_(__0__.start))) 
	 
	return self 
""","Objectifier_mustReadToken_in_")
,"parsing","""mustReadToken: token in: stream
	" Private - Ensure token is the next contents to read from stream. "

	| start |
	start := stream position + 1.
	token = (stream next: token size) ifFalse: [
		^self error: token ,' expected at ' ,start asString
	]""",nil)

smalltalk.bind(smalltalk.Objectifier,"jsonObject:",0
,smalltalk.__f__("""(self,stream):
	#Objectifier>>#jsonObject:
	__0__=smalltalk.newContext()
	def __blk1__():
		return smalltalk.isObject_equalTo_(stream.peek(),smalltalk.String("}")) 
	__0__.result=nil
	__0__.result=smalltalk.PoolDictionary.new() 
	__0__.result.at_put_(smalltalk.String("objectifier_isObject"),self) 
	self.mustRead_in_(smalltalk.String("{"),stream) 
	while not smalltalk.b(smalltalk.blk(__blk1__,0)()):
		__1__=smalltalk.newContext()
		def __blk2__():
			return stream.next() 
		__1__.assoc=nil
		__1__.assoc=self.jsonBinding_(stream) 
		__0__.result.at_put_(__1__.assoc.key(),__1__.assoc.value()) 
		smalltalk.if_true_false_(smalltalk.isObject_equalTo_(stream.peek(),smalltalk.String(",")),smalltalk.blk(__blk2__,0),nil) 
	 
	self.mustRead_in_(smalltalk.String("}"),stream) 
	return __0__.result 
""","Objectifier_jsonObject_")
,"parsing","""jsonObject: stream
	" Private - Returns the next json object from stream. "

	| result |
	result := PoolDictionary new.
	result at: #objectifier_isObject put: self.
	self mustRead: ${ in: stream.
	[stream peek = $}] whileFalse: [ | assoc |
		assoc := self jsonBinding: stream.
		result at: assoc key put: assoc value.
		stream peek = $, ifTrue: [ stream next ].
	].
	self mustRead: $} in: stream.
	^result""",nil)

smalltalk.bind(smalltalk.Objectifier,"jsonBinding:",0
,smalltalk.__f__("""(self,stream):
	#Objectifier>>#jsonBinding:
	__0__=smalltalk.newContext()
	__0__.key=nil
	__0__.value=nil
	__0__.key=self.jsonString_(stream) 
	self.mustRead_in_(smalltalk.String(":"),stream) 
	__0__.value=self.jsonValue_(stream) 
	return smalltalk.Association.key_value_(__0__.key,__0__.value) 
""","Objectifier_jsonBinding_")
,"parsing","""jsonBinding: stream
	" Private - Returns the next json binding from stream. "

	| key value |
	key := self jsonString: stream.
	self mustRead: $: in: stream.
	value := self jsonValue: stream.
	^Association key: key value: value""",nil)

smalltalk.bind(smalltalk.Objectifier,"newArray",0
,smalltalk.__f__("""(self):
	#Objectifier>>#newArray
	def __blk1__():
		return smalltalk.Array 
	return smalltalk.Smalltalk.at_ifAbsent_(smalltalk.String("OrderedCollection"),smalltalk.blk(__blk1__,0)).new() 
""","Objectifier_newArray")
,"instantiating","""newArray
	" Private - Returns a new extensible arrayed collection. "

	^(Smalltalk at: #OrderedCollection ifAbsent: [ Array ]) new""",nil)

smalltalk.bind(smalltalk.Objectifier,"numberFromString:",0
,smalltalk.__f__("""(self,string):
	_s8Ret_=smalltalk.newContext()
	try:
		#Objectifier>>#numberFromString:
		__0__=smalltalk.newContext()
		def __blk1__():
			return smalltalk.raise_result_(_s8Ret_,string.asNumber()) 
		__0__.support=nil
		__0__.support=smalltalk.Smalltalk.at_ifAbsent_(smalltalk.String("Float"),smalltalk.blk(__blk1__,0)) 
		if not smalltalk.b(string.includes_(smalltalk.String("."))):
			smalltalk.raise_result_(_s8Ret_,string.asNumber()) 
		 
		smalltalk.raise_result_(_s8Ret_,__0__.support.fromString_decimalSeparator_(string,smalltalk.String("."))) 
	except Exception as __ex:
		if smalltalk.exception_at(__ex,_s8Ret_):
			return smalltalk.exceptionResult_(__ex)
		raise __ex
	
""","Objectifier_numberFromString_")
,"instantiating","""numberFromString: string
	" Private - Returns the number encoded in string. "

	| support |
	support := Smalltalk at: #Float ifAbsent: [ ^string asNumber ].
	(string includes: $.) ifFalse: [ ^string asNumber ].
	^support fromString: string decimalSeparator: '.'""",nil)

smalltalk.bind(smalltalk.Objectifier,"jsonValue:",0
,smalltalk.__f__("""(self,stream):
	#Objectifier>>#jsonValue:
	__0__=smalltalk.newContext()
	__0__.char=nil
	__0__.char=stream.peek() 
	if smalltalk.b(smalltalk.isNil_(__0__.char)):
		return self.error_(smalltalk.object_comma_(smalltalk.String("Unexpected end at "),smalltalk.asString_(stream.position()._plus(smalltalk.Number(1))))) 
	 
	if smalltalk.b(smalltalk.isObject_equalTo_(__0__.char,smalltalk.String('"'))):
		return self.jsonString_(stream) 
	 
	if smalltalk.b(__0__.char.isDigit()):
		return self.jsonNumber_(stream) 
	 
	if smalltalk.b(smalltalk.isObject_equalTo_(__0__.char,smalltalk.String("-"))):
		stream.next() 
		return self.jsonNumber_(stream).negated() 
	 
	if smalltalk.b(smalltalk.isObject_equalTo_(__0__.char,smalltalk.String("{"))):
		return self.jsonObject_(stream) 
	 
	if smalltalk.b(smalltalk.isObject_equalTo_(__0__.char,smalltalk.String("["))):
		return self.jsonArray_(stream) 
	 
	if smalltalk.b(smalltalk.isObject_equalTo_(__0__.char,smalltalk.String("t"))):
		self.mustReadToken_in_(smalltalk.String("true"),stream) 
		return smalltalk.true 
	 
	if smalltalk.b(smalltalk.isObject_equalTo_(__0__.char,smalltalk.String("f"))):
		self.mustReadToken_in_(smalltalk.String("false"),stream) 
		return smalltalk.false 
	 
	if smalltalk.b(smalltalk.isObject_equalTo_(__0__.char,smalltalk.String("n"))):
		self.mustReadToken_in_(smalltalk.String("null"),stream) 
		return nil 
	 
	return self.error_(smalltalk.object_comma_(smalltalk.String("Corrupt contents at "),smalltalk.asString_(stream.position()._plus(smalltalk.Number(1))))) 
""","Objectifier_jsonValue_")
,"parsing","""jsonValue: stream
	" Private - Returns the next json value from stream. "

	| char |
	char := stream peek.
	char isNil ifTrue: [ ^self error: 'Unexpected end at ' ,(stream position + 1) asString ].
	char = $" ifTrue: [ ^self jsonString: stream ].
	char isDigit ifTrue: [ ^self jsonNumber: stream ].
	char = $- ifTrue: [ stream next. ^(self jsonNumber: stream) negated ].
	char = ${ ifTrue: [ ^self jsonObject: stream ].
	char = $[ ifTrue: [ ^self jsonArray: stream ].
	char = $t ifTrue: [ self mustReadToken: 'true' in: stream. ^true ].
	char = $f ifTrue: [ self mustReadToken: 'false' in: stream. ^false ].
	char = $n ifTrue: [ self mustReadToken: 'null' in: stream. ^nil ].
	^self error: 'Corrupt contents at ' ,(stream position + 1) asString """,nil)

smalltalk.bind(smalltalk.Objectifier,"jsonArray:",0
,smalltalk.__f__("""(self,stream):
	#Objectifier>>#jsonArray:
	__0__=smalltalk.newContext()
	def __blk1__():
		return smalltalk.isObject_equalTo_(stream.peek(),smalltalk.String("]")) 
	__0__.result=nil
	__0__.result=self.newArray() 
	self.mustRead_in_(smalltalk.String("["),stream) 
	while not smalltalk.b(smalltalk.blk(__blk1__,0)()):
		def __blk2__():
			return stream.next() 
		__0__.result.add_(self.jsonValue_(stream)) 
		smalltalk.if_true_false_(smalltalk.isObject_equalTo_(stream.peek(),smalltalk.String(",")),smalltalk.blk(__blk2__,0),nil) 
	 
	self.mustRead_in_(smalltalk.String("]"),stream) 
	return __0__.result 
""","Objectifier_jsonArray_")
,"parsing","""jsonArray: stream
	" Private - Returns the json array from stream. "

	| result |
	result := self newArray.
	self mustRead: $[ in: stream.
	[ stream peek = $] ] whileFalse: [
		result add: (self jsonValue: stream).
		stream peek = $, ifTrue: [ stream next ].
	].
	self mustRead: $] in: stream.
	^result""",nil)

smalltalk.bind(smalltalk.Objectifier,"jsonString:",0
,smalltalk.__f__("""(self,stream):
	#Objectifier>>#jsonString:
	self.mustRead_in_(smalltalk.String('"'),stream) 
	return self.unEscape_(self.jsonStringChars_(stream)) 
""","Objectifier_jsonString_")
,"parsing","""jsonString: stream
	" Private - Returns the json string from stream. "

	self mustRead: $" in: stream.
	^self unEscape: (self jsonStringChars: stream)""",nil)

smalltalk.bind(smalltalk.Objectifier,"jsonStringChars:",0
,smalltalk.__f__("""(self,stream):
	_s8Ret_=smalltalk.newContext()
	try:
		#Objectifier>>#jsonStringChars:
		__0__=smalltalk.newContext()
		def __blk1__():
			def __blk2__():
				return smalltalk.isObject_equalTo_(__0__.part.last(),__0__.bar) 
			__0__.part=stream.upTo_(smalltalk.String('"')) 
			if smalltalk.b(stream.atEnd()):
				smalltalk.raise_result_(_s8Ret_,self.error_(smalltalk.object_comma_(smalltalk.String("Missing end of string at "),smalltalk.asString_(__0__.start)))) 
			 
			return smalltalk.boolean_and_(__0__.part.notEmpty(),smalltalk.blk(__blk2__,0)) 
		def __blk3__():
			return __0__.part 
		def __blk4__():
			return __0__.result 
		__0__.start=nil
		__0__.result=nil
		__0__.bar=nil
		__0__.part=nil
		__0__.bar=smalltalk.String("\\\\") 
		__0__.start=stream.position()._plus(smalltalk.Number(1)) 
		while smalltalk.b(smalltalk.blk(__blk1__,0)()):
			def __blk5__():
				return __0__.part 
			def __blk6__():
				return smalltalk.object_comma_(__0__.result,__0__.part) 
			__0__.part=__0__.part.copyWith_(smalltalk.String('"')) 
			__0__.result=smalltalk.if_true_false_(smalltalk.isNil_(__0__.result),smalltalk.blk(__blk5__,0),smalltalk.blk(__blk6__,0)) 
		 
		smalltalk.raise_result_(_s8Ret_,smalltalk.if_true_false_(smalltalk.isNil_(__0__.result),smalltalk.blk(__blk3__,0),smalltalk.blk(__blk4__,0))) 
	except Exception as __ex:
		if smalltalk.exception_at(__ex,_s8Ret_):
			return smalltalk.exceptionResult_(__ex)
		raise __ex
	
""","Objectifier_jsonStringChars_")
,"parsing","""jsonStringChars: stream
	" Private - Returns the next sequence of json characters from stream. "

	| start result bar part |
	bar := $\\.
	start := stream position + 1.
	[	part := stream upTo: $".
		stream atEnd ifTrue: [ ^self error: 'Missing end of string at ', start asString ].
		part notEmpty and: [ part last = bar ]
	] whileTrue: [
		part := part copyWith: $".
		result := result isNil ifTrue: [part] ifFalse: [result , part]
	].
	^result isNil ifTrue: [part] ifFalse: [result]""",nil)

smalltalk.bind(smalltalk.Objectifier,"jsonUCharacter:",0
,smalltalk.__f__("""(self,fourDigits):
	#Objectifier>>#jsonUCharacter:
	__0__=smalltalk.newContext()
	def __blk1__():
		return smalltalk.Number 
	__0__.ascii=nil
	__0__.ascii=smalltalk.Smalltalk.at_ifAbsent_(smalltalk.String("Integer"),smalltalk.blk(__blk1__,0)).readFrom_radix_(self.readStream_(fourDigits),smalltalk.Number(16)) 
	return smalltalk.asCharacter_(__0__.ascii) 
""","Objectifier_jsonUCharacter_")
,"parsing","""jsonUCharacter: fourDigits
	" Private - Returns the character escaped in fourDigits. "

	| ascii |
	ascii := (Smalltalk at: #Integer ifAbsent: [Number])
		readFrom: (self readStream: fourDigits)
		radix: 16.
	^ascii asCharacter""",nil)

smalltalk.bind(smalltalk.Objectifier,"unEscape:",0
,smalltalk.__f__("""(self,string):
	#Objectifier>>#unEscape:
	__0__=smalltalk.newContext()
	def __blk1__():
		return __0__.input.atEnd() 
	__0__.input=nil
	__0__.output=nil
	__0__.bar=nil
	__0__.bar=smalltalk.String("\\\\") 
	if not smalltalk.b(string.includes_(__0__.bar)):
		return string 
	 
	__0__.input=self.readStream_(string) 
	__0__.output=self.writeStreamOn_(smalltalk.String("")) 
	while not smalltalk.b(smalltalk.blk(__blk1__,0)()):
		__1__=smalltalk.newContext()
		def __blk2__():
			def __blk3__():
				return __0__.output.nextPut_(self.jsonUCharacter_(__0__.input.next_(smalltalk.Number(4)))) 
			__1__.c=__0__.input.next() 
			if smalltalk.b(smalltalk.isObject_equalTo_(__1__.c,__0__.bar)):
				__0__.output.nextPut_(__0__.bar) 
			 
			if smalltalk.b(smalltalk.isObject_equalTo_(__1__.c,smalltalk.String("/"))):
				__0__.output.nextPut_(smalltalk.String("/")) 
			 
			if smalltalk.b(smalltalk.isObject_equalTo_(__1__.c,smalltalk.String("b"))):
				__0__.output.nextPut_(smalltalk.asCharacter_(smalltalk.Number(8))) 
			 
			if smalltalk.b(smalltalk.isObject_equalTo_(__1__.c,smalltalk.String("f"))):
				__0__.output.nextPut_(smalltalk.asCharacter_(smalltalk.Number(12))) 
			 
			if smalltalk.b(smalltalk.isObject_equalTo_(__1__.c,smalltalk.String("n"))):
				__0__.output.nextPut_(smalltalk.asCharacter_(smalltalk.Number(10))) 
			 
			if smalltalk.b(smalltalk.isObject_equalTo_(__1__.c,smalltalk.String("r"))):
				__0__.output.nextPut_(smalltalk.asCharacter_(smalltalk.Number(13))) 
			 
			if smalltalk.b(smalltalk.isObject_equalTo_(__1__.c,smalltalk.String("t"))):
				__0__.output.nextPut_(smalltalk.asCharacter_(smalltalk.Number(9))) 
			 
			return smalltalk.if_true_false_(smalltalk.isObject_equalTo_(__1__.c,smalltalk.String("u")),smalltalk.blk(__blk3__,0),nil) 
		__1__.c=nil
		__0__.output.nextPutAll_(__0__.input.upTo_(__0__.bar)) 
		smalltalk.if_true_false_(__0__.input.atEnd(),nil,smalltalk.blk(__blk2__,0)) 
	 
	return __0__.output.contents() 
""","Objectifier_unEscape_")
,"parsing","""unEscape: string
	" Private - Returns the result of unescaping a string. "

	| input output bar |
	bar := $\\.
	(string includes: bar) ifFalse: [ ^string ].
	input := self readStream: string.
	output := self writeStreamOn: ''.
	[input atEnd] whileFalse: [ | c |
		output nextPutAll: (input upTo: bar).
		input atEnd ifFalse: [
			c := input next.
			c = bar ifTrue: [ output nextPut: bar ].
			c = $/ ifTrue: [ output nextPut: $/ ].
			c = $b ifTrue: [ output nextPut: 8 asCharacter ].
			c = $f ifTrue: [ output nextPut: 12 asCharacter ].
			c = $n ifTrue: [ output nextPut: 10 asCharacter ].
			c = $r ifTrue: [ output nextPut: 13 asCharacter ].
			c = $t ifTrue: [ output nextPut: 9 asCharacter ].
			c = $u ifTrue: [ output nextPut: (self jsonUCharacter: (input next: 4)) ].
		]
	].
	^output contents""",nil)

smalltalk.bind(smalltalk.Objectifier,"jsonNumber:",0
,smalltalk.__f__("""(self,stream):
	#Objectifier>>#jsonNumber:
	__0__=smalltalk.newContext()
	def __blk1__():
		return smalltalk.String("0123456789.+-eE").includes_(stream.peek()) 
	__0__.output=nil
	__0__.valid=nil
	__0__.output=self.writeStreamOn_(smalltalk.String("")) 
	while smalltalk.b(smalltalk.blk(__blk1__,0)()):
		__0__.output.nextPut_(stream.next()) 
	 
	return self.numberFromString_(__0__.output.contents()) 
""","Objectifier_jsonNumber_")
,"parsing","""jsonNumber: stream
	" Private - Returns the json number from stream. "

	| output valid |
	output := self writeStreamOn: ''.
	['0123456789.+-eE' includes: stream peek] whileTrue: [
		output nextPut: stream next
	].
	^self numberFromString: output contents""",nil)
