void MakeOutDictionaryElement(FCValueType value)
    {
        StringBuilder fileData    = m_szTempBuilder;
        string        szKeyName   = FCValueType.GetFCLibFuncShortName(value.m_nKeyType);
        string        szValueName = FCValueType.GetFCLibFuncShortName(value.m_nValueType);

        if (string.IsNullOrEmpty(szKeyName) || string.IsNullOrEmpty(szValueName))
        {
            return;
        }
        if (FCValueType.IsRefType(value.m_nKeyType))
        {
            fileData.AppendFormat("                k = v.Key;", szKeyName);
            fileData.AppendFormat("                FCLibHelper.fc_set_value_{0}(pKey, ref k);", szKeyName);
        }
        else
        {
            fileData.AppendFormat("                FCLibHelper.fc_set_value_{0}(pKey, v.Key);", szKeyName);
        }
        if (FCValueType.IsRefType(value.m_nValueType))
        {
            fileData.AppendFormat("                v = v.Value;", szKeyName);
            fileData.AppendFormat("                FCLibHelper.fc_set_value_{0}(pKey, ref v);", szKeyName);
        }
        else
        {
            fileData.AppendFormat("                FCLibHelper.fc_set_value_{0}(pValue, v.Value);", szValueName);
        }
        fileData.AppendLine("                FCLibHelper.fc_map_push_key_value(ptr);");
    }
Exemple #2
0
    void MakeOutListElement(FCValueType value)
    {
        StringBuilder fileData = m_szTempBuilder;

        if (fc_value_type.fc_value_system_object == value.m_nValueType ||
            fc_value_type.fc_value_object == value.m_nValueType ||
            fc_value_type.fc_value_unity_object == value.m_nValueType)
        {
            fileData.AppendLine("                FCLibHelper.fc_set_value_intptr(pItem, FCGetObj.PushObj(rList[i]));");
            return;
        }

        string szName = FCValueType.GetFCLibFuncShortName(value.m_nValueType);

        if (string.IsNullOrEmpty(szName))
        {
            return;
        }

        if (FCValueType.IsRefType(value.m_nValueType))
        {
            fileData.AppendLine("                v = rList[i];");
            fileData.AppendFormat("                FCLibHelper.fc_set_value_{0}(pItem, ref v);\r\n", szName);
        }
        else
        {
            fileData.AppendFormat("                FCLibHelper.fc_set_value_{0}(pItem, rList[i]);\r\n", szName);
        }
    }
Exemple #3
0
    void MakeOutListElement(FCValueType value)
    {
        string szName = FCValueType.GetFCLibFuncShortName(value.m_nValueType);

        if (string.IsNullOrEmpty(szName))
        {
            return;
        }
        StringBuilder fileData = m_szTempBuilder;

        if (FCValueType.IsRefType(value.m_nValueType))
        {
            fileData.AppendLine("                v = rList[i];");
            fileData.AppendFormat("                FCLibHelper.fc_set_value_{0}(pItem, ref v);\r\n", szName);
        }
        else
        {
            fileData.AppendFormat("                FCLibHelper.fc_set_value_{0}(pItem, rList[i]);\r\n", szName);
        }
    }
