Răsfoiți Sursa

Removed src/jsonifier test project.

Mark Sibly 7 ani în urmă
părinte
comite
f8dc858662

+ 0 - 112
src/jsonifier/comparejson.monkey2

@@ -1,112 +0,0 @@
-Namespace jsonifier
-
-Function CompareJson:Int( x:JsonObject,y:JsonValue )
-	If y=JsonValue.NullValue Return 1
-	Local r:=Cast<JsonObject>( y )
-	If Not r Return 1
-	Local xit:=x.All(),rit:=r.All()
-	While Not xit.AtEnd And Not rit.AtEnd
-		Local cmp:=xit.Current.Key<=>rit.Current.Key
-		If cmp Return cmp
-		cmp=CompareJson( xit.Current.Value,rit.Current.Value )
-		If cmp Return cmp
-		xit.Bump()
-		rit.Bump()
-	Wend
-	Return x.Count()<=>r.Count()
-End
-
-Function CompareJson:Int( x:JsonArray,y:JsonValue )
-	If y=JsonValue.NullValue Or y.IsBool Or y.IsNumber Or y.IsString Return 1
-	Local r:=Cast<JsonArray>( y )
-	If Not r Return -1
-	For Local i:=0 Until Min( x.Length,r.Length )
-		Local cmp:=CompareJson( x[i],r[i] )
-		If cmp Return cmp
-	Next
-	Return x.Length<=>r.Length
-End
-
-Function CompareJson:Int( x:JsonString,y:JsonValue )
-	If y=JsonValue.NullValue Or y.IsBool Or y.IsNumber Return 1
-	Local r:=Cast<JsonString>( y )
-	Return r ? x.Data<=>r.Data Else -1
-End
-
-Function CompareJson:Int( x:JsonNumber,y:JsonValue )
-	If y=JsonValue.NullValue Or y.IsBool Return 1
-	Local r:=Cast<JsonNumber>( y )
-	Return r ? x.Data<=>r.Data Else -1
-End
-
-Function CompareJson:Int( x:JsonBool,y:JsonValue )
-	If y=JsonValue.NullValue Return 1
-	Local r:=Cast<JsonBool>( y )
-	Return r ? x.Data<=>r.Data Else -1
-End
-
-Function CompareJson:Int( x:JsonValue,y:JsonValue )
-	If x=JsonValue.NullValue Return y=JsonValue.NullValue ? 0 Else -1
-	Local jbool:=Cast<JsonBool>( x )
-	If jbool Return CompareJson( jbool,y )
-	Local jnumber:=Cast<JsonNumber>( x )
-	If jnumber Return CompareJson( jnumber,y )
-	Local jstring:=Cast<JsonString>( x )
-	If jstring Return CompareJson( jstring,y )
-	local jarray:=Cast<JsonArray>( x )
-	If jarray Return CompareJson( jarray,y )
-	Local jobj:=Cast<JsonObject>( x )
-	If jobj Return CompareJson( jobj,y )
-	RuntimeError( "TODO" )
-	Return 0
-End
-
-#rem
-Function RndJson:JsonValue( range:Int=6 )
-	
-	Select Int( Rnd( range ) )
-	Case 0 
-		Return JsonValue.NullValue
-	Case 1 
-		Return Rnd()>.5 ? JsonBool.TrueValue Else JsonBool.FalseValue
-	Case 2 
-		Return New JsonNumber( Rnd(10000) )
-	Case 3 
-		Return New JsonString( Rnd(10000) )
-	Case 4
-		Local data:=New Stack<JsonValue>( Rnd( 10,20 ) )
-		For Local i:=0 Until data.Length
-			data[i]=RndJson( 4 )
-		Next
-		Return New JsonArray( data )
-	Case 5
-		Local data:=New StringMap<JsonValue>
-		For Local i:=0 Until Rnd( 10,20 )
-			data[ Rnd(100) ]=RndJson( 4 )
-		Next
-		Return New JsonObject( data )
-	End
-	Return Null
-End
-
-Function Main()
-	
-	Print "Start..."
-	
-	For Local i:=1 To 100000
-		
-		Local x:=RndJson()
-		Local y:=RndJson()
-		
-		Local cmp1:=CompareJson( x,y )
-		Local cmp2:=CompareJson( y,x )
-		
-		If cmp1<0 Assert( cmp2>=0 )
-		If cmp1=0 Assert( cmp2 =0 )
-		If cmp1>0 Assert( cmp2<=0 )
-	End
-	
-	Print "Success!"
-		
-End
-#end

