Page 1 of 1

How do I know the Funtion Index with Native AddIns

PostPosted: Fri Mar 14, 2008 7:22 pm
by parissmith
Sorry for this really simple question, but when using Native Add Ins, how do I know what the function index is. For example:
SampleAddIn.oc

int add(int x, int y) @ library("SampleAddIn", 0);
bool hookcontrast(bool hook) @ library("SampleAddIn", 12);
struct SampleSerial {
int id;
void _init() @ library("SampleAddIn", 7);
void _destroy() @ 80;
void _copy(SampleSerial) @ 89;
bool open(int baud) @ library("SampleAddIn", 8 );
void close() @ library("SampleAddIn", 9);
void send(char byte) @ library("SampleAddIn", 10);
char recv() @ library("SampleAddIn", 11);
};

Where did the 0 come from in the add declaration? And the 12 in hookcontrast?
What about the index numbers in the struct?
I'm just playing around with PocketCArchitect, and getting used to the functionallity, and I'm finding myself with a whole lot of questions.
Thanks for all your input!

Re: How do I know the Funtion Index with Native AddIns

PostPosted: Tue Jul 08, 2008 7:00 am
by dewey
These come from the native code which calls the correct native function based on the iFunc parameter as seen in SampleAddIn.cpp:

Code: Select all
void* __Startup__(OrbFormsInterface* ofi, void* data, UInt16 iFunc)
{
   // we don't need to setup any global state
   if (iFunc == NATIVE_STARTUP) return NULL;
   if (iFunc == NATIVE_SHUTDOWN) return NULL;

   switch (iFunc) {
      case 0: add(ofi); break;
      case 1: TG_onopen(ofi); break;