Skip to content

Class name detection failure #4

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

Open
NachtRaveVL opened this issue Oct 24, 2020 · 0 comments
Open

Class name detection failure #4

NachtRaveVL opened this issue Oct 24, 2020 · 0 comments

Comments

@NachtRaveVL
Copy link

Running your script across a few of my libraries, I noticed that the way you're detecting the class name of the library could be a bit more robust. Running your script I get:

Getting Functions....

Traceback (most recent call last):
  File "../keywords_populator.py", line 350, in <module>
    create_keyword_file(libData)
  File "../keywords_populator.py", line 323, in create_keyword_file
    get_functions(srcPath, headerFilePath, className, functionList)
  File "../keywords_populator.py", line 134, in get_functions
    classInfo = header.classes[cName]
KeyError: ''

Turns out that this line appears in the main header of one of my libraries before the class definition, which it gets stuck on:

    BY8X0116P_EqualizerProfile_Classic,         // Equalizer profile classic

So I cruised through your script and noticed the lines:

    with open(headerPath, 'r') as h: 
        for line in h:
            if "class" in line:
                words = line.split(' ')
                className = words[1] 

Which is a rather naive way to detect class name. I added a single space after class so it said "class ", which seemed to work for my specific use case, but you might want to, instead, open the file up using the Cpp processor thing (the dependency you use) and get class name that way. That way you're not relying on a simple match for "class" but rather an actual definition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant