static private BindSignalHandlers ( System.CodeDom.CodeExpression targetObjectVar, |
||
targetObjectVar | System.CodeDom.CodeExpression | |
wrapper | ||
map | Stetic | |
statements | ||
options | ||
return | void |
static void GenerateComponentCode(object component, SteticCompilationUnit globalUnit, CodeNamespace globalNs, CodeExpression cobj, CodeStatementCollection statements, CodeTypeDeclaration globalType, GenerationOptions options, List <SteticCompilationUnit> units, CodeIdentifiers ids, ArrayList warnings) { Gtk.Widget widget = component as Gtk.Widget; Wrapper.Widget wwidget = Stetic.Wrapper.Widget.Lookup(widget); Wrapper.ActionGroup agroup = component as Wrapper.ActionGroup; string name = widget != null ? widget.Name : agroup.Name; string internalClassName = ids.MakeUnique(CodeIdentifier.MakeValid(name)); string typeName = widget != null ? wwidget.WrappedTypeName : "Gtk.ActionGroup"; // Create the build method for the top level CodeMemberMethod met; met = GetBuildMethod(name, internalClassName, typeName, globalUnit, options, units); // Generate the build code CodeVariableDeclarationStatement varDecHash = new CodeVariableDeclarationStatement(typeof(System.Collections.Hashtable), "bindings"); met.Statements.Add(varDecHash); varDecHash.InitExpression = new CodeObjectCreateExpression( typeof(System.Collections.Hashtable), new CodeExpression [0] ); CodeVariableReferenceExpression targetObjectVar = new CodeVariableReferenceExpression("cobj"); Stetic.WidgetMap map; if (widget != null) { map = Stetic.CodeGenerator.GenerateCreationCode(globalNs, globalType, widget, targetObjectVar, met.Statements, options, warnings); CodeGenerator.BindSignalHandlers(targetObjectVar, wwidget, map, met.Statements, options); } else { map = Stetic.CodeGenerator.GenerateCreationCode(globalNs, globalType, agroup, targetObjectVar, met.Statements, options, warnings); foreach (Wrapper.Action ac in agroup.Actions) { CodeGenerator.BindSignalHandlers(targetObjectVar, ac, map, met.Statements, options); } } GenerateBindFieldCode(met.Statements, cobj); // Add a method call to the build method statements.Add( new CodeMethodInvokeExpression( new CodeTypeReferenceExpression(options.GlobalNamespace + ".SteticGenerated." + internalClassName), "Build", new CodeCastExpression(typeName, cobj) ) ); }
static void GenerateWidgetCode(SteticCompilationUnit globalUnit, CodeNamespace globalNs, GenerationOptions options, List <SteticCompilationUnit> units, Gtk.Widget w, ArrayList warnings) { // Generate the build method CodeTypeDeclaration type = CreatePartialClass(globalUnit, units, options, w.Name); CodeMemberMethod met = new CodeMemberMethod(); met.Name = "Build"; type.Members.Add(met); met.ReturnType = new CodeTypeReference(typeof(void)); met.Attributes = MemberAttributes.Family; Stetic.Wrapper.Widget wwidget = Stetic.Wrapper.Widget.Lookup(w); if (options.GenerateEmptyBuildMethod) { GenerateWrapperFields(type, wwidget); return; } met.Statements.Add( new CodeMethodInvokeExpression( new CodeTypeReferenceExpression(new CodeTypeReference(globalNs.Name + ".Gui", CodeTypeReferenceOptions.GlobalReference)), "Initialize", new CodeThisReferenceExpression() ) ); if (wwidget.GeneratePublic) { type.TypeAttributes = TypeAttributes.Public; } else { type.TypeAttributes = TypeAttributes.NotPublic; } if (!String.IsNullOrEmpty(wwidget.UIManagerName)) { type.Members.Add(new CodeMemberField(new CodeTypeReference("Gtk.UIManager", CodeTypeReferenceOptions.GlobalReference), wwidget.UIManagerName)); } Stetic.WidgetMap map = Stetic.CodeGenerator.GenerateCreationCode(globalNs, type, w, new CodeThisReferenceExpression(), met.Statements, options, warnings); CodeGenerator.BindSignalHandlers(new CodeThisReferenceExpression(), wwidget, map, met.Statements, options); }
static void GenerateGlobalActionGroupCode(SteticCompilationUnit globalUnit, CodeNamespace globalNs, GenerationOptions options, List <SteticCompilationUnit> units, Wrapper.ActionGroup agroup, ArrayList warnings) { CodeTypeDeclaration type = CreatePartialClass(globalUnit, units, options, agroup.Name); // Generate the build method CodeMemberMethod met = new CodeMemberMethod(); met.Name = "Build"; type.Members.Add(met); met.ReturnType = new CodeTypeReference(typeof(void)); met.Attributes = MemberAttributes.Public; Stetic.WidgetMap map = Stetic.CodeGenerator.GenerateCreationCode(globalNs, type, agroup, new CodeThisReferenceExpression(), met.Statements, options, warnings); foreach (Wrapper.Action ac in agroup.Actions) { CodeGenerator.BindSignalHandlers(new CodeThisReferenceExpression(), ac, map, met.Statements, options); } }
static void GenerateWidgetCode(SteticCompilationUnit globalUnit, CodeNamespace globalNs, GenerationOptions options, List <SteticCompilationUnit> units, Gtk.Widget w, ArrayList warnings, bool regenerateWidgetClass) { if (options.GenerateSingleFile) { regenerateWidgetClass = true; } // Don't register this unit if the class doesn't need to be regenerated if (!regenerateWidgetClass) { units = null; } CodeTypeDeclaration type = CreatePartialClass(globalUnit, units, options, w.Name); // Generate the build method CodeMemberMethod met = new CodeMemberMethod(); met.Name = "Build"; type.Members.Add(met); met.ReturnType = new CodeTypeReference(typeof(void)); met.Attributes = MemberAttributes.Family; Stetic.Wrapper.Widget wwidget = Stetic.Wrapper.Widget.Lookup(w); if (regenerateWidgetClass) { if (options.GenerateEmptyBuildMethod) { GenerateWrapperFields(type, wwidget); return; } met.Statements.Add( new CodeMethodInvokeExpression( new CodeTypeReferenceExpression(new CodeTypeReference(globalNs.Name + ".Gui", CodeTypeReferenceOptions.GlobalReference)), "Initialize", new CodeThisReferenceExpression() ) ); if (wwidget.GeneratePublic) { type.TypeAttributes = TypeAttributes.Public; } else { type.TypeAttributes = TypeAttributes.NotPublic; } if (!String.IsNullOrEmpty(wwidget.UIManagerName)) { type.Members.Add(new CodeMemberField(new CodeTypeReference("Gtk.UIManager", CodeTypeReferenceOptions.GlobalReference), wwidget.UIManagerName)); } } // We need to generate the creation code even if regenerateWidgetClass is false because GenerateCreationCode // may inject support classes or methods into the global namespace, which is always generated Stetic.WidgetMap map = Stetic.CodeGenerator.GenerateCreationCode(globalNs, type, w, new CodeThisReferenceExpression(), met.Statements, options, warnings); if (regenerateWidgetClass) { CodeGenerator.BindSignalHandlers(new CodeThisReferenceExpression(), wwidget, map, met.Statements, options); } }