+ 0 - 114
src/jsonifier/invocation.monkey2

@@ -1,114 +0,0 @@
-Namespace jsonifier
-
-Class Invocation
-	
-	Method New( scope:TypeInfo,decl:DeclInfo,inst:Variant,args:Variant[] )
-		_scope=scope
-		_decl=decl
-		_inst=inst
-		_args=args
-	End
-	
-	Property Scope:TypeInfo()
-		Return _scope
-	End
-	
-	Property Decl:DeclInfo()
-		Return _decl
-	End
-	
-	Property Inst:Variant()
-		Return _inst
-	End
-	
-	Property Args:Variant[]()
-		Return _args
-	End
-	
-	Method Execute:Variant()
-		Return _decl.Invoke( _inst,_args )
-	End
-	
-	Function Ctor:Invocation( obj:Object,args:Variant[] )
-		
-		Return Ctor( obj,"New",args )
-		
-		#rem
-		
-		Local type:=obj.DynamicType
-		
-		For Local decl:=Eachin type.GetDecls( "New" )
-			
-			Local ftype:=decl.Type
-			If ftype.ParamTypes.Length<>args.Length Continue
-			
-			Local match:=True
-			For Local i:=0 Until args.Length
-				If args[i]
-					If args[i].Type.ExtendsType( ftype.ParamTypes[i] ) Continue
-				Else
-					If ftype.ParamTypes[i].Kind="Class" Continue
-				Endif
-				match=False
-				Exit
-			Next
-			
-			If match Return New Invocation( type,decl,Null,args )
-		Next
-		
-		RuntimeError( "Can't find matching ctor for args" )
-		
-		Return Null
-		#end
-	End
-	
-	Function Ctor:Invocation( obj:Object,dname:String,args:Variant[] )
-		
-		Local type:=obj.DynamicType
-
-		For Local decl:=Eachin type.GetDecls( dname )
-			
-			Local ftype:=decl.Type
-			If ftype.ParamTypes.Length<>args.Length Continue
-			
-			Local match:=True
-			For Local i:=0 Until args.Length
-				
-				If args[i]
-					
-					If args[i].Type.ExtendsType( ftype.ParamTypes[i] ) Continue
-					
-					If args[i].Type.Kind="Class" And ftype.ParamTypes[i].Kind="Class"
-						
-						Local obj:=Cast<Object>( args[i] )
-						
-						If Not obj Or obj.DynamicType.ExtendsType( ftype.ParamTypes[i] ) Continue
-						
-					Endif
-					
-				Else
-					If ftype.ParamTypes[i].Kind="Class" Continue
-				Endif
-				match=False
-				Exit
-			Next
-			
-			If match Return New Invocation( type,decl,Null,args )
-		Next
-		
-		RuntimeError( "Can't find matching ctor for args" )
-		
-		Return Null
-	End
-	
-'	Function DefaultCtor:Invocation( obj:Object )
-'	End
-	
-	Private
-	
-	Field _scope:TypeInfo
-	Field _decl:DeclInfo
-	Field _inst:Variant
-	Field _args:Variant[]
-End
-

+ 0 - 250
src/jsonifier/jsonifier.monkey2

