Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Treat partial class template specializations correctly #136

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion cldoc/nodes/cclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from ..clang import cindex

class Class(Node):
kind = cindex.CursorKind.CLASS_DECL
kinds = [cindex.CursorKind.CLASS_DECL]

class Base:
def __init__(self, cursor, access=cindex.AccessSpecifier.PUBLIC):
Expand Down
9 changes: 6 additions & 3 deletions cldoc/nodes/classtemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@
from ..clang import cindex

class StructTemplate(Struct, Templated):
kind = None
kinds = []

def __init__(self, cursor, comment):
super(StructTemplate, self).__init__(cursor, comment)

class ClassTemplate(Class, Templated):
kind = None
kinds = []

def __init__(self, cursor, comment):
super(ClassTemplate, self).__init__(cursor, comment)

class ClassTemplatePlexer(Node):
kind = cindex.CursorKind.CLASS_TEMPLATE
kinds = [
cindex.CursorKind.CLASS_TEMPLATE,
cindex.CursorKind.CLASS_TEMPLATE_PARTIAL_SPECIALIZATION,
]

def __new__(cls, cursor, comment):
# Check manually if this is actually a struct, so that we instantiate
Expand Down
2 changes: 1 addition & 1 deletion cldoc/nodes/constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from ..clang import cindex

class Constructor(Method):
kind = cindex.CursorKind.CONSTRUCTOR
kinds = [cindex.CursorKind.CONSTRUCTOR]

def __init__(self, cursor, comment):
Method.__init__(self, cursor, comment)
Expand Down
2 changes: 1 addition & 1 deletion cldoc/nodes/conversionfunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from ..clang import cindex

class ConversionFunction(Method):
kind = cindex.CursorKind.CONVERSION_FUNCTION
kinds = [cindex.CursorKind.CONVERSION_FUNCTION]

def __init__(self, cursor, comment):
Method.__init__(self, cursor, comment)
Expand Down
2 changes: 1 addition & 1 deletion cldoc/nodes/cstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from ..clang import cindex

class Struct(Class):
kind = cindex.CursorKind.STRUCT_DECL
kinds = [cindex.CursorKind.STRUCT_DECL]

def __init__(self, cursor, comment):
Class.__init__(self, cursor, comment)
Expand Down
2 changes: 1 addition & 1 deletion cldoc/nodes/destructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from ..clang import cindex

class Destructor(Method):
kind = cindex.CursorKind.DESTRUCTOR
kinds = [cindex.CursorKind.DESTRUCTOR]

def __init__(self, cursor, comment):
Method.__init__(self, cursor, comment)
Expand Down
2 changes: 1 addition & 1 deletion cldoc/nodes/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from ..clang import cindex

class Enum(Node):
kind = cindex.CursorKind.ENUM_DECL
kinds = [cindex.CursorKind.ENUM_DECL]

def __init__(self, cursor, comment):
Node.__init__(self, cursor, comment)
Expand Down
2 changes: 1 addition & 1 deletion cldoc/nodes/enumvalue.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ..cmp import cmp

class EnumValue(Node):
kind = cindex.CursorKind.ENUM_CONSTANT_DECL
kinds = [cindex.CursorKind.ENUM_CONSTANT_DECL]

def __init__(self, cursor, comment):
Node.__init__(self, cursor, comment)
Expand Down
2 changes: 1 addition & 1 deletion cldoc/nodes/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ..clang import cindex

class Field(Node):
kind = cindex.CursorKind.FIELD_DECL
kinds = [cindex.CursorKind.FIELD_DECL]

def __init__(self, cursor, comment):
Node.__init__(self, cursor, comment)
Expand Down
2 changes: 1 addition & 1 deletion cldoc/nodes/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def is_unlabeled(self):
return False

class Function(Node):
kind = cindex.CursorKind.FUNCTION_DECL
kinds = [cindex.CursorKind.FUNCTION_DECL]

