From 88662624c1f1e868c0d1b4f4962b61395f7cd6ae Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 24 Oct 2008 21:15:11 +0200 Subject: [PATCH] Remove support for argv and argc. Remove support for argv and argc, as it's currently unchangable anyway. argc is now always 1 and argv is now always {"app.exe"}. --- src/main/symbian/SDL_main.cpp | 92 +++++++++++-------------------------- src/main/symbian/sdlexe.cpp | 4 +- symbian/include/internal/epoc_sdl.h | 2 - symbian/include/sdlepocapi.h | 2 +- 4 files changed, 30 insertions(+), 70 deletions(-) diff --git a/src/main/symbian/SDL_main.cpp b/src/main/symbian/SDL_main.cpp index 00b2370..ab20dea 100644 --- a/src/main/symbian/SDL_main.cpp +++ b/src/main/symbian/SDL_main.cpp @@ -30,8 +30,6 @@ class EpocSdlEnvData void Delete(); CEventQueue* iEventQueue; TMainFunc iMain; - int iArgc; - char** iArgv; CDsa* iDsa; CSdlAppServ* iAppSrv; TThreadId iId; @@ -48,8 +46,7 @@ EpocSdlEnvData* gEpocEnv; static void RunSingleThread() { - int count = RThread().RequestCount(); - if(count > 0) + if(RThread().RequestCount() > 0) { int err; if(CActiveScheduler::RunIfReady(err, CActive::EPriorityIdle)) @@ -206,18 +203,6 @@ CEventQueue& EpocSdlEnv::EventQueue() return *gEpocEnv->iEventQueue; } -int EpocSdlEnv::Argc() -{ - __ASSERT_DEBUG(gEpocEnv != NULL, PANIC(KErrNotReady)); - return gEpocEnv->iArgc; -} - -char** EpocSdlEnv::Argv() -{ - __ASSERT_DEBUG(gEpocEnv != NULL, PANIC(KErrNotReady)); - return gEpocEnv->iArgv; -} - TBool EpocSdlEnv::IsDsaAvailable() { __ASSERT_DEBUG(gEpocEnv != NULL, PANIC(KErrNotReady)); @@ -344,22 +329,11 @@ void EpocSdlEnvData::Free() return; } - __ASSERT_ALWAYS(iArgv == NULL || CheckSdl(), PANIC(KErrNotReady)); + __ASSERT_ALWAYS(CheckSdl(), PANIC(KErrNotReady)); } void EpocSdlEnvData::Delete() { - for(int i = 0; i <= iArgc; i++) - { - if(iArgv != NULL) - delete[] iArgv[i]; - } - - delete[] iArgv; - - iArgv = NULL; - iArgc = 0; - delete iEventQueue; if(iDsa != NULL) @@ -373,7 +347,11 @@ static int MainL() { gEpocEnv->iCleanupItems = new CArrayFixFlat(8); - char** envp=0; + char** envp = 0; + char** argv = new char*[1]; + argv[0] = new char[8]; + strcpy(argv[0], "app.exe"); + /* !! process exits here if there is "exit()" in main! */ int ret = 0; for(int i = 0; i < 6; i++) @@ -384,31 +362,39 @@ static int MainL() switch(i) { case 0: - ret = ((mainfunc1)f)(); - return ret; + ret = ((mainfunc1)f)(); + break; case 3: - ((mainfunc1)f)(); - return ret; + ((mainfunc1)f)(); + break; case 1: - ret = ((mainfunc2)f)(EpocSdlEnv::Argc(), EpocSdlEnv::Argv()); - return ret; + ret = ((mainfunc2)f)(1, argv); + break; case 4: - ((mainfunc2)f)(EpocSdlEnv::Argc(), EpocSdlEnv::Argv()); - return ret; + ((mainfunc2)f)(1, argv); + break; case 2: - ret = ((mainfunc3)f)(EpocSdlEnv::Argc(), EpocSdlEnv::Argv(), envp); - return ret; + ret = ((mainfunc3)f)(1, argv, envp); + break; case 5: - ((mainfunc3)f)(EpocSdlEnv::Argc(), EpocSdlEnv::Argv(), envp); - return ret; + ((mainfunc3)f)(1, argv, envp); + break; + + default: + break; } + + delete[] argv[0]; + delete[] argv; + return ret; } } + PANIC(KErrNotFound); return 0; } @@ -503,32 +489,10 @@ void EpocSdlEnv::SetOrientation(CAknAppUi::TAppUiOrientation orientation, const TRAPD(err, static_cast(CEikonEnv::Static()->EikAppUi())->SetOrientationL(orientation)); } -TThreadId CSDL::CallMainL(const TMainFunc& aFunc, TRequestStatus* const aStatus, const CDesC8Array* const aArg) +TThreadId CSDL::CallMainL(const TMainFunc& aFunc, TRequestStatus* const aStatus) { ASSERT(gEpocEnv != NULL); gEpocEnv->iMain = aFunc; - const TBool args = aArg != NULL; - - gEpocEnv->iArgc = args ? aArg->Count() + 1 : 0; - gEpocEnv->iArgv = new char*[gEpocEnv->iArgc + 2]; - - int k = 0; - const TFileName processName = RProcess().FileName(); - const int len = processName.Length(); - gEpocEnv->iArgv[k] = new char[len + 1]; - memcpy(gEpocEnv->iArgv[k], processName.Ptr(), len); - gEpocEnv->iArgv[k][len] = 0; - - for(int i = 0; args && (i < aArg->Count()); i++) - { - k++; - const int len = aArg->MdcaPoint(i).Length(); - gEpocEnv->iArgv[k] = new char[len + 1]; - memcpy(gEpocEnv->iArgv[k], aArg->MdcaPoint(i).Ptr(), len); - gEpocEnv->iArgv[k][len] = 0; - } - - gEpocEnv->iArgv[k + 1] = NULL; gEpocEnv->iAppSrv->ConstructL(); diff --git a/src/main/symbian/sdlexe.cpp b/src/main/symbian/sdlexe.cpp index 3d65cde..a0c4ae1 100644 --- a/src/main/symbian/sdlexe.cpp +++ b/src/main/symbian/sdlexe.cpp @@ -81,7 +81,6 @@ class CSDLAppUi : public CAknAppUi CSDLWin* iSDLWin; CSDL* iSdl; CIdle* iStarter; - CDesC8Array* iParams; }; //////////////////////////////////////////////////////////////////////////// @@ -140,7 +139,6 @@ CSDLAppUi::~CSDLAppUi() delete iWait; delete iSdl; delete iSDLWin; - delete iParams; } void CSDLAppUi::ConstructL() @@ -168,7 +166,7 @@ TBool CSDLAppUi::StartL(void* aThis) void CSDLAppUi::StartL() { iWait = new CExitWait(*this); - iSdl->CallMainL(SDL_main, &iWait->iStatus, iParams); + iSdl->CallMainL(SDL_main, &iWait->iStatus); } void CSDLAppUi::HandleCommandL(int aCommand) diff --git a/symbian/include/internal/epoc_sdl.h b/symbian/include/internal/epoc_sdl.h index 9e60076..19371e5 100644 --- a/symbian/include/internal/epoc_sdl.h +++ b/symbian/include/internal/epoc_sdl.h @@ -42,8 +42,6 @@ class EpocSdlEnv static void Request(TInt aService); static CEventQueue& EventQueue(); static TDisplayMode DisplayMode(); - static TInt Argc(); - static char** Argv(); static TBool IsDsaAvailable(); static TInt AllocSurface(const TSize& aSize, TDisplayMode aMode); static void UnlockHwSurface(); diff --git a/symbian/include/sdlepocapi.h b/symbian/include/sdlepocapi.h index a19272d..bfc8ab7 100644 --- a/symbian/include/sdlepocapi.h +++ b/symbian/include/sdlepocapi.h @@ -55,7 +55,7 @@ class CSDL : public CBase, public MRemConCoreApiTargetObserver void SetContainerWindowL(RWindow& aWindow, RWsSession& aSession, CWsScreenDevice& aDevice); //the window where drawn happens, should be recalled (propably in application HandleResourceChange) if screen device changes ~CSDL(); void AppendWsEvent(const TWsEvent& aEvent); //give event to SDL - TThreadId CallMainL(const TMainFunc& aFunc, TRequestStatus* const aStatus, const CDesC8Array* const iArg); //internal + TThreadId CallMainL(const TMainFunc& aFunc, TRequestStatus* const aStatus); //internal void Resize(); void MrccatoCommand(TRemConCoreApiOperationId aOperationId, TRemConCoreApiButtonAction aButtonAct); -- 2.11.4.GIT