Esempio n. 1
0
        public static SGSClassInfo GetStaticClassInfo( Context ctx, Type type )
        {
            SGSClassInfo cinfo;
            if( ctx.GetEngine()._sgsStaticClassInfo.TryGetValue( type, out cinfo ) )
                return cinfo;

            NI.OC_Self d_destruct, d_getindex, d_setindex;
            NI.ObjInterface oi = new NI.ObjInterface()
            {
                destruct = d_destruct = new NI.OC_Self( _sgsDestruct ),
                getindex = d_getindex = new NI.OC_Self( _sgsGetIndex ),
                setindex = d_setindex = new NI.OC_Self( _sgsSetIndex ),
            };

            cinfo = new SGSClassInfo()
            {
                iface = AllocInterface( oi, type.Name + "[static]" ),
                props = _ReadClassProps( ctx, type, true ),
                d_destruct = d_destruct,
                d_getindex = d_getindex,
                d_setindex = d_setindex,
            };
            ctx.GetEngine()._sgsStaticClassInfo.Add( type, cinfo );
            return cinfo;
        }
Esempio n. 2
0
        // returns the cached interface for any supporting (IObject-based) class
        public static SGSClassInfo GetClassInfo( Context ctx, Type type )
        {
            SGSClassInfo cinfo;
            if( ctx.GetEngine()._sgsClassInfo.TryGetValue( type, out cinfo ) )
                return cinfo;

            NI.OC_Self d_destruct, d_gcmark, d_getindex, d_setindex, d_serialize, d_call, d_expr;
            NI.OC_SlPr d_convert, d_dump, d_getnext;
            NI.ObjInterface oi = new NI.ObjInterface()
            {
                destruct = d_destruct = new NI.OC_Self( _sgsDestruct ),
                gcmark = d_gcmark = new NI.OC_Self( _sgsGCMark ),

                getindex = d_getindex = new NI.OC_Self( _sgsGetIndex ),
                setindex = d_setindex = new NI.OC_Self( _sgsSetIndex ),

                convert = d_convert = new NI.OC_SlPr( _sgsConvert ),
                serialize = d_serialize = new NI.OC_Self( _sgsSerialize ),
                dump = d_dump = new NI.OC_SlPr( _sgsDump ),
                getnext = d_getnext = new NI.OC_SlPr( _sgsGetNext ),

                call = d_call = new NI.OC_Self( _sgsCall ),
                expr = d_expr = new NI.OC_Self( _sgsExpr ),
            };

            cinfo = new SGSClassInfo()
            {
                iface = AllocInterface( oi, type.Name ),
                props = _ReadClassProps( ctx, type, false ),
                d_destruct = d_destruct,
                d_gcmark = d_gcmark,
                d_getindex = d_getindex,
                d_setindex = d_setindex,
                d_convert = d_convert,
                d_serialize = d_serialize,
                d_dump = d_dump,
                d_call = d_call,
            };
            ctx.GetEngine()._sgsClassInfo.Add( type, cinfo );
            return cinfo;
        }