@@ -1,250 +0,0 @@
-Namespace jsonifier
-
-Class Jsonifier
-	
-	Method AddInstance( obj:Object,ctor:Invocation )
-		
-		Assert( Not _instsByObj.Contains( obj ) )
-		
-		Local inst:=New Instance
-		inst.obj=obj
-		inst.id="@"+String(_insts.Length)
-		inst.ctor=ctor
-		inst.initialState=JsonifyState( obj )
-		
-		_instsByObj[inst.obj]=inst
-		_instsById[inst.id]=inst
-
-		_insts.Add( inst )
-	End
-	
-	Method AddInstance( obj:Object,args:Variant[] )
-		
-		AddInstance( obj,Invocation.Ctor( obj,args ) )
-	end
-	
-	Method AddInstance( obj:Object,name:String,args:Variant[] )
-		
-		AddInstance( obj,Invocation.Ctor( obj,name,args ) )
-	End
-	
-	Method JsonifyInstances:JsonObject()
-		
-		Local jobj:=New JsonObject
-		
-		Local jinsts:=New JsonArray( _insts.Length )
-		
-		For Local i:=0 Until jinsts.Length
-			
-			Local inst:=_insts[i]
-			Local jobj:=New JsonObject
-			
-			jobj["id"]=New JsonString( inst.id )
-			jobj["type"]=New JsonString( inst.obj.DynamicType.Name )
-			jobj["ctor"]=Jsonify( inst.ctor )
-			
-			Local state:=JsonifyState( inst.obj ),dstate:=New JsonObject
-			
-			For Local it:=Eachin state.All()
-				
-				Local x:=it.Value
-				Local y:=inst.initialState.GetValue( it.Key )
-				
-				If CompareJson( x,y )<>0 dstate[it.Key]=x
-			Next
-			
-			jobj["state"]=dstate
-			
-			jinsts[i]=jobj
-		Next
-
-		jobj["instances"]=jinsts
-		
-		Return jobj
-	End
-	
-	Method DejsonifyInstances( jobj:JsonObject )
-		
-		Local jinsts:=jobj.GetArray( "instances" )
-		
-		For Local i:=0 Until jinsts.Length
-			
-			Local jobj:=jinsts.GetObject( i )
-			Local ctor:=Cast<Invocation>( Dejsonify( jobj["ctor"],Typeof<Invocation> ) )
-			
-			Local obj:=Cast<Object>( ctor.Execute() )
-			
-			_dejsonified.Add( obj )
-			
-			DejsonifyState( obj,jobj.GetObject( "state" ),obj.DynamicType )
-		Next
-	End
-	
-	Method Jsonify:JsonValue( value:Variant )
-		
-		If Not value Return JsonValue.NullValue
-		
-		Local type:=value.Type
-		Assert( type )
-		
-		'handle primitive types
-		Select type
-		Case Typeof<Bool>
-			Return New JsonBool( Cast<Bool>( value ) )
-		Case Typeof<Int>
-			Return New JsonNumber( Cast<Int>( value ) )
-		Case Typeof<Float>
-			Return New JsonNumber( Cast<Float>( value ) )
-		Case Typeof<String>
-			Return New JsonString( Cast<String>( value ) )
-		End
-		
-		'handle references
-		Select type.Kind
-		Case "Class"
-			Local obj:=Cast<Object>( value )
-			If Not obj Return JsonValue.NullValue
-			Local inst:=_instsByObj[obj]
-			If inst Return New JsonString( inst.id )
-		End
-		
-		'try custom jsonifiers
-		For Local jext:=Eachin JsonifierExt.All
-			Local jvalue:=jext.Jsonify( value,Self )
-			If jvalue Return jvalue
-		Next
-		
-		RuntimeError( "TODO: No jsonifier found for type '"+type+"'" )
-		Return Null
-	End
-	
-	Method Dejsonify:Variant( jvalue:JsonValue,type:TypeInfo )
-		
-		'handle primitive types
-		Select type
-		Case Typeof<Bool>
-			Return jvalue.ToBool()
-		Case Typeof<Int>
-			Return Int( jvalue.ToNumber() )
-		Case Typeof<Float>
-			Return Float( jvalue.ToNumber() )
-		Case Typeof<String>
-			Return jvalue.ToString()
-		End
-		
-		'handle references
-		Select type.Kind
-		Case "Class"
-			If jvalue.IsNull
-				Return type.NullValue
-			Elseif jvalue.IsString
-				Local id:=Int( jvalue.ToString().Slice( 1 ) )
-				Assert( id>=0 And id<_dejsonified.Length,"Dejsonify error" )
-				Return _dejsonified[id]
-			Endif
-		End
-		
-		'try custom jsonifiers
-		For Local jext:=Eachin JsonifierExt.All
-			Local value:=jext.Dejsonify( jvalue,type,Self )
-			If value Return value
-		Next
-		
-		RuntimeError( "No dejsonifier found for type '"+type+"'" )
-		Return Null
-	End
-	
-	Method JsonifyArray<C>:JsonArray( values:C[] )
-		
-		Local jvalues:=New JsonArray( values.Length )
-		
-		For Local i:=0 Until jvalues.Length
-			jvalues[i]=Jsonify( values[i] )
-		Next
-		
-		Return jvalues
-	End
-	
-	Method DejsonifyArray<C>:C[]( jvalue:JsonValue )
-		
-		Local jvalues:=jvalue.ToArray()
-		Local values:=New C[jvalues.Length]
-		
-		For Local i:=0 Until values.Length
-			values[i]=Cast<C>( Dejsonify( jvalues[i],Typeof<C> ) )
-		Next
-		
-		Return values
-	End
-	
-	Private
-	
-	Class Instance
-		Field obj:Object
-		Field id:String
-		Field ctor:Invocation
-		Field initialState:JsonObject
-	End
-	
-	Field _insts:=New Stack<Instance>
-	
-	Field _instsByObj:=New Map<Object,Instance>
-	Field _instsById:=New StringMap<Instance>
-	
-	Field _dejsonified:=New Stack<Object>
-	
-	Method JsonifyState:JsonObject( obj:Object )
-		
-		Local jobj:=New JsonObject
-		
-		JsonifyState( obj,jobj,obj.DynamicType )
-		
-		Return jobj
-	End
-	
-	Method JsonifyState( obj:Object,jobj:JsonObject,type:TypeInfo )
-		
-		If type.SuperType JsonifyState( obj,jobj,type.SuperType )
-		
-		For Local d:=Eachin type.GetDecls()
-			
-			If d.Kind<>"Property" Continue
-			'Note: Add DeclInfo.Access property so we can do public fields only?
-			If Not d.Gettable Or Not d.Settable Continue
-			
-			jobj.SetValue( d.Name,Jsonify( d.Get( obj ) ) )
-		Next
-		
-	End
-	
-	Method DejsonifyState( obj:Object,jobj:JsonObject,type:TypeInfo  )
-		
-		If type.SuperType DejsonifyState( obj,jobj,type.SuperType )
-
-		For Local d:=Eachin type.GetDecls()
-			
-			If d.Kind<>"Property" Continue
-			'Note: Add DeclInfo.Access property so we can do public fields only?
-			If Not d.Gettable Or Not d.Settable Or Not jobj.Contains( d.Name ) Continue
-			
-			d.Set( obj,Dejsonify( jobj.GetValue( d.Name ),d.Type ) )
-		Next
-	
-	End
-	
-End
-
-
-Class JsonifierExt
-	
-	Const All:=New Stack<JsonifierExt>
-	
-	Method New()
-		All.Add( Self )
-	End
-	
-	Method Jsonify:JsonValue( value:Variant,jsonifier:Jsonifier ) Abstract
-	
-	Method Dejsonify:Variant( jvalue:JsonValue,type:TypeInfo,jsonifier:Jsonifier ) Abstract
-End
-

