diff --git a/cpp/ast.py b/cpp/ast.py index 5ea0ee3..624ca4f 100644 --- a/cpp/ast.py +++ b/cpp/ast.py @@ -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) diff --git a/test/foo.h b/test/foo.h index a0e8f4e..0655aaa 100644 --- a/test/foo.h +++ b/test/foo.h @@ -291,3 +291,11 @@ typedef boost::function&, uint32_t, bool struct is_hashable_data : integral_constant<((42))> {}; extern "C" {} + +class Resource +{ + OGRE_AUTO_MUTEX + class Listener + { + }; +}; diff --git a/test_ast.py b/test_ast.py index 499e11c..37f9133 100755 --- a/test_ast.py +++ b/test_ast.py @@ -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 f',