os/graphics/graphicscomposition/openwfcompositionengine/adaptation/src/Platform/OS/symbian/owfconsole.cpp
Update contrib.
1 // Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
3 // Permission is hereby granted, free of charge, to any person obtaining a
4 // copy of this software and/or associated documentation files (the
5 // "Materials"), to deal in the Materials without restriction, including
6 // without limitation the rights to use, copy, modify, merge, publish,
7 // distribute, sublicense, and/or sell copies of the Materials, and to
8 // permit persons to whom the Materials are furnished to do so, subject to
9 // the following conditions:
11 // The above copyright notice and this permission notice shall be included
12 // in all copies or substantial portions of the Materials.
14 // THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 // MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
23 // Console adaptation for OpenWFC conformance tests
32 #include <e32property.h>
36 static const TInt KOpenWfcImplCleanupKey = 0x10286FC4; // same as DLL UID3
39 Re-directs vprintf to RDebug so the console doesn't trash the visual tests.
41 Not exported. The CT should not depend on functions provided by the SI adaptation.
43 extern "C" int xvprintf(const char* aFormat, va_list aArgs)
45 #define SAFE_STRING_SIZE 2040
46 char buffer[SAFE_STRING_SIZE+4];
47 buffer[SAFE_STRING_SIZE]=0;
48 buffer[SAFE_STRING_SIZE+1]=0;
49 buffer[SAFE_STRING_SIZE+2]=0;
50 // Symbian format syntax is different so convert to a buffer using P.I.P.S first
51 vsnprintf(buffer,SAFE_STRING_SIZE, aFormat, aArgs);
52 TPtrC8 ptr(reinterpret_cast<unsigned char*>(buffer), strlen(buffer));
53 RDebug::RawPrint(ptr);
58 Re-directs printf to RDebug so the console doesn't trash the visual tests.
60 Not exported. The CT should not depend on functions provided by the SI adaptation.
62 extern "C" void xprintf(const char* aFormat, ...)
65 va_start(list, aFormat);
66 // Disabled Coverity warning, since it does not support vararg and throws a warning
67 // coverity[uninit_use_in_call]
68 xvprintf(aFormat, list);
72 static void (*gAtExitFunc)(void) = NULL;
74 static int DoAtExit(void* aData)
76 * This function is required because the signature of atexit callback is
77 * different to TCallBack func. Additionaly, this function checks the heap
78 * supplied to the callback is the heap used for the singelton.
80 * It is intended but not guaranteed that WServ will invoke this callback at
81 * shutdown. The primary purpose is to support detection of memory leaks so
82 * production code should not depend on this function being called.
84 * @param aData The data parameter for the callback which must be a pointer
85 * to the heap that the singleton was created on.
88 // Blank the property for this callback
91 TCallBack cb(NULL, NULL);
92 TPckgC<TCallBack> cbPckg(cb);
93 prop.Set(TUid::Uid(t.SecureId().iId), KOpenWfcImplCleanupKey, cbPckg);
97 if (aData == &User::Heap() && gAtExitFunc)
105 extern "C" void RegisterCleanup(TInt (*aFunction)(void* aPtr))
107 * Register the cleanup function in a property defined by WServ.
108 * @param aFunction A pointer to the function that WServ should use to
109 * cleanup singletons on exit.
113 TUid category = {t.SecureId().iId};
115 TCallBack cb(aFunction, &User::Heap());
116 TPckgC<TCallBack> cbPckg(cb);
118 // If the property cannot be set the assumption is that the cleanup is not needed
119 (void) prop.Set(category, KOpenWfcImplCleanupKey, cbPckg);
124 extern "C" int xatexit(void (*func)(void))
126 * To minimise changes to the SI code the function is similar to the standard
127 * atexit function. However, instead of providing a general purpose cleanup
128 * operation this implementaion simply allows WServ to trigger the cleanup
129 * of singleton objects during memory leak tests.
131 * This is done purely to simplify the implementation.
133 * @param func A pointer to the function responsible for deleting singletons
137 __ASSERT_ALWAYS( ( ! gAtExitFunc ) || ( gAtExitFunc == func ), User::Invariant());
139 RegisterCleanup( DoAtExit );