Difficulties creating an External Library Class

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Difficulties creating an External Library Class

Dominique Dartois-2
I am trying to call mySQL library functions from Dolphin.
I created a wrapper class and a connection class.
MySQL needs a data structure which is passed to functions.
This structure can be allocated and initialized by the
library, by passing a null pointer to the init function.

The problem : I get no errors but the library returns a nil (NULL)
object meaning there is no memory to allocate (a few hundred bytes).

Here is my code :

ExternalLibrary subclass: #MySQLLibrary

Class method:
fileName
   ^'C:\mysql\lib\opt\libmySQL'

Instance method:
mysqlInit: aMySQL
   <stdcall: lpvoid mysql_init lpvoid>
   ^self invalidCall
----------------
Object subclass: #MySQLConnection
   instanceVariableNames: 'mysql'

Class method:
new
   ^super new setMySQLHandle.

Instance methods:
setMySQLHandle
   mysql := MySQLLibrary default mysqlInit: 0.
----------------
I try in a WorkSpace :
m := MySQLConnection new. "Inspect it"
The variable mysql of the m instance is 4 zeros.

I tried to call the library in a C program like that:
MYSQL * myData ;
myData = mysql_init((MYSQL*) 0);
and it runs OK;

I think I am missing something even if I followed the
external interfacing patterns.

Thanks to all.

----
Dominique Dartois


Reply | Threaded
Open this post in threaded view
|

Re: Difficulties creating an External Library Class

Blair McGlashan
"Dominique Dartois" <[hidden email]> wrote in message
news:[hidden email]...
> I am trying to call mySQL library functions from Dolphin.
> I created a wrapper class and a connection class.
> MySQL needs a data structure which is passed to functions.
> This structure can be allocated and initialized by the
> library, by passing a null pointer to the init function.
>
> The problem : I get no errors but the library returns a nil (NULL)
> object meaning there is no memory to allocate (a few hundred bytes).

I'm not sure what the problem is here, but I believe others may already have
successfully wrapped this library. Anybody?

Regards

Blair