[gobject-introspection] mallardwriter: Fix fundamental false alarms for the C formatter
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] mallardwriter: Fix fundamental false alarms for the C formatter
- Date: Thu, 30 Aug 2012 02:26:46 +0000 (UTC)
commit c197f266916f57b94fca92c75d060fa9891e9973
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Wed Aug 29 14:46:02 2012 -0300
mallardwriter: Fix fundamental false alarms for the C formatter
Just use a constant translation dictionary. If somebody needs something
more fancy they can use a custom match.
giscanner/mallardwriter.py | 26 +++++++++++++-------------
1 files changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/giscanner/mallardwriter.py b/giscanner/mallardwriter.py
index 1fab10d..9c83384 100644
--- a/giscanner/mallardwriter.py
+++ b/giscanner/mallardwriter.py
@@ -223,7 +223,7 @@ class MallardFormatter(object):
self.format_function_name(node))
def _process_fundamental(self, namespace, match, props):
- raise NotImplementedError
+ return self.fundamentals.get(props['fundamental'], match)
def _process_token(self, tok):
namespace = self._transformer.namespace
@@ -281,6 +281,12 @@ class MallardFormatter(object):
class MallardFormatterC(MallardFormatter):
language = "C"
+ fundamentals = {
+ "TRUE": "TRUE",
+ "FALSE": "FALSE",
+ "NULL": "NULL",
+ }
+
def format_type(self, type_):
if isinstance(type_, ast.Array):
return self.format_type(type_.element_type) + '*'
@@ -292,12 +298,15 @@ class MallardFormatterC(MallardFormatter):
def format_function_name(self, func):
return func.symbol
- def _process_fundamental(self, namespace, match, props):
- return props['fundamental']
-
class MallardFormatterPython(MallardFormatter):
language = "Python"
+ fundamentals = {
+ "TRUE": "True",
+ "FALSE": "False",
+ "NULL": "None",
+ }
+
def format_type(self, type_):
if isinstance(type_, ast.Array):
return '[' + self.format_type(type_.element_type) + ']'
@@ -315,15 +324,6 @@ class MallardFormatterPython(MallardFormatter):
else:
return func.name
- def _process_fundamental(self, namespace, match, props):
- translation = {
- "NULL": "None",
- "TRUE": "True",
- "FALSE": "False",
- }
-
- return translation.get(props['fundamental'], match)
-
LANGUAGES = {
"c": MallardFormatterC,
"python": MallardFormatterPython,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]