Switch the hash tables used to store fields, properties and methods to
strong-type dictionaries, and make them private. Make the necessary
adjustments in the subclasses.
The additional type information makes the code a bit more safe
and readable.
At least one bug is fixed by this: in ObjectGen, an invalid child
property could still be generated, as it was not removed from the hash
table.
This should cause no real change to the generated code, except maybe in
the order of some members.
In a lot of places, we were only checking the presence of boolean
attributes, like "array", automatically assuming they were true. This
meant that we didn't allow setting them explicitly to false, which
apparently is needed for some bindings.
For all boolean attributes, we now use the GetAttributeAsBoolean method
added in the previous commit, to correctly check the value of the
attribute. As before, if the attribute is not present, it is considered
to be false.
Thanks to Stephan Sundermann for noticing this issue.
* generator/*.cs: Add a LogWriter class which formats warnings
consistently on the console. Supports the concept of non-fatal
validation warnings, since it doesn't rely on the unrolling of the
validation stack to associate a warning to a given type.
Main purpose was to add a non-fatal warning for missing element_type
attributes on list return values, though it results in cleaner log
output, and also updates some warning messages to be more helpful in
how to resolve them.
* generator/*.cs: add DefaultValue prop for obtaining a
sane value when we need to return a value but something bad has
happened such that we can't get a real value. Needed for iface
signal marshaling, among other places we're partially working
around it now.
svn path=/trunk/gtk-sharp/; revision=86157
* generator/*.cs : switch to IntPtr marshaling for struct types
in the managed to native direction.
* gtk/*.custom : adjust to new gapi struct pinvoke sigs.
svn path=/trunk/gtk-sharp/; revision=83961
* generator/StructBase.cs : use typeof to pass type to PtrToStruct
to avoid an instantiation and method call. Duh.
svn path=/trunk/gtk-sharp/; revision=81907
* generator/CallbackGen.cs : switch to NativeCallbackSignature.
* generator/GenBase.cs : add NativeCallbackType member.
* generator/IGeneratable.cs : add NativeCallbackType member.
* generator/ManagedCallString.cs : add guarded post call struct
marshaling back to the native struct.
* generator/NativeCallbackSignature.cs : new parallel to ImportSignature
but using NativeCallbackType instead of MarshalType.
* generator/Signal.cs : switch vm and sig marshaler callbacks to
NativeCallbackSignature. Perform guarding post call struct marshaling
back to the native struct.
* generator/Parameters.cs : add NativeCallbackType member.
* generator/SimpleBase.cs : add NativeCallbackType member.
* generator/StructBase.cs : add NativeCallbackType member using IntPtr
to support NULL handling.
* gtk/NodeCellDataFunc.cs : update native marshaler sig.
svn path=/trunk/gtk-sharp/; revision=76011
properties can't be set until Validate-time (eg, Method.IsGetter),
but it's annoying for every potential user of those properties to
have to make sure it has Validated the generatable first. So now
we add an explicit Validate() step after everything is loaded but
before anything is Generated, so that at Generation time,
everything can be assumed to have been Validated.
* generator/IGeneratable.cs: add "bool Validate()"
* generator/CodeGenerator.cs (Main): after loading all of the
generatables, DeAlias the SymbolTable, Validate() all the
generatables, and discard any invalid ones.
* generator/*.cs: Implement Validate() trivially in generatables
that didn't implement it before. Move Validate() calls from
Generate() to Validate(). Remove non-hierarchical Validate()
calls.
* generator/SymbolTable.cs: GPtrArray is IntPtr, not IntPtr[]
svn path=/trunk/gtk-sharp/; revision=48046
* generator/CodeGenerator.cs: add a --glue-includes flag
* generator/GenerationInfo.cs: Accept glue_includes value from
Main and output it to the glue_filename.
* generator/FieldBase.cs (Ignored): handle more ignorable cases.
(CheckGlue): New method to figure out what kind of glue we'll need
for a field.
(GenerateImports): generate appropriate imports per CheckGlue.
(GenerateGlue): Generate C glue for accessing a struct field;
either a fully-C-based accessor, or a method to just return the
field's offset in the struct.
(Generate): Use the generated glue to read the field.
* generator/PropertyBase.cs (CType): if the field is a single bit,
set its type to gboolean.
* generator/ObjectGen.cs (Generate):
* generator/OpaqueGen.cs (Generate): Call GenFields.
* generator/StructField.cs: Use FieldBase's glue-generation code
to handle bitfields. [#54489]
* generator/ObjectField.cs: Generates accessors for public fields
of objects and opaque structs. [#69514]
* generator/ClassBase.cs (ClassBase): Parse <fields> nodes and
create ObjectField objects.
(GenFields): Output field properties
(IgnoreMethod): Ignore Get/Set methods that duplicate fields
* generator/Makefile.am (sources): update
* {gdk,gnome,gtk,pango}/*.metadata: Mark some additional fields as
public. Rename/retype some fields for consistency with earlier
hand-coded bindings.
* {gdk,gnome,gtk,pango}/*.custom: Remove custom methods that can
now be autogenerated.
* {gdk,gnome,gtk,pango}/glue/*.c: Remove glue methods that can now
be autogenerated
* {gdk,glade,gnome,gtk,pango,vte}/Makefile.am
* {gdk,glade,gnome,gtk,pango,vte}/glue/Makefile.am
* {gdk,gnome,gtk,pango}/glue/makefile.win32: Update
svn path=/trunk/gtk-sharp/; revision=44563
don't actually affect the generated output
* generator/PropertyBase.cs: new base class for fields and
properties (mostly containing code formerly in Property.cs).
* generator/Property.cs: derive from PropertyBase
* generator/FieldBase.cs: base class for fields (containing some
code formerly in Field.cs)
* generator/StructField.cs: class for struct fields (the rest of
what used to be Field.cs)
* generator/StructBase.cs: s/Field/StructField/
* gnome/Gnome.metadata: hide a few funky _get_ methods that the
generator is just now noticing, to preserve the old output.
svn path=/trunk/gtk-sharp/; revision=43896
valid type (or is hidden).
* generator/StructBase.cs (Validate): new, to check that all of
the struct fields have valid types
* generator/BoxedGen.cs (Generate):
* generator/StructGen.cs: (Generate): Call Validate() and bail out
if it fails; it's no good to generate a struct with the wrong
layout.
* gdk/gdk-symbols.xml: add a line for GdkKey -> Gdk.Key. (There's
no actual C type GdkKey, but we can use metadata to change uints
to GdkKeys, which will then become Gdk.Keys.)
* gtk/AccelKey.custom: remove the "Key" field (which was being
added in the wrong place in the struct), since it's properly
generated now.
* gtk/Gtk.metadata: Fix the line that renames AccelKey.AccelKey
to AccelKey.Key
* gnomevfs/Gnomevfs.metadata: hide the (mis-parsed) "action" field
in MimeAction, leaving the struct in the same broken state it was
in with the old generator code
svn path=/trunk/gtk-sharp/; revision=41104
* gda/Makefile.am : add new custom.
* gda/XmlConnection.custom : add backcompat static ctor.
* generator/ClassBase.cs : refactor lookup logic to here from Ctor
and improve the collision resolution.
* generator/Ctor.cs : refactor to use MethodBase.
* generator/Makefile.am : add new file.
* generator/MethodBase.cs : new base class for ctors and methods.
* generator/Method.cs : refactor to use MethodBase.
* generator/StructBase.cs : move some logic from here to Ctor.
* gnome/CanvasPathDef.custom : add backcompat static ctor.
* gnome/GPPath.custom : add backcompat static ctor.
* gnome/Makefile.am : add new custom.
* gtk/Gtk.metadata : mark a colliding Button ctor shared.
svn path=/trunk/gtk-sharp/; revision=39431
* generator/*Gen.cs : implement IGeneratable fully on GenBase
with abstract methods where necessary to refactor a ton of redundant
code.
svn path=/trunk/gtk-sharp/; revision=38091
* generator/*Gen.cs : add ToNativeReturnType to deal with
the g_free string nonsense in the virtual method case.
svn path=/trunk/gtk-sharp/; revision=36289
* generator/Field.cs : add field hiding, for manual impl.
* generator/StructBase.cs : support disable_new, for manual impl.
svn path=/trunk/gtk-sharp/; revision=28715
* generator/ClassBase.cs : remove default ctor generation and
hasDefaultConstructor field.
* generator/Ctor.cs : chain to base (IntPtr.Zero).
* generator/StructBase.cs : remove hasDefaultConstructor usage.
* glib/Object.cs : remove Object () ctor. Add Ben's GetGType
method, although nothing uses it yet. Still working on integrating
the remainder of Ben's patch.
* gtk/Gtk.metadata : remove all the disabledefaultctor rules.
* */*.custom : add base (IntPtr.Zero) or this (...) chaining for
all ctors.
svn path=/trunk/gtk-sharp/; revision=25184
* generator/StructBase.cs:
* generator/SymbolTable.cs: Fixed the keyword base was not
mangled, also did a little refactoring.
svn path=/trunk/gtk-sharp/; revision=17702
[Equal credit to Ettore Perazzoli <ettore@ximian.com> for fixing
all the bugs in the initial patch]
* */*.custom : fix incorrect usage of new Object (IntPtr) where
Glib.Object.GetObject should've been used. add ref_owned param
to GetObject calls.
* generator/CallbackGen.cs : setup ref_owned in bodies
* generator/ClassBase.cs : add ref_owned to GetObject FromNative call
* generator/Method.cs : setup ref_owned in bodies
* generator/Property.cs : setup ref_owned in bodies
* generator/SignalHandler.cs : pass ref_owned to GetObject
* generator/StructBase.cs : setup ref_owned in bodies
* glib/Object.cs : kill Ref/Unref methods. Don't want it to be
easy for users to screw with ref counts, or make it look like they
should need to.
(GetObject): add ref_owned param and ref/unref to remain at 1
* glib/Value.cs : pass ref_owned to GetObject
svn path=/trunk/gtk-sharp/; revision=16581
* generator/GenBase.cs : put #line directive after the
#region so line numbers match up.
2003-07-02 Mike Kestner <mkestner@speakeasy.net>
* generator/StructBase.cs : remove doc comments
svn path=/trunk/gtk-sharp/; revision=15873
* gconf/Value.cs: Update to use new string marshalling.
* generator/StringGen.cs, ConstStringGen.cs: Added.
* generator/IGeneratable.cs: Add new method ToNativeReturn.
* generator/CallbackGen.cs: Implement ToNativeReturn. Call
ToNativeReturn for the return statement. Fix a couple of
places where s_ret was being used incorrectly for m_ret.
* generator/ClassGen.cs, EnumGen.cs, ManualGen.cs,
SimpleGen.cs, StructBase.cs: Implement ToNativeReturn.
* generator/SignalHandler.cs: Call ToNativeReturn for the
return statement, instead of CallByName.
* generator/SymbolTable.cs: Use StringGen for gchar, char,
and gunichar, and ConstStringGen for their const variants.
Add a new method wrapper for ToNativeReturn.
(Trim): Add a special-case for const strings so that the
const is not stripped. Otherwise there is no way of
resolving the const case.
* glade/XML.custom: Update to use new string marshalling.
* glib/Marshaller.cs: Added.
* glib/GException.cs, Markup.cs, ObjectManager.cs,
Value.cs: Update to use new string marshalling.
* glib/Object.cs: Remove old g_type_name DllImport
as it is no longer used.
* glue/fileselection.c (gtksharp_file_selection_get_fileop_entry):
Mark this as const return.
* gtk/ColorSelection.custom, FileSelection.custom,
SelectionData.custom: Update to use new string marshalling.
svn path=/trunk/gtk-sharp/; revision=15286
* generator/CallbackGen.cs : use non-static symtab, kill doc comments
* generator/ClassBase.cs : use non-static symtab
* generator/CodeGenerator.cs : use non-static symtab
* generator/EnumGen.cs : kill doc comments, don't gen using System here
* generator/GenBase.cs : gen using System here for all types
* generator/InterfaceGen.cs : don't gen using System here.
* generator/Method.cs : use non-static symtab
* generator/ObjectGen.cs : kill doc comments, use non-static symtab
* generator/OpaqueGen.cs : don't gen using System here.
* generator/Parameters.cs : use non static symtab.
* generator/Parser.cs : use non static symtab. add SimpleGen's and
ManualGen's
* generator/Property.cs : use non static symtab
* generator/SignalHandler.cs : use non static symtab
* generator/StructBase.cs : use non static symtab
* generator/SymbolTable.cs : major refactoring. now uses SimpleGen and
ManualGen IGeneratables to simplify the method and prop code. Is now
instance based with a static prop to get the singleton instance, so that
a this indexer can be provided to access the IGeneratables nicely. Gearing
up to remove even more code from here by accessing IGeneratables directly.
svn path=/trunk/gtk-sharp/; revision=14687
* generator/CallbackGen.cs: the new generated wrappers have:
-(optional) Field of the same type returned by the callback.
-A call to RemoveIfNotAlive at the beginning. It returns true,
return the dummy field.
-Added an object to the ctor signature and pass it to the base
class.
* generator/Ctor.cs: added a Params property.
* generator/Method.cs: set Static property in Parameters if the method
is static.
* generator/Parameters.cs: added Static property. The call creation of
the delegate wrapper (if applicable) uses the new signature. Pass a null
as object is the method is static.
* generator/StructBase.cs: set Static for the parameters of the ctors.
* glib/DelegateWrapper.cs: the ctor takes an object (the one creating
the wrapper or null) and creates a weak reference to it. Store it in
a static Hashtable (this way the wrapper itself is not garbage
collected).
(RemoveIfNotAlive): called from the native delegate callbacks. If the
target of the weak reference has been garbage collected, removes itself
from the hashtable to let the GC dispose this instance and returns true.
* gdk/Pixbuf.custom:
* gtk/Clipboard.custom:
* gtk/GtkSharp.GtkClipboardClearFuncNative.cs:
* gtk/GtkSharp.GtkClipboardGetFuncNative.cs:
* glade/XML.custom: changed delegate wrappers to match the new
signature.
svn path=/trunk/gtk-sharp/; revision=13237
use when the IntPtr is NULL.
* generator/SignalHandler.cs, generator/CallbackGen.cs: removed
call to Initialize for structs
* gtk/Clipboard.custom, gtk/ClipboardClearFunc.cs,
gtk/ClipboardGetFunc.cs,
gtk/GtkSharp.GtkClipboardClearFuncNative.cs,
gtk/GtkSharp.ClipboardGetFuncNative.cs, SelectionData.custom:
Hand-wrapped selection handling stuff, along with relevant
signals and the like.
* gnome/voidObjectAffineSVPintSignal.cs: removed Initialize
for hand-wrapped signal
* sample/GnomeHelloWorld.cs, sample/Size.cs: compare against
.Zero instead of using IsNull
* api/gtk-api.xml, sources/Gtk.metadata: metadata updates for
hiding some manually-wrapped stuff
svn path=/trunk/gtk-sharp/; revision=8912
* glib/Object.cs (Ref): Added.
* gtk/Object.custom (Ref): Overload. Note that we were reffed.
(DisposeNative): Unref if we were explicitly reffed.
* generator/Method.cs: Call Ref if needs_ret is set.
* generator/StructBase.cs: Call Ref on all object accessors.
* glue/style.c: Ref returned GCs.
* sources/Gtk.metadata: Set needs_ret on various gdk-related
accessors in GtkWidget. Hide Ref/Unref methods on Widget and
RcStyle as these ought to be deprecated anyway.
svn path=/trunk/gtk-sharp/; revision=7380
* parser/gapi2xml.pl: Add support for "fake struct" opaque types.
* generator/StructBase.cs: Generate wrapper fields for opaque
fields as well as pointer fields.
* api/gdk-symbols.xml: Remove GdkAtom as it is now wrapped.
svn path=/trunk/gtk-sharp/; revision=7311
[ Mike, this is everything I wanted in for the release. ]
* generator/StructBase.cs: Generate field accessors for wrapped
types (opaque, object, and structs/boxed). Bitfields, unions, and
arrays are still unsupported for accessors, and are probably marshalling
incorrectly. But this is enough to get events working (see example
in sample/GnomeHelloWorld.cs).
* parser/Metadata.pm: Support a "delete" directive, and set metadata
on structs and boxed (previously was only checking objects and interfaces).
* parser/Gdk.metadata: Delete bogus entries GdkWindowObject and
GdkPixmapObject (more evil drawable stuff.)
* sample/GnomeHelloWorld.cs: Show an example of how to use marshalled
events, in our selection callback.
svn path=/trunk/gtk-sharp/; revision=6370