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 PushPropertyDelegate(FCValueType ret_value, string szName, bool bCanGet, bool bCanSet, bool bStatic) { WrapFuncDesc func = new WrapFuncDesc(); func.m_bAttrib = true; func.m_szName = szName; if (bCanGet) { func.m_szGetName = string.Format("get_{0}_wrap", szName); } else { func.m_szGetName = "null"; } if (bCanSet) { func.m_szSetName = string.Format("set_{0}_wrap", szName); } else { func.m_szSetName = "null"; } m_szTempBuilder.Length = 0; StringBuilder fileData = m_szTempBuilder; string szLeftName = string.Format("ret.{0}", szName); if (bStatic) { szLeftName = string.Format("{0}.{1}", m_szCurClassName, szName); } string szDelegateClassName = string.Format("{0}_deletate", ret_value.GetDelegateName(true)); m_deleteWrap.PushDelegateWrap(ret_value.m_value, szDelegateClassName); if (bCanSet) { fileData.AppendLine(" [MonoPInvokeCallbackAttribute(typeof(FCLibHelper.fc_call_back_inport_class_func))]"); fileData.AppendFormat(" public static int {0}(long L)\r\n", func.m_szSetName); fileData.AppendLine(" {"); fileData.AppendLine(" try"); fileData.AppendLine(" {"); fileData.AppendFormat(" {0} func = FCDelegateMng.Instance.GetDelegate<{1}>(L);\r\n", szDelegateClassName, szDelegateClassName); if (bStatic) { fileData.AppendLine(" if(func != null)"); fileData.AppendFormat(" {0} = func.CallFunc;\r\n", szLeftName); fileData.AppendLine(" else"); fileData.AppendFormat(" {0} = null;\r\n", szLeftName); } else { fileData.AppendLine(" long nThisPtr = FCLibHelper.fc_get_inport_obj_ptr(L);"); fileData.AppendFormat(" {0} ret = get_obj(nThisPtr);\r\n", m_szCurClassName); fileData.AppendLine(" if(func != null)"); fileData.AppendFormat(" {0} = func.CallFunc;\r\n", szLeftName); fileData.AppendLine(" else"); fileData.AppendFormat(" {0} = null;\r\n", szLeftName); } fileData.AppendFormat(" FCDelegateMng.Instance.RecordDelegate({0}, func);\r\n", szLeftName); fileData.AppendLine(" }"); fileData.AppendLine(" catch(Exception e)"); fileData.AppendLine(" {"); fileData.AppendLine(" Debug.LogException(e);"); fileData.AppendLine(" }"); fileData.AppendLine(" return 0;"); fileData.AppendLine(" }"); } func.m_szContent = fileData.ToString(); func.m_szRegister = string.Format("FCLibHelper.fc_register_class_attrib(nClassName,\"{0}\",{1},{2});", func.m_szName, func.m_szGetName, func.m_szSetName); m_CurClassFunc.Add(func); }