sl@0: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\euser\epoc\win32\uc_epoc.cpp sl@0: // sl@0: // sl@0: sl@0: /* sl@0: #include sl@0: #include sl@0: #include sl@0: */ sl@0: sl@0: #ifdef __SYMC__ sl@0: sl@0: //That stuff comes mostly from estub and uc_stub.cpp sl@0: //We had to put it in there since we don't know how to do an MMP firstlib on Windows sl@0: sl@0: /* sl@0: extern "C" sl@0: GLDEF_C TInt _E32Startup() sl@0: // sl@0: // Unused in the stub sl@0: // sl@0: { sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: sl@0: // sl@0: #include sl@0: sl@0: sl@0: int CALLBACK _E32Bootstrap(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) sl@0: { sl@0: BootEpoc(EFalse); sl@0: return 0; sl@0: }; sl@0: sl@0: */ sl@0: sl@0: #endif sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: /* sl@0: #if defined __SYMC__ sl@0: sl@0: //#include sl@0: #include sl@0: sl@0: sl@0: //#include sl@0: sl@0: //SL: Empty on FCL ? sl@0: //For now we use this for basic testing on our SYMC implementation sl@0: sl@0: sl@0: TInt IdleCallBack(TAny* aParam) sl@0: { sl@0: static TInt count=0; sl@0: sl@0: count++; sl@0: sl@0: if (count>5) sl@0: { sl@0: //Stop it there sl@0: CActiveScheduler::Stop(); sl@0: return EFalse; sl@0: } sl@0: sl@0: //Keep playing sl@0: return ETrue; sl@0: } sl@0: sl@0: sl@0: sl@0: class CBaseTest: public CBase sl@0: { sl@0: sl@0: }; sl@0: sl@0: sl@0: GLDEF_C void MainL() sl@0: { sl@0: sl@0: //Testing CBase object sl@0: CBase* other=new(ELeave) CBase(); sl@0: CleanupStack::PushL(other); sl@0: CBase* base=new(ELeave) CBase(); sl@0: CleanupStack::PushL(base); sl@0: CleanupStack::PopAndDestroy(2,other); sl@0: //delete base; sl@0: sl@0: //Testing cleanup stack sl@0: TRAPD(err, sl@0: base=new(ELeave) CBase(); sl@0: CleanupStack::PushL(base); sl@0: User::Leave(KErrCancel); sl@0: ); sl@0: sl@0: ASSERT(err==KErrCancel); sl@0: sl@0: //Testing alloc failure sl@0: //See TProcess sl@0: TRAP(err, sl@0: TUint8* shouldFail=new(ELeave) TUint8[1024*1024*10]; sl@0: delete[] shouldFail; sl@0: ); sl@0: sl@0: // sl@0: ASSERT(err==KErrNoMemory); sl@0: sl@0: //Testing alloc failure without leave sl@0: TUint8* tooLarge=new TUint8[1024*1024*10]; sl@0: ASSERT(tooLarge==NULL); sl@0: delete[] tooLarge; sl@0: sl@0: //Testing simple alloc of T class sl@0: TUint8* tinyAlloc=new TUint8; sl@0: ASSERT(tinyAlloc!=NULL); sl@0: delete tinyAlloc; sl@0: sl@0: //TODO: sl@0: //RHashSet hash; sl@0: sl@0: //Testing AOs sl@0: //Install an active scheduler sl@0: CActiveScheduler* activeScheduler = new(ELeave) CActiveScheduler; sl@0: CActiveScheduler::Install(activeScheduler); sl@0: CleanupStack::PushL(activeScheduler); sl@0: sl@0: CIdle* idle = CIdle::NewL(CActive::EPriorityIdle); sl@0: CleanupStack::PushL(idle); sl@0: sl@0: idle->Start(TCallBack(IdleCallBack,NULL)); sl@0: sl@0: CActiveScheduler::Start(); sl@0: sl@0: CleanupStack::PopAndDestroy(idle); sl@0: CActiveScheduler::Install(NULL); sl@0: CleanupStack::PopAndDestroy(activeScheduler); sl@0: sl@0: sl@0: //Testing unbalanced cleanup stack sl@0: //base=new(ELeave) CBase(); sl@0: //CleanupStack::PushL(base); sl@0: } sl@0: sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: //What do we do then sl@0: //SetReturnedHandle sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: //CBase* base=new(ELeave) CBase(); sl@0: CBase* base=new CBase(); sl@0: delete base; sl@0: sl@0: CBaseTest* baseTest=new CBaseTest(); sl@0: delete baseTest; sl@0: sl@0: HBufC* buf=HBufC::New(10); sl@0: delete buf; sl@0: sl@0: CArrayFix* active=new CArrayFixFlat(10); sl@0: delete active; sl@0: sl@0: TUint8* test=new TUint8[1024*9]; sl@0: delete[] test; sl@0: sl@0: CTrapCleanup* cleanupStack = CTrapCleanup::New(); sl@0: if (!cleanupStack) sl@0: { sl@0: return KErrNoMemory; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: TInt err=KErrNone; sl@0: TRAP(err,MainL()); sl@0: sl@0: delete cleanupStack; sl@0: sl@0: __UHEAP_MARKEND; sl@0: sl@0: return err; sl@0: } sl@0: sl@0: sl@0: sl@0: #include sl@0: sl@0: int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) sl@0: { sl@0: //User::InitProcess(); sl@0: //E32Main(); sl@0: //User::Exit(0); sl@0: sl@0: BootEpoc(ETrue); sl@0: sl@0: return 0; sl@0: } sl@0: sl@0: #endif sl@0: */