Ejemplo n.º 1
0
    /*
     * ExtractCSParams
     *
     * extract some info to use latter
     * write into m_ParamInfo and lstCSParam
     * ONLY for Reflection
     */
    public void ExtractCSParams()
    {
        if (m_ParamInfo == null)
        {
            m_ParamInfo = m_Method.GetParameters();
        }

        arrCSParamsLength = m_ParamInfo.Length;
        for (int i = 0; i < m_ParamInfo.Length; i++)
        {
            ParameterInfo p = m_ParamInfo[i];

            CSParam csParam = arrCSParam[i];
            csParam.isOptional = p.IsOptional;
            csParam.isRef      = p.ParameterType.IsByRef;
            csParam.isArray    = p.ParameterType.IsArray;
            csParam.type       = p.ParameterType;
        }
    }
Ejemplo n.º 2
0
    // index means
    // lstJSParam[index]
    // lstCSParam[index]
    // ps[index]
    // for calling method
    public object JSValue_2_CSObject(int index)
    {
        JSParam jsParam    = arrJSParam[index];
        int     paramIndex = jsParam.index;
        CSParam csParam    = arrCSParam[index];
        //ParameterInfo p = m_ParamInfo[index];

        Type t = csParam.type;

        if (csParam.isRef)
        {
            t = t.GetElementType();
        }

        if (jsParam.isNull)
        {
            return(null);
        }
        else if (jsParam.isWrap)
        {
            return(jsParam.wrappedObj);
        }
        else if (jsParam.csObj != null)
        {
            return(jsParam.csObj);
        }

//         if (typeof(UnityEngine.Object).IsAssignableFrom(t))
//         {
//             if (jsParam.isNull)
//                 return null;
//
//             if (jsParam.isWrap)
//                 return jsParam.wrappedObj;
//
//             return jsParam.csObj;
//         }

        return(JSValue_2_CSObject(csParam.type, paramIndex));
    }
Ejemplo n.º 3
0
    public void Reset(IntPtr cx, IntPtr vp)
    {
        if (arrJSParam == null)
        {
            arrJSParam = new JSParam[(int)Consts.MaxParams];
            arrCSParam = new CSParam[(int)Consts.MaxParams];
            for (int i = 0; (int)Consts.MaxParams > i; i++)
            {
                arrJSParam[i] = new JSParam();
                arrCSParam[i] = new CSParam();
            }
            callParams = new object[(int)Consts.MaxParams];
        }
        arrJSParamsLength = 0;
        arrCSParamsLength = 0;
        callParamsLength  = 0;

        m_Method    = null;
        m_ParamInfo = null;

        this.cx   = cx;
        this.vp   = vp;
        currIndex = 0;
    }