Ejemplo n.º 1
0
    void MakeReturnDictionary(FCValueType value)
    {
        StringBuilder fileData = m_szTempBuilder;

        string szKeyName   = value.GetKeyName(true);
        string szValeuName = value.GetValueName(true);

        fileData.AppendFormat("    public static void ReturnDictionary(Dictionary<{0}, {1}> rList, long L)\r\n", szKeyName, szValeuName);
        fileData.AppendLine("    {");
        fileData.AppendLine("        try");
        fileData.AppendLine("        {");
        fileData.AppendLine("            long ptr = FCLibHelper.fc_get_return_ptr(L);");
        fileData.AppendLine("            FCLibHelper.fc_map_clear(ptr); // 先清空map");
        fileData.AppendLine("            if (rList == null) return;");
        fileData.AppendLine("            long pKey = FCLibHelper.fc_get_map_push_key_ptr(ptr);");
        fileData.AppendLine("            long pValue = FCLibHelper.fc_get_map_push_value_ptr(ptr);");
        if (FCValueType.IsRefType(value.m_nKeyType))
        {
            fileData.AppendFormat("            {0} k;\r\n", szKeyName);
        }
        if (FCValueType.IsRefType(value.m_nValueType))
        {
            fileData.AppendFormat("            {0} v;\r\n", szKeyName);
        }
        fileData.AppendLine("            foreach (var v in rList)");
        fileData.AppendLine("            {");
        MakeOutDictionaryElement(value);
        fileData.AppendLine("            }");
        fileData.AppendLine("        }");
        fileData.AppendLine("        catch(Exception e)");
        fileData.AppendLine("        {");
        fileData.AppendLine("            Debug.LogException(e);");
        fileData.AppendLine("        }");
        fileData.AppendLine("    }");
    }
Ejemplo n.º 2
0
    void MakeDictionary(FCValueType value)
    {
        StringBuilder fileData = m_szTempBuilder;

        string szKeyName     = value.GetKeyName(true, true);
        string szValeuName   = value.GetValueName(true, true);
        string szFuncDeclare = string.Format("    public static Dictionary<{0},{1}> GetDictionary(ref Dictionary<{2},{3}> rList, long L, int nIndex)", szKeyName, szValeuName, szKeyName, szValeuName);

        if (TrySetExportFlag(szFuncDeclare))
        {
            return;
        }
        fileData.AppendLine(szFuncDeclare);
        fileData.AppendLine("    {");
        fileData.AppendLine("        try");
        fileData.AppendLine("        {");
        fileData.AppendLine("            if (rList == null)");
        fileData.AppendFormat("                rList = new Dictionary<{0}, {1}>();\r\n", szKeyName, szValeuName);
        fileData.AppendLine("            else");
        fileData.AppendLine("                rList.Clear();");

        fileData.AppendLine("            long VM = FCLibHelper.fc_get_vm_ptr(L);");
        fileData.AppendLine("            long ptr = FCLibHelper.fc_get_param_ptr(L, nIndex);");
        fileData.AppendLine("            int nCount = FCLibHelper.fc_get_map_size(VM, ptr);");

        fileData.AppendLine("            for(; nCount > 0; --nCount)");
        fileData.AppendLine("            {");
        fileData.AppendLine("                FCLibHelper.fc_map_to_next_pair(VM);");
        fileData.AppendLine("                long key_ptr = FCLibHelper.fc_map_get_cur_key_ptr(VM);");
        fileData.AppendLine("                long value_ptr = FCLibHelper.fc_map_get_cur_value_ptr(VM);");
        bool bValidKey   = AddKeyValueCall(value.m_nKeyType, "key", "key_ptr", szKeyName);
        bool bValidValue = AddKeyValueCall(value.m_nValueType, "value", "value_ptr", szValeuName);

        if (bValidKey && bValidValue)
        {
            fileData.AppendLine("                rList[key] = value;");
        }

        fileData.AppendLine("            }");

        fileData.AppendLine("        }");
        fileData.AppendLine("        catch(Exception e)");
        fileData.AppendLine("        {");
        fileData.AppendLine("            Debug.LogException(e);");
        fileData.AppendLine("        }");
        fileData.AppendLine("        return rList;");

        fileData.AppendLine("    }");
    }