os/kernelhwsrv/kerneltest/e32test/dll/oe/t_oedll.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 
    17 #include "t_oedll.h"
    18 
    19 // construct/destruct
    20 
    21 EXPORT_C CMessenger* CMessenger::NewLC(CConsoleBase& aConsole, const TDesC& aString)
    22 	{
    23 	CMessenger* self=new (ELeave) CMessenger(aConsole);
    24 	CleanupStack::PushL(self);
    25 	self->ConstructL(aString);
    26 	return self;
    27 	}
    28 
    29 CMessenger::~CMessenger() // destruct - virtual, so no export
    30 	{
    31 	delete iString;
    32 	}
    33 
    34 EXPORT_C void CMessenger::ShowMessage()
    35 	{
    36 	_LIT(KFormat1,"%S\n");
    37 	iConsole.Printf(KFormat1, iString); // notify completion
    38 	}
    39 
    40 // constructor support
    41 // don't export these, because used only by functions in this DLL, eg our NewLC()
    42 
    43 CMessenger::CMessenger(CConsoleBase& aConsole) // first-phase C++ constructor
    44 	: iConsole(aConsole)
    45 	{
    46 	}
    47 
    48 void CMessenger::ConstructL(const TDesC& aString) // second-phase constructor
    49 	{
    50 	iString=aString.AllocL(); // copy given string into own descriptor
    51     }
    52 
    53 class MY_MY
    54 {
    55 public:
    56 	MY_MY(int aA){iA = aA;}
    57 	int iA;
    58 	int get() { return iA;}
    59 };
    60 
    61 class MY_TYPE
    62 {
    63 public:
    64 	MY_TYPE(MY_MY& aA){memcpy(&iA, &aA, sizeof(iA));}
    65 	int iA;
    66 	int get() { return iA;}
    67 };
    68 
    69 EXPORT_C int bar()
    70 {
    71 	MY_MY amymy(0x1234);
    72 	static MY_TYPE mytype(amymy);
    73 	myfoo();
    74 	return mytype.get();
    75 }
    76 
    77 extern "C" {
    78 EXPORT_C int myfoo()
    79 {
    80 	return 0x1234;
    81 }
    82 
    83 }