Ejemplo n.º 1
0
    public static StringBuilder BuildConstructors(Type type, ConstructorInfo[] constructors, int slot, int howmanyConstructors, List <string> lstNames)
    {
        string fmt = @"
_jstype.definition.{0} = function({1}) [[ CS.Call({2}); ]]";

        StringBuilder sb        = new StringBuilder();
        var           argActual = new cg.args();
        var           argFormal = new cg.args();

        for (int i = 0; i < constructors.Length; i++)
        {
            ConstructorInfo con = constructors[i];
            ParameterInfo[] ps  = con == null? new ParameterInfo[0] : con.GetParameters();

            argActual.Clear().Add(
                (int)JSVCall.Oper.CONSTRUCTOR, // OP
                slot,
                i,                             // NOTICE
                "true",                        // IsStatics
                "this"
                );

            argFormal.Clear();

            // add T to formal param
            if (type.IsGenericTypeDefinition)
            {
                // TODO check
                int TCount = type.GetGenericArguments().Length;
                for (int j = 0; j < TCount; j++)
                {
                    argFormal.Add("t" + j + "");
                    argActual.Add("t" + j + ".getNativeType()");
                }
            }

            //StringBuilder sbFormalParam = new StringBuilder();
            //StringBuilder sbActualParam = new StringBuilder();
            for (int j = 0; j < ps.Length; j++)
            {
                argFormal.Add("a" + j.ToString());
                argActual.Add("a" + j.ToString());
            }

            string mName = SharpKitMethodName("ctor", ps, howmanyConstructors > 1);
            lstNames.Add(mName);

            sb.AppendFormat(fmt,
                            mName,      // [0]
                            argFormal,  // [1]
                            argActual); // [2]
        }
        return(sb);
    }
Ejemplo n.º 2
0
    public static StringBuilder BuildConstructors(Type type, ConstructorInfo[] constructors, int slot, int howmanyConstructors)
    {
        string fmt = @"
        _jstype.definition.{0} = function({1}) [[ CS.Call({2}); ]]";

        StringBuilder sb = new StringBuilder();
        var argActual = new cg.args();
        var argFormal = new cg.args();

        for (int i = 0; i < constructors.Length; i++)
        {
            ConstructorInfo con = constructors[i];
            ParameterInfo[] ps = con == null? new ParameterInfo[0] : con.GetParameters();

            argActual.Clear().Add(
                (int)JSVCall.Oper.CONSTRUCTOR, // OP
                slot,
                i,  // NOTICE
                "true", // IsStatics
                "this"
                );

            argFormal.Clear();

            // add T to formal param
            if (type.IsGenericTypeDefinition)
            {
                // TODO check
                int TCount = type.GetGenericArguments().Length;
                for (int j = 0; j < TCount; j++)
                {
                    argFormal.Add("t" + j + "");
                    argActual.Add("t" + j + ".getNativeType()");
                }
            }

            //StringBuilder sbFormalParam = new StringBuilder();
            //StringBuilder sbActualParam = new StringBuilder();
            for (int j = 0; j < ps.Length; j++)
            {
                argFormal.Add("a" + j.ToString());
                argActual.Add("a" + j.ToString());
            }
            sb.AppendFormat(fmt,
                SharpKitMethodName("ctor", ps, howmanyConstructors > 1), // [0]
                argFormal,    // [1]
                argActual);    // [2]
        }
        return sb;
    }