Commit graph

584 commits

Author SHA1 Message Date
Stephan Sundermann 53312d5fc0 generator: fixed optional array parameters 2013-10-09 20:35:02 +02:00
Stephan Sundermann 2152f4626e generator: use default value for optional generation 2013-10-09 20:30:14 +02:00
Stephan Sundermann 5f271e04fa generator: ignore private structs completely
Don't spam the log with these messages for private structs
(and don't count this in the statistics), as there are too
many. These kind of types are just empty structs marked as
hidden and private.
2013-10-09 20:28:38 +02:00
Stephan Sundermann c3f7b8e32b generator: fixed optional array parameters 2013-10-09 20:05:03 +02:00
Stephan Sundermann 5eea00f705 generator: new --gapidir flag to search for xml files 2013-10-09 20:00:14 +02:00
Stephan Sundermann f958b2247b generator: include api files from XML 2013-10-09 19:49:28 +02:00
Stephan Sundermann b868b80dee glib,generator: map MainContext type and expose members
This is needed to reference a MainContext from
external bindings, which need to create a
MainContext using a Handle
2013-10-09 19:44:50 +02:00
Stephan Sundermann 6ab620d689 generator,glib: added GPollFD and GSource types
GSource type was already there (but was not mapped by
the generator yet) so then the autogenerated methods
have been added manually inside the class after the
custom methods.

Other Source-related class are also generated and added
(but not mapped in the SymbolTable) to glib.
2013-10-09 19:41:21 +02:00
Stephan Sundermann 139479036b generator: do not generate methods without (C)Name 2013-10-09 18:53:31 +02:00
Stephan Sundermann e031a4ff18 generator: auto escape string constants 2013-10-09 18:51:38 +02:00
Stephan Sundermann 9abde602ec glib: add GDate, GDateTime
Add GDate and GDateTime classes to glib, and map
them in the generator's SymbolTable.

(The types TimeZone and TimeVal are also added because
the Date* types depend on them, but there is no need
to map them in the generator.)

Also move the TODOs of other auto-generated classes
to a single TODO in the Makefile
2013-10-09 18:30:10 +02:00
Stephan Sundermann 55ab3ab284 generator: fixed glue code for callbacks 2013-10-09 15:44:33 +02:00
Stephan Sundermann ddd2419151 generator: fix optional parameters again 2013-10-09 15:41:27 +02:00
Stephan Sundermann 949c538fe3 generator: IntPtr.Zero for optional IntPtr params
IntPtr.Zero should be passed for optional IntPtr params
instead of null
2013-10-09 15:38:46 +02:00
Stephan Sundermann 972e6257fc generator: removed wrong glue code for structs 2013-10-09 15:35:36 +02:00
Stephan Sundermann 388a2fe659 generator: added handling of optional parameters 2013-10-09 15:31:10 +02:00
Stephan Sundermann 33fd293b84 generator: null check for handle (NativeStructGen)
Check Handle against IntPtr.Zero before marshalling.
2013-10-09 14:02:46 +02:00
Stephan Sundermann 29a900e51e generator: added conversion for byref structs
The pointer from native is stored inside of a class which
wraps the structure. Fields can be accessed by marshalling
from and to the pointer. glib: Value.Update does now invoke
a private Update() method which is needed to update the new
structures.
2013-10-09 13:40:56 +02:00
Stephan Sundermann d01be26f0c generator: added defaultconstructoraccess attrib 2013-10-09 13:13:15 +02:00
Stephan Sundermann 112e2b9598 generator,glib: Added Mutex, RecMutex, Cond types
Bind these types manually and added generator support
for them.
2013-10-09 13:09:34 +02:00
Stephan Sundermann 747a4ad871 generator: Added conversion for unions
Also removed all assumptions for parameters when
ParserVersion >= 3
2013-10-08 20:22:16 +02:00
Stephan Sundermann fd2fb44f99 generator: readable&writable attribs to be backwards compat 2013-10-08 18:55:34 +02:00
Stephan Sundermann dc4e7f30b9 generator: Added long long conversion 2013-10-08 18:48:05 +02:00
Stephan Sundermann c5909d32fb generator: fixed string array return type for virtual_methods 2013-10-08 18:47:45 +02:00
Stephan Sundermann f6219b97e0 generator: Added count param detection for return values 2013-10-08 18:47:21 +02:00
Stephan Sundermann edde96c5be generator: fixed writeable and readable detection 2013-10-08 18:46:44 +02:00
Stephan Sundermann c53147c1c4 generator: Added constants to gapi
Unfortunately, gir marks all integers as gint regardless
of its size. We have to check if the value will really
fit into a int, that is why there is an automatic fallback
to long.
2013-10-08 18:45:42 +02:00
Stephan Sundermann b5806d2a1b generator: fixed string[] return types 2013-10-08 17:54:29 +02:00
Stephan Sundermann 8d4ec22ef2 generator: Added throws attribute to parameters
This enables gapi to decide whether a parameter is
really throwing or should be handled as a usual parameter.
2013-10-08 17:46:19 +02:00
Stephan Sundermann 94da3fb2ab generator: faster Equals implementation 2013-10-08 16:27:47 +02:00
Stephan Sundermann 115659f46b generator: fixed Equals/GetHashCode for no fields or padding
Fixed Equals/GetHashCode methods when struct has no fields,
or field is padding.
2013-10-08 15:52:47 +02:00
Stephan Sundermann c14277f391 generator: GThread type should be SimpleGen 2013-10-08 15:43:23 +02:00
Stephan Sundermann 4b470cadbb generator: Added GThread type 2013-10-08 15:41:14 +02:00
Stephan Sundermann 3eefa37272 generator: Bumped parser_version to 3
Added support for new closure and destroy attributes from which we can
determine which callback a parameter belongs to.
2013-10-08 15:39:31 +02:00
Andrés G. Aragoneses 9327d7d085 generator: fix possible unhandled KeyNotFoundException (regression)
This regression surfaced after 82a957bc9d [1],
when many collections were migrated to generic collections. HashTables
simply return null when queried for certain key, while Dictionary objects
throw KeyNotFoundException.

The regression could be noticed, more particularly, when trying to
compile the gtk3 branch of the gudevsharp project [2].

[1] 82a957bc9d
[2] https://github.com/mono/gudev-sharp/commits/gtk3
2013-08-23 22:09:06 +02:00
Andrés G. Aragoneses 4046a4c4bd generator: avoid double lookup in dictionary when DeAlias is called
We can avoid a double lookup in the types dictionary here because the
method TryGetValue() was just called before.
2013-08-23 22:09:06 +02:00
Andres G. Aragoneses 6cb03440c1 generator: generate all interfaces with the "I" prefix (.NET convention)
To be able to do this, Name property of GenBase class is now virtual, so
that it can be overriden in InterfaceGen with the new name.

Adapters, however, are still classes and then need special care as such
(cannot use the 'Name' property anymore), but this improves a bit the
readability of some parts of the code as the *Implementor and *Adapter
suffixes are now concentrated in just two new properties of GenBase and
not repeated all over the place.
2013-07-23 12:05:24 -05:00
Andres G. Aragoneses 9ff7ec8b2c glib: install interfaces earlier, override properties in class_init
GObject upstream has started disabling support for installing interfaces
in GTypes after they have already been initialized (class_init) [1], so
we need to add GInterfaces a bit earlier (*before* class_init starts).

As GLib.Object.OverrideProperty() cannot to be called before class_init
(because it receives a GObjectClass, not a GType) or after (because
otherwise class_init would complain about properties of an interface not
being defined), then we need to call it during class_init.

[1] http://bugzilla.gnome.org/687659

A good side-effect of this fix is that we no longer use the hacky uint
field 'idx' to track the properties count for each class; now it gets
moved to the ClassInitializer class, and thus can be non-static, which
makes a bit more sense (we leave the old OverrideProperty overload for
backwards compatibility).

Simplest way to test this is launching the sample/treemodeldemo.exe and
sample/custom-scrollable.exe in Ubuntu 13.04 beta (which has GLib 2.36).
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=11510
2013-04-07 07:51:30 +01:00
Bertrand Lorentz 99cb57e7aa generator: Add option to validate GAPI XML against an XSD schema
With a new --schema option, you can specify the path to an XSD file, and
all GAPI XML files will be validated against this schema, including the
files given through the --include option.
2013-02-23 13:41:50 +01:00
Bertrand Lorentz 629a34aa4f generator: Improve handling of command-line parameters
Bundle Options.cs from the Mono source tree, and use it to parse the
command-line options for gapi-codegen. This gives us clearer code,
descriptions for each option, and a nice "--help" output.

This does not change the options syntax, except that -I|--include needs
to specified for each file to include. Two Makefiles in sample/ are
updated for that change.
2012-11-25 15:05:17 +01:00
Bertrand Lorentz f0f998ccf3 generator: Fix compilation warning in some generated interface adapters
Don't generate a static field if it's not going to be used.

This fixes a compilation warning on the generated code for interfaces
that don't have virtual methods.
2012-11-18 11:10:18 +01:00
Bertrand Lorentz 306f422c38 Fix a crash during initialization of interfaces (bxc#8447)
GInterfaceInfo.Data was automatically set to be a GCHandle on the
interface adapter. But the generated GInterfaceInitHandlers were
not using it, just free'ing it.

But for the GInterface property support, the Data field is now used to
pass the class pointer, so casting it to a GCHandle to free it would
cause an exception.

We now don't assume anything about GInterfaceInfo.Data.
2012-11-17 17:34:50 +01:00
Bertrand Lorentz f20970258e generator: Update the documentation in generator/DESIGN 2012-11-15 19:31:28 +01:00
Bertrand Lorentz fdd1b201f7 generator: Fix misleading warning for callbacks in virtual methods
Wen generating a virtual method, the current member was not set in the
GenerationInfo. That caused the warning message about the callback scope
to refer to a wrong method name.
2012-11-15 15:06:07 +01:00
Bertrand Lorentz fa32f2ec36 generator: Refactor the member hashes in ClassBase
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.
2012-11-04 17:26:26 +01:00
Bertrand Lorentz eddc5fa796 generator: Use a Dictionary to hold the class structs cache
Again, nicer generated code, and no impact outside of it.
2012-11-04 16:58:49 +01:00
Bertrand Lorentz 3d6decbd0d generator: Use List<T> in generated constructors
This makes the generated code a bit nicer, but has no impact outside of
the generated constructors.
2012-11-04 16:58:49 +01:00
Bertrand Lorentz 15c5820cd8 generator: Rework data structures used by ManagedCallString
Use a single dictionary to hold the parameters and mark them as special,
instead of maintaining two lists in parallel.
2012-11-04 16:58:49 +01:00
Bertrand Lorentz 82a957bc9d generator: Switch a lot of collections to their generic counterpart
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.
2012-11-04 16:58:49 +01:00
Bertrand Lorentz 687e986c55 generator: Add using statements in generated code for generics 2012-11-03 17:03:31 +01:00