Hace you considered a SheetCAM plugin API?

Request and discuss new features
jemmyell

Here is my .DEF file

Post by jemmyell »

Hi again,

Here is the .DEF file I made to generate the .LIB from

-James
jemmyell

oops....

Post by jemmyell »

sorry, my attachment did not go. here it is:

LIBRARY "SheetCAM"

EXPORTS
scAddMainMenu
scAddMenu
scIsProcessing
scLoadDrawing
scLoadJob
scRunPost

-James

the LINK /DUMP options DOES definitely see all your exports from SheetCAM BTW

-James
jemmyell

Got my DLL to link, but the news is not good

Post by jemmyell »

Hi Les,

here is my .DEF file modified to add silent function signature junk that Microsoft is putting there. It allows my DLL to link, BUT sheetCAM cannot use it. I am attaching a ZIP file with the .DEF and the DLL for you.

I am afraid that MS deliberately is making binary linkage with borland tools (and probably others) not work.

-James
jemmyell

Post by jemmyell »

Hi Les,

Just to give you a taste of my 'soft' linkage I was developing:


This is what the SheetCAM side would look like:

------------------------------------------------------------------------------------

#define ID_LOADJOB 0x01

void CALLBACK LoadJob(char *);

WORD numInterface;

typedef struct {
WORD *SCInterfaceID;
FARPROC *SCInterface;
} PLUGIN_DATA;

PLUGIN_DATA SCData;

HINSTANCE hPlugin = NULL;

typedef VOID (CALLBACK *PLUGINSTARTUP)(WORD, PLUGIN_DATA *);
typedef VOID (CALLBACK *PLUGINSHUTDOWN)();

PLUGINSTARTUP PluginStartup = NULL;
PLUGINSHUTDOWN PluginShutdown = NULL;


// Build Callback / capabilities table

numInterface = 1;

SCData.SCInterfaceID = (WORD *)calloc(numInterface, sizeof(WORD));

SCData.SCInterface = (FARPROC *)calloc(numInterface, sizeof(FARPROC));

SCData.SCInterfaceID[0] = ID_LOADJOB;

SCData.SCInterface[0] = (FARPROC)(LoadJob);

// Load the plugin DLL

hPlugin = LoadLibrary("SheetCAMPlugin.dll");

if (NULL != hPlugin) {

// Call PluginStartup()

PluginStartup = (PLUGINSTARTUP)GetProcAddress(hPlugin,"PluginStartup");

if (NULL != PluginStartup) {

(*PluginStartup)(numInterface, &SCData);
}
}

-----------------------------------------------------------------------------------

And this is what the startup in the DLL would look like:

STDAPI PluginStartup(WORD numInterface, PLUGIN_DATA *scData)

{
int idx;

AFX_MANAGE_STATE(AfxGetStaticModuleState());

DbgMsg("PluginStartup entry");

// Setup the SheetCAM callback table

pluginTable.SCInterfaceID = (WORD *)calloc(numInterface, sizeof(WORD));

pluginTable.SCInterface = (FARPROC *)calloc(numInterface, sizeof(FARPROC));

for (idx = 0; idx < numInterface; idx++) {

pluginTable.SCInterfaceID[idx] = scData->SCInterfaceID[idx];

pluginTable.SCInterface[idx] = scData->SCInterface[idx];
}

// Start the callback thread

CreateThread(NULL,0L,CallbackThread,&threadData,0,NULL);

// Since we were called, SheetCAM is running

IsRunning = TRUE;

DbgMsg("PluginStartup exit");

return S_OK;
}

------------------------------------------------------------------------------------

Just my two cents. I hope we can make the hard linkage work, it is simpler.

-James
User avatar
Les Newell
Site Admin
Posts: 3660
Joined: Thu May 11, 2006 8:12 pm

Hace you considered a SheetCAM plugin API?

Post by Les Newell »

I downloaded Visual Studio 2005 and did some experiments. VC++ really
insists on name mangling, no matter what you do. In the end I have had
to resort to referencing functions by ordinal. This arrangement will
still make SheetCam backwards compatible with older plugins. Newer
plugins trying to use functions that are not available will load but
when they try to access unavailable functions they will crash. In the
same situation, BCB based plugins (using names) will simply fail to load.

The next release of SheetCam (due out in a few hours) will include an
SDK directory containing both VC++ and BCB demo projects.

Les
jemmyell

Thank you so much

Post by jemmyell »

Hi Les,

That is good news. I will look forward to this.

-James
Post Reply