void MakeReturnList(FCValueType value) { StringBuilder fileData = m_szTempBuilder; string szValueName = value.GetValueName(true, true); string szFuncDeclare = string.Format(" public static void ReturnList(List<{0}> rList, long ptr)", szValueName); if (TrySetExportFlag(szFuncDeclare)) { return; } fileData.AppendLine(szFuncDeclare); fileData.AppendLine(" {"); fileData.AppendLine(" try"); fileData.AppendLine(" {"); fileData.AppendLine(" int nCount = rList != null ? rList.Count : 0;"); //fileData.AppendLine(" long ptr = FCLibHelper.fc_get_return_ptr(L);"); fileData.AppendLine(" FCLibHelper.fc_set_array_size(ptr, nCount);"); if (FCValueType.IsRefType(value.m_nValueType)) { fileData.AppendFormat(" {0} v;\r\n", szValueName); } fileData.AppendLine(" for(int i = 0; i<nCount; ++i)"); fileData.AppendLine(" {"); fileData.AppendLine(" long pItem = FCLibHelper.fc_get_array_node_temp_ptr(ptr, i);"); MakeOutListElement(value); fileData.AppendLine(" }"); fileData.AppendLine(" }"); fileData.AppendLine(" catch(Exception e)"); fileData.AppendLine(" {"); fileData.AppendLine(" Debug.LogException(e);"); fileData.AppendLine(" }"); fileData.AppendLine(" }"); }
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(" }"); }
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);"); }
void MakeOutList(FCValueType value) { StringBuilder fileData = m_szTempBuilder; string szTypeName = value.GetTypeName(true); fileData.AppendFormat(" public static void OutList({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.AppendLine(" FCLibHelper.fc_set_array_size(ptr, nCount);"); if (FCValueType.IsRefType(value.m_nValueType)) { fileData.AppendFormat(" {0} v;\r\n", value.GetValueName(true)); } fileData.AppendLine(" for(int i = 0; i<nCount; ++i)"); fileData.AppendLine(" {"); fileData.AppendLine(" long pItem = FCLibHelper.fc_get_array_node_temp_ptr(ptr, i);"); MakeOutListElement(value); fileData.AppendLine(" }"); fileData.AppendLine(" }"); fileData.AppendLine(" catch(Exception e)"); fileData.AppendLine(" {"); fileData.AppendLine(" Debug.LogException(e);"); fileData.AppendLine(" }"); fileData.AppendLine(" }"); }
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); } }
void MakeOutArray(FCValueType value) { 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_color32: case fc_value_type.fc_value_color: 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: MakeOutFastArray(value); return; default: break; } StringBuilder fileData = m_szTempBuilder; string szTypeName = value.GetValueName(true, true); string szFuncDeclare = string.Format(" public static void OutArray({0} []rList, long L, int nIndex)", 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 VM = FCLibHelper.fc_get_vm_ptr(L);"); fileData.AppendLine(" long ptr = FCLibHelper.fc_get_param_ptr(L, nIndex);"); fileData.AppendLine(" FCLibHelper.fc_set_array_size(VM, ptr, nCount);"); if (FCValueType.IsRefType(value.m_nValueType)) { fileData.AppendFormat(" {0} v;\r\n", value.GetValueName(true)); } fileData.AppendLine(" for(int i = 0; i<nCount; ++i)"); fileData.AppendLine(" {"); fileData.AppendLine(" long pItem = FCLibHelper.fc_get_array_node_temp_ptr(VM, ptr, i);"); MakeOutListElement(value); fileData.AppendLine(" }"); fileData.AppendLine(" }"); fileData.AppendLine(" catch(Exception e)"); fileData.AppendLine(" {"); fileData.AppendLine(" Debug.LogException(e);"); fileData.AppendLine(" }"); fileData.AppendLine(" }"); }
void MakeDeleteCallFunc(Type nClassType) { // 得到委托的参数 MethodInfo method = nClassType.GetMethod("Invoke"); ParameterInfo[] allParams = method.GetParameters(); // 函数参数 FCValueType ret_value = FCValueType.TransType(method.ReturnType); string szCallDesc = string.Empty; int nParamCount = allParams != null ? allParams.Length : 0; for (int i = 0; i < nParamCount; ++i) { FCValueType value_param = FCValueType.TransType(allParams[i].ParameterType); if (i > 0) { szCallDesc += ","; } szCallDesc += string.Format("{0} arg{1}", value_param.GetTypeName(true, true), i); } m_szTempBuilder.AppendFormat(" public {0} CallFunc({1})\r\n", ret_value.GetTypeName(true, true), szCallDesc); m_szTempBuilder.AppendLine(" {"); m_szTempBuilder.AppendLine(" try"); m_szTempBuilder.AppendLine(" {"); string szArg = string.Empty; for (int i = 0; i < nParamCount; ++i) { szArg = string.Format("arg{0}", i); FCValueType value_param = FCValueType.TransType(allParams[i].ParameterType); if (value_param.m_nTemplateType != fc_value_tempalte_type.template_none) { Debug.LogError(nClassType.FullName + "参数不支持模板"); continue; } if (FCValueType.IsRefType(value_param.m_nValueType)) { m_szTempBuilder.AppendFormat(" FCDll.PushCallParam(ref {0});\r\n", szArg); } else { m_szTempBuilder.AppendFormat(" FCDll.PushCallParam({0});\r\n", szArg); } } m_szTempBuilder.AppendLine(" FCLibHelper.fc_call(m_nThisPtr, m_szFuncName);"); m_szTempBuilder.AppendLine(" }"); m_szTempBuilder.AppendLine(" catch(Exception e)"); m_szTempBuilder.AppendLine(" {"); m_szTempBuilder.AppendLine(" Debug.LogException(e);"); m_szTempBuilder.AppendLine(" }"); m_szTempBuilder.AppendLine(" }"); }
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); } }