C bridge test; method param name correction

This commit is contained in:
Daniel Boelzle
2001-04-12 12:39:24 +00:00
parent 8683dd7b4d
commit ceafe5a64b
6 changed files with 124 additions and 45 deletions

View File

@@ -2,9 +2,9 @@
*
* $RCSfile: lbnames.h,v $
*
* $Revision: 1.1.1.1 $
* $Revision: 1.2 $
*
* last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $
* last change: $Author: dbo $ $Date: 2001-04-12 13:39:23 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,6 +65,10 @@
*/
#define UNO_LB_JAVA_NAMESPACE java
#define UNO_LB_JAVA "java"
/** ANSI C compilers<br>
*/
#define UNO_LB_C_NAMESPACE c_uno
#define UNO_LB_C "c"
/** Miscrosoft VC++ 4.2 - 6.0 compiler; RTTI is not supported<br>
*/
#define UNO_LB_MSCI_NAMESPACE msci

View File

@@ -2,9 +2,9 @@
*
* $RCSfile: static_types.cxx,v $
*
* $Revision: 1.7 $
* $Revision: 1.8 $
*
* last change: $Author: jsc $ $Date: 2001-03-30 13:39:19 $
* last change: $Author: dbo $ $Date: 2001-04-12 13:39:23 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -278,12 +278,12 @@ typelib_TypeDescriptionReference ** SAL_CALL typelib_static_type_getByTypeClass(
typelib_CompoundMember_Init aMembers[2];
OUString sMemberType0( RTL_CONSTASCII_USTRINGPARAM("string") );
OUString sMemberName0( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.Exception::Message") );
OUString sMemberName0( RTL_CONSTASCII_USTRINGPARAM("Message") );
aMembers[0].eTypeClass = typelib_TypeClass_STRING;
aMembers[0].pTypeName = sMemberType0.pData;
aMembers[0].pMemberName = sMemberName0.pData;
OUString sMemberType1( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface") );
OUString sMemberName1( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.Exception::Context") );
OUString sMemberName1( RTL_CONSTASCII_USTRINGPARAM("Context") );
aMembers[1].eTypeClass = typelib_TypeClass_INTERFACE;
aMembers[1].pTypeName = sMemberType1.pData;
aMembers[1].pMemberName = sMemberName1.pData;
@@ -307,7 +307,7 @@ typelib_TypeDescriptionReference ** SAL_CALL typelib_static_type_getByTypeClass(
// XInterface members
typelib_InterfaceMethodTypeDescription * pMethod = 0;
typelib_Parameter_Init aParameters[1];
OUString sParamName0( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface::aType") );
OUString sParamName0( RTL_CONSTASCII_USTRINGPARAM("aType") );
OUString sParamType0( RTL_CONSTASCII_USTRINGPARAM("type") );
aParameters[0].pParamName = sParamName0.pData;
aParameters[0].eTypeClass = typelib_TypeClass_TYPE;

View File

@@ -2,9 +2,9 @@
*
* $RCSfile: lbmap.cxx,v $
*
* $Revision: 1.15 $
* $Revision: 1.16 $
*
* last change: $Author: dbo $ $Date: 2001-03-28 10:46:10 $
* last change: $Author: dbo $ $Date: 2001-04-12 13:39:23 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -472,8 +472,11 @@ static Mapping getMediateMapping(
Environment aUno;
Mapping aUno2To;
// backwards: from dest to source of mapping chain
// connect to uno
if (rTo.getTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(UNO_LB_UNO ) )) // to is uno
OUString aUnoEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) );
if (rTo.getTypeName() == aUnoEnvTypeName) // to is uno
{
aUno = rTo;
// no Uno2To mapping necessary
@@ -481,11 +484,12 @@ static Mapping getMediateMapping(
else
{
// get registered uno env
OUString aEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) );
uno_getEnvironment( (uno_Environment **)&aUno, aEnvTypeName.pData, 0 );
::uno_getEnvironment( (uno_Environment **)&aUno, aUnoEnvTypeName.pData, 0 );
aUno2To = getDirectMapping( aUno, rTo );
// : uno <-> to
if (! aUno2To.is())
return Mapping();
}
// connect to uno
@@ -493,8 +497,7 @@ static Mapping getMediateMapping(
{
// create anonymous uno env
Environment aAnUno;
OUString aEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) );
uno_createEnvironment( (uno_Environment **)&aAnUno, aEnvTypeName.pData, 0 );
::uno_createEnvironment( (uno_Environment **)&aAnUno, aUnoEnvTypeName.pData, 0 );
Mapping aAnUno2Uno( getDirectMapping( aAnUno, aUno, rAddPurpose ) );
if (! aAnUno2Uno.is())

View File

@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.15 $
# $Revision: 1.16 $
#
# last change: $Author: dbo $ $Date: 2001-03-21 11:35:34 $
# last change: $Author: dbo $ $Date: 2001-04-12 13:39:24 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -90,7 +90,7 @@ OBJFILES= \
APP1TARGET= testcppu
APP1OBJS= \
$(OBJ)$/testcppu.obj \
$(OBJ)$/test_di.obj
$(OBJ)$/test_di.obj
# $(OBJ)$/test_sec.obj
APP1STDLIBS+= \

View File

@@ -2,9 +2,9 @@
*
* $RCSfile: test_di.cxx,v $
*
* $Revision: 1.5 $
* $Revision: 1.6 $
*
* last change: $Author: jl $ $Date: 2001-03-27 13:55:46 $
* last change: $Author: dbo $ $Date: 2001-04-12 13:39:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -590,50 +590,118 @@ sal_Bool raiseException( const Reference< XLanguageBindingTest > & xLBT )
}
//==================================================================================================
void test_di(void)
static bool perform_test( Reference< XInterface > const & xObj, Reference< XInterface > const & xDummy )
{
Reference< XLanguageBindingTest > xLBT( xObj, UNO_QUERY );
if (xLBT.is() && performTest( xLBT, xDummy ))
{
if (raiseException( xLBT ))
{
::fprintf( stderr, "> dynamic invocation test succeeded!\n" );
return true;
}
else
{
::fprintf( stderr, "> exception test failed!\n" );
}
}
else
{
::fprintf( stderr, "> dynamic invocation test failed!\n" );
}
return false;
}
//==================================================================================================
void test_Cpp(void)
{
// C++-UNO test
{
TestDummy * p = new TestDummy();
Reference< XInterface > xDummy( *p );
{
Test_Impl * p = new Test_Impl();
Reference< XInterface > x( *p );
Reference< XInterface > xOriginal( *p );
{
Reference<XLanguageBindingTest > xOriginal( x, UNO_QUERY );
Reference<XLanguageBindingTest > xLBT;
Reference< XInterface > xMapped;
uno_Environment * pCppEnv1 = 0;
uno_Environment * pCppEnv2 = 0;
OUString aCppEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) );
uno_getEnvironment( &pCppEnv1, aCppEnvTypeName.pData, 0 );
uno_createEnvironment( &pCppEnv2, aCppEnvTypeName.pData, 0 ); // anonymous
::uno_getEnvironment( &pCppEnv1, aCppEnvTypeName.pData, 0 );
::uno_createEnvironment( &pCppEnv2, aCppEnvTypeName.pData, 0 ); // anonymous
Mapping aMapping( pCppEnv1, pCppEnv2, OUString( RTL_CONSTASCII_USTRINGPARAM("prot") ) );
aMapping.mapInterface( (void **)&xLBT, xOriginal.get(), ::getCppuType( &xOriginal ) );
OSL_ENSURE( aMapping.is(), "### cannot get mapping!" );
OSL_ENSURE( aMapping.is(), "### cannot get mapping C++ <-> prot <-> C++!" );
aMapping.mapInterface( (void **)&xMapped, xOriginal.get(), ::getCppuType( &xMapped ) );
(*pCppEnv2->release)( pCppEnv2 );
(*pCppEnv1->release)( pCppEnv1 );
(*pCppEnv2->release)( pCppEnv2 );
OSL_ASSERT( xLBT.is() );
if (xLBT.is() && performTest( xLBT, xDummy ))
if (perform_test( xMapped, xDummy ))
{
if (raiseException( xLBT ))
{
printf( "> dynamic invocation test succeeded!\n" );
}
else
{
printf( "> exception test failed!\n" );
}
::fprintf( stderr, "> C++-UNO test succeeded!\n" );
}
else
{
printf( "> dynamic invocation test failed!\n" );
::fprintf( stderr, "### C++-UNO test failed!\n" );
exit( 1 );
}
}
OSL_ENSURE( p->getRefCount() == 1, "### test object ref count > 1 !" );
}
OSL_ENSURE( p->getRefCount() == 1, "### dummy object ref count > 1 !" );
}
}
//==================================================================================================
void test_C(void)
{
// C-UNO test
{
TestDummy * p = new TestDummy();
Reference< XInterface > xDummy( *p );
{
Test_Impl * p = new Test_Impl();
Reference< XInterface > xOriginal( *p );
{
Reference< XInterface > xMapped;
uno_Environment * pCppEnv1 = 0;
uno_Environment * pCppEnv2 = 0;
uno_Environment * pCEnv1 = 0;
uno_Environment * pCEnv2 = 0;
OUString aCppEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) );
OUString aCEnvTypeName( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_C) );
::uno_getEnvironment( &pCEnv1, aCEnvTypeName.pData, 0 );
::uno_createEnvironment( &pCEnv2, aCEnvTypeName.pData, 0 ); // anonymous
::uno_getEnvironment( &pCppEnv1, aCppEnvTypeName.pData, 0 );
::uno_createEnvironment( &pCppEnv2, aCppEnvTypeName.pData, 0 ); // anonymous
Mapping aCpp1ToC1( pCppEnv1, pCEnv1 );
Mapping aC2ToCpp2( pCEnv2, pCppEnv2 );
void * pC = 0;
aCpp1ToC1.mapInterface( &pC, xOriginal.get(), ::getCppuType( &xOriginal ) );
aC2ToCpp2.mapInterface( (void **)&xMapped, pC, ::getCppuType( &xOriginal ) );
(*pCEnv1->pExtEnv->releaseInterface)( pCEnv1->pExtEnv, pC );
(*pCppEnv1->release)( pCppEnv1 );
(*pCppEnv2->release)( pCppEnv2 );
(*pCEnv1->release)( pCEnv1 );
(*pCEnv2->release)( pCEnv2 );
if (perform_test( xMapped, xDummy ))
{
::fprintf( stderr, "> C-UNO test succeeded!\n" );
}
else
{
::fprintf( stderr, "### C-UNO test failed!\n" );
exit( 1 );
}
}
OSL_ENSURE( p->getRefCount() == 1, "### test object ref count > 1 !" );
}
OSL_ENSURE( p->getRefCount() == 1, "### dummy object ref count > 1 !" );
}
}

View File

@@ -2,9 +2,9 @@
*
* $RCSfile: testcppu.cxx,v $
*
* $Revision: 1.11 $
* $Revision: 1.12 $
*
* last change: $Author: jsc $ $Date: 2001-04-02 10:07:14 $
* last change: $Author: dbo $ $Date: 2001-04-12 13:39:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1007,8 +1007,12 @@ int SAL_CALL main(int argc, char **argv)
// void test_security( const Reference< XMultiServiceFactory > & );
// test_security( xMgr );
// perform test
void test_di(void);
test_di();
void test_Cpp(void);
void test_C(void);
test_Cpp();
test_C();
testAssignment();
testCppu();
testArray();