Skip to content

Commit 42fc54e

Browse files
author
roman_yakovenko
committed
"has_inline" property was added to declarations.calldef_t class.
1 parent ce6278e commit 42fc54e

File tree

6 files changed

+79
-2
lines changed

6 files changed

+79
-2
lines changed

docs/history/history.rest

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ SVN Version
6565
for providing the patch.
6666

6767
12. Thanks to Aron Xu, for pointing out that it is better to use "os.name",
68-
instead of "sys.platform" for platform specific logic
68+
instead of "sys.platform" for platform specific logic.
69+
70+
13. "has_inline" property was added to ``declarations.calldef_t`` class.
6971

7072

7173
-----------

pygccxml/declarations/calldef.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def __init__( self, name='', arguments=None, exceptions=None, return_type=None,
166166
self._has_extern = has_extern
167167
self._demangled_name = None
168168
self._calling_convention = None
169+
self._has_inline = None
169170

170171
def _get__cmp__call_items(self):
171172
"""implementation details"""
@@ -178,7 +179,8 @@ def _get__cmp__items( self ):
178179
, self.has_extern
179180
, self.does_throw
180181
, self._sorted_list( self.exceptions )
181-
, self.demangled_name ]
182+
, self.demangled_name
183+
, self.has_inline ]
182184
items.extend( self._get__cmp__call_items() )
183185
return items
184186

@@ -274,6 +276,15 @@ def _set_has_extern(self, has_extern):
274276
@type: bool
275277
""")
276278

279+
def _get_has_inline(self):
280+
return self._has_inline
281+
def _set_has_inline(self, has_inline):
282+
self._has_inline = has_inline
283+
has_inline = property( _get_has_inline, _set_has_inline,
284+
doc="""Was this callable declared with "inline" specifier
285+
@type: bool
286+
""")
287+
277288
def __remove_parent_fname( self, demangled ):
278289
"""implementation details"""
279290
demangled = demangled.strip()

pygccxml/parser/scanner.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
XML_AN_ID = "id"
3636
XML_AN_INCOMPLETE = "incomplete"
3737
XML_AN_INIT = "init"
38+
XML_AN_INLINE = "inline"
3839
XML_AN_LINE = "line"
3940
XML_AN_MANGLED = "mangled"
4041
XML_AN_MAX = "max"
@@ -406,6 +407,7 @@ def __read_calldef( self, calldef, attrs, is_declaration ):
406407
self.__calldefs.append( calldef )
407408
calldef.name = attrs.get(XML_AN_NAME, '')
408409
calldef.has_extern = attrs.get( XML_AN_EXTERN, False )
410+
calldef.has_inline = bool( attrs.get( XML_AN_INLINE, "" ) == "1" )
409411
throw_stmt = attrs.get( XML_AN_THROW, None )
410412
if None is throw_stmt:
411413
calldef.does_throw = True

unittests/data/inline_specifier.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
struct text_t{
2+
inline bool inlined() const { return true; }
3+
unsigned long not_inlined() const;
4+
};
5+
6+
7+
inline bool inlined(text_t){ return true; }
8+
unsigned long not_inlined(text_t);

unittests/inline_specifier_tester.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright 2004-2008 Roman Yakovenko.
2+
# Distributed under the Boost Software License, Version 1.0. (See
3+
# accompanying file LICENSE_1_0.txt or copy at
4+
# http://www.boost.org/LICENSE_1_0.txt)
5+
6+
import unittest
7+
import autoconfig
8+
import parser_test_case
9+
10+
from pygccxml import utils
11+
from pygccxml import parser
12+
from pygccxml import declarations
13+
14+
class tester_t( parser_test_case.parser_test_case_t ):
15+
16+
global_ns = None
17+
18+
def __init__(self, *args ):
19+
parser_test_case.parser_test_case_t.__init__( self, *args )
20+
self.header = 'inline_specifier.hpp'
21+
22+
def setUp(self):
23+
if not tester_t.global_ns:
24+
decls = parser.parse( [self.header], self.config )
25+
tester_t.global_ns = declarations.get_global_namespace( decls )
26+
tester_t.global_ns.init_optimizer()
27+
28+
def test( self ):
29+
inlined_funcs = self.global_ns.calldefs( 'inlined' )
30+
self.failUnless( len(inlined_funcs) )
31+
for f in inlined_funcs:
32+
self.failUnless( f.has_inline == True )
33+
34+
not_inlined_funcs = self.global_ns.calldefs( 'not_inlined' )
35+
self.failUnless( len(not_inlined_funcs) )
36+
for f in not_inlined_funcs:
37+
self.failUnless( f.has_inline == False )
38+
39+
40+
def test2( self ):
41+
pass
42+
43+
def create_suite():
44+
suite = unittest.TestSuite()
45+
suite.addTest( unittest.makeSuite(tester_t))
46+
return suite
47+
48+
def run_suite():
49+
unittest.TextTestRunner(verbosity=2).run( create_suite() )
50+
51+
if __name__ == "__main__":
52+
run_suite()

unittests/test_all.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import gccxml10183_tester
5959
import gccxml10184_tester
6060
import gccxml10185_tester
61+
import inline_specifier_tester
6162

6263
testers = [
6364
decl_string_tester
@@ -112,6 +113,7 @@
112113
, gccxml10183_tester
113114
, gccxml10184_tester
114115
, gccxml10185_tester
116+
, inline_specifier_tester
115117
]
116118

117119
def create_suite():

0 commit comments

Comments
 (0)