1*9d7e27acSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9d7e27acSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9d7e27acSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9d7e27acSAndrew Rist * distributed with this work for additional information 6*9d7e27acSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9d7e27acSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9d7e27acSAndrew Rist * "License"); you may not use this file except in compliance 9*9d7e27acSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*9d7e27acSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*9d7e27acSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9d7e27acSAndrew Rist * software distributed under the License is distributed on an 15*9d7e27acSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9d7e27acSAndrew Rist * KIND, either express or implied. See the License for the 17*9d7e27acSAndrew Rist * specific language governing permissions and limitations 18*9d7e27acSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*9d7e27acSAndrew Rist *************************************************************/ 21*9d7e27acSAndrew Rist 22*9d7e27acSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_cppuhelper.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "cppu/EnvDcp.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "cppu/helper/purpenv/Environment.hxx" 30cdf0e10cSrcweir #include "cppu/helper/purpenv/Mapping.hxx" 31cdf0e10cSrcweir 32cdf0e10cSrcweir 33cdf0e10cSrcweir 34cdf0e10cSrcweir #define LOG_LIFECYCLE_TestEnv 35cdf0e10cSrcweir #ifdef LOG_LIFECYCLE_TestEnv 36cdf0e10cSrcweir # include <iostream> 37cdf0e10cSrcweir # define LOG_LIFECYCLE_TestEnv_emit(x) x 38cdf0e10cSrcweir 39cdf0e10cSrcweir #else 40cdf0e10cSrcweir # define LOG_LIFECYCLE_TestEnv_emit(x) 41cdf0e10cSrcweir 42cdf0e10cSrcweir #endif 43cdf0e10cSrcweir 44cdf0e10cSrcweir 45cdf0e10cSrcweir class SAL_DLLPRIVATE TestEnv : public cppu::Enterable 46cdf0e10cSrcweir { 47cdf0e10cSrcweir int m_inCount; 48cdf0e10cSrcweir 49cdf0e10cSrcweir virtual ~TestEnv(); 50cdf0e10cSrcweir 51cdf0e10cSrcweir public: 52cdf0e10cSrcweir explicit TestEnv(); 53cdf0e10cSrcweir 54cdf0e10cSrcweir protected: 55cdf0e10cSrcweir virtual void v_enter(void); 56cdf0e10cSrcweir virtual void v_leave(void); 57cdf0e10cSrcweir 58cdf0e10cSrcweir virtual void v_callInto_v(uno_EnvCallee * pCallee, va_list * pParam); 59cdf0e10cSrcweir virtual void v_callOut_v (uno_EnvCallee * pCallee, va_list * pParam); 60cdf0e10cSrcweir 61cdf0e10cSrcweir virtual int v_isValid (rtl::OUString * pReason); 62cdf0e10cSrcweir }; 63cdf0e10cSrcweir 64cdf0e10cSrcweir TestEnv::TestEnv() 65cdf0e10cSrcweir : m_inCount(0) 66cdf0e10cSrcweir { 67cdf0e10cSrcweir LOG_LIFECYCLE_TestEnv_emit(fprintf(stderr, "LIFE: %s -> %p\n", "TestEnv::TestEnv(...)", this)); 68cdf0e10cSrcweir } 69cdf0e10cSrcweir 70cdf0e10cSrcweir TestEnv::~TestEnv(void) 71cdf0e10cSrcweir { 72cdf0e10cSrcweir LOG_LIFECYCLE_TestEnv_emit(fprintf(stderr, "LIFE: %s -> %p\n", "TestEnv::~TestEnv(void)", this)); 73cdf0e10cSrcweir } 74cdf0e10cSrcweir 75cdf0e10cSrcweir 76cdf0e10cSrcweir void TestEnv::v_callInto_v(uno_EnvCallee * pCallee, va_list * pParam) 77cdf0e10cSrcweir { 78cdf0e10cSrcweir ++ m_inCount; 79cdf0e10cSrcweir pCallee(pParam); 80cdf0e10cSrcweir -- m_inCount; 81cdf0e10cSrcweir } 82cdf0e10cSrcweir 83cdf0e10cSrcweir void TestEnv::v_callOut_v(uno_EnvCallee * pCallee, va_list * pParam) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir -- m_inCount; 86cdf0e10cSrcweir pCallee(pParam); 87cdf0e10cSrcweir ++ m_inCount; 88cdf0e10cSrcweir } 89cdf0e10cSrcweir 90cdf0e10cSrcweir void TestEnv::v_enter(void) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir ++ m_inCount; 93cdf0e10cSrcweir } 94cdf0e10cSrcweir 95cdf0e10cSrcweir void TestEnv::v_leave(void) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir -- m_inCount; 98cdf0e10cSrcweir } 99cdf0e10cSrcweir 100cdf0e10cSrcweir int TestEnv::v_isValid(rtl::OUString * pReason) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir int result = m_inCount & 1; 103cdf0e10cSrcweir 104cdf0e10cSrcweir if (result) 105cdf0e10cSrcweir *pReason = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OK")); 106cdf0e10cSrcweir 107cdf0e10cSrcweir else 108cdf0e10cSrcweir *pReason = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("not entered/invoked")); 109cdf0e10cSrcweir 110cdf0e10cSrcweir return result; 111cdf0e10cSrcweir } 112cdf0e10cSrcweir 113cdf0e10cSrcweir extern "C" void SAL_CALL uno_initEnvironment(uno_Environment * pEnv) SAL_THROW_EXTERN_C() 114cdf0e10cSrcweir { 115cdf0e10cSrcweir cppu::helper::purpenv::Environment_initWithEnterable(pEnv, new TestEnv()); 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir extern "C" void uno_ext_getMapping(uno_Mapping ** ppMapping, 119cdf0e10cSrcweir uno_Environment * pFrom, 120cdf0e10cSrcweir uno_Environment * pTo ) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir cppu::helper::purpenv::createMapping(ppMapping, pFrom, pTo); 123cdf0e10cSrcweir } 124cdf0e10cSrcweir 125