Commit graph

38 commits

Author SHA1 Message Date
thefiddler
4f6c2ac2b4 Support multiple overloads
It is now possible to specify multiple overloads for the same function.
This is helpful for maintaining backwards compatibility with previous
releases.
2013-11-12 23:38:09 +01:00
thefiddler
af16be42d5 Corrected Parameter.IsEnum property 2013-11-11 10:00:54 +01:00
Stefanos A.
d0e025b86d Restrict convenience overloads
Only Get*, Gen*, Delete* and New* functions get convenience overloads.
This avoids issues with functions such as Rect() that have similar
signatures but cannot use such overloads.

This restriction will be relaxed in the future.
2013-11-10 19:03:49 +01:00
Stefanos A.
293c020151 Added WrapperTypes.ConvenienceArrayType
These are convenience parameters for function receiving a size and an
array parameter, like DeleteTextures(int n, int[] ids). The generator
will now add overloads taking a single parameter, such as
DeleteTexture(int id).
2013-11-10 18:29:53 +01:00
Stefanos A.
af7fdea449 Return types must be cls-compliant
CreateCLSCompliantWrappers must always change return types into
cls-compliant types. The reason is that we cannot overload on return
type alone, so we should always choose the compliant version.
2013-11-10 15:35:47 +01:00
Stefanos A.
6098fa05ce Plural name to singular in convenience overloads 2013-11-10 10:16:47 +01:00
thefiddler
d126d25215 Add helper overload generation
Functions returning a value or array via an 'out' parameter will now get a convenience overload that returns the result via a return statement. In the case of arrays, only single-valued arrays will be supported. For example:

void GetIntegerv(enum pname, out int value)

will be get an overload of

int GetIntegerv(enum pname)

This will reduce the amount of helper overloads that must be maintained manually in GLHelpers.cs.
2013-11-10 08:28:58 +01:00
Stefanos A
49df5ff453 Do not generate delegates for overloads
We should only generate delegates for actual OpenGL entry points, not
for overloaded functions that resolve to the same entry point. This
improves loading speeds and reduces the size of the compiled dll.
2013-11-08 16:40:43 +01:00
Stefanos A
7ab5e3ab6c Use paths without apiversion attribute
Paths that don't define a "version" attribute will now match all
possible versions. This will make it easier to add support for newer
APIs as they are introduced.
2013-11-07 16:48:11 +01:00
Stefanos A
2511cb1086 Implemented support for <overload> element
The <overload> element simplifies the addition of overloads for
backwards compatibility. It is defined similar to the <replace>
element, but instead of replacing the parameters of a function
in-place, it adds a new overload and modifies the overload instead.
2013-11-05 08:55:52 +01:00
Stefanos A
b29a4aacb3 Respect apiversion in overrides
We should not use overrides from foreign apiversions.
2013-11-04 19:32:52 +01:00
Stefanos A
f95925302b No extension attribute now matches all extensions
This allows us to reduce the amount of clutter in overrides.xml.
2013-11-03 21:28:24 +01:00
Stefanos A.
9789225e0c Allow overloads of the same function
It is now possible to define multiple overloads of the same function,
each with different parameters. This is extremely useful for
maintaining backwards compatibility in the face of the changes between
GL 4.3 and 4.4.
2013-11-03 16:09:11 +01:00
Stefanos A.
0548806487 Improved debug output on high-order pointers
OpenTK does not currently support generating bindings for pointers of
order 3 or higher. No OpenGL or OpenGL ES API currently uses such
pointers, so we just issue a warning message if such an API is
encountered in the future.
2013-11-03 12:12:39 +01:00
Stefanos A
c5b9dbc83e Added GetOverridesPath method
GetOverridesPath encapsulates the code that retrieves an override enum
or function from overrides.xml. Additionally, it now supports names and
extensions with multiple values (e.g. extension="Core|Ext").
2013-11-03 01:20:17 +01:00
Stefanos A.
8219f7a0f6 Avoid singletons; collect all translation logic
FuncProcessor now implements all translation logic for types, parameters
and functions. This used to be scattered in the various classes (Type,
Parameter, etc) resulting in a rather disgusting spaghetti. Code
generation has been removed from FuncProcessor and is now handled by the
various language-specific ISpecWriter backends.
2013-11-01 09:24:18 +01:00
Stefanos A.
2444ccf082 Improve override lookup for extension functions.
Function overrides are now looked up in the following order: specific
name (e.g. ProgramParameteriARB), extensionless name (e.g.
ProgramParameteri) and generic mame (e.g. ProgramParameter). This
improves the override resolution for functions with multiple extension
forms (core, ext, arb, etc).
2013-10-27 02:35:53 +02:00
Stefanos A.
51f52d7fc4 Moved more transformations into the *Processor classes.
An EnumProcessor or FuncProcessor instance is now required in order to
call their Translate*() methods. A number of transformations that
relied on calling the static methods have now been moved inside the
processor classes.
2013-10-27 01:30:45 +02:00
Stefanos A.
7296edafac Added support for overriding the element count of an array parameter. 2013-10-24 22:42:12 +02:00
Stefanos A.
a005fab243 Prefer overrides with exact name matches over generic name matches.
For instance, if we override both ClearBufferfi and ClearBuffer, then
ClearBuffer{i f ui}v will be overriden be ClearBuffer and
ClearBufferfi will be overriden by ClearBufferfi. This allows us to
specialize overrides when necessary.
2013-10-23 11:42:24 +02:00
Stefanos A.
18643b8f1d Allow version attribute in overrides.xml. 2013-10-22 21:09:18 +02:00
Stefanos A.
9685f6e2f0 Array overloads with count=1 should be turned into ref/out parameters.
This fixes an issue where arrays with count=1 would remain as unsafe
pointers instead of becoming ref/out parameters.
2013-10-22 13:41:31 +02:00
thefiddler
8dcb8601a2 Normalized line endings
Hopefully this is the first and last time we have to do this.
2013-10-11 01:58:54 +02:00
the_fiddler
af2c2fc64b Further improvements to suffix trimming regexes. Now matches GetInteger(ui)64 and does not match functions ending in "Coord", "Attrib", "Access" and more. 2011-12-07 00:22:10 +00:00
the_fiddler
22d3b26769 Ensured function names are trimmed using the same code as documentation and function parameters.
Improved trimming for functions with '64' suffices.
2011-12-07 00:01:48 +00:00
the_fiddler
b394962854 Use Parameter.RawName when accessing the spec xml files (these files are platform-agnostic, so parameter names are not escaped!) 2011-12-05 11:52:28 +00:00
the_fiddler
1db9c38ed8 Do not reuse a single StreamReader for reading signatures. Avoids issues with XPathDocument closing the stream behind our backs. 2010-12-06 14:34:16 +00:00
the_fiddler
5b40433350 * XmlSpecReader.cs:
* EnumProcessor.cs:
* GL2/Generator.cs:
* FuncProcessor.cs: Fixed handling of overrides file: we now add
  signatures as requested and reset the stream after we are done
  reading the file.
