#1 Dll wrapper suggestion

closed
5
2002-02-03
2002-01-31
Mark McConkey
No

Are you aware of a code generator that would slap a win32 C dll interface on top of the C++ proxy
classes you create. Unfortunately I have to support Java, C++, and Visual Basic users and I don't
want to use the ActiveX wrapper in Sun's plug in because of speed issues in addition to the fact
that Sun is dropping support in JDK 1.4

For example:

//****
//JAVA
//****
class MyJavaClass{
public MyJavaClass( String strMessage ){
testMessage_ = strMessage;
}

public String getTestMessage(){
return testMessage_;
}

private String testMessage_;
}

//***********************
//C++ PROXY CREATED BY JNI++
//***********************
class CMyJavaClass
{
CMyJavaClass( std::string str_message )
{
//jni magic here
}

std::string getTestMessage()
{
//jni magic here
}
};

//******************************************
//DLL WRAPPER (does a tool exist that will generate this?)
//******************************************
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved )
{
BOOL ret_val = false;

switch( ul_reason_for_call )
{
case DLL_PROCESS_ATTACH:
//use jni to instantiate jvm here
break;
case DLL_PROCESS_DETACH:
//use jni to destruct jvm here
break;
}
}

extern "c"
{
void __declspec(dllexport) constructMyJavaClass( void* this, construct_param1, ... )
{
//call to your C++ proxy class constructor here and place a reference to the object
//in a hash map
}

char* getTestMessage( void* this )
{
//call getTestMessage on object corresponding with *this using the hash map
}

void __declspec(dllexport) destructMyJavaClass( void* this )
{
}
}

Discussion

    • status: open --> closed
     
  • Logged In: YES
    user_id=123204

    It would be a simple task to generate procedural entry
    points for the generated proxy classes, but generating
    parameter and return types that VB can work with is another
    challenge. I am not sure how VB could pass in (or return)
    native JNI types, and am not terribly interested in
    generating VB proxy classes. I have toyed with the idea of
    providing the option of generating COM interfaces and
    coclasses for the generated proxies, but given the fate of
    COM, I can't say I'm very interested in that, either.

     
    • assigned_to: nobody --> ptrewhella
     
  • Logged In: NO

    I personally wish I could ignore VB and COM too. Unfortunately the day has not yet come when I can do
    that. Thanks for your reply.