+ 0 - 133
src/jsonifier/jsonifierexts.monkey2

@@ -1,133 +0,0 @@
-
-Namespace jsonifier
-
-Class StdJsonifierExt Extends JsonifierExt
-	
-	Const Instance:=New StdJsonifierExt
-
-	Method Jsonify:JsonValue( value:Variant,jsonifier:Jsonifier ) Override
-		
-		Select value.Type
-		Case Typeof<Vec2i>
-			Local v:=Cast<Vec2i>( value )
-			Return jsonifier.JsonifyArray( New Int[]( v.x,v.y ) )
-		Case Typeof<Vec2f>
-			Local v:=Cast<Vec2f>( value )
-			Return jsonifier.JsonifyArray( New Float[]( v.x,v.y ) )
-		Case Typeof<Recti>
-			Local v:=Cast<Recti>( value )
-			Return jsonifier.JsonifyArray( new Int[]( v.min.x,v.min.y,v.max.x,v.max.y ) )
-		Case Typeof<Rectf>
-			Local v:=Cast<Rectf>( value )
-			Return jsonifier.JsonifyArray( New Float[]( v.min.x,v.min.y,v.max.x,v.max.y ) )
-		Case Typeof<Vec3f>
-			Local v:=Cast<Vec3f>( value )
-			Return jsonifier.JsonifyArray( New Float[]( v.x,v.y,v.z ) )
-		Case Typeof<AffineMat4f>
-			Local v:=Cast<AffineMat4f>( value )
-			Return jsonifier.JsonifyArray( New Float[]( v.m.i.x,v.m.i.y,v.m.i.z, v.m.j.x,v.m.j.y,v.m.j.z, v.m.k.x,v.m.k.y,v.m.k.z, v.t.x,v.t.y,v.t.z ) )
-		Case Typeof<Color>
-			Local v:=Cast<Color>( value )
-			Return jsonifier.JsonifyArray( New Float[]( v.r,v.g,v.b,v.a ) )
-		End
-		
-		Return Null
-	End
-
-	Method Dejsonify:Variant( jvalue:JsonValue,type:TypeInfo,jsonifier:Jsonifier ) Override
-		
-		Select type
-		Case Typeof<Vec2i>
-			Local v:=jsonifier.DejsonifyArray<Int>( jvalue )
-			Return New Vec2i( v[0],v[1] )
-		Case Typeof<Vec2f>
-			Local v:=jsonifier.DejsonifyArray<Float>( jvalue )
-			Return New Vec2f( v[0],v[1] )
-		Case Typeof<Recti>
-			Local v:=jsonifier.DejsonifyArray<Float>( jvalue )
-			Return New Recti( v[0],v[1],v[2],v[3] )
-		Case Typeof<Rectf>
-			Local v:=jsonifier.DejsonifyArray<Float>( jvalue )
-			Return New Rectf( v[0],v[1],v[2],v[3] )
-		Case Typeof<Vec3f>
-			Local v:=jsonifier.DejsonifyArray<Float>( jvalue )
-			Return New Vec3f( v[0],v[1],v[2] )
-		Case Typeof<Color>
-			Local v:=jsonifier.DejsonifyArray<Float>( jvalue )
-			Return New Color( v[0],v[1],v[2],v[3] )
-		Case Typeof<AffineMat4f>
-			Local v:=jsonifier.DejsonifyArray<Float>( jvalue )
-			Return New AffineMat4f( v[0],v[1],v[2], v[3],v[4],v[5], v[6],v[7],v[8], v[9],v[10],v[11] )
-		End
-		
-		Return Null
-	End
-	
-End
-
-Class InvocationJsonifierExt Extends JsonifierExt
-	
-	Const Instance:=New InvocationJsonifierExt
-	
-	Method Jsonify:JsonValue( value:Variant,jsonifier:Jsonifier ) Override
-		
-		Select value.Type
-		Case Typeof<Invocation>
-			
-			Local v:=Cast<Invocation>( value )
-			
-			Local jobj:=New JsonObject
-			
-			jobj.SetString( "scope",v.Scope.Name )
-			jobj.SetString( "decl",v.Decl.Name )
-			jobj.SetString( "type",v.Decl.Type )
-			jobj.SetValue( "inst",jsonifier.Jsonify( v.Inst ) )
-			jobj.SetValue( "args",jsonifier.JsonifyArray( v.Args ) )
-			
-			Return jobj
-		End
-		
-		Return Null
-	End
-	
-	Method Dejsonify:Variant( jvalue:JsonValue,type:TypeInfo,jsonifier:Jsonifier ) Override
-		
-		Select type
-		Case Typeof<Invocation>
-			
-			Local jobj:=Cast<JsonObject>( jvalue )
-			
-			Local scope:=TypeInfo.GetType( jobj.GetString( "scope" ) )
-			Local dname:=jobj.GetString( "decl" )
-			Local dtype:=jobj.GetString( "type" )
-			Local jinst:=jobj.GetValue( "inst" )
-			Local jargs:=jobj.GetArray( "args" )
-			
-			Local decl:DeclInfo
-			
-			For Local tdecl:=Eachin scope.GetDecls( dname )
-				If String(tdecl.Type)<>dtype Continue
-				decl=tdecl
-				Exit
-			Next
-			
-			Local type:=dname="New" ? scope Else decl.Type.ReturnType
-			
-			Local inst:=jsonifier.Dejsonify( jinst,type )
-			
-			Local args:=New Variant[jargs.Length]
-			For Local i:=0 Until args.Length
-				args[i]=jsonifier.Dejsonify( jargs[i],decl.Type.ParamTypes[i] )
-			Next
-			
-			Local ctor:=New Invocation( scope,decl,inst,args )
-			
-			Return ctor
-		End
-		
-		Return Null
-	End
-	
-End
-
-

