On Sun, 21 Sep 2014, J??rn Erik M??rne wrote: > Hi! > > I had a C++ introduction course at the University, so my knowledge of > the language is very basic (no play on words intended :) ). > > I've been looking at how to put together a simple C++ component, tried > to get an understanding from the documentation and looking at some > components in the svn repo. I hvave gotten to the point of making the > "skeleton" from the script inside the TEMPLATES folder. > > Now, just to get an understanding of how it is done, how can I make a > simple component that has a property, and two methods, one for setting > and one for getting the property's value? >
If that helps you, you can have a look at main/lib/data/c_circular.c which implements a ring buffer in gb.data and is sufficiently simple. You normally do the following: 1. Create your source files c_ClassName.c and c_ClassName.h (or .cpp/.hpp), 2. Put them into your src/Makefile.am and ./reconf && ./configure, 3. Write your code: 3.1. You need a GB_DESC array which describes your class: you define method and property signatures there and link your C/C++ implementation functions, 3.2. Write those functions, 3.3. Make the GB_DESC array externally visible and declare it in your c_ClassName.h, 3.4. In your main.c you need to add the GB_DESC array to the list of exported classes, 4. make && sudo make install, 5. Create a new project, add your component and try it out. Doing that the first time is the toughest. Look at how other components do it. Normally, if you study the process of how a C/C++ class definition gets its way to the interpreter, it suffices to look at the files mentioned above: src/Makefile.am, src/c_ClassName.c src/c_ClassName.h, src/main.c. Regards, Tobi PS: Also, this question is more suited for the gambas-devel list. -- "There's an old saying: Don't change anything... ever!" -- Mr. Monk ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that Matters. http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user