private void ParseBody(StructData parent, string body) { var memberDeclerations = body.Split(';'); for (var i = 0; i <= memberDeclerations.Length - 2; i++) { if (memberDeclerations[i].Contains("CEF_CALLBACK")) { var sm = ParseCallback(memberDeclerations[i]); if (sm != null) { parent.StructMembers.Add(sm); } } else { if (!varEx.IsMatch(memberDeclerations[i])) { System.Diagnostics.Debugger.Break(); } var m = varEx.Match(memberDeclerations[i]); var sm = new StructMemberData(); var unused = false; sm.MemberType = ParseTypeDecl(m.Groups[1].Value.Trim(), ref unused); sm.Name = m.Groups[2].Value; parent.StructMembers.Add(sm); } } }
protected void GetCallbackFunctions(Parser.StructData sd, ApiTypeBuilder api) { var cblist = new List <CefCallbackFunction>(); for (int i = 1; i < sd.StructMembers.Count; ++i) { var sm = sd.StructMembers[i]; Debug.Assert(sm.CallbackSignature != null); cblist.Add(new CefCallbackFunction(CefStruct, Category, sm.Name, sm.CefConfig, sm.CallbackSignature, api, sm.Comments)); } CallbackFunctions = cblist.ToArray(); }
private void ParseStructs(string code, List <StructData> structs) { var mm = structRegex.Matches(code); foreach (Match m in mm) { var cefStruct = new StructData(); cefStruct.Name = m.Groups[1].Value; ParseBody(cefStruct, m.Groups[2].Value); structs.Add(cefStruct); } }
private StructData MatchCefStructPrefix(string name, List <StructData> structs) { StructData result = null; foreach (var cefStruct in structs) { if (name.StartsWith(cefStruct.Name.Substring(0, cefStruct.Name.Length - 2))) { if (result == null || result.Name.Length < cefStruct.Name.Length) { result = cefStruct; } } } return(result); }
public CfxValueClass(CefStructType cefStruct, Parser.StructData sd, ApiTypeBuilder api) : base(cefStruct, sd, api) { var smlist = new List <StructMember>(); foreach (var smd in sd.StructMembers) { smlist.Add(new StructMember(cefStruct, Category, smd, api)); } var sm0 = smlist[0]; if (sm0.Name == "size" && sm0.MemberType.OriginalSymbol == "size_t") { smlist.RemoveAt(0); hasSizeMember = true; } StructMembers = smlist.ToArray(); }
public CfxLibraryClass(CefStructType cefStruct, Parser.StructData sd, ApiTypeBuilder api) : base(cefStruct, sd, api) { var flist = new List <CefExportFunction>(); foreach (var fd in sd.CefFunctions) { flist.Add(new CefExportFunction(cefStruct, fd, api)); } ExportFunctions = flist.ToArray(); GetCallbackFunctions(sd, api); foreach (var cb in CallbackFunctions) { var isBoolean = false; if (cb.IsPropertyGetter(ref isBoolean)) { CefCallbackFunction setter = null; foreach (var cb2 in CallbackFunctions) { if (cb2.IsPropertySetterFor(cb)) { setter = cb2; setter.Signature.ManagedArguments[1].IsPropertySetterArgument = true; break; } } var prop = new StructProperty(cb, setter, isBoolean); m_structProperties.Add(prop); } } foreach (var sm in CallbackFunctions) { if (!sm.IsProperty) { m_structFunctions.Add(sm); } } NeedsWrapFunction = true; }
public static CfxClass Create(CefStructType cefStruct, Parser.StructData sd, ApiTypeBuilder api) { if (sd.CefConfig != null) { switch (sd.CefConfig.Source) { case "client": return(new CfxClientClass(cefStruct, sd, api)); case "library": return(new CfxLibraryClass(cefStruct, sd, api)); default: Debug.Assert(false); throw new Exception(); } } else { Debug.Assert(sd.StructMembers.Count == 1 || sd.StructMembers[1].CallbackSignature == null); return(new CfxValueClass(cefStruct, sd, api)); } }
protected CfxClass(CefStructType cefStruct, Parser.StructData sd, ApiTypeBuilder api) { CefStruct = cefStruct; OriginalSymbol = cefStruct.OriginalSymbol; CfxNativeSymbol = cefStruct.CfxNativeSymbol; CfxName = cefStruct.CfxName; ClassName = cefStruct.ClassName; ApiClassName = ClassName.Substring(3); RemoteClassName = cefStruct.RemoteClassName; Comments = sd.Comments; if (sd.CefConfig != null) { switch (sd.CefConfig.Source) { case "client": Category = StructCategory.ApiCallbacks; break; case "library": Category = StructCategory.ApiCalls; break; default: Debug.Assert(false); break; } } else { Debug.Assert(sd.StructMembers.Count == 1 || sd.StructMembers[1].CallbackSignature == null); Category = StructCategory.Values; } Debug.Assert(sd.CefFunctions.Count == 0 || Category == StructCategory.ApiCalls); }
public CfxClientClass(CefStructType cefStruct, Parser.StructData sd, ApiTypeBuilder api) : base(cefStruct, sd, api) { GetCallbackFunctions(sd, api); }