123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- Namespace mojo3d.jsonifier
- Class Invocation
-
- Method New( scope:TypeInfo,decl:DeclInfo,inst:Variant,args:Variant[] )
- _scope=scope
- _decl=decl
- _inst=inst
- _args=args
- End
-
- Method New( scope:TypeInfo,decl:String,inst:Variant,args:Variant[] )
- Init( scope,decl,inst,args )
- End
-
- Method New( name:String,inst:Variant,args:Variant[] )
- Local i:=name.FindLast( "." )
- Init( TypeInfo.GetType( name.Slice( 0,i ) ),name.Slice( i+1 ),inst,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
-
- Private
-
- Field _scope:TypeInfo
- Field _decl:DeclInfo
- Field _inst:Variant
- Field _args:Variant[]
-
- Function FindDecl:DeclInfo( scope:TypeInfo,name:String,args:Variant[] )
-
- For Local decl:=Eachin scope.GetDecls( name )
-
- 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 decl
-
- Next
-
- Return Null
- End
- Method Init( scope:TypeInfo,name:String,inst:Variant,args:Variant[] )
-
- _scope=scope
- _inst=inst
- _args=args
-
- _decl=FindDecl( _scope,name,args )
-
- If Not _decl
- For Local type:=Eachin GetTypeExtensions( _scope )
- _decl=FindDecl( type,name,args )
- If Not _decl Continue
- _scope=type
- Exit
- Next
- Assert( _decl )
- Endif
- End
-
- End
|