diff options
| author | Michael Meeks <michael.meeks@collabora.com> | 2014-09-19 12:23:46 +0100 |
|---|---|---|
| committer | Michael Meeks <michael.meeks@collabora.com> | 2014-09-19 15:31:06 +0100 |
| commit | 19ee058a21747efd36a91a5aaa2231fefe1e7fa4 (patch) | |
| tree | a9de0e82924d31a022bab190163b3d9375cae465 /basic/source/runtime/dllmgr-none.cxx | |
| parent | 24d1a89285caeaaa0289a06c6be909160ee57583 (diff) | |
vba: initial impl. of compatibility methods.
Change-Id: Iebc25f1730766e96d2ad6921a8b4d2ea880c63f3
Diffstat (limited to 'basic/source/runtime/dllmgr-none.cxx')
| -rw-r--r-- | basic/source/runtime/dllmgr-none.cxx | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/basic/source/runtime/dllmgr-none.cxx b/basic/source/runtime/dllmgr-none.cxx index 5272d172df2f..10079d65bbd9 100644 --- a/basic/source/runtime/dllmgr-none.cxx +++ b/basic/source/runtime/dllmgr-none.cxx @@ -26,23 +26,68 @@ #include <basic/sbx.hxx> #include <basic/sbxvar.hxx> -#include <osl/thread.h> #include <rtl/ref.hxx> #include <rtl/string.hxx> #include <rtl/ustring.hxx> #include <salhelper/simplereferenceobject.hxx> +#include <osl/time.h> #include "dllmgr.hxx" struct SbiDllMgr::Impl {}; -SbError SbiDllMgr::Call( - OUString const &, OUString const &, SbxArray *, SbxVariable &, - bool) +namespace { + +// Overcome the mess of Currency vs. custom types etc. +SbError returnInt64(SbxArray *pArgs, SbxVariable &rRetVal, + sal_Int64 nValue) +{ + if (!rRetVal.PutLong(true) && !rRetVal.PutInteger(true)) + return ERRCODE_BASIC_BAD_ARGUMENT; + if (!pArgs || pArgs->Count() != 2) + return ERRCODE_BASIC_BAD_ARGUMENT; + SbxVariable *pOut = pArgs->Get(1); + if (!pOut) + return ERRCODE_BASIC_BAD_ARGUMENT; + if (pOut->IsCurrency()) + { + pOut->PutCurrency(nValue); + return ERRCODE_NONE; + } + // FIXME: tolerate custom type bits ... + return ERRCODE_BASIC_BAD_ARGUMENT; +} + +SbError builtin_kernel32(const OUString &aFuncName, SbxArray *pArgs, + SbxVariable &rRetVal) { + sal_Int64 nNanoSecsPerSec = 1000.0*1000*1000; + if (aFuncName == "QueryPerformanceFrequency") + return returnInt64(pArgs, rRetVal, nNanoSecsPerSec); + + else if (aFuncName == "QueryPerformanceCounter") + { + TimeValue aNow; + osl_getSystemTime( &aNow ); + sal_Int64 nStamp = aNow.Nanosec + aNow.Seconds * nNanoSecsPerSec; + return returnInt64(pArgs, rRetVal, nStamp); + } return ERRCODE_BASIC_NOT_IMPLEMENTED; } +}; + +SbError SbiDllMgr::Call( + const OUString &aFuncName, const OUString &aDllName, + SbxArray *pArgs, SbxVariable &rRetVal, + bool /* bCDecl */) +{ + if (aDllName == "kernel32") + return builtin_kernel32(aFuncName, pArgs, rRetVal); + else + return ERRCODE_BASIC_NOT_IMPLEMENTED; +} + void SbiDllMgr::FreeDll(OUString const &) {} SbiDllMgr::SbiDllMgr(): impl_(new Impl) {} |
