Autore Topic: Creare un componente di Gambas in C++  (Letto 483 volte)

Offline vuott

  • Moderatore globale
  • Senatore Gambero
  • *****
  • Post: 11.724
  • Ne mors quidem nos iunget
    • Mostra profilo
Creare un componente di Gambas in C++
« il: 21 Settembre 2014, 13:30:05 »
Riporto questa discussione:


" 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?

Kind regards
Jørn Erik
"


" 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.
"
« Chiunque, non ricorrendo lo stato di necessità, nel proprio progetto Gambas fa uso delle istruzioni Shell o Exec, è punito con la sanzione pecuniaria da euro 20,00 a euro 60,00. »