def __init__(self, cursor, comment):
super(Function, self).__init__(cursor, comment)
Expand Down
6 changes: 3 additions & 3 deletions cldoc/nodes/functiontemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
from ..clang import cindex

class FunctionTemplate(Templated, Function):
kind = None
kinds = []

def __init__(self, cursor, comment):
super(FunctionTemplate, self).__init__(cursor, comment)

class MethodTemplate(Templated, Method):
kind = None
kinds = []

def __init__(self, cursor, comment):
super(MethodTemplate, self).__init__(cursor, comment)

class FunctionTemplatePlexer(Node):
kind = cindex.CursorKind.FUNCTION_TEMPLATE
kinds = [cindex.CursorKind.FUNCTION_TEMPLATE]

def __new__(cls, cursor, comment):
if not cursor is None and (cursor.semantic_parent.kind == cindex.CursorKind.CLASS_DECL or \
Expand Down
2 changes: 1 addition & 1 deletion cldoc/nodes/method.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from ..comment import Comment

class Method(Function):
kind = cindex.CursorKind.CXX_METHOD
kinds = [cindex.CursorKind.CXX_METHOD]

def __init__(self, cursor, comment):
super(Method, self).__init__(cursor, comment)
Expand Down
2 changes: 1 addition & 1 deletion cldoc/nodes/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ..clang import cindex

class Namespace(Node):
kind = cindex.CursorKind.NAMESPACE
kinds = [cindex.CursorKind.NAMESPACE]

def __init__(self, cursor, comment):
Node.__init__(self, cursor, comment)
Expand Down
4 changes: 2 additions & 2 deletions cldoc/nodes/templatetypeparameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from ..cmp import cmp

class TemplateTypeParameter(Node):
kind = cindex.CursorKind.TEMPLATE_TYPE_PARAMETER
kinds = [cindex.CursorKind.TEMPLATE_TYPE_PARAMETER]

def __init__(self, cursor, comment):
Node.__init__(self, cursor, comment)
Expand Down Expand Up @@ -49,7 +49,7 @@ def compare_same(self, other):
return cmp(self.sort_index, other.sort_index)

class TemplateNonTypeParameter(Node):
kind = cindex.CursorKind.TEMPLATE_NON_TYPE_PARAMETER
kinds = [cindex.CursorKind.TEMPLATE_NON_TYPE_PARAMETER]

def __init__(self, cursor, comment):
super(TemplateNonTypeParameter, self).__init__(cursor, comment)
Expand Down
2 changes: 1 addition & 1 deletion cldoc/nodes/typedef.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ..clang import cindex

class Typedef(Node):
kind = cindex.CursorKind.TYPEDEF_DECL
kinds = [cindex.CursorKind.TYPEDEF_DECL]

def __init__(self, cursor, comment):
Node.__init__(self, cursor, comment)
Expand Down
2 changes: 1 addition & 1 deletion cldoc/nodes/union.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ..cmp import cmp

class Union(Node):
kind = cindex.CursorKind.UNION_DECL
kinds = [cindex.CursorKind.UNION_DECL]

def __init__(self, cursor, comment):
Node.__init__(self, cursor, comment)
Expand Down
2 changes: 1 addition & 1 deletion cldoc/nodes/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ..clang import cindex

class Variable(Node):
kind = cindex.CursorKind.VAR_DECL
kinds = [cindex.CursorKind.VAR_DECL]

def __init__(self, cursor, comment):
Node.__init__(self, cursor, comment)
Expand Down
5 changes: 3 additions & 2 deletions cldoc/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ def __init__(self, files, flags):
# Create a map from CursorKind to classes representing those cursor
# kinds.
for cls in nodes.Node.subclasses():
if hasattr(cls, 'kind'):
self.kindmap[cls.kind] = cls
if hasattr(cls, 'kinds'):
for kind in cls.kinds:
self.kindmap[kind] = cls

self.root = nodes.Root()

Expand Down