-
Notifications
You must be signed in to change notification settings - Fork 50
Add declaration object for deprecation message. #138
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
Merged
tom-osika
merged 2 commits into
CastXML:develop
from
josephsnyder:pass_attribute_comments
Feb 2, 2021
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Copyright 2021 Insight Software Consortium. | ||
| // Distributed under the Boost Software License, Version 1.0. | ||
| // See http://www.boost.org/LICENSE_1_0.txt | ||
|
|
||
| namespace deprecation { | ||
|
|
||
|
|
||
| class __attribute__((deprecated("Test class Deprecated"))) test | ||
| { | ||
| public: | ||
| test(); | ||
| __attribute__((deprecated("One arg constructor is Deprecated"))) test(int a); | ||
|
|
||
| int hello(); | ||
| void __attribute__((deprecated("Function is deprecated"))) goodbye(); | ||
| }; | ||
| enum __attribute__((deprecated("Enumeration is Deprecated"))) com_enum { | ||
| One = 1, | ||
| Two = 2 | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| # Copyright 2014-2020 Insight Software Consortium. | ||
| # Copyright 2004-2009 Roman Yakovenko. | ||
| # Distributed under the Boost Software License, Version 1.0. | ||
| # See http://www.boost.org/LICENSE_1_0.txt | ||
|
|
||
| import unittest | ||
|
|
||
| from . import parser_test_case | ||
|
|
||
| from pygccxml import parser | ||
| from pygccxml import declarations | ||
|
|
||
|
|
||
| class Test(parser_test_case.parser_test_case_t): | ||
| global_ns = None | ||
|
|
||
| def __init__(self, *args): | ||
| parser_test_case.parser_test_case_t.__init__(self, *args) | ||
| self.header = "test_deprecation.hpp" | ||
| self.global_ns = None | ||
| self.config.castxml_epic_version = 1 | ||
|
|
||
| def _check_text_content(self, list, comment_decl): | ||
tom-osika marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if comment_decl: | ||
| self.assertEqual(list, comment_decl) | ||
| else: | ||
| print("No text in comment to check") | ||
|
|
||
| def setUp(self): | ||
|
|
||
tom-osika marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if not self.global_ns: | ||
| decls = parser.parse([self.header], self.config) | ||
| Test.global_ns = declarations.get_global_namespace(decls) | ||
| Test.xml_generator_from_xml_file = \ | ||
| self.config.xml_generator_from_xml_file | ||
| self.xml_generator_from_xml_file = Test.xml_generator_from_xml_file | ||
|
|
||
| self.global_ns = Test.global_ns | ||
|
|
||
| def test(self): | ||
| """ | ||
| Check the comment parsing | ||
| """ | ||
|
|
||
| if self.config.castxml_epic_version != 1: | ||
| # Run this test only with castxml epic version == 1 | ||
| return | ||
| tnamespace = self.global_ns.namespace("deprecation") | ||
|
|
||
| tenumeration = tnamespace.enumeration("com_enum") | ||
| self.assertIn("deprecation", dir(tenumeration)) | ||
| self._check_text_content('Enumeration is Deprecated', | ||
| tenumeration.deprecation) | ||
|
|
||
| tclass = tnamespace.class_("test") | ||
| self.assertIn("deprecation", dir(tclass)) | ||
| self._check_text_content("Test class Deprecated", tclass.deprecation) | ||
|
|
||
| tmethod = tclass.member_functions()[0] | ||
| tmethod_dep = tclass.member_functions()[1] | ||
|
|
||
| self.assertIn("deprecation", dir(tmethod)) | ||
| self.assertIsNone(tmethod.deprecation) | ||
| self._check_text_content("Function is deprecated", | ||
| tmethod_dep.deprecation) | ||
|
|
||
| tconstructor = tclass.constructors()[0] | ||
| tconstructor_dep = tclass.constructors()[1] | ||
|
|
||
| self.assertIsNone(tconstructor.deprecation) | ||
| self.assertIn("deprecation", dir(tconstructor_dep)) | ||
| self._check_text_content("One arg constructor is Deprecated", | ||
| tconstructor_dep.deprecation) | ||
|
|
||
|
|
||
| def create_suite(): | ||
| suite = unittest.TestSuite() | ||
| suite.addTest(unittest.makeSuite(Test)) | ||
| return suite | ||
|
|
||
|
|
||
| def run_suite(): | ||
| unittest.TextTestRunner(verbosity=2).run(create_suite()) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| run_suite() | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.