+ 0 - 426
src/jsonifier/test.monkey2

@@ -1,426 +0,0 @@
-
-Namespace test
-
-#Reflect test
-
-#Import "<std>"
-
-#Import "jsonifier"
-#Import "invocation"
-#Import "jsonifierexts"
-#Import "comparejson"
-
-Using std..
-Using jsonifier..
-
-Global editing:=True
-Global jsonifier:=New Jsonifier
-
-Class Component
-	
-	'simple contructor
-	Method New( entity:Entity )
-		
-		_entity=entity
-		
-		_entity.AddComponent( Self )
-	End
-
-	'copy contructor
-	Method New( component:Component,entity:Entity )
-		
-		Self.New( entity )
-	End
-	
-	Property Entity:Entity()
-		
-		Return _entity
-	End
-	
-	Protected
-	
-	Method OnCopy:Component( entity:Entity ) Abstract
-	
-	Method SaveInitialState()
-		
-		If editing jsonifier.AddInstance( Self,New Variant[]( _entity ) )
-	End
-	
-	Method SaveInitialState( component:Component )
-		
-		If editing jsonifier.AddInstance( Self,New Variant[]( component,_entity ) )
-	End
-	
-	Private
-	
-	Field _entity:Entity
-	
-End
-
-Class Behaviour Extends Component
-	
-	'simple contructor
-	Method New( entity:Entity )
-		
-		Super.New( entity )
-		
-		Color=graphics.Color.White
-			
-		SaveInitialState()
-	End
-	
-	'copy constructor
-	Method New( behaviour:Behaviour,entity:Entity )
-		
-		Super.New( entity )
-		
-		Color=behaviour.Color
-		
-		SaveInitialState( behaviour )
-	End
-	
-	Property Color:Color()
-		
-		Return _color
-		
-	Setter( color:Color )
-		
-		_color=color
-	End
-	
-	Internal
-	
-	Method OnCopy:Behaviour( entity:Entity ) Override
-		
-		Return New Behaviour( Self,entity )
-	End
-	
-	Private
-	
-	Field _color:Color
-End
-
-Class Entity
-	
-	'simple ctor
-	Method New( parent:Entity )
-		
-		_parent=parent
-		
-		If _parent _parent._children.Add( Self )
-	End
-	
-	'copy ctor
-	Method New( entity:Entity,parent:Entity )
-		
-		Self.New( parent )
-	End
-	
-	Property Visible:Bool()
-		
-		Return _visible
-	
-	Setter( visible:Bool )
-		
-		_visible=visible
-	End
-	
-	Method Copy:Entity( parent:Entity ) Virtual
-		
-		Local copy:=OnCopy( parent )
-		
-		CopyTo( copy )
-		
-		Return copy
-	End
-	
-	Method AddComponent<T>:T()
-		
-		Local component:=New T( Self )
-		
-		Return component
-	End
-	
-	Protected
-	
-	Method OnCopy:Entity( parent:Entity ) Virtual
-		
-		Return New Entity( Self,parent )
-	End
-	
-	Method CopyTo( copy:Entity )
-		
-		For Local child:=Eachin _children
-			
-			child.CopyTo( child.OnCopy( copy ) )
-		Next
-		
-		For Local c:=Eachin _components
-			
-			c.OnCopy( copy )
-		Next
-	End
-	
-	Method SaveInitialState()
-		
-		If editing jsonifier.AddInstance( Self,New Variant[]( _parent ) )
-	End
-
-	Method SaveInitialState( entity:Entity )
-		
-		If editing jsonifier.AddInstance( Self,New Variant[]( entity,_parent ) )
-	End
-	
-	Private
-	
-	Field _parent:Entity
-	
-	Field _children:=New Stack<Entity>
-	
-	Field _visible:Bool
-	
-	Field _components:=New Stack<Component>
-	
-	Method AddComponent( component:Component )
-		
-		_components.Add( component )
-	End
-	
-End
-
-Class Camera Extends Entity
-	
-	Method New( parent:Entity )
-
-		Super.New( parent )
-		
-		FOV=90
-		
-		SaveInitialState()
-		
-		Visible=True
-	End
-	
-	Method New( camera:Camera,parent:Entity )
-		
-		Super.New( camera,parent )
-		
-		FOV=camera.FOV
-		
-		SaveInitialState( camera )
-		
-		Visible=True
-	End
-	
-	Property FOV:Float()
-	
-		Return _fov
-	
-	Setter( fov:Float )
-		
-		_fov=fov
-	End
-	
-	Method Copy:Camera( parent:Entity ) Override
-		
-		Local camera:=OnCopy( parent )
-		
-		CopyTo( camera )
-		
-		Return camera
-	End
-
-	Protected
-		
-	Method OnCopy:Camera( parent:Entity ) Override
-		
-		Return New Camera( Self,parent )
-	End
-	
-	Private
-	
-	Field _fov:Float
-	
-End
-
-Class Light Extends Entity
-	
-	Method New( parent:Entity )
-		
-		Super.New( parent )
-		
-		SaveInitialState()
-		
-		Visible=True
-	End
-
-	Method New( light:Light,parent:Entity )
-		
-		Super.New( parent )
-		
-		SaveInitialState( light )
-		
-		Visible=True
-	End
-
-	Method Copy:Light( parent:Entity ) Override
-		
-		Local light:=OnCopy( parent )
-		
-		CopyTo( light )
-		
-		Return light
-	End
-
-	Protected
-		
-	Method OnCopy:Light( parent:Entity ) Override
-		
-		Return New Light( Self,parent )
-	End
-	
-End
-
-Class Model Extends Entity
-	
-	Method New( parent:Entity )
-		
-		Super.New( parent )
-		
-		Mesh=""
-		
-		SaveInitialState()
-		
-		Visible=True
-	End
-	
-	Method New( model:Model,parent:Entity )
-		
-		Super.New( parent )
-		
-		Mesh=model.Mesh
-		
-		SaveInitialState( model )
-		
-		Visible=True
-	End
-	
-	Property Mesh:String()
-		
-		Return _mesh
-		
-	Setter( mesh:String )
-		
-		_mesh=mesh
-	End
-	
-	Function Load:Model( path:String,parent:Entity )
-		
-		Local model:=New Model( parent,True )
-		
-		model.Mesh="<"+path+">"
-		
-		If editing jsonifier.AddInstance( model,"Load",New Variant[]( path,parent ) )
-		
-		Return model
-	End
-	
-	Method Copy:Model( parent:Entity ) Override
-		
-		Local model:=OnCopy( parent )
-		
-		CopyTo( model )
-		
-		Return model
-	End
-
-	Protected
-		
-	Method OnCopy:Model( parent:Entity ) Override
-		
-		Return New Model( Self,parent )
-	End
-	
-	Private
-	
-	Field _mesh:String
-	
-	Method New( parent:Entity,loading:Bool )
-		
-		Super.New( parent )
-	End
-
-End
-
-Function CreateScene()
-	
-	Print "CreateScene"
-
-	jsonifier=New Jsonifier
-	
-	Local model1:=Model.Load( "model1.png",Null )
-	
-	Local behavour1:=New Behaviour( model1 )
-	
-	Local model2:=model1.Copy( Null )
-	
-End
-
-Function CreateScene2()
-	
-	Print "CreateScene"
-
-	jsonifier=New Jsonifier
-	
-	Local camera:=New Camera( Null )
-	
-	Local light:=New Light( Null )
-	
-	Local root:=Model.Load( "blah.txt",Null )
-	
-	For Local i:=0 Until 3
-		
-		Local model:=New Model( root )
-		
-		Local component:=New Behaviour( model )
-	Next
-	
-	Local copy:=root.Copy( Null )
-	
-End
-
-Function SaveScene:JsonObject()
-	
-	Print "SaveScene"
-
-	Local jobj:=jsonifier.JsonifyInstances()
-	
-	Return jobj
-End
-
-Function LoadScene( jobj:JsonObject )
-	
-	Print "LoadScene"
-	
-	jsonifier=New Jsonifier
-	
-	jsonifier.DejsonifyInstances( jobj )
-End
-
-Function Main()
-	
-	CreateScene()
-	
-	Local saved1:=SaveScene()
-	
-	LoadScene( saved1 )
-	
-	Local saved2:=SaveScene()
-	
-	If CompareJson( saved1,saved2 )=0
-		Print saved1.ToJson()+"~nSuccess!"
-	Else
-		Print "saved1:~n"+saved1.ToJson()+"~nsaved2:~n"+saved2.ToJson()+"~nError!"
-	Endif
-	
-End