public static void AddMethodHandlersClass(DefClass type, IndentStringBuilder sb) { if (!type.HasWrapType(WrapTypes.NativeDirector)) throw new Exception("Unexpected"); if (type.IsNested) sb.AppendIndent("public: "); else sb.AppendIndent("public "); sb.Append("ref class " + type.Name + " abstract sealed\n"); sb.AppendLine("{"); sb.AppendLine("public:"); sb.IncreaseIndent(); foreach (DefFunction f in type.PublicMethods) { if (f.IsDeclarableFunction && f.IsVirtual) { sb.AppendIndent("delegate static " + f.CLRTypeName + " " + f.CLRName + "Handler("); for (int i = 0; i < f.Parameters.Count; i++) { DefParam param = f.Parameters[i]; sb.Append(" " + param.Type.GetCLRParamTypeName(param) + " " + param.Name); if (i < f.Parameters.Count - 1) sb.Append(","); } sb.Append(" );\n"); } } sb.DecreaseIndent(); sb.AppendLine("};"); sb.AppendLine(); }
protected virtual string GetNativeDirectorName(DefClass type) { if (!type.HasWrapType(WrapTypes.NativeDirector)) { throw new Exception("Unexpected"); } string name = (type.IsNested) ? type.ParentClass.Name + "_" + type.Name : type.Name; return(name + "_Director"); }
public static void AddMethodHandlersClass(DefClass type, IndentStringBuilder sb) { if (!type.HasWrapType(WrapTypes.NativeDirector)) { throw new Exception("Unexpected"); } if (type.IsNested) { sb.AppendIndent("public: "); } else { sb.AppendIndent("public "); } sb.Append("ref class " + type.Name + " abstract sealed\n"); sb.AppendLine("{"); sb.AppendLine("public:"); sb.IncreaseIndent(); foreach (DefFunction f in type.PublicMethods) { if (f.IsDeclarableFunction && f.IsVirtual) { //if (f.Parameters.Count > 0) //{ // AddEventArgsClass(f, sb); //} sb.AppendIndent("delegate static " + f.CLRTypeName + " " + f.CLRName + "Handler("); for (int i = 0; i < f.Parameters.Count; i++) { DefParam param = f.Parameters[i]; sb.Append(" " + param.Type.GetCLRParamTypeName(param) + " " + param.Name); if (i < f.Parameters.Count - 1) { sb.Append(","); } } sb.Append(" );\n"); } } sb.DecreaseIndent(); sb.AppendLine("};"); sb.AppendLine(); }
protected virtual string GetNativeDirectorReceiverInterfaceName(DefClass type) { if (!type.HasWrapType(WrapTypes.NativeDirector)) throw new Exception("Unexpected"); string name = (type.IsNested) ? type.ParentClass.Name + "_" + type.Name : type.Name; return "I" + name + "_Receiver"; }