Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions cpp/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,13 +769,11 @@ def _generate_one(self, token):
if last_token.name == '{':
assert_parse(temp_tokens, 'not enough tokens')

self._add_back_tokens(temp_tokens[1:])
self._add_back_token(last_token)
self._add_back_tokens(temp_tokens[1:])
method_name = temp_tokens[0].name
method = getattr(self, 'handle_' + method_name, None)
if not method:
# Must be declaring a variable.
# TODO(nnorwitz): handle the declaration.
return None
return method()
return self._get_method(temp_tokens, 0, None, False)
Expand Down
8 changes: 8 additions & 0 deletions test/foo.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,3 +291,11 @@ typedef boost::function<void(const boost::shared_array<uint8_t>&, uint32_t, bool
struct is_hashable_data : integral_constant<((42))> {};

extern "C" {}

class Resource
{
OGRE_AUTO_MUTEX
class Listener
{
};
};
7 changes: 7 additions & 0 deletions test_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,13 @@ def test_variable_anonymous_class(self):
self.assertEqual(VariableDeclaration('a', Type(Class(None, body=[]))),
nodes[0])

def test_variable_anonymous_class2(self):
nodes = list(MakeBuilder('const class {public:} a;').generate())
self.assertEqual(1, len(nodes))
# TODO: modifiers=['const']
self.assertEqual(VariableDeclaration('a', Type(Class(None, body=[]))),
nodes[0])

def test_function_one_argument_with_name(self):
for argument in ('Foo f', 'const Foo f', 'Foo& f', 'const Foo& f',
'unsigned int f', 'ns::foo f', 'std::vector<int> f',
Expand Down