G
Guest
Hello,
I noticed an unexplained (for me) behaviour while wrapping unmanaged virtual
methods.
This is the test situation:
An unmanaged class has four methods defined DoIt1 .. DoIt4. Each method just
returns false.
DoIt3 and DoIt4 are virtual methods defined in the base class MyBase of my
unmanaged code.
MyClass is an unmanaged class I derived from MyBase.
MMyClass is the managed wrapper class for MyClass.
I only get the correct return value, when I explicitly give the name of
MyClass when calling the DoItx method. See code parts below.
Does anyone know the reason?
Thank you
Carl
---------------------------------------------------------
class __declspec(dllexport) MyBase
{
public:
bool DoIt2 (void) { return false ; }
virtual bool DoIt3 (void) { return false ; }
virtual bool DoIt4 (void) = 0 ;
} ;
---------------------------------------------------------
class __declspec(dllexport) MyClass : public MyBase
{
public:
bool DoIt1 (void) { return false ; }
bool DoIt3 (void) { return false ; }
bool DoIt4 (void) { return false ; }
} ;
---------------------------------------------------------
#include "..\UnManagedCode\MyClass.h"
using namespace System ;
public __gc class MMyClass
{
public:
MMyClass (Void) { m_MyClass = new MyClass() ; } ;
~MMyClass (Void) { delete m_MyClass ; } ;
Boolean DoIt1 (Void) { return m_MyClass->DoIt1(); } ; // returns false --
Boolean DoIt5 (Void) { return m_MyClass->MyClass:oIt1(); } ; // returns
false -- > Ok.
Boolean DoIt6 (Void) { return m_MyClass->MyClass:oIt2(); } ; // returns
false -- > Ok.
Boolean DoIt7 (Void) { return m_MyClass->MyClass:oIt3(); } ; // returns
false -- > Ok.
Boolean DoIt8 (Void) { return m_MyClass->MyClass:oIt4(); } ; // returns
false -- > Ok.
private:
MyClass __nogc * m_MyClass ;
} ;
I noticed an unexplained (for me) behaviour while wrapping unmanaged virtual
methods.
This is the test situation:
An unmanaged class has four methods defined DoIt1 .. DoIt4. Each method just
returns false.
DoIt3 and DoIt4 are virtual methods defined in the base class MyBase of my
unmanaged code.
MyClass is an unmanaged class I derived from MyBase.
MMyClass is the managed wrapper class for MyClass.
I only get the correct return value, when I explicitly give the name of
MyClass when calling the DoItx method. See code parts below.
Does anyone know the reason?
Thank you
Carl
---------------------------------------------------------
class __declspec(dllexport) MyBase
{
public:
bool DoIt2 (void) { return false ; }
virtual bool DoIt3 (void) { return false ; }
virtual bool DoIt4 (void) = 0 ;
} ;
---------------------------------------------------------
class __declspec(dllexport) MyClass : public MyBase
{
public:
bool DoIt1 (void) { return false ; }
bool DoIt3 (void) { return false ; }
bool DoIt4 (void) { return false ; }
} ;
---------------------------------------------------------
#include "..\UnManagedCode\MyClass.h"
using namespace System ;
public __gc class MMyClass
{
public:
MMyClass (Void) { m_MyClass = new MyClass() ; } ;
~MMyClass (Void) { delete m_MyClass ; } ;
Boolean DoIt1 (Void) { return m_MyClass->DoIt1(); } ; // returns false --
Boolean DoIt2 (Void) { return m_MyClass->DoIt2(); } ; // returns false --
Boolean DoIt3 (Void) { return m_MyClass->DoIt3(); } ; // returns true --
Boolean DoIt4 (Void) { return m_MyClass->DoIt4(); } ; // returns true --!!!!!!!! Oops.
!!!!!!!! Oops.
Boolean DoIt5 (Void) { return m_MyClass->MyClass:oIt1(); } ; // returns
false -- > Ok.
Boolean DoIt6 (Void) { return m_MyClass->MyClass:oIt2(); } ; // returns
false -- > Ok.
Boolean DoIt7 (Void) { return m_MyClass->MyClass:oIt3(); } ; // returns
false -- > Ok.
Boolean DoIt8 (Void) { return m_MyClass->MyClass:oIt4(); } ; // returns
false -- > Ok.
private:
MyClass __nogc * m_MyClass ;
} ;