Revision: 148
Author: clach04
Date: Wed Aug 21 04:01:00 2013 UTC
Log: Fix issue #43, add support for bool type. Patch from Ronald Bos.
Patch from Ronald adds support for GCC _Bool type and
ANSI bool type (via stdbool.h).
NOTE1 this updates the parsetab.py by running cgrammar.py
NOTE2 the ctypes c_bool type does not work with Python 2.4 or 2.5,
c_bool was introduced with Python 2.6, there are no
"if sys.version_info < 2.6" checks so this change requires
at least py2.6.
http://code.google.com/p/ctypesgen/source/detail?r=148
Modified:
/trunk/test/testsuite.py
=======================================
--- /trunk/test/testsuite.py Sun Feb 3 06:08:32 2013 UTC
+++ /trunk/test/testsuite.py Wed Aug 21 04:01:00 2013 UTC
@@ -28,7 +28,7 @@
import ctypes
import math
import unittest
-import logging
+#import logging
test_directory = os.path.abspath(os.path.dirname(__file__))
sys.path.append(test_directory)
@@ -99,6 +99,36 @@
self.failUnlessEqual(expect_result, result)
+class StdBoolTest(unittest.TestCase):
+ "Test correct parsing and generation of bool type"
+
+ def setUp(self):
+ """NOTE this is called once for each test* method
+ (it is not called once per class).
+ FIXME This is slightly inefficient as it is called *way* more
times than it needs to be.
+ """
+ header_str = '''
+#include <stdbool.h>
+
+struct foo
+{
+ bool is_bar;
+ int a;
+};
+'''
+ self.module, _ = ctypesgentest.test(header_str)#, all_headers=True)
+
+ def tearDown(self):
+ del self.module
+ ctypesgentest.cleanup()
+
+ def test_stdbool_type(self):
+ """Test is bool is correctly parsed"""
+ module = self.module
+ struct_foo = module.struct_foo
+ self.failUnlessEqual(struct_foo._fields_, [("is_bar",
ctypes.c_bool), ("a", ctypes.c_int)])
+
+
class SimpleMacrosTest(unittest.TestCase):
"""Based on simple_macros.py
"""