Exemple #4
0
    void SetMemberValue(StringBuilder fileData, string szLeftEmpty, FCValueType value, string szLeftName, string Ptr, string szIndex, bool bTempValue, bool bOut)
    {
        string szCSharpName = value.GetTypeName(true, true);
        string szDefine     = string.Empty;

        if (bTempValue)
        {
            szDefine = szCSharpName + " ";
        }
        if (value.IsArray)
        {
            fileData.AppendFormat("{0}{1} {2} = null;\r\n", szLeftEmpty, szCSharpName, szLeftName);
            fileData.AppendFormat("{0}{1} = FCCustomParam.GetArray(ref {2},{3},{4});\r\n", szLeftEmpty, szLeftName, szLeftName, Ptr, szIndex);
            return;
        }
        else if (value.IsList)
        {
            fileData.AppendFormat("{0}{1} {2} = null;\r\n", szLeftEmpty, szCSharpName, szLeftName);
            fileData.AppendFormat("{0}{1} = FCCustomParam.GetList(ref {2},{3},{4});\r\n", szLeftEmpty, szLeftName, szLeftName, Ptr, szIndex);
            return;
        }
        else if (value.IsMap)
        {
            fileData.AppendFormat("{0}{1} {2} = null;\r\n", szLeftEmpty, szCSharpName, szLeftName);
            fileData.AppendFormat("{0}{1} = FCCustomParam.GetDictionary(ref {2},{3},{4});\r\n", szLeftEmpty, szLeftName, szLeftName, Ptr, szIndex);
            return;
        }
        string szFuncAppend = FCValueType.GetFCLibFuncShortName(value.m_nValueType);

        if (string.IsNullOrEmpty(szFuncAppend))
        {
            if (value.m_nValueType == fc_value_type.fc_value_enum)
            {
                fileData.AppendFormat("{0}{1}{2} = ({3})(FCLibHelper.fc_get_int({4},{5}));\r\n", szLeftEmpty, szDefine, szLeftName, szCSharpName, Ptr, szIndex);
                return;
            }
            if (value.m_nValueType == fc_value_type.fc_value_int_ptr)
            {
                fileData.AppendFormat("{0}{1}{2} = ({3})(FCLibHelper.fc_get_intptr({4},{5}));\r\n", szLeftEmpty, szDefine, szLeftName, szCSharpName, Ptr, szIndex);
                return;
            }
            if (value.m_nValueType == fc_value_type.fc_value_system_object)
            {
                fileData.AppendFormat("{0}{1}{2} = FCGetObj.GetObj<System.Object>(FCLibHelper.fc_get_intptr({3},{4}));\r\n", szLeftEmpty, szDefine, szLeftName, Ptr, szIndex);
                return;
            }
            if (value.m_nValueType == fc_value_type.fc_value_unity_object)
            {
                fileData.AppendFormat("{0}{1}{2} = FCGetObj.GetObj<UnityObject>(FCLibHelper.fc_get_intptr({3},{4}));\r\n", szLeftEmpty, szDefine, szLeftName, Ptr, szIndex);
                return;
            }
            if (value.m_nValueType == fc_value_type.fc_value_delegate)
            {
                string szDelegateClassName = string.Format("{0}_deletate", value.GetDelegateName(true));
                m_deleteWrap.PushDelegateWrap(value.m_value, szDelegateClassName);

                fileData.AppendFormat("{0}{1} func{2} = FCDelegateMng.Instance.GetDelegate<{3}>({4},{5});\r\n", szLeftEmpty, szDelegateClassName, szIndex, szDelegateClassName, Ptr, szIndex);
                fileData.AppendFormat("{0}{1} arg{2} = null;\r\n", szLeftEmpty, szCSharpName, szIndex);
                fileData.AppendFormat("{0}if(func{1} != null)\r\n", szLeftEmpty, szIndex);
                fileData.AppendFormat("{0}    arg{1} = func{2}.CallFunc;\r\n", szLeftEmpty, szIndex, szIndex);
                fileData.AppendFormat("{0}// 尽量不要在函数参数中传递委托指针,这个无法自动托管,要尽可能是使用get, set属性方法\r\n", szLeftEmpty);
                fileData.AppendFormat("{0}// 如果在参数中传递了委托指针,请在对应的函数中调用FCDelegateMng.Instance.RecordDelegate(delegate_func, func);\r\n", szLeftEmpty);
                //fileData.AppendFormat("{0}else\r\n", szLeftEmpty, szIndex);
                //fileData.AppendFormat("{0}    arg{1} = null;\r\n", szLeftEmpty, szIndex);
                //fileData.AppendFormat("{0}FCDelegateMng.Instance.RecordDelegate({1}, func{2});\r\n", szLeftEmpty, szLeftName, szIndex); // 这里不能调用这个,对象不一样的噢
                return;
            }
        }
        else
        {
            if (FCValueType.IsGraphicType(value.m_nValueType))
            {
                fileData.AppendFormat("{0}{1} {2} = new {3}();\r\n", szLeftEmpty, szCSharpName, szLeftName, szCSharpName);
                fileData.AppendFormat("{0}FCLibHelper.fc_get_{1}({2},{3},ref {4});\r\n", szLeftEmpty, szFuncAppend, Ptr, szIndex, szLeftName);
                return;
            }
            else
            {
                fileData.AppendFormat("{0}{1}{2} = FCLibHelper.fc_get_{3}({4},{5});\r\n", szLeftEmpty, szDefine, szLeftName, szFuncAppend, Ptr, szIndex);
                return;
            }
        }
        fileData.AppendFormat("{0}{1}{2} = FCGetObj.GetObj<{3}>(FCLibHelper.fc_get_intptr({4},{5}));\r\n", szLeftEmpty, szDefine, szLeftName, szCSharpName, Ptr, szIndex);
    }
    void MakeReturnFastArray(FCValueType value)
    {
        StringBuilder fileData      = m_szTempBuilder;
        string        szTypeName    = value.GetValueName(true, true);
        string        szFuncDeclare = string.Format("    public static void ReturnArray({0} []rList, long ptr)", szTypeName);

        if (TrySetExportFlag(szFuncDeclare))
        {
            return;
        }
        fileData.AppendLine(szFuncDeclare);
        fileData.AppendLine("    {");
        fileData.AppendLine("        try");
        fileData.AppendLine("        {");
        fileData.AppendLine("            int nCount = rList != null ? rList.Length : 0;");
        //fileData.AppendLine("            long ptr = FCLibHelper.fc_get_return_ptr(L);");
        fileData.AppendFormat("            FCLibHelper.fc_set_array_{0}(ptr, rList, 0, nCount);\r\n", FCValueType.GetFCLibFuncShortName(value.m_nValueType));
        fileData.AppendLine("        }");
        fileData.AppendLine("        catch(Exception e)");
        fileData.AppendLine("        {");
        fileData.AppendLine("            Debug.LogException(e);");
        fileData.AppendLine("        }");
        fileData.AppendLine("    }");
    }
    void  AddFCFuncCall(FCValueType value, string szCharpName, bool bList)
    {
        StringBuilder fileData = m_szTempBuilder;

        switch (value.m_nValueType)
        {
        case fc_value_type.fc_value_bool:
        case fc_value_type.fc_value_byte:
        case fc_value_type.fc_value_short:
        case fc_value_type.fc_value_ushort:
        case fc_value_type.fc_value_int:
        case fc_value_type.fc_value_uint:
        case fc_value_type.fc_value_float:
        case fc_value_type.fc_value_double:
        case fc_value_type.fc_value_vector2:
        case fc_value_type.fc_value_vector3:
        case fc_value_type.fc_value_vector4:
        case fc_value_type.fc_value_rect:
        case fc_value_type.fc_value_color32:
        case fc_value_type.fc_value_color:
        {
            string szFuncAppend = FCValueType.GetFCLibFuncShortName(value.m_nValueType);
            if (bList)
            {
                fileData.AppendFormat("            {0}[] buffer = new {1}[nArraySize];\r\n", szCharpName, szCharpName);
                fileData.AppendFormat("            FCLibHelper.fc_get_array_{0}(ptr, buffer, 0, nArraySize);\r\n", szFuncAppend);
                fileData.AppendLine("            rList.AddRange(buffer);");
            }
            else
            {
                fileData.AppendFormat("            FCLibHelper.fc_get_array_{0}(ptr, rList, 0, nArraySize);\r\n", szFuncAppend);
            }
        }
        break;

        case fc_value_type.fc_value_int64:
        {
            fileData.AppendLine("            for (int i = 0; i < nArraySize; ++i)");
            fileData.AppendLine("            {");
            fileData.AppendLine("                long item_ptr = FCLibHelper.fc_get_array_node_temp_ptr(ptr, i);");
            if (bList)
            {
                fileData.AppendLine("                rList.Add(FCLibHelper.fc_get_value_int64(item_ptr));");
            }
            else
            {
                fileData.AppendLine("                rList[i] = FCLibHelper.fc_get_value_int64(item_ptr);");
            }
            fileData.AppendLine("            }");
        }
        break;

        case fc_value_type.fc_value_plane:
        {
            fileData.AppendLine("            for (int i = 0; i < nArraySize; ++i)");
            fileData.AppendLine("            {");
            fileData.AppendLine("                long item_ptr = FCLibHelper.fc_get_array_node_temp_ptr(ptr, i);");
            fileData.AppendLine("                Plane item = new Plane();");
            fileData.AppendLine("                FCLibHelper.fc_get_value_plane(item_ptr, ref item);");
            if (bList)
            {
                fileData.AppendLine("                rList.Add(item);");
            }
            else
            {
                fileData.AppendLine("                rList[i] = item;");
            }
            fileData.AppendLine("            }");
        }
        break;

        case fc_value_type.fc_value_bounds:
        {
            fileData.AppendLine("            for (int i = 0; i < nArraySize; ++i)");
            fileData.AppendLine("            {");
            fileData.AppendLine("                long item_ptr = FCLibHelper.fc_get_array_node_temp_ptr(ptr, i);");
            fileData.AppendLine("                Bounds item = new Bounds();");
            fileData.AppendLine("                FCLibHelper.fc_get_value_bounds(item_ptr, ref item);");
            if (bList)
            {
                fileData.AppendLine("                rList.Add(item);");
            }
            else
            {
                fileData.AppendLine("                rList[i] = item;");
            }
            fileData.AppendLine("            }");
        }
        break;

        case fc_value_type.fc_value_matrix:
        {
            fileData.AppendLine("            for (int i = 0; i < nArraySize; ++i)");
            fileData.AppendLine("            {");
            fileData.AppendLine("                long item_ptr = FCLibHelper.fc_get_array_node_temp_ptr(ptr, i);");
            fileData.AppendLine("                Matrix4x4 item = new Matrix4x4();");
            fileData.AppendLine("                FCLibHelper.fc_get_value_matrix(item_ptr, ref item);");
            if (bList)
            {
                fileData.AppendLine("                rList.Add(item);");
            }
            else
            {
                fileData.AppendLine("                rList[i] = item;");
            }
            fileData.AppendLine("            }");
        }
        break;

        case fc_value_type.fc_value_ray:
        {
            fileData.AppendLine("            for (int i = 0; i < nArraySize; ++i)");
            fileData.AppendLine("            {");
            fileData.AppendLine("                long item_ptr = FCLibHelper.fc_get_array_node_temp_ptr(ptr, i);");
            fileData.AppendLine("                Ray item = new Ray();");
            fileData.AppendLine("                FCLibHelper.fc_get_value_ray(item_ptr, ref item);");
            if (bList)
            {
                fileData.AppendLine("                rList.Add(item);");
            }
            else
            {
                fileData.AppendLine("                rList[i] = item;");
            }
            fileData.AppendLine("            }");
        }
        break;

        case fc_value_type.fc_value_uint64:
        {
            fileData.AppendLine("            for (int i = 0; i < nArraySize; ++i)");
            fileData.AppendLine("            {");
            fileData.AppendLine("                long item_ptr = FCLibHelper.fc_get_array_node_temp_ptr(ptr, i);");
            fileData.AppendLine("                long item = FCLibHelper.fc_get_value_uint64(item_ptr);");
            if (bList)
            {
                fileData.AppendLine("                rList.Add(item);");
            }
            else
            {
                fileData.AppendLine("                rList[i] = item;");
            }
            fileData.AppendLine("            }");
        }
        break;

        case fc_value_type.fc_value_string_a:
        {
            fileData.AppendLine("            for (int i = 0; i < nArraySize; ++i)");
            fileData.AppendLine("            {");
            fileData.AppendLine("                long item_ptr = FCLibHelper.fc_get_array_node_temp_ptr(ptr, i);");
            fileData.AppendLine("                string item = FCLibHelper.fc_get_value_string_a(item_ptr);");
            if (bList)
            {
                fileData.AppendLine("                rList.Add(item);");
            }
            else
            {
                fileData.AppendLine("                rList[i] = item;");
            }
            fileData.AppendLine("            }");
        }
        break;

        case fc_value_type.fc_value_system_object:
        case fc_value_type.fc_value_unity_object:
        case fc_value_type.fc_value_object:
        {
            fileData.AppendLine("            for (int i = 0; i < nArraySize; ++i)");
            fileData.AppendLine("            {");
            fileData.AppendLine("                long item_ptr = FCLibHelper.fc_get_array_node_temp_ptr(ptr, i);");
            //if(value.m_value.IsClass)
            fileData.AppendFormat("                {0} item = FCGetObj.GetObj<{0}>(item_ptr);\r\n", szCharpName, szCharpName);
            //else
            //    fileData.AppendFormat("                {0} item = FCGetObj.GetStructObj<{0}>(item_ptr);\r\n", szCharpName, szCharpName);
            if (bList)
            {
                fileData.AppendLine("                rList.Add(item);");
            }
            else
            {
                fileData.AppendLine("                rList[i] = item;");
            }
            fileData.AppendLine("            }");
        }
        break;

        case fc_value_type.fc_value_enum:
        {
            fileData.AppendLine("            for (int i = 0; i < nArraySize; ++i)");
            fileData.AppendLine("            {");
            fileData.AppendLine("                long item_ptr = FCLibHelper.fc_get_array_node_temp_ptr(ptr, i);");
            fileData.AppendFormat("                {0} item = ({1})FCLibHelper.fc_get_value_int(item_ptr);\r\n", szCharpName, szCharpName);
            if (bList)
            {
                fileData.AppendLine("                rList.Add(item);");
            }
            else
            {
                fileData.AppendLine("                rList[i] = item;");
            }
            fileData.AppendLine("            }");
        }
        break;

        default:
            break;
        }
    }
Exemple #7
0
    void MakeOutFastArray(FCValueType value)
    {
        StringBuilder fileData   = m_szTempBuilder;
        string        szTypeName = value.GetValueName(true);

        fileData.AppendFormat("    public static void OutArray({0} []rList, long L, int nIndex)\r\n", szTypeName);
        fileData.AppendLine("    {");
        fileData.AppendLine("        try");
        fileData.AppendLine("        {");
        fileData.AppendLine("            int nCount = rList != null ? rList.Count : 0;");
        fileData.AppendLine("            long ptr = FCLibHelper.fc_get_param_ptr(L, nIndex);");
        fileData.AppendFormat("            FCLibHelper.fc_set_array_{0}(ptr, rList, 0, nCount);", FCValueType.GetFCLibFuncShortName(value.m_nValueType));
        fileData.AppendLine("        }");
        fileData.AppendLine("        catch(Exception e)");
        fileData.AppendLine("        {");
        fileData.AppendLine("            Debug.LogException(e);");
        fileData.AppendLine("        }");
        fileData.AppendLine("    }");
    }