void AddMoreTypeInfo() { //-------- //copy all Freeze(); // Dictionary <string, TypeSymbol> tempSymbols = new Dictionary <string, TypeSymbol>(); int typeCount = typeSymbols.Count; foreach (var kp in typeSymbols) { tempSymbols.Add(kp.Key, kp.Value); } //Cef- find tune detail of base type foreach (TypeSymbol t in tempSymbols.Values) { switch (t.TypeSymbolKind) { default: throw new NotSupportedException(); case TypeSymbolKind.Simple: { SimpleTypeSymbol simpleType = (SimpleTypeSymbol)t; if (simpleType.PrimitiveTypeKind == PrimitiveTypeKind.NotPrimitiveType) { //resolve base type CodeTypeDeclaration typedecl = simpleType.CreatedByTypeDeclaration; if (typedecl != null && typedecl.BaseTypes != null && typedecl.BaseTypes.Count > 0) { CefResolvingContext ctx = new CefResolvingContext(this, null, ResolvingContextKind.Base); simpleType.BaseType = ctx.ResolveType(typedecl.BaseTypes[0]); } else { } } else { } } break; case TypeSymbolKind.TypeDef: { CTypeDefTypeSymbol typedefSymbol = (CTypeDefTypeSymbol)t; CefResolvingContext ctx = new CefResolvingContext(this, null, ResolvingContextKind.Base); typedefSymbol.ReferToTypeSymbol = ctx.ResolveType(typedefSymbol.OriginalTypeDecl); } break; } } //------- //assign bridge information //------- //swap this.typeSymbols = tempSymbols; }
internal TypeSymbol RegisterBaseCToCppTypeSymbol(CodeTypeReference cToCppTypeReference) { #if DEBUG if (!CefResolvingContext.IsAllLowerLetter(cToCppTypeReference.Name)) { //cef-name convention throw new NotSupportedException(); } #endif TypeSymbol found; if (!typeSymbols.TryGetValue(cToCppTypeReference.Name, out found)) { //if not found then create the new simple type found = new SimpleTypeSymbol(cToCppTypeReference.Name); RegisterType(cToCppTypeReference.Name, found); } return(cToCppTypeReference.ResolvedType = found); }
// protected virtual void PreviewVisitSimpleTypeNonPrimitive(SimpleTypeSymbol t) { //check its base TypeSymbol baseType = t.BaseType; if (baseType == null) { VisitSimpleTypeNoBaseType(t); } else { switch (baseType.TypeSymbolKind) { default: VisitSimpleTypeOtherBase(t); break; case TypeSymbolKind.Template: { TemplateTypeSymbol tt = (TemplateTypeSymbol)baseType; switch (tt.ItemCount) { default: throw new NotSupportedException(); case 1: VisitSimpleTypeBase1(t, (TemplateTypeSymbol1)tt); break; case 2: VisitSimpleTypeBase2(t, (TemplateTypeSymbol2)tt); break; case 3: VisitSimpleTypeBase3(t, (TemplateTypeSymbol3)tt); break; } } break; } } }
protected virtual void VisitChar(SimpleTypeSymbol t) { }
protected virtual void VisitFloat(SimpleTypeSymbol t) { }
protected virtual void VisitCefString(SimpleTypeSymbol t) { }
protected virtual void Visit_size_t(SimpleTypeSymbol t) { }
protected virtual void VisitDouble(SimpleTypeSymbol t) { }
protected virtual void VisitSimpleTypeBase3(SimpleTypeSymbol t, TemplateTypeSymbol3 baseT3) { }
TypeSymbol ResolveType(string typename) { TypeSymbol foundSymbol = null; if (_currentResolvingType != null) { //1. if (_currentResolvingType.IsTemplateTypeDefinition) { // //check if this is the template type parameter //if (typename == _currentResolvingType.TemplateNotation.templatePar.ReAssignToTypeName) //{ //found // return new TemplateParameterTypeSymbol(_currentResolvingType.TemplateNotation.templatePar); //} CodeTemplateParameter foundTemplatePar = null; if (_currentResolvingType.TemplateNotation.TryGetTemplateParByReAssignToName(typename, out foundTemplatePar)) { //TODO: resolve template type parameter return(new TemplateParameterTypeSymbol(foundTemplatePar)); } if (_currentResolvingType.TemplateNotation.TryGetTemplateParByParameterName(typename, out foundTemplatePar)) { //TODO: resolve template type parameter return(new TemplateParameterTypeSymbol(foundTemplatePar)); } } //2. //search nest type //TODO: review here -> use field if (_currentResolvingType.HasSubType) { List <CodeMemberDeclaration> tempResults = new List <CodeMemberDeclaration>(); int foundCount; if ((foundCount = _currentResolvingType.FindSubType(typename, tempResults)) > 0) { for (int i = 0; i < foundCount; ++i) { CodeMemberDeclaration subtype = tempResults[i]; switch (subtype.MemberKind) { default: throw new NotSupportedException(); case CodeMemberKind.Type: break; case CodeMemberKind.TypeDef: { CodeCTypeDef ctypedef = (CodeCTypeDef)subtype; TypeSymbol resolveFromType = ResolveType(ctypedef.From); if (resolveFromType != null) { //found return(resolveFromType); } } break; } } } } //3 if (_currentResolvingType.BaseTypes != null) { //check if we need to search in other scopes int baseCount = _currentResolvingType.BaseTypes.Count; //we get only 1 base count if (baseCount > 0) { if ((foundSymbol = SearchFromFirstBase(_currentResolvingType.BaseTypes[0] as CodeTypeTemplateTypeReference, typename)) != null) { return(foundSymbol); } } } } //------- if (this._typeCollection.TryGetType(typename, out foundSymbol)) { return(foundSymbol); } //this is convention if (typename.StartsWith("cef_") && IsAllLowerLetter(typename)) { //assume this is base c/cpp type foundSymbol = new SimpleTypeSymbol(typename); this._typeCollection.RegisterType( typename, foundSymbol); return(foundSymbol); } //not found return(foundSymbol); }
protected virtual void VisitSimpleTypeNoBaseType(SimpleTypeSymbol t) { }
protected virtual void VisitSimpleTypeBase1(SimpleTypeSymbol t, TemplateTypeSymbol1 baseT1) { }
protected virtual void VisitBool(SimpleTypeSymbol t) { }
protected virtual void VisitVoid(SimpleTypeSymbol t) { }
protected virtual void PreviewVisitSimpleType(SimpleTypeSymbol t) { switch (t.PrimitiveTypeKind) { default: throw new NotSupportedException(); case PrimitiveTypeKind.NotPrimitiveType: PreviewVisitSimpleTypeNonPrimitive(t); break; case PrimitiveTypeKind.Void: VisitVoid(t); break; case PrimitiveTypeKind.Int32: VisitInt32(t); break; case PrimitiveTypeKind.UInt32: VisitUInt32(t); break; case PrimitiveTypeKind.UInt64: VisitUInt64(t); break; case PrimitiveTypeKind.Int64: VisitInt64(t); break; case PrimitiveTypeKind.NaitveInt: VisitNativeInt(t); break; case PrimitiveTypeKind.IntPtr: VisitIntPtr(t); break; case PrimitiveTypeKind.Double: VisitDouble(t); break; case PrimitiveTypeKind.Float: VisitFloat(t); break; case PrimitiveTypeKind.Char: VisitChar(t); break; case PrimitiveTypeKind.Bool: VisitBool(t); break; case PrimitiveTypeKind.String: VisitString(t); break; case PrimitiveTypeKind.CefString: VisitCefString(t); break; case PrimitiveTypeKind.size_t: Visit_size_t(t); break; } }
TypeSymbol SearchFromFirstBase(CodeTypeTemplateTypeReference firstBase, string typename) { if (firstBase == null) { return(null); } CodeTypeTemplateTypeReference templateTypeRef = (CodeTypeTemplateTypeReference)firstBase; //----------- //first base is not resolve switch (templateTypeRef.Items.Count) { case 3: { //we accept only known template name switch (firstBase.Name) { default: break; case "CefCppToCScoped": case "CefCppToCRefCounted": // case "CefCToCppRefCounted": case "CefCToCppScoped": { //c-to-cpp //search in another scope item2 CodeTypeReference typeRef1 = templateTypeRef.Items[1]; if (typeRef1.Name == typename) { TypeSymbol foundSymbol1; if (this._typeCollection.TryGetType(typename, out foundSymbol1)) { return(foundSymbol1); } } else { } TemplateTypeSymbol3 t3 = (TemplateTypeSymbol3)templateTypeRef.ResolvedType; TypeSymbol t1 = t3.Item1; // switch (t1.TypeSymbolKind) { default: break; case TypeSymbolKind.Simple: { SimpleTypeSymbol s = (SimpleTypeSymbol)t1; //check nested type if (s.NestedTypeSymbols != null) { int nestedTypeCount = s.NestedTypeSymbols.Count; for (int n = 0; n < nestedTypeCount; ++n) { TypeSymbol nestedType = s.NestedTypeSymbols[n]; switch (nestedType.TypeSymbolKind) { case TypeSymbolKind.Simple: { } break; case TypeSymbolKind.TypeDef: { CTypeDefTypeSymbol cTypeDef = (CTypeDefTypeSymbol)nestedType; if (cTypeDef.Name == typename) { //found return(cTypeDef); } } break; default: break; } } } } break; } } break; } } break; } return(null); }
void RegisterTypeDeclaration(CodeTypeDeclaration typeDecl) { //1. collect if (typeDecl.IsGlobalCompilationUnitType) { //this is global type if (typeDecl.MemberCount == 0) { //skip this global type return; } } if (!typeDecl.IsForwardDecl && typeDecl.Name != null) { CodeTypeDeclaration existingDecl; if (typedeclDic.TryGetValue(typeDecl.FullName, out existingDecl)) { //found throw new Exception("duplicated key " + typeDecl.Name); } typedeclDic.Add(typeDecl.FullName, typeDecl); //----------------------- SimpleTypeSymbol typeSymbol = new SimpleTypeSymbol(typeDecl); typeDecl.ResolvedType = typeSymbol; // TypeSymbol existingTypeSymbol; if (TryGetType(typeSymbol.Name, out existingTypeSymbol)) { //have existing value throw new NotSupportedException(); } else { RegisterType(typeSymbol.Name, typeSymbol); } // //and sub types if (!typeDecl.IsGlobalCompilationUnitType) { foreach (CodeMemberDeclaration subType in typeDecl.GetSubTypeIter()) { if (subType.MemberKind == CodeMemberKind.TypeDef) { CodeCTypeDef ctypeDef = (CodeCTypeDef)subType; // CTypeDefTypeSymbol ctypedefTypeSymbol = new CTypeDefTypeSymbol(ctypeDef.Name, ctypeDef.From); ctypedefTypeSymbol.CreatedTypeCTypeDef = ctypeDef; ctypedefTypeSymbol.ParentType = typeSymbol; //--- RegisterType(typeSymbol.Name + "." + ctypeDef.Name, ctypedefTypeSymbol); List <TypeSymbol> nestedTypes = typeSymbol.NestedTypeSymbols; if (nestedTypes == null) { typeSymbol.NestedTypeSymbols = nestedTypes = new List <TypeSymbol>(); } nestedTypes.Add(ctypedefTypeSymbol); } } } } }
protected virtual void VisitSimpleTypeOtherBase(SimpleTypeSymbol t) { }
protected virtual void VisitUInt64(SimpleTypeSymbol t) { }
protected virtual void VisitSimpleTypeBase2(SimpleTypeSymbol t, TemplateTypeSymbol2 baseT2) { }
protected virtual void VisitNativeInt(SimpleTypeSymbol t) { }
public void GenerateBridge(string cefSrcFolder) { string cefDir = cefSrcFolder; List <CodeCompilationUnit> totalCuList_capi = new List <CodeCompilationUnit>(); List <CodeCompilationUnit> totalCuList = new List <CodeCompilationUnit>(); List <CodeCompilationUnit> test_cpptoc_List = new List <CodeCompilationUnit>(); //----------------------------- { //cpptoc folder string libcef_dll_folder = cefDir + @"\libcef_dll"; string[] onlyCppFiles = System.IO.Directory.GetFiles(libcef_dll_folder + @"\cpptoc", "*.cc"); //we skip some files Dictionary <string, bool> skipFiles = CreateSkipFiles(new string[] { "base_ref_counted_cpptoc.cc", "base_scoped_cpptoc.cc" }); int j = onlyCppFiles.Length; for (int i = 0; i < j; ++i) { if (skipFiles.ContainsKey(System.IO.Path.GetFileName(onlyCppFiles[i]))) { continue; } CodeCompilationUnit cu = ParseCppFile(onlyCppFiles[i]); test_cpptoc_List.Add(cu); // CppToCsImplCodeGen cppToCsImplCodeGen = new CppToCsImplCodeGen(); string onlyFileName = System.IO.Path.GetFileName(cu.Filename); if (onlyFileName == "v8interceptor_cpptoc.cc") { continue; } //cppToCsImplCodeGen.PatchCppMethod(cu, cefDir + @"\libcef_dll\cpptoc\" + onlyFileName, cefDir + @"\cpptoc"); cppToCsImplCodeGen.PatchCppMethod(cu, null, libcef_dll_folder + @"\cpptoc"); } } //----------------------------- //----------------------------- { //cef capi string[] onlyHeaderFiles = System.IO.Directory.GetFiles(cefDir + @"\include\capi", "*.h"); Dictionary <string, bool> skipFiles = CreateSkipFiles(new string[0]); int j = onlyHeaderFiles.Length; for (int i = 0; i < j; ++i) { if (skipFiles.ContainsKey(System.IO.Path.GetFileName(onlyHeaderFiles[i]))) { continue; } CodeCompilationUnit cu = Parse(onlyHeaderFiles[i]); totalCuList_capi.Add(cu); } } { //cef capi/views string[] onlyHeaderFiles = System.IO.Directory.GetFiles(cefDir + @"\include\capi\views", "*.h"); Dictionary <string, bool> skipFiles = CreateSkipFiles(new string[0]); int j = onlyHeaderFiles.Length; for (int i = 0; i < j; ++i) { if (skipFiles.ContainsKey(System.IO.Path.GetFileName(onlyHeaderFiles[i]))) { continue; } CodeCompilationUnit cu = Parse(onlyHeaderFiles[i]); totalCuList_capi.Add(cu); } } { //include/internal totalCuList.Add(Parse(cefDir + @"\include\internal\cef_types.h")); totalCuList.Add(Parse(cefDir + @"\include\internal\cef_types_wrappers.h")); totalCuList.Add(Parse(cefDir + @"\include\internal\cef_win.h")); //for windows } { //include folder string[] onlyHeaderFiles = System.IO.Directory.GetFiles(cefDir + @"\include\", "*.h"); Dictionary <string, bool> skipFiles = CreateSkipFiles(new string[0]); int j = onlyHeaderFiles.Length; for (int i = 0; i < j; ++i) { if (skipFiles.ContainsKey(System.IO.Path.GetFileName(onlyHeaderFiles[i]))) { continue; } CodeCompilationUnit cu = Parse(onlyHeaderFiles[i]); totalCuList.Add(cu); } } //c to cpp { string[] onlyHeaderFiles = System.IO.Directory.GetFiles(cefDir + @"\libcef_dll\ctocpp", "*.h"); Dictionary <string, bool> skipFiles = CreateSkipFiles(new string[0]); int j = onlyHeaderFiles.Length; for (int i = 0; i < j; ++i) { if (skipFiles.ContainsKey(System.IO.Path.GetFileName(onlyHeaderFiles[i]))) { continue; } CodeCompilationUnit cu = Parse(onlyHeaderFiles[i]); totalCuList.Add(cu); } } //cpp to c { string[] onlyHeaderFiles = System.IO.Directory.GetFiles(cefDir + @"\libcef_dll\cpptoc", "*.h"); Dictionary <string, bool> skipFiles = CreateSkipFiles(new string[0]); int j = onlyHeaderFiles.Length; for (int i = 0; i < j; ++i) { if (skipFiles.ContainsKey(System.IO.Path.GetFileName(onlyHeaderFiles[i]))) { continue; } CodeCompilationUnit cu = Parse(onlyHeaderFiles[i]); totalCuList.Add(cu); } } // CefTypeCollection cefTypeCollection = new CefTypeCollection(); cefTypeCollection.RootFolder = cefDir; cefTypeCollection.SetTypeSystem(totalCuList); // TypeTranformPlanner txPlanner = new TypeTranformPlanner(); txPlanner.CefTypeCollection = cefTypeCollection; Dictionary <string, CefTypeTx> allTxPlans = new Dictionary <string, CefTypeTx>(); List <CefHandlerTx> handlerPlans = new List <CefHandlerTx>(); List <CefCallbackTx> callbackPlans = new List <CefCallbackTx>(); List <CefInstanceElementTx> instanceClassPlans = new List <CefInstanceElementTx>(); List <CefEnumTx> enumTxPlans = new List <CefEnumTx>(); List <CefCStructTx> cstructPlans = new List <CefCStructTx>(); //-- //-- int typeName = 1; List <TypePlan> typeTxInfoList = new List <TypePlan>(); foreach (CodeTypeDeclaration typedecl in cefTypeCollection._v_instanceClasses) { //eg. CefApp, CefBrowser, CefCommandLine, CefFrame CefInstanceElementTx instanceClassPlan = new CefInstanceElementTx(typedecl); instanceClassPlans.Add(instanceClassPlan); allTxPlans.Add(typedecl.Name, instanceClassPlan); TypePlan typeTxPlan = txPlanner.MakeTransformPlan(typedecl); instanceClassPlan.CsInterOpTypeNameId = typeTxPlan.CsInterOpTypeNameId = typeName++; typedecl.TypePlan = typeTxPlan; typeTxInfoList.Add(typeTxPlan); } foreach (CodeTypeDeclaration typedecl in cefTypeCollection._v_handlerClasses) { //eg. CefDisplayHandler, CefDownloadHandler CefHandlerTx handlerPlan = new CefHandlerTx(typedecl); handlerPlans.Add(handlerPlan); allTxPlans.Add(typedecl.Name, handlerPlan); TypePlan typeTxPlan = txPlanner.MakeTransformPlan(typedecl); handlerPlan.CsInterOpTypeNameId = typeTxPlan.CsInterOpTypeNameId = typeName++; typedecl.TypePlan = typeTxPlan; typeTxInfoList.Add(typeTxPlan); } foreach (CodeTypeDeclaration typedecl in cefTypeCollection._v_callBackClasses) { //eg. CefAuthenCallback, CefPdfCallback CefCallbackTx callbackPlan = new CefCallbackTx(typedecl); callbackPlans.Add(callbackPlan); allTxPlans.Add(typedecl.Name, callbackPlan); //// TypePlan typeTxPlan = txPlanner.MakeTransformPlan(typedecl); callbackPlan.CsInterOpTypeNameId = typeTxPlan.CsInterOpTypeNameId = typeName++; typedecl.TypePlan = typeTxPlan; typeTxInfoList.Add(typeTxPlan); } // foreach (CodeTypeDeclaration typedecl in cefTypeCollection._enumClasses) { CefEnumTx enumTxPlan = new CefEnumTx(typedecl); enumTxPlans.Add(enumTxPlan); allTxPlans.Add(typedecl.Name, enumTxPlan); TypePlan typeTxPlan = txPlanner.MakeTransformPlan(typedecl); enumTxPlan.CsInterOpTypeNameId = typeTxPlan.CsInterOpTypeNameId = typeName++; typedecl.TypePlan = typeTxPlan; } List <CodeTypeDeclaration> notFoundAbstractClasses = new List <CodeTypeDeclaration>(); foreach (CodeTypeDeclaration typedecl in cefTypeCollection.cToCppClasses) { TypePlan typeTxPlan = txPlanner.MakeTransformPlan(typedecl); typeTxPlan.CsInterOpTypeNameId = typeName++; typedecl.TypePlan = typeTxPlan; //cef -specific TemplateTypeSymbol3 baseType0 = (TemplateTypeSymbol3)typedecl.BaseTypes[0].ResolvedType; //add information to our model SimpleTypeSymbol abstractType = (SimpleTypeSymbol)baseType0.Item1; SimpleTypeSymbol underlying_c_type = (SimpleTypeSymbol)baseType0.Item2; CefTypeTx found; if (!allTxPlans.TryGetValue(abstractType.Name, out found)) { notFoundAbstractClasses.Add(typedecl); continue; } found.UnderlyingCType = underlying_c_type; found.ImplTypeDecl = typedecl; abstractType.CefTxPlan = found; ////[chrome] cpp<-to<-c <--- ::::: <--- c-interface-to[external - user - lib] .... } foreach (CodeTypeDeclaration typedecl in cefTypeCollection.cppToCClasses) { //callback, handle, visitor etc TypePlan typeTxPlan = txPlanner.MakeTransformPlan(typedecl); typeTxPlan.CsInterOpTypeNameId = typeName++; typedecl.TypePlan = typeTxPlan; //cef -specific TemplateTypeSymbol3 baseType0 = (TemplateTypeSymbol3)typedecl.BaseTypes[0].ResolvedType; SimpleTypeSymbol abstractType = (SimpleTypeSymbol)baseType0.Item1; SimpleTypeSymbol underlying_c_type = (SimpleTypeSymbol)baseType0.Item2; CefTypeTx found; if (!allTxPlans.TryGetValue(abstractType.Name, out found)) { notFoundAbstractClasses.Add(typedecl); continue; } found.UnderlyingCType = underlying_c_type; found.ImplTypeDecl = typedecl; abstractType.CefTxPlan = found; ////[chrome] cpp->to->c ---> ::::: ---> c-interface-to [external-user-lib] .... ////eg. handlers and callbacks } //-------- foreach (CodeTypeDeclaration typedecl in cefTypeCollection._plainCStructs) { //create raw type if (!typedecl.Name.EndsWith("Traits") && typedecl.Name.StartsWith("_")) { // CefCStructTx cstructTx = new CefCStructTx(typedecl); cstructPlans.Add(cstructTx); TypePlan typeTxPlan = txPlanner.MakeTransformPlan(typedecl); cstructTx.CsInterOpTypeNameId = typeTxPlan.CsInterOpTypeNameId = typeName++; typedecl.TypePlan = typeTxPlan; // typeTxInfoList.Add(typeTxPlan); } else { } } //-------- //code gen List <CefTypeTx> customImplClasses = new List <CefTypeTx>(); StringBuilder cppCodeStBuilder = new StringBuilder(); AddCppBuiltInBeginCode(cppCodeStBuilder); CodeStringBuilder cppHeaderInternalForExportFunc = new CodeStringBuilder(); cppHeaderInternalForExportFunc.AppendLine( "//MIT, 2017, WinterDev\r\n" + "//AUTOGEN"); foreach (TypePlan txinfo in typeTxInfoList) { cppHeaderInternalForExportFunc.AppendLine("const int CefTypeName_" + txinfo.TypeDecl.Name + " = " + txinfo.CsInterOpTypeNameId.ToString() + ";"); } StringBuilder csCodeStBuilder = new StringBuilder(); AddCsCodeHeader(csCodeStBuilder); CefCodeGenOutput codeGenOutput = null; foreach (CefTypeTx tx in enumTxPlans) { codeGenOutput = new CefCodeGenOutput(); tx.GenerateCode(codeGenOutput); //get cs output csCodeStBuilder.Append(codeGenOutput._csCode.ToString()); } csCodeStBuilder.Append("}"); //close namespace //save to file System.IO.File.WriteAllText("CefEnums.cs", csCodeStBuilder.ToString()); //------------------------- CodeStringBuilder cppHeaderExportFuncAuto = new CodeStringBuilder(); cppHeaderExportFuncAuto.AppendLine("//AUTOGEN"); //------------------------- //cef instance is quite large //so we spit the code gen into 2 sections int instance_count = instanceClassPlans.Count; int mid = instance_count / 2; { //1st part csCodeStBuilder = new StringBuilder(); AddCsCodeHeader(csCodeStBuilder); //------------------------- for (int cc = 0; cc < mid; ++cc) { CefInstanceElementTx tx = instanceClassPlans[cc]; codeGenOutput = new CefCodeGenOutput(); tx.GenerateCode(codeGenOutput); //---------------------------------------------------- cppCodeStBuilder.AppendLine(); cppCodeStBuilder.AppendLine("// " + tx.OriginalDecl.ToString()); cppCodeStBuilder.Append(codeGenOutput._cppCode.ToString()); cppCodeStBuilder.AppendLine(); //---------------------------------------------------- csCodeStBuilder.AppendLine(); csCodeStBuilder.AppendLine("// " + tx.OriginalDecl.ToString()); csCodeStBuilder.Append(codeGenOutput._csCode.ToString()); csCodeStBuilder.AppendLine(); //-------------------------------------------- cppHeaderExportFuncAuto.Append(codeGenOutput._cppHeaderExportFuncAuto.ToString()); cppHeaderInternalForExportFunc.Append(codeGenOutput._cppHeaderInternalForExportFuncAuto.ToString()); //---------- if (tx.CppImplClassNameId > 0) { customImplClasses.Add(tx); } } csCodeStBuilder.Append("}"); //save to file System.IO.File.WriteAllText("CefInstances_P1.cs", csCodeStBuilder.ToString()); //------------------------- } { //2nd part //1st part csCodeStBuilder = new StringBuilder(); AddCsCodeHeader(csCodeStBuilder); for (int cc = mid; cc < instance_count; ++cc) { CefInstanceElementTx tx = instanceClassPlans[cc]; codeGenOutput = new CefCodeGenOutput(); tx.GenerateCode(codeGenOutput); //---------------------------------------------------- cppCodeStBuilder.AppendLine(); cppCodeStBuilder.AppendLine("// " + tx.OriginalDecl.ToString()); cppCodeStBuilder.Append(codeGenOutput._cppCode.ToString()); cppCodeStBuilder.AppendLine(); //---------------------------------------------------- csCodeStBuilder.AppendLine(); csCodeStBuilder.AppendLine("// " + tx.OriginalDecl.ToString()); csCodeStBuilder.Append(codeGenOutput._csCode.ToString()); csCodeStBuilder.AppendLine(); //-------------------------------------------- cppHeaderExportFuncAuto.Append(codeGenOutput._cppHeaderExportFuncAuto.ToString()); cppHeaderInternalForExportFunc.Append(codeGenOutput._cppHeaderInternalForExportFuncAuto.ToString()); //---------- if (tx.CppImplClassNameId > 0) { customImplClasses.Add(tx); } } csCodeStBuilder.Append("}"); //save to file System.IO.File.WriteAllText("CefInstances_P2.cs", csCodeStBuilder.ToString()); //------------------------- } csCodeStBuilder = new StringBuilder(); AddCsCodeHeader(csCodeStBuilder); foreach (CefCallbackTx tx in callbackPlans) { codeGenOutput = new CefCodeGenOutput(); tx.GenerateCode(codeGenOutput); cppCodeStBuilder.Append(codeGenOutput._cppCode.ToString()); csCodeStBuilder.Append(codeGenOutput._csCode.ToString()); //---------- cppHeaderExportFuncAuto.Append(codeGenOutput._cppHeaderExportFuncAuto.ToString()); cppHeaderInternalForExportFunc.Append(codeGenOutput._cppHeaderInternalForExportFuncAuto.ToString()); //---------- if (tx.CppImplClassNameId > 0) { customImplClasses.Add(tx); } } csCodeStBuilder.Append("}"); //save to file System.IO.File.WriteAllText("CefCallbacks.cs", csCodeStBuilder.ToString()); //------------------------- csCodeStBuilder = new StringBuilder(); AddCsCodeHeader(csCodeStBuilder); foreach (CefHandlerTx tx in handlerPlans) { codeGenOutput = new CefCodeGenOutput(); tx.GenerateCode(codeGenOutput); cppCodeStBuilder.Append(codeGenOutput._cppCode.ToString()); csCodeStBuilder.Append(codeGenOutput._csCode.ToString()); //---------- cppHeaderExportFuncAuto.Append(codeGenOutput._cppHeaderExportFuncAuto.ToString()); cppHeaderInternalForExportFunc.Append(codeGenOutput._cppHeaderInternalForExportFuncAuto.ToString()); //---------- } csCodeStBuilder.Append("}"); //save to file System.IO.File.WriteAllText("CefHandlers.cs", csCodeStBuilder.ToString()); //------------------------- csCodeStBuilder = new StringBuilder(); AddCsCodeHeader(csCodeStBuilder); foreach (CefCStructTx tx in cstructPlans) { codeGenOutput = new CefCodeGenOutput(); tx.GenerateCode(codeGenOutput); csCodeStBuilder.Append(codeGenOutput._csCode.ToString()); } csCodeStBuilder.Append("}"); //save to file System.IO.File.WriteAllText("CefPlainCStructs.cs", csCodeStBuilder.ToString()); //------------------------- csCodeStBuilder = new StringBuilder(); AddCsCodeHeader(csCodeStBuilder); CsNativeHandlerSwitchTableCodeGen csNativeHandlerSwitchTableCodeGen = new CsNativeHandlerSwitchTableCodeGen(); csNativeHandlerSwitchTableCodeGen.GenerateCefNativeRequestHandlers(handlerPlans, csCodeStBuilder); //cs... csCodeStBuilder.AppendLine("}"); System.IO.File.WriteAllText("CefApiSwitchTables.cs", csCodeStBuilder.ToString()); //-------- //cpp CppSwicthTableCodeGen cppSwitchTableCodeGen = new CppSwicthTableCodeGen(); cppSwitchTableCodeGen.CreateCppSwitchTableForInstanceMethods(cppCodeStBuilder, instanceClassPlans); cppSwitchTableCodeGen.CreateCppSwitchTableForStaticMethods(cppCodeStBuilder, instanceClassPlans); // CppInstanceMethodCodeGen instanceMetCodeGen = new CppInstanceMethodCodeGen(); instanceMetCodeGen.CreateCppNewInstanceMethod(cppCodeStBuilder, customImplClasses); //-------- cppCodeStBuilder.AppendLine("/////////////////////////////////////////////////"); // }
protected virtual void VisitIntPtr(SimpleTypeSymbol t) { }