On Feb 20, 2012, at 12:15 PM, Goncalo Oliveira wrote:
> C header
>
> // callback (ConnEventType is an enum)
> typedef void (*CommCallback) (ConnEventType status, unsigned long connID);
>
> // method (callingConvention is also an enum)
> long Msg_StartUp (void *pConnEventFn, const char *pConfigPath, bool
> bIsProLicensed = true, bool bIsSDKLicensed = true, bool bStartConnection =
> true, callingConvention convention = convention_default);
The most important question: the above appears to be C++, not C (due to default
parameters). Is that function declaration within an `extern "C" {` block?
> C#
>
> // callback
> delegate void DelegateCommCallback( ConnEventType status, uint connID );
I'd suggest UIntPtr instead of `uint`, at least if this library is present on
ILP32 and LP64 platforms. If it's on Windows P64, uh....
For the same reason, I'd suggest using `IntPtr` for the `long` returned by
Msg_StartUp().
> // metohd
> [DllImport( "libsdk", EntryPoint = "Java_com_sdk_Msg_Msg_1StartUp", CharSet =
> CharSet.Auto )]
> private static extern int Msg_StartUp( DelegateCommCallback commCallback,
> byte[] configDir, bool isProLicensed, bool isSDKLicensed, bool
> startConnection, int convention );
1. Either provide the full filename or provide the "base" filename for the
library, e.g. "libsdk.so" or "sdk". Mono will only try a few filename patterns
when loading the native library.
2. I'm not sure why you're setting EntryPoint to a Java method name if the C
method is Msg_Startup(). I would suggest omitting the EntryPoint setting.
3. What is the type of `callingConvention` in C? Is it an enum compatible with
`int` or some other type?
I would suggest:
enum CallingConvention : int {
Default,
// ...
}
[DllImport ("sdk", CharSet=CharSet.Ansi)
IntPtr Msg_Startup (DelegateCommCallback pConnEventFn,
string pConfigPath,
bool bIsProLicensed=true,
bool bStartConnection=true,
CallingConvention convention =
CallingConvention.Default);
- Jon
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid