summaryrefslogtreecommitdiff
path: root/basic/source/runtime/dllmgr-none.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'basic/source/runtime/dllmgr-none.cxx')
-rw-r--r--basic/source/runtime/dllmgr-none.cxx53
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) {}