update dev300-m58
[ooovba.git] / cppuhelper / test / bootstrap / TestEnv.cxx
blobdbb6889a57e49b61db069e1a87759db09d9eae1c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TestEnv.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_cppuhelper.hxx"
34 #include "cppu/EnvDcp.hxx"
36 #include "cppu/helper/purpenv/Environment.hxx"
37 #include "cppu/helper/purpenv/Mapping.hxx"
41 #define LOG_LIFECYCLE_TestEnv
42 #ifdef LOG_LIFECYCLE_TestEnv
43 # include <iostream>
44 # define LOG_LIFECYCLE_TestEnv_emit(x) x
46 #else
47 # define LOG_LIFECYCLE_TestEnv_emit(x)
49 #endif
52 class SAL_DLLPRIVATE TestEnv : public cppu::Enterable
54 int m_inCount;
56 virtual ~TestEnv();
58 public:
59 explicit TestEnv();
61 protected:
62 virtual void v_enter(void);
63 virtual void v_leave(void);
65 virtual void v_callInto_v(uno_EnvCallee * pCallee, va_list * pParam);
66 virtual void v_callOut_v (uno_EnvCallee * pCallee, va_list * pParam);
68 virtual int v_isValid (rtl::OUString * pReason);
71 TestEnv::TestEnv()
72 : m_inCount(0)
74 LOG_LIFECYCLE_TestEnv_emit(fprintf(stderr, "LIFE: %s -> %p\n", "TestEnv::TestEnv(...)", this));
77 TestEnv::~TestEnv(void)
79 LOG_LIFECYCLE_TestEnv_emit(fprintf(stderr, "LIFE: %s -> %p\n", "TestEnv::~TestEnv(void)", this));
83 void TestEnv::v_callInto_v(uno_EnvCallee * pCallee, va_list * pParam)
85 ++ m_inCount;
86 pCallee(pParam);
87 -- m_inCount;
90 void TestEnv::v_callOut_v(uno_EnvCallee * pCallee, va_list * pParam)
92 -- m_inCount;
93 pCallee(pParam);
94 ++ m_inCount;
97 void TestEnv::v_enter(void)
99 ++ m_inCount;
102 void TestEnv::v_leave(void)
104 -- m_inCount;
107 int TestEnv::v_isValid(rtl::OUString * pReason)
109 int result = m_inCount & 1;
111 if (result)
112 *pReason = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OK"));
114 else
115 *pReason = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("not entered/invoked"));
117 return result;
120 extern "C" void SAL_CALL uno_initEnvironment(uno_Environment * pEnv) SAL_THROW_EXTERN_C()
122 cppu::helper::purpenv::Environment_initWithEnterable(pEnv, new TestEnv());
125 extern "C" void uno_ext_getMapping(uno_Mapping ** ppMapping,
126 uno_Environment * pFrom,
127 uno_Environment * pTo )
129 cppu::helper::purpenv::createMapping(ppMapping, pFrom, pTo);