Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bug-Fix for multi-keyword variable-list parsing for properties#52

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
PBCOnGit wants to merge1 commit intorobotpy:main
base:main
Choose a base branch
Loading
fromPBCOnGit:master
Open
Show file tree
Hide file tree
Changes fromall 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
35 changes: 31 additions & 4 deletionsCppHeaderParser/CppHeaderParser.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2458,11 +2458,38 @@ def _evaluate_property_stack(self, clearStack=True, addToVar=None):
self.nameStack,
". Separating processing",
)
orig_nameStack = self.nameStack[:]
i = leftMostComma - 2 # start right before the first var name
typeFound = []
typeEndIndex = 0

while not i < 0: # find the type by assuming that the first non-ptr/ref related word before the first varname has to be the end of the type stack
if self.nameStack[i] == "*" or self.nameStack[i] == "&":
if i > 0 and self.nameStack[i - 1] == "const": # handle declarations like "int const& const_int_ref;" correctly
i -= 1; # skip next const
else: # the real type declaration starts (ends) at index i
typeEndIndex = i + 1
typeFound.extend(self.nameStack[0:i + 1])

type_nameStack = orig_nameStack[: leftMostComma - 1]
for name in orig_nameStack[leftMostComma - 1 :: 2]:
self.nameStack = type_nameStack + [name]
break

i-= 1

nameStacks = []
currStack = typeFound.copy()

for word in self.nameStack[typeEndIndex:]:
if word == ",":
nameStacks.append(currStack)
currStack = typeFound.copy() # reset currStack
continue

currStack.append(word)

if not currStack == typeFound: # add last var in the list
nameStacks.append(currStack)

for nameStack in nameStacks:
self.nameStack = nameStack
self._evaluate_property_stack(
clearStack=False, addToVar=addToVar
)
Expand Down
13 changes: 7 additions & 6 deletionstest/TestSampleClass.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@ class SampleClass: public BaseSampleClass

double prop7; //!< prop7 description
//!< with two lines

/// prop8 description
int prop8;
};
Expand DownExpand Up@@ -642,6 +642,7 @@ class Grape
int a, b,c;
map<string, int> d;
map<string, int> e, f;
const int* g, const& h, const* i, j;
};

// Bug BitBucket #14
Expand DownExpand Up@@ -719,7 +720,7 @@ struct Lemon
virtual void foo() final;
virtual void foo2();
};

struct Lime final : Lemon
{
void abc();
Expand DownExpand Up@@ -749,12 +750,12 @@ union olive {

// Sourceforge bug 61
typedef struct
{
enum BeetEnum : int
{
{
enum BeetEnum : int
{
FAIL = 0,
PASS = 1
};
};
} BeetStruct;

void set_callback(int* b, long (*callback) (struct test_st *, int, const char*, int long, long, long));
Expand Down
51 changes: 45 additions & 6 deletionstest/test_CppHeaderParser.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1752,7 +1752,7 @@ class functions_TestCase(unittest.TestCase):
def setUp(self):
self.cppHeader = CppHeaderParser.CppHeader(
"""\
void global_funct1(int i);
void global_funct1(int i);
int global_funct2(void);
""",
"string",
Expand DownExpand Up@@ -1787,7 +1787,7 @@ class functions2_TestCase(unittest.TestCase):
def setUp(self):
self.cppHeader = CppHeaderParser.CppHeader(
"""\
void global_funct1(int i);
void global_funct1(int i);
int global_funct2(void){
// do something
}
Expand DownExpand Up@@ -2171,6 +2171,45 @@ def test_f_exists(self):
self.cppHeader.classes["Grape"]["properties"]["public"][5]["name"], "f"
)

def test_g_exists(self):
self.assertEqual(
self.cppHeader.classes["Grape"]["properties"]["public"][6]["name"], "g"
)

def test_g_type(self):
self.assertEqual(
self.cppHeader.classes["Grape"]["properties"]["public"][6]["type"], "const int *"
)

def test_h_exists(self):
self.assertEqual(
self.cppHeader.classes["Grape"]["properties"]["public"][7]["name"], "h"
)

def test_h_type(self):
self.assertEqual(
self.cppHeader.classes["Grape"]["properties"]["public"][7]["type"], "const int const &"
)

def test_i_exists(self):
self.assertEqual(
self.cppHeader.classes["Grape"]["properties"]["public"][8]["name"], "i"
)

def test_i_type(self):
self.assertEqual(
self.cppHeader.classes["Grape"]["properties"]["public"][8]["type"], "const int const *"
)

def test_j_exists(self):
self.assertEqual(
self.cppHeader.classes["Grape"]["properties"]["public"][9]["name"], "j"
)

def test_j_type(self):
self.assertEqual(
self.cppHeader.classes["Grape"]["properties"]["public"][9]["type"], "const int"
)

# Bug BitBucket #14
class Avacado_TestCase(unittest.TestCase):
Expand DownExpand Up@@ -2433,7 +2472,7 @@ def setUp(self):
virtual void foo() final;
virtual void foo2();
};

struct Lime final : Lemon
{
void abc();
Expand DownExpand Up@@ -3488,7 +3527,7 @@ class StaticAssert_TestCase(unittest.TestCase):
def setUp(self):
self.cppHeader = CppHeaderParser.CppHeader(
"""
static_assert(sizeof(int) == 4,
static_assert(sizeof(int) == 4,
"integer size is wrong"
"for some reason");
""",
Expand All@@ -3511,7 +3550,7 @@ def setUp(self):
}

void fn();

std::vector<int> m_stuff;
};

Expand DownExpand Up@@ -3859,7 +3898,7 @@ def setUp(self):
template <class SomeType> class A {
public:
typedef B <SomeType> C;

A();

protected:
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp