// OPLAPI.H
//
// Copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
//
#ifndef __OPLAPI_H__
#define __OPLAPI_H__

#include <e32base.h>


enum TReturnType
	{
	EReturnFloat=0,
	EReturnInt='%',
	EReturnLong='&',
	EReturnString='$'
	};

//#if !defined(__OPLR_H)
class CStack;
class CIOCollection;
class RHeap;
class RWsSession;
class RBackedUpWindow;
class RWindowGroup;
class COplRuntime;
class COplDbManager;
class CWsScreenDevice;
//#endif

struct SCallbackInfo
	{
	TAny* iStackPtr;
	TInt16 iParamCount;
	};

class CEikonEnv;
class OplAPI : public CBase
	{
public:
	OplAPI(COplRuntime* aRuntime,RHeap& aHeap);
    // Functions forwarded to CStack
	IMPORT_C void Push(TInt16 aInt16);
	IMPORT_C void Push(TInt32 aInt32);
	IMPORT_C void Push(const TReal64 aReal);
	IMPORT_C void PushL(const TText8* aLbc);
	IMPORT_C void PushL(const TDesC8& aDes);
	IMPORT_C TInt16 PopInt16();
	IMPORT_C TInt32 PopInt32();
	IMPORT_C TReal64 PopReal64();
	IMPORT_C TPtrC8 PopString8();            
	IMPORT_C TInt16* PopPtrInt16();
	IMPORT_C TInt32* PopPtrInt32();
	IMPORT_C TReal64* PopPtrReal64();
	IMPORT_C TAny* StackPtr() const;
	IMPORT_C void SetStackPtr(const TAny* aSP);
	IMPORT_C TInt FreeBytes() const;
    // Functions forwarded to OplUtil
    //  - these are for getting and putting values to non-aligned addresses
	IMPORT_C TUint8* OffsetToAddrL(TInt aOffset,TInt aSize);
	IMPORT_C static void PutLong(TAny* aPtr,TInt32 aLong);
	IMPORT_C static TInt32 GetLong(TAny* aPtr);
	IMPORT_C static void PutFloat(TAny* aPtr,TReal64 aFloat);
	IMPORT_C static TReal64 GetFloat(TAny* aPtr);
	IMPORT_C static TInt16 MapError(TInt aE32Error);
    IMPORT_C static TInt MapTranslatorError(TInt aErr,TInt& aResId);
    // - arithmetic with overflow checking
	IMPORT_C static TInt16 MultiplyL(TInt16 aArg1,TInt16 aArg2);
	IMPORT_C static TInt32 MultiplyL(TInt32 aArg1,TInt32 aArg2);
    // - Database interface
	IMPORT_C COplDbManager* DbManager();
	IMPORT_C void OpenCheckL();
    // - WSERV interface
	IMPORT_C RWsSession& WsSession();
	IMPORT_C RWindowGroup& RootWindow();
	IMPORT_C RBackedUpWindow& WindowFromIdL(TInt aId);
	IMPORT_C CWsScreenDevice* ScreenDevice();
	IMPORT_C void CancelRuntimeEventReadyRequest();
	//
	IMPORT_C TInt BitmapHandleFromIdL(TInt aId);
    // - Eikon environment
    IMPORT_C CEikonEnv& EikonEnv() const;
	IMPORT_C void StartActiveScheduler();
	IMPORT_C void NotifyActiveSchedulerStopped();
	// - for doing callbacks
	IMPORT_C void InitCallbackL(TDesC8& aProcName);
	IMPORT_C void PushParamL(TInt16 aInt);
	IMPORT_C void PushParamL(TInt32 aLong);
	IMPORT_C void PushParamL(TReal64 aFloat);
	IMPORT_C void PushParamL(const TDesC8& aString);
	IMPORT_C TInt CallProcedure(TReturnType aReturnType);
	// AppArch
	IMPORT_C TUid AppUid();
	// Asynchronous programming support
	IMPORT_C TRequestStatus& NewRequestL(TInt16* aUserStatusPtr,TCallBack aCallBack);
	IMPORT_C TRequestStatus& NewRequestL(TInt32* aUserStatusPtr,TCallBack aCallBack);
	// New in Unicode
	IMPORT_C TPtrC PopString();
#if defined(_UNICODE)
	IMPORT_C void PushL(const TText16* aLbc);
	IMPORT_C void PushL(const TDesC16& aDes);

	IMPORT_C TPtrC16 PopString16();
	IMPORT_C void InitCallbackL(TDesC16& aProcName);
	IMPORT_C void PushParamL(const TDesC16& aString);
#endif

private:
	void ResetStack();
	COplRuntime* iRuntime;
	CStack* iStack;
	RHeap& iHeap;
	CArrayFixSeg<SCallbackInfo> iCallbackInfoArray;
	};

#endif

/* End of $Workfile:   OPLAPI.H  $ */

