generating API for C

Nikola
2012-04-11
2012-11-14
  • Nikola
    Nikola
    2012-04-11

    Hello, i am new at this community.

    I made python script for recursively generating API for C.

    Introduction:
    Standard C API is useless because there are only basic functions in C.
    So … this allows you to load new API recursively from includes in current file.
    This way you are 1 step closer to having quick and fast programable IDE (notepad++) :)
    Also you can add shortcut like F9 to execute compile_and_execute.bat in current dir.

    Download:
    python_C_Parser.py http://pastebin.com/A04K2Gjz
    cparser.xml http://pastebin.com/AKzsZ1D6
    Installation:
    save files to notepad installation dir

    You can make shortcut for F10 button:
    just edit shortcuts.xml, add this line:

    <Command name="load hints C" Ctrl="no" Alt="no" Shift="no" Key="121">python python_C_Parser.py "$(FULL_CURRENT_PATH)"</Command>
    

    it is tested on python 3.2.x, 2.7.x
    be carefull when editing shortcuts.xml with np++ when closing np++, it overwrites shortcuts.xml.
    So … after editing shortcuts.xml, set shortcuts.xml to readonly in properties, close np++,
    clear readonly, open np++, if you find (Run->load hints C) you win :).

    How To Use:
    - you can use python file with console or you can use shortcut in npp.

    - press F10 in any .c file, python script will popup for short time and cache all functions and defines from current file and recursively from includes.

    - You will have to manually reload cache by switching tabs (go to other tab and go back to c file).

    - Sometimes new cache will bug a little, so to fix that just type first function from cache and invoke function params hint, thats it, so now u got cached up to date API of which u can actually have some use :).

    - there is option in cparser.xml to enter startXML, so it appends new functions in it (for that set active = "true" and insert correct path). if u set startXML to same file where u r outputing then every time u cache something it will be added to cache. If u use startXML as different path then first cache from startXML will be loaded and new cache appended then saved on outputXML. Without using startXML every cache is new so no functions from old cache will be in it.

    - be aware that if you dont clear cache and use startXML in the way as appending (startXML = outputXML) then cache file might grow large (1-10MB or more), when caching windows.h u get about 1MB cache.

    - Turn on Auto-Completion and enjoy scripting.

    cparser.xml must be in same directory as script or u can edit CONFIG_FILE = "your path" to insert your path, but cparser.xml must be loaded.

    Bugs:
    I created this in hurry because im working on OpenGL project and I needed a good and fast IDE (I hate IDE where i have to click too much - that would be Visual Studio)
    So if u find any bugs post them here or u can edit .py and post it as solution.

    I've tried to implement this in Python Script plugin but there is one problem:
    xml.etree.ElementTree - not working so i tried sax package.
    xml.etree.sax   - not working (it says something socket module not found, why would socket be needed when parsing .xml xD).
    then i gave up … so if you want you can try to implement it. That would be nice. Also it would be great if notepad++ add more support to scripting(IDE) so other IDE's won't be necessary. I dont like having hundreds of IDE's on computer.