Parsing Class Definition (class methods etc)

Find and share HowTos to various installations / configurations!
5 posts • Page 1 of 1
shokkul
Posts:37
Joined: Mon Feb 25, 2019 8:50 am

Parsing Class Definition (class methods etc)

Post by shokkul »

Hello All,

I want to parse class definition to get methods and variables. On top of it I want to parse methods further like which inputs are used, what are the type of these inputs. I checked helped section but I could not find suitable function for my objective. Also I checked HighSpeedProgramming and doxygen classes, since technically these functionalities should parse the class/methods to achieve their goal, whether I can use some function from there but I could not detect it.

So is there any function that can help me? I really don't want write my own parser if there is a function that is already doing what I want to achieve.

e.g For class definition parser, I imagine a function that gives all the information about class methods, variables in a mapping

Code: Select all

class Pump
{
  public string pumpName;

  public bool startPump(int action, bool withFeature)
  {
    .....
  }
}


mapping mClassFeatures = parseClass("Pump")

mClassFeatures:

name -> "Pump"

variables->pumpName->type->"string"
                                        ->AM-> "public"

methods->startPump->returnType->bool
                                     ->inputs-> 1 -> name -> action
                                                           -> type   -> int
                                                        2 -> name -> withFeature
                                                           -> type   -> bool
 

kilianvp
Posts:443
Joined: Fri Jan 16, 2015 10:29 am

Re: Parsing Class Definition (class methods etc)

Post by kilianvp »

You can write a parser or use the C++ API to create an CTRL Extension that use getCtrlFuncs() which outputs all functions as well. I did both in the past :D

CTRL Extension & getCtrlFuncs() is the fast and easiest way. There is no ready to use ctrl function.

shokkul
Posts:37
Joined: Mon Feb 25, 2019 8:50 am

Re: Parsing Class Definition (class methods etc)

Post by shokkul »

Hello

Sorry for late reply, we started our feature that needs parsing again. I am using Controller class to get CtrlScript so I can use getCtrlFuncs() as you suggested. However I could not achive to do it. Do you have any example how to use these classes and get script/class functions and its properties with ctrlExtension?

Thanks

shokkul
Posts:37
Joined: Mon Feb 25, 2019 8:50 am

Re: Parsing Class Definition (class methods etc)

Post by shokkul »

Hello Again,

I made some progress, now I can parse scripts with free functions, however when I parse classes, getCtrlFuncs() returns null value. How can I parse the class?

amichon
Posts:93
Joined: Sat May 17, 2014 3:49 pm

Re: Parsing Class Definition (class methods etc)

Post by amichon »

you should use a meta attribute that describes the functionality of your class.

I think it's more efficient and less complex to do

5 posts • Page 1 of 1