diff --git a/README.rst b/README.rst
index 8e6d1f2..60a29e5 100644
--- a/README.rst
+++ b/README.rst
@@ -25,7 +25,7 @@ hierarchies. It aims at supporting:
- dependency relationships
-The package relies on the `CppHeaderParser `_ package for parsing of C++ header
+The package relies on the `CppHeaderParser `_ package for parsing of C++ header
files.
diff --git a/doc/source/conf.py b/doc/source/conf.py
index abbf66b..2d8710a 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -79,9 +79,9 @@
# built documents.
#
# The short X.Y version.
-version = u'v' + u'0.6'
+version = u'v' + u'0.7'
# The full version, including alpha/beta/rc tags.
-release = u'v' + u'0.6'
+release = u'v' + u'0.7'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@@ -155,7 +155,7 @@
# The name for this set of Sphinx documents.
# " v documentation" by default.
#
-# html_title = u'hpp2plantuml ' + u'v' + u'0.6'
+# html_title = u'hpp2plantuml ' + u'v' + u'0.7'
# A shorter title for the navigation bar. Default is the same as html_title.
#
diff --git a/doc/source/index.rst b/doc/source/index.rst
index 49ac472..024f4bb 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -30,7 +30,7 @@ hierarchies. It aims at supporting:
- dependency relationships
-The package relies on the `CppHeaderParser `_ package for parsing of C++ header
+The package relies on the `CppHeaderParser `_ package for parsing of C++ header
files.
diff --git a/doc/source/org-doc.rst b/doc/source/org-doc.rst
index 42c2c62..c33c7a9 100644
--- a/doc/source/org-doc.rst
+++ b/doc/source/org-doc.rst
@@ -13,7 +13,7 @@ The current version of the code is:
::
:name: hpp2plantuml-version
- 0.6
+ 0.7
The source code can be found on GitHub:
@@ -43,7 +43,7 @@ hierarchies. It aims at supporting:
- dependency relationships
-The package relies on the `CppHeaderParser `_ package for parsing of C++ header
+The package relies on the `CppHeaderParser `_ package for parsing of C++ header
files.
License
@@ -82,18 +82,18 @@ Requirements
------------
This module has mostly standard dependencies; the only exception is the
-`CppHeaderParser `_ module used to parse header files.
+`CppHeaderParser `_ module used to parse header files.
.. table:: List of dependencies.
:name: py-dependency-list
- +-----------------+
- | argparse |
- +-----------------+
- | CppHeaderParser |
- +-----------------+
- | jinja2 |
- +-----------------+
+ +-------------------------+-----------------+
+ | argparse | argparse |
+ +-------------------------+-----------------+
+ | robotpy-cppheaderparser | CppHeaderParser |
+ +-------------------------+-----------------+
+ | jinja2 | jinja2 |
+ +-------------------------+-----------------+
The full list of non-standard dependencies is produced by the following source
block (returning either imports or a dependency list used in `sec-package-setup-py`_):
@@ -104,7 +104,7 @@ block (returning either imports or a dependency list used in `sec-package-setup-
(cond
((string= output "import")
(mapconcat
- (lambda (el) (concat "import " (car el))) dep-list "\n"))
+ (lambda (el) (concat "import " (cadr el))) dep-list "\n"))
((string= output "requirements")
(concat "["
(mapconcat
@@ -190,7 +190,6 @@ of elementary properties and links.
# - The third element is a function returning the corresponding internal object
CONTAINER_TYPE_MAP = [
['classes', lambda objs: objs.items(), lambda obj: Class(obj)],
- ['structs', lambda objs: objs.items(), lambda obj: Struct(obj)],
['enums', lambda objs: objs, lambda obj: Enum(obj)]
]
@@ -216,7 +215,8 @@ Base class
C++ objects are represented by objects derived from the base ``Container`` class.
The ``Container`` class is abstract and contains:
-- the container type (``class``, ``enum``, ``struct``),
+- the container type (``class``, ``enum``, ``struct`` objects are handled as ``class``
+ objects),
- the object name,
@@ -274,7 +274,7 @@ The ``Container`` class is abstract and contains:
Parameters
----------
- header_container : CppClass, CppStruct or CppEnum
+ header_container : CppClass or CppEnum
Parsed header for container
"""
namespace = header_container.get('namespace', None)
@@ -290,7 +290,7 @@ The ``Container`` class is abstract and contains:
Parameters
----------
- header_container : CppClass, CppStruct or CppEnum
+ header_container : CppClass or CppEnum
Parsed header for container
"""
raise NotImplementedError(
@@ -439,7 +439,7 @@ which is used to determine aggregation relationships between classes.
element is the class name and the second element is a CppClass
object)
"""
- super().__init__('class', header_class[0])
+ super().__init__(header_class[1]['declaration_method'], header_class[0])
self._abstract = header_class[1]['abstract']
self._template_type = None
if 'template' in header_class[1]:
@@ -467,8 +467,9 @@ which is used to determine aggregation relationships between classes.
for member_prop in MEMBER_PROP_MAP.keys():
member_list = header_class[member_type][member_prop]
for header_member in member_list:
- self._member_list.append(
- member_type_handler(header_member, member_prop))
+ if not header_member.get('deleted', False):
+ self._member_list.append(
+ member_type_handler(header_member, member_prop))
def build_variable_type_list(self):
"""Get type of member variables
@@ -730,38 +731,6 @@ implemented in the future.
return method_str
-Structures
-^^^^^^^^^^
-
-While ``struct`` objects are currently not supported, their addition should be
-relatively straightforward and the ``Struct`` class may simply inherit from the
-``Class`` class. The following should give a starting point.
-
-.. code:: python
- :name: py-render-structs
-
- # %% Struct object
-
-
- class Struct(Class):
- """Representation of C++ struct objects
-
- This class derived is almost identical to `Class`, the only difference
- being the container type name ("struct" instead of "class").
- """
- def __init__(self, header_struct):
- """Class constructor
-
- Parameters
- ----------
- header_struct : list (str, CppStruct)
- Parsed header for struct object (two-element list where the first
- element is the structure name and the second element is a CppStruct
- object)
- """
- super().__init__(header_struct[0])
- super(Class).__init__('struct')
-
Enumeration lists
^^^^^^^^^^^^^^^^^
@@ -1618,8 +1587,9 @@ variable types by eliminating spaces around ``\*`` characters.
str
The type string after cleanup
"""
- return re.sub(r'[ ]+([*&])', r'\1',
- re.sub(r'(\s)+', r'\1', type_str))
+ return re.sub('\s*([<>])\s*', r'\1',
+ re.sub(r'[ ]+([*&])', r'\1',
+ re.sub(r'(\s)+', r'\1', type_str)))
The ``_cleanup_single_line`` function transforms a multiline input string into a
single string version.
@@ -1864,7 +1834,7 @@ to parse input arguments. The function passes the command line arguments to the
required=False, default=None, metavar='JINJA-FILE',
help='path to jinja2 template file')
parser.add_argument('--version', action='version',
- version='%(prog)s ' + '0.6')
+ version='%(prog)s ' + '0.7')
args = parser.parse_args()
if len(args.input_files) > 0:
CreatePlantUMLFile(args.input_files, args.output_file,
@@ -2129,7 +2099,7 @@ the representation of variables.
for test_idx, (input_str, output_ref_str) in \
enumerate(fix_test_list_def(test_list_classvar)):
p = get_parsed_element(input_str)
- class_name = re.sub(r'.*class\s*(\w+).*', r'\1',
+ class_name = re.sub(r'.*(class|struct)\s*(\w+).*', r'\2',
input_str.replace('\n', ' '))
class_input = [class_name, p.classes[class_name]]
obj_c = hpp2plantuml.hpp2plantuml.Class(class_input)
@@ -2174,7 +2144,7 @@ supported by PlantUML.
for test_idx, (input_str, output_ref_str) in \
enumerate(fix_test_list_def(test_list_classmethod)):
p = get_parsed_element(input_str)
- class_name = re.sub(r'.*class\s*(\w+).*', r'\1',
+ class_name = re.sub(r'.*(class|struct)\s*(\w+).*', r'\2',
input_str.replace('\n', ' '))
class_input = [class_name, p.classes[class_name]]
obj_c = hpp2plantuml.hpp2plantuml.Class(class_input)
@@ -2192,19 +2162,21 @@ TableĀ `tbl-unittest-class`_. It includes templates and abstract classes.
.. table:: List of test segments and corresponding PlantUML strings.
:name: tbl-unittest-class
- +-----------------------------------------------------------------------+----------------------------------------------------------------------------------------+
- | C++ | plantuml |
- +=======================================================================+========================================================================================+
- | "class Test {\nprotected:\nint & member; };" | "class Test {\n\t#member : int&\n}\n" |
- +-----------------------------------------------------------------------+----------------------------------------------------------------------------------------+
- | "class Test\n{\npublic:\nvirtual int func() = 0; };" | "abstract class Test {\n\t+{abstract} func() : int\n}\n" |
- +-----------------------------------------------------------------------+----------------------------------------------------------------------------------------+
- | "template class Test{\nT* func(T& arg); };" | "class Test > {\n\t-func(T& arg) : T\*\n}\n" |
- +-----------------------------------------------------------------------+----------------------------------------------------------------------------------------+
- | "template class Test{\nvirtual T\* func(T& arg)=0; };" | "abstract class Test > {\n\t-{abstract} func(T& arg) : T\*\n}\n" |
- +-----------------------------------------------------------------------+----------------------------------------------------------------------------------------+
- | "namespace Interface {\nclass Test {\nprotected:\nint & member; };};" | "namespace Interface {\n\tclass Test {\n\t\t#member : int&\n\t}\n}\n" |
- +-----------------------------------------------------------------------+----------------------------------------------------------------------------------------+
+ +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+
+ | C++ | plantuml |
+ +=======================================================================+=======================================================================================+
+ | "class Test {\nprotected:\nint & member; };" | "class Test {\n\t#member : int&\n}\n" |
+ +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+
+ | "struct Test {\nprotected:\nint & member; };" | "struct Test {\n\t#member : int&\n}\n" |
+ +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+
+ | "class Test\n{\npublic:\nvirtual int func() = 0; };" | "abstract class Test {\n\t+{abstract} func() : int\n}\n" |
+ +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+
+ | "template class Test{\nT* func(T& arg); };" | "class Test > {\n\t-func(T& arg) : T\*\n}\n" |
+ +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+
+ | "template class Test{\nvirtual T\* func(T& arg)=0; };" | "abstract class Test > {\n\t-{abstract} func(T& arg) : T\*\n}\n" |
+ +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+
+ | "namespace Interface {\nclass Test {\nprotected:\nint & member; };};" | "namespace Interface {\n\tclass Test {\n\t\t#member : int&\n\t}\n}\n" |
+ +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+
.. code:: python
:name: test-unit-class
@@ -2217,7 +2189,7 @@ TableĀ `tbl-unittest-class`_. It includes templates and abstract classes.
for test_idx, (input_str, output_ref_str) in \
enumerate(fix_test_list_def(test_list_class)):
p = get_parsed_element(input_str)
- class_name = re.sub(r'.*class\s*(\w+).*', r'\1',
+ class_name = re.sub(r'.*(class|struct)\s*(\w+).*', r'\2',
input_str.replace('\n', ' '))
class_input = [class_name, p.classes[class_name]]
obj_c = hpp2plantuml.hpp2plantuml.Class(class_input)
@@ -2347,6 +2319,7 @@ The following can be extended to improve testing, as long as the corresponding
static bool _StaticProtectedMethod(bool param);
virtual bool _AbstractMethod(int param) = 0;
public:
+ Class01& operator=(const Class01&) & = delete;
int public_var;
bool PublicMethod(int param) const;
static bool StaticPublicMethod(bool param);
@@ -2948,7 +2921,7 @@ obtained using the source block described `sec-org-el-version`_.
__title__ = "hpp2plantuml"
__description__ = "Convert C++ header files to PlantUML"
- __version__ = '0.6'
+ __version__ = '0.7'
__uri__ = "https://github.com/thibaultmarin/hpp2plantuml"
__doc__ = __description__ + " <" + __uri__ + ">"
__author__ = "Thibault Marin"
@@ -3046,7 +3019,7 @@ The non-boilerplate part of the ``setup.py`` file defines the package informatio
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries :: Python Modules",
]
- INSTALL_REQUIRES = ['argparse', 'CppHeaderParser', 'jinja2']
+ INSTALL_REQUIRES = ['argparse', 'robotpy-cppheaderparser', 'jinja2']
INSTALL_REQUIRES += ['sphinx', ]
SETUP_REQUIRES = ['sphinx', 'numpydoc']
###################################################################
@@ -3219,7 +3192,7 @@ org-file (converted to RST format).
- dependency relationships
- The package relies on the `CppHeaderParser `_ package for parsing of C++ header
+ The package relies on the `CppHeaderParser `_ package for parsing of C++ header
files.
@@ -3463,9 +3436,9 @@ content of the file is mostly following the defaults, with a few exceptions:
# built documents.
#
# The short X.Y version.
- version = u'v' + u'0.6'
+ version = u'v' + u'0.7'
# The full version, including alpha/beta/rc tags.
- release = u'v' + u'0.6'
+ release = u'v' + u'0.7'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@@ -3539,7 +3512,7 @@ content of the file is mostly following the defaults, with a few exceptions:
# The name for this set of Sphinx documents.
# " v documentation" by default.
#
- # html_title = u'hpp2plantuml ' + u'v' + u'0.6'
+ # html_title = u'hpp2plantuml ' + u'v' + u'0.7'
# A shorter title for the navigation bar. Default is the same as html_title.
#
@@ -3790,7 +3763,7 @@ to the automatically generated and the org-file documents.
- dependency relationships
- The package relies on the `CppHeaderParser `_ package for parsing of C++ header
+ The package relies on the `CppHeaderParser `_ package for parsing of C++ header
files.
diff --git a/hpp2plantuml.org b/hpp2plantuml.org
index 96c4f71..7238bec 100644
--- a/hpp2plantuml.org
+++ b/hpp2plantuml.org
@@ -15,7 +15,7 @@ this single org-file.
The current version of the code is:
#+NAME: hpp2plantuml-version
-: 0.6
+: 0.7
The source code can be found on GitHub:
https://github.com/thibaultmarin/hpp2plantuml.
@@ -40,7 +40,7 @@ hierarchies. It aims at supporting:
- aggregation relationships (very basic support).
- dependency relationships
-The package relies on the [[http://senexcanis.com/open-source/cppheaderparser/][CppHeaderParser]] package for parsing of C++ header
+The package relies on the [[https://pypi.org/project/robotpy-cppheaderparser/][CppHeaderParser]] package for parsing of C++ header
files.
@@ -79,13 +79,13 @@ THE SOFTWARE.
* DONE Requirements
This module has mostly standard dependencies; the only exception is the
-[[http://senexcanis.com/open-source/cppheaderparser/][CppHeaderParser]] module used to parse header files.
+[[https://pypi.org/project/robotpy-cppheaderparser/][CppHeaderParser]] module used to parse header files.
#+NAME: py-dependency-list
#+CAPTION: List of dependencies.
-| argparse |
-| CppHeaderParser |
-| jinja2 |
+| argparse | argparse |
+| robotpy-cppheaderparser | CppHeaderParser |
+| jinja2 | jinja2 |
The full list of non-standard dependencies is produced by the following source
block (returning either imports or a dependency list used in [[#sec-package-setup-py][=setup.py=]]):
@@ -95,7 +95,7 @@ block (returning either imports or a dependency list used in [[#sec-package-setu
(cond
((string= output "import")
(mapconcat
- (lambda (el) (concat "import " (car el))) dep-list "\n"))
+ (lambda (el) (concat "import " (cadr el))) dep-list "\n"))
((string= output "requirements")
(concat "["
(mapconcat
@@ -178,7 +178,6 @@ LINK_TYPE_MAP = {
# - The third element is a function returning the corresponding internal object
CONTAINER_TYPE_MAP = [
['classes', lambda objs: objs.items(), lambda obj: Class(obj)],
- ['structs', lambda objs: objs.items(), lambda obj: Struct(obj)],
['enums', lambda objs: objs, lambda obj: Enum(obj)]
]
#+END_SRC
@@ -203,7 +202,8 @@ class.
C++ objects are represented by objects derived from the base ~Container~ class.
The ~Container~ class is abstract and contains:
-- the container type (~class~, ~enum~, ~struct~),
+- the container type (~class~, ~enum~, ~struct~ objects are handled as ~class~
+ objects),
- the object name,
- a list of members (e.g. class variable or method for a class object),
- a ~parse_members~ method which can build the list of members from a parsed
@@ -256,7 +256,7 @@ class Container(object):
Parameters
----------
- header_container : CppClass, CppStruct or CppEnum
+ header_container : CppClass or CppEnum
Parsed header for container
"""
namespace = header_container.get('namespace', None)
@@ -272,7 +272,7 @@ class Container(object):
Parameters
----------
- header_container : CppClass, CppStruct or CppEnum
+ header_container : CppClass or CppEnum
Parsed header for container
"""
raise NotImplementedError(
@@ -421,7 +421,7 @@ class Class(Container):
element is the class name and the second element is a CppClass
object)
"""
- super().__init__('class', header_class[0])
+ super().__init__(header_class[1]['declaration_method'], header_class[0])
self._abstract = header_class[1]['abstract']
self._template_type = None
if 'template' in header_class[1]:
@@ -449,8 +449,9 @@ class Class(Container):
for member_prop in MEMBER_PROP_MAP.keys():
member_list = header_class[member_type][member_prop]
for header_member in member_list:
- self._member_list.append(
- member_type_handler(header_member, member_prop))
+ if not header_member.get('deleted', False):
+ self._member_list.append(
+ member_type_handler(header_member, member_prop))
def build_variable_type_list(self):
"""Get type of member variables
@@ -717,38 +718,6 @@ class ClassMethod(ClassMember):
#+END_SRC
-*** DONE Structures
-
-While ~struct~ objects are currently not supported, their addition should be
-relatively straightforward and the ~Struct~ class may simply inherit from the
-~Class~ class. The following should give a starting point.
-
-#+NAME: py-render-structs
-#+BEGIN_SRC python
-# %% Struct object
-
-
-class Struct(Class):
- """Representation of C++ struct objects
-
- This class derived is almost identical to `Class`, the only difference
- being the container type name ("struct" instead of "class").
- """
- def __init__(self, header_struct):
- """Class constructor
-
- Parameters
- ----------
- header_struct : list (str, CppStruct)
- Parsed header for struct object (two-element list where the first
- element is the structure name and the second element is a CppStruct
- object)
- """
- super().__init__(header_struct[0])
- super(Class).__init__('struct')
-#+END_SRC
-
-
*** DONE Enumeration lists
The ~Enum~ class representing enumeration object is a trivial extension of the
@@ -1594,8 +1563,9 @@ def _cleanup_type(type_str):
str
The type string after cleanup
"""
- return re.sub(r'[ ]+([*&])', r'\1',
- re.sub(r'(\s)+', r'\1', type_str))
+ return re.sub('\s*([<>])\s*', r'\1',
+ re.sub(r'[ ]+([*&])', r'\1',
+ re.sub(r'(\s)+', r'\1', type_str)))
#+END_SRC
The ~_cleanup_single_line~ function transforms a multiline input string into a
@@ -2094,7 +2064,7 @@ class TestClassVariable:
for test_idx, (input_str, output_ref_str) in \
enumerate(fix_test_list_def(test_list_classvar)):
p = get_parsed_element(input_str)
- class_name = re.sub(r'.*class\s*(\w+).*', r'\1',
+ class_name = re.sub(r'.*(class|struct)\s*(\w+).*', r'\2',
input_str.replace('\n', ' '))
class_input = [class_name, p.classes[class_name]]
obj_c = hpp2plantuml.hpp2plantuml.Class(class_input)
@@ -2132,7 +2102,7 @@ class TestClassMethod:
for test_idx, (input_str, output_ref_str) in \
enumerate(fix_test_list_def(test_list_classmethod)):
p = get_parsed_element(input_str)
- class_name = re.sub(r'.*class\s*(\w+).*', r'\1',
+ class_name = re.sub(r'.*(class|struct)\s*(\w+).*', r'\2',
input_str.replace('\n', ' '))
class_input = [class_name, p.classes[class_name]]
obj_c = hpp2plantuml.hpp2plantuml.Class(class_input)
@@ -2150,13 +2120,14 @@ Table{{{tt}}}[[tbl-unittest-class]]. It includes templates and abstract classes
#+NAME: tbl-unittest-class
#+CAPTION: List of test segments and corresponding PlantUML strings.
-| C++ | plantuml |
-|-----------------------------------------------------------------------+---------------------------------------------------------------------------------------|
-| "class Test {\nprotected:\nint & member; };" | "class Test {\n\t#member : int&\n}\n" |
-| "class Test\n{\npublic:\nvirtual int func() = 0; };" | "abstract class Test {\n\t+{abstract} func() : int\n}\n" |
-| "template class Test{\nT* func(T& arg); };" | "class Test > {\n\t-func(T& arg) : T*\n}\n" |
-| "template class Test{\nvirtual T* func(T& arg)=0; };" | "abstract class Test > {\n\t-{abstract} func(T& arg) : T*\n}\n" |
-| "namespace Interface {\nclass Test {\nprotected:\nint & member; };};" | "namespace Interface {\n\tclass Test {\n\t\t#member : int&\n\t}\n}\n" |
+| C++ | plantuml |
+|-----------------------------------------------------------------------+--------------------------------------------------------------------------------------|
+| "class Test {\nprotected:\nint & member; };" | "class Test {\n\t#member : int&\n}\n" |
+| "struct Test {\nprotected:\nint & member; };" | "struct Test {\n\t#member : int&\n}\n" |
+| "class Test\n{\npublic:\nvirtual int func() = 0; };" | "abstract class Test {\n\t+{abstract} func() : int\n}\n" |
+| "template class Test{\nT* func(T& arg); };" | "class Test > {\n\t-func(T& arg) : T*\n}\n" |
+| "template class Test{\nvirtual T* func(T& arg)=0; };" | "abstract class Test > {\n\t-{abstract} func(T& arg) : T*\n}\n" |
+| "namespace Interface {\nclass Test {\nprotected:\nint & member; };};" | "namespace Interface {\n\tclass Test {\n\t\t#member : int&\n\t}\n}\n" |
#+NAME: test-unit-class
#+BEGIN_SRC python :var test_list_class=tbl-unittest-class
@@ -2168,7 +2139,7 @@ class TestClass:
for test_idx, (input_str, output_ref_str) in \
enumerate(fix_test_list_def(test_list_class)):
p = get_parsed_element(input_str)
- class_name = re.sub(r'.*class\s*(\w+).*', r'\1',
+ class_name = re.sub(r'.*(class|struct)\s*(\w+).*', r'\2',
input_str.replace('\n', ' '))
class_input = [class_name, p.classes[class_name]]
obj_c = hpp2plantuml.hpp2plantuml.Class(class_input)
@@ -2284,6 +2255,7 @@ protected:
static bool _StaticProtectedMethod(bool param);
virtual bool _AbstractMethod(int param) = 0;
public:
+ Class01& operator=(const Class01&) & = delete;
int public_var;
bool PublicMethod(int param) const;
static bool StaticPublicMethod(bool param);
@@ -3598,7 +3570,7 @@ encapsulated in the following source block.
- [-] Add tests
- [ ] Add test coverage report to documentation (full test from within org-mode?)
- - [ ] Test structs
+ - [X] Test structs
- [X] Unit tests
- [X] Full diagram test
- [ ] Extra files for package
@@ -3620,6 +3592,24 @@ encapsulated in the following source block.
- [X] creates documentation rst (and README.rst)
- [X] Link to org-mode rst documentation from index.rst -> Use only org-mode rst?
+** v0.7
+
+*** DONE Handle =delete= keyword
+ CLOSED: [2020-11-10 Tue 00:03]
+
+https://github.com/thibaultmarin/hpp2plantuml/issues/8
+
+*** DONE Use CppHeaderParser fork with support for C++11
+ CLOSED: [2020-11-10 Tue 00:03]
+
+https://github.com/thibaultmarin/hpp2plantuml/issues/7
+
+*** Notes
+
+The change of parser (from =CppHeaderParser= to =robotpy-cppheaderparser=)
+results in minor whitespace changes in the rendered plantuml content
+(e.g. ~>~ becomes ~>~).
+
** v0.6
*** DONE Rename =do_parsed_member=
diff --git a/setup.py b/setup.py
index d0a70cf..e41980b 100644
--- a/setup.py
+++ b/setup.py
@@ -34,7 +34,7 @@
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries :: Python Modules",
]
-INSTALL_REQUIRES = ['argparse', 'CppHeaderParser', 'jinja2']
+INSTALL_REQUIRES = ['argparse', 'robotpy-cppheaderparser', 'jinja2']
INSTALL_REQUIRES += ['sphinx', ]
SETUP_REQUIRES = ['sphinx', 'numpydoc']
###################################################################
diff --git a/src/hpp2plantuml/__init__.py b/src/hpp2plantuml/__init__.py
index ab3f3bf..8483078 100644
--- a/src/hpp2plantuml/__init__.py
+++ b/src/hpp2plantuml/__init__.py
@@ -106,7 +106,7 @@
__title__ = "hpp2plantuml"
__description__ = "Convert C++ header files to PlantUML"
-__version__ = '0.6'
+__version__ = '0.7'
__uri__ = "https://github.com/thibaultmarin/hpp2plantuml"
__doc__ = __description__ + " <" + __uri__ + ">"
__author__ = "Thibault Marin"
diff --git a/src/hpp2plantuml/hpp2plantuml.py b/src/hpp2plantuml/hpp2plantuml.py
index 9628b29..06569f7 100644
--- a/src/hpp2plantuml/hpp2plantuml.py
+++ b/src/hpp2plantuml/hpp2plantuml.py
@@ -31,7 +31,6 @@
# - The third element is a function returning the corresponding internal object
CONTAINER_TYPE_MAP = [
['classes', lambda objs: objs.items(), lambda obj: Class(obj)],
- ['structs', lambda objs: objs.items(), lambda obj: Struct(obj)],
['enums', lambda objs: objs, lambda obj: Enum(obj)]
]
@@ -77,7 +76,7 @@ def parse_members(self, header_container):
Parameters
----------
- header_container : CppClass, CppStruct or CppEnum
+ header_container : CppClass or CppEnum
Parsed header for container
"""
namespace = header_container.get('namespace', None)
@@ -93,7 +92,7 @@ def _do_parse_members(self, header_container):
Parameters
----------
- header_container : CppClass, CppStruct or CppEnum
+ header_container : CppClass or CppEnum
Parsed header for container
"""
raise NotImplementedError(
@@ -223,7 +222,7 @@ def __init__(self, header_class):
element is the class name and the second element is a CppClass
object)
"""
- super().__init__('class', header_class[0])
+ super().__init__(header_class[1]['declaration_method'], header_class[0])
self._abstract = header_class[1]['abstract']
self._template_type = None
if 'template' in header_class[1]:
@@ -251,8 +250,9 @@ def _do_parse_members(self, header_class):
for member_prop in MEMBER_PROP_MAP.keys():
member_list = header_class[member_type][member_prop]
for header_member in member_list:
- self._member_list.append(
- member_type_handler(header_member, member_prop))
+ if not header_member.get('deleted', False):
+ self._member_list.append(
+ member_type_handler(header_member, member_prop))
def build_variable_type_list(self):
"""Get type of member variables
@@ -467,28 +467,6 @@ def _render_name(self):
return method_str
-# %% Struct object
-
-
-class Struct(Class):
- """Representation of C++ struct objects
-
- This class derived is almost identical to `Class`, the only difference
- being the container type name ("struct" instead of "class").
- """
- def __init__(self, header_struct):
- """Class constructor
-
- Parameters
- ----------
- header_struct : list (str, CppStruct)
- Parsed header for struct object (two-element list where the first
- element is the structure name and the second element is a CppStruct
- object)
- """
- super().__init__(header_struct[0])
- super(Class).__init__('struct')
-
# %% Enum object
@@ -1190,8 +1168,9 @@ def _cleanup_type(type_str):
str
The type string after cleanup
"""
- return re.sub(r'[ ]+([*&])', r'\1',
- re.sub(r'(\s)+', r'\1', type_str))
+ return re.sub('\s*([<>])\s*', r'\1',
+ re.sub(r'[ ]+([*&])', r'\1',
+ re.sub(r'(\s)+', r'\1', type_str)))
# %% Single line version of string
@@ -1319,7 +1298,7 @@ def main():
required=False, default=None, metavar='JINJA-FILE',
help='path to jinja2 template file')
parser.add_argument('--version', action='version',
- version='%(prog)s ' + '0.6')
+ version='%(prog)s ' + '0.7')
args = parser.parse_args()
if len(args.input_files) > 0:
CreatePlantUMLFile(args.input_files, args.output_file,
diff --git a/tests/simple_classes_1_2.hpp b/tests/simple_classes_1_2.hpp
index d1cfb5c..9d877d5 100644
--- a/tests/simple_classes_1_2.hpp
+++ b/tests/simple_classes_1_2.hpp
@@ -7,6 +7,7 @@ class Class01 {
static bool _StaticProtectedMethod(bool param);
virtual bool _AbstractMethod(int param) = 0;
public:
+ Class01& operator=(const Class01&) & = delete;
int public_var;
bool PublicMethod(int param) const;
static bool StaticPublicMethod(bool param);
diff --git a/tests/test_hpp2plantuml.py b/tests/test_hpp2plantuml.py
index ba24a6e..2e0a151 100644
--- a/tests/test_hpp2plantuml.py
+++ b/tests/test_hpp2plantuml.py
@@ -73,7 +73,7 @@ def test_list_entries(self):
for test_idx, (input_str, output_ref_str) in \
enumerate(fix_test_list_def(test_list_classvar)):
p = get_parsed_element(input_str)
- class_name = re.sub(r'.*class\s*(\w+).*', r'\1',
+ class_name = re.sub(r'.*(class|struct)\s*(\w+).*', r'\2',
input_str.replace('\n', ' '))
class_input = [class_name, p.classes[class_name]]
obj_c = hpp2plantuml.hpp2plantuml.Class(class_input)
@@ -101,7 +101,7 @@ def test_list_entries(self):
for test_idx, (input_str, output_ref_str) in \
enumerate(fix_test_list_def(test_list_classmethod)):
p = get_parsed_element(input_str)
- class_name = re.sub(r'.*class\s*(\w+).*', r'\1',
+ class_name = re.sub(r'.*(class|struct)\s*(\w+).*', r'\2',
input_str.replace('\n', ' '))
class_input = [class_name, p.classes[class_name]]
obj_c = hpp2plantuml.hpp2plantuml.Class(class_input)
@@ -115,6 +115,11 @@ def test_list_entries(self):
int & member; };""", """class Test {
#member : int&
}
+"""], ["""struct Test {
+protected:
+int & member; };""", """struct Test {
+ #member : int&
+}
"""], ["""class Test
{
public:
@@ -122,11 +127,11 @@ def test_list_entries(self):
+{abstract} func() : int
}
"""], ["""template class Test{
-T* func(T& arg); };""", """class Test > {
+T* func(T& arg); };""", """class Test > {
-func(T& arg) : T*
}
"""], ["""template class Test{
-virtual T* func(T& arg)=0; };""", """abstract class Test > {
+virtual T* func(T& arg)=0; };""", """abstract class Test > {
-{abstract} func(T& arg) : T*
}
"""], ["""namespace Interface {
@@ -146,7 +151,7 @@ def test_list_entries(self):
for test_idx, (input_str, output_ref_str) in \
enumerate(fix_test_list_def(test_list_class)):
p = get_parsed_element(input_str)
- class_name = re.sub(r'.*class\s*(\w+).*', r'\1',
+ class_name = re.sub(r'.*(class|struct)\s*(\w+).*', r'\2',
input_str.replace('\n', ' '))
class_input = [class_name, p.classes[class_name]]
obj_c = hpp2plantuml.hpp2plantuml.Class(class_input)