[cogl/wip/cogl-sharp: 25/30] cogl-sharp: Apply method name overrides
- From: Damien Lespiau <dlespiau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl/wip/cogl-sharp: 25/30] cogl-sharp: Apply method name overrides
- Date: Tue, 9 Oct 2012 16:43:43 +0000 (UTC)
commit f280ee43e52c38b356a5e7ba2dd979ba2346aba3
Author: Damien Lespiau <damien lespiau intel com>
Date: Wed Oct 3 11:06:40 2012 +0100
cogl-sharp: Apply method name overrides
This allows us to be able to change methods names when generating the
bindings, say to implement function overloading.
cogl-sharp/_FrameBuffer.cs | 2 +-
cogl-sharp/parse-gir.py | 13 ++++++++++++-
2 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/cogl-sharp/_FrameBuffer.cs b/cogl-sharp/_FrameBuffer.cs
index 63e637e..2f65ba2 100644
--- a/cogl-sharp/_FrameBuffer.cs
+++ b/cogl-sharp/_FrameBuffer.cs
@@ -17,7 +17,7 @@ namespace Cogl
[DllImport("cogl2.dll")]
public static extern void cogl_framebuffer_clear4f(IntPtr o, BufferBit buffers, float red, float green, float blue, float alpha);
- public void Clear4f(BufferBit buffers, float red, float green, float blue, float alpha)
+ public void Clear(BufferBit buffers, float red, float green, float blue, float alpha)
{
cogl_framebuffer_clear4f(handle, buffers, red, green, blue, alpha);
}
diff --git a/cogl-sharp/parse-gir.py b/cogl-sharp/parse-gir.py
index e046c6a..07581c7 100755
--- a/cogl-sharp/parse-gir.py
+++ b/cogl-sharp/parse-gir.py
@@ -40,7 +40,7 @@ name_overrides = {
'Framebuffer': {
'class': 'FrameBuffer',
'methods': {
- 'clear4f', 'clear'
+ 'clear4f': 'clear'
},
'blacklist': (
'vdraw_attributes', 'draw_rectangles'
@@ -187,6 +187,15 @@ def derive_cs_type(gir_type, c_type):
return gir_type
+def apply_name_override(gir_name, overrides):
+ if not overrides or not 'methods' in overrides:
+ return gir_name
+
+ if not gir_name in overrides['methods']:
+ return gir_name
+
+ return overrides['methods'][gir_name]
+
def is_blacklisted(gir_name, overrides):
if not overrides:
return False
@@ -199,6 +208,8 @@ def is_blacklisted(gir_name, overrides):
def generate_method(node, overrides, fo):
gir_name = node.getAttribute("name")
+ gir_name = apply_name_override(gir_name, overrides)
+
native_method_name = node.getAttributeNS(C_NS, "identifier")
native_return_value = "void"
native_params = ['IntPtr o']
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]