2010-12-06 12:29:18 +00:00
the_fiddler
029957c03a * EnumProcessor.cs:
* FuncProcessor.cs: Corrected the XPath for signature overrides.
2010-12-06 11:53:50 +00:00
the_fiddler
177813e47a * FuncProcessor.cs:
* Structures/Parameter.cs: Avoid qualifying IntPtr fully ((a) it's
  unnecessary, since we have "using System;" already and (b) the
  namespace qualification is not portable to C++).
2010-12-05 15:53:04 +00:00
the_fiddler
82ba7143bb * Main.cs:
* Settings.cs:
* FuncProcessor.cs:
* Structures/Type.cs:
* Structures/Constant.cs:
* Structures/Delegate.cs: Do not hardcode namespace separator to ".".
2010-12-05 15:45:23 +00:00
the_fiddler
f9365a4cc4 Merged gl4 branch into trunk 2010-12-04 21:51:40 +00:00
the_fiddler
057dfb9448 Handle multiple /signatures/add statements in the same file.
Trim enum and constant names before adding them to the relevant collection.
Fixed handling of extensions in enum names.
2010-12-03 11:24:58 +00:00
the_fiddler
94cd438166 Use identical XPath for signatures.xml and overrides.xml to unify and simplify their handlers. 2010-12-03 09:45:20 +00:00
the_fiddler
a55102ef2f Allow exact function name overrides for extension functions. 2010-11-21 16:03:37 +00:00
the_fiddler
5a3cbeb3ef Allow function overrides on exact names, too (i.e. PatchParameteri vs PatchParameter). 2010-11-21 11:26:12 +00:00
the_fiddler
137818d10c Moved enum, constant, delegate and function transformations to EnumProcessor and FuncProcessor respectively.
Removed global enum, delegate and function collections.
Simplified loading process and removed global Initialize() methods.
Read "count" attributes for function parameters in overrides.xml.
Disabled wgl/glx/glu generators.
Removed large amounts of stale code.
2010-10-13 21:41:06 +00:00
the_fiddler
4e8c643c39 Added GL4Generator that utilizes xml files instead of spec files.
Made GL4Generator the default.
Added FuncProcessor that will contain all function transforms.
2010-10-12 17:39:14 +00:00