summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2011-09-21 16:34:46 +0200
committerStephan Bergmann <sbergman@redhat.com>2011-09-21 18:16:43 +0200
commit9ffee68dc027662fd8e6aa044d7ee01b0ed5df16 (patch)
tree25f265198a400f9ac4a17c6ccc73e30ddf4187b8 /sal
parent6560e48afa53a0ca1ab9417ac2637f8d64332375 (diff)
Cleaned up sal_textenc, making it work on Mac OS X.
Diffstat (limited to 'sal')
-rw-r--r--sal/prj/build.lst33
-rw-r--r--sal/prj/d.lst6
-rw-r--r--sal/textenc/makefile.mk6
-rw-r--r--sal/textenc/tables.cxx12
-rw-r--r--sal/textenc/textenc.cxx99
-rw-r--r--sal/util/makefile.mk9
-rw-r--r--sal/util/sal_textenc/makefile.mk46
-rw-r--r--sal/util/sal_textenc/saltextenc.map32
-rw-r--r--sal/util/saltextenc.map6
9 files changed, 171 insertions, 78 deletions
diff --git a/sal/prj/build.lst b/sal/prj/build.lst
index 9f9a6accf2ef..47b8f58ecac9 100644
--- a/sal/prj/build.lst
+++ b/sal/prj/build.lst
@@ -12,21 +12,22 @@ sa sal\qa nmake - all sa_qa sa_util NULL
sa sal\osl\unx nmake - u sa_oslu sa_tc.u sa_inc NULL
sa sal\osl\all nmake - all sa_oslall sa_tc.u sa_inc NULL
sa sal\util nmake - all sa_util sa_tc.u sa_oslall sa_uwinapi.n sa_onlineupdate.n sa_osln.n sa_oslu.u sa_rtl sa_textenc NULL
+sa sal\util\sal_textenc nmake - all sa_util_saltextenc sa_util NULL
sa sal\cppunittester nmake - all sa_cppunittester sa_cpprt.u sa_util NULL
-sa sal\qa\ByteSequence nmake - all sa_qa_ByteSequence sa_cppunittester sa_util NULL
-sa sal\qa\OStringBuffer nmake - all sa_qa_OStringBuffer sa_cppunittester sa_util NULL
-sa sal\qa\osl\getsystempathfromfileurl nmake - all sa_qa_osl_getsystempathfromfileurl sa_cppunittester sa_util NULL
-sa sal\qa\osl\file nmake - u sa_qa_osl_file sa_cppunittester sa_util NULL
-sa sal\qa\osl\module nmake - u sa_qa_osl_module sa_cppunittester sa_util NULL
-sa sal\qa\osl\condition nmake - all sa_qa_osl_condition sa_cppunittester sa_util NULL
-sa sal\qa\osl\security nmake - all sa_qa_osl_security sa_cppunittester sa_util NULL
-sa sal\qa\osl\process nmake - all sa_qa_osl_process sa_cppunittester sa_util NULL
-sa sal\qa\rtl\strings nmake - all sa_qa_rt_strings sa_cppunittester sa_util NULL
-sa sal\qa\rtl\oustringbuffer nmake - all sa_qa_rt_oustringbuffer sa_cppunittester sa_util NULL
-sa sal\qa\rtl\alloc nmake - all sa_qa_rt_alloc sa_cppunittester sa_util NULL
-sa sal\qa\rtl\crc32 nmake - all sa_qa_rtl_crc32 sa_cppunittester sa_util NULL
-sa sal\qa\rtl\cipher nmake - all sa_qa_rtl_cipher sa_cppunittester sa_util NULL
-sa sal\qa\rtl\doublelock nmake - all sa_qa_rtl_doublelock sa_cppunittester sa_util NULL
-sa sal\qa\rtl\locale nmake - all sa_qa_rtl_locale sa_cppunittester sa_util NULL
-sa sal\qa\sal nmake - all sa_qa_sal sa_cppunittester sa_util NULL
+sa sal\qa\ByteSequence nmake - all sa_qa_ByteSequence sa_cppunittester sa_util_saltextenc NULL
+sa sal\qa\OStringBuffer nmake - all sa_qa_OStringBuffer sa_cppunittester sa_util_saltextenc NULL
+sa sal\qa\osl\getsystempathfromfileurl nmake - all sa_qa_osl_getsystempathfromfileurl sa_cppunittester sa_util_saltextenc NULL
+sa sal\qa\osl\file nmake - u sa_qa_osl_file sa_cppunittester sa_util_saltextenc NULL
+sa sal\qa\osl\module nmake - u sa_qa_osl_module sa_cppunittester sa_util_saltextenc NULL
+sa sal\qa\osl\condition nmake - all sa_qa_osl_condition sa_cppunittester sa_util_saltextenc NULL
+sa sal\qa\osl\security nmake - all sa_qa_osl_security sa_cppunittester sa_util_saltextenc NULL
+sa sal\qa\osl\process nmake - all sa_qa_osl_process sa_cppunittester sa_util_saltextenc NULL
+sa sal\qa\rtl\strings nmake - all sa_qa_rt_strings sa_cppunittester sa_util_saltextenc NULL
+sa sal\qa\rtl\oustringbuffer nmake - all sa_qa_rt_oustringbuffer sa_cppunittester sa_util_saltextenc NULL
+sa sal\qa\rtl\alloc nmake - all sa_qa_rt_alloc sa_cppunittester sa_util_saltextenc NULL
+sa sal\qa\rtl\crc32 nmake - all sa_qa_rtl_crc32 sa_cppunittester sa_util_saltextenc NULL
+sa sal\qa\rtl\cipher nmake - all sa_qa_rtl_cipher sa_cppunittester sa_util_saltextenc NULL
+sa sal\qa\rtl\doublelock nmake - all sa_qa_rtl_doublelock sa_cppunittester sa_util_saltextenc NULL
+sa sal\qa\rtl\locale nmake - all sa_qa_rtl_locale sa_cppunittester sa_util_saltextenc NULL
+sa sal\qa\sal nmake - all sa_qa_sal sa_cppunittester sa_util_saltextenc NULL
sa sal\qa\static nmake - u sal_qa_static sa_qa_ByteSequence sa_qa_OStringBuffer sa_qa_osl_file.u sa_qa_osl_condition sa_qa_osl_security sa_qa_rt_alloc sa_qa_rtl_crc32 sa_qa_rtl_cipher sa_qa_rtl_doublelock sa_qa_rtl_locale sa_qa_sal NULL
diff --git a/sal/prj/d.lst b/sal/prj/d.lst
index ac6bc63ecf80..f7ac5255bc83 100644
--- a/sal/prj/d.lst
+++ b/sal/prj/d.lst
@@ -22,10 +22,8 @@ mkdir: %_DEST%\inc\systools\win32
symlink: %_DEST%\lib\libuno_sal.so.3 %_DEST%\lib\libuno_sal.so
..\%__SRC%\lib\libuno_sal.dylib.3 %_DEST%\lib\libuno_sal.dylib.3
symlink: %_DEST%\lib\libuno_sal.dylib.3 %_DEST%\lib\libuno_sal.dylib
-..\%__SRC%\lib\libsal_textenc.so.3 %_DEST%\lib\libsal_textenc.so.3
-symlink: %_DEST%\lib\libsal_textenc.so.3 %_DEST%\lib\libsal_textenc.so
-..\%__SRC%\lib\libsal_textenc.dylib.3 %_DEST%\lib\libsal_textenc.dylib.3
-symlink: %_DEST%\lib\libsal_textenc.dylib.3 %_DEST%\lib\libsal_textenc.dylib
+..\%__SRC%\lib\libsal_textenc.so %_DEST%\lib\libsal_textenc.so
+..\%__SRC%\lib\libsal_textenc.dylib %_DEST%\lib\libsal_textenc.dylib
..\%__SRC%\lib\*.sl %_DEST%\lib\*.sl
..\%__SRC%\lib\*.a %_DEST%\lib\*.a
diff --git a/sal/textenc/makefile.mk b/sal/textenc/makefile.mk
index 7970ae0526eb..09bf20841e71 100644
--- a/sal/textenc/makefile.mk
+++ b/sal/textenc/makefile.mk
@@ -105,12 +105,6 @@ LIB1TARGET= $(SLB)$/$(TARGET).lib
LIB1OBJFILES= $(SAL_OBJECTS) $(SAL_COMMON_OBJECTS)
OBJTARGET=$(LB)$/$(TARGET).lib
-# be nicer to avoid DLLPRE
-.IF "$(GUI)" == "WNT"
-CDEFS+=-DPLUGIN_NAME=$(DLLPRE)sal_textenc$(UDK_MAJOR)$(DLLPOST)
-.ELSE
-CDEFS+=-DPLUGIN_NAME=$(DLLPRE)sal_textenc$(DLLPOST).$(UDK_MAJOR)
-.ENDIF
LIB2TARGET= $(SLB)$/textenc_tables.lib
LIB2OBJFILES= $(SAL_TABLES_OBJECTS) $(SAL_COMMON_OBJECTS)
diff --git a/sal/textenc/tables.cxx b/sal/textenc/tables.cxx
index 8197f6810c49..3f96dcb3e7b5 100644
--- a/sal/textenc/tables.cxx
+++ b/sal/textenc/tables.cxx
@@ -26,13 +26,9 @@
*
************************************************************************/
-#ifdef IOS
-#define Impl_getTextEncodingData tables_Impl_getTextEncodingData
-#endif
+#include "sal/config.h"
-#ifndef INCLUDED_RTL_TEXTENC_GETTEXTENCODINGDATA_H
-#include "gettextencodingdata.h"
-#endif
+#include "sal/types.h"
#ifndef INCLUDED_RTL_TEXTENC_TENCHELP_H
#include "tenchelp.h"
@@ -129,8 +125,8 @@ static sal_uInt16 const aImplDoubleByteIdentifierTab[1] = { 0 };
#include "convertiso2022kr.tab"
#include "convertadobe.tab"
-ImplTextEncodingData const *
-Impl_getTextEncodingData(rtl_TextEncoding nEncoding)
+extern "C" ImplTextEncodingData const * sal_getFullTextEncodingData(
+ rtl_TextEncoding nEncoding)
{
static ImplTextEncodingData const * const aData[]
= { NULL, /* DONTKNOW */
diff --git a/sal/textenc/textenc.cxx b/sal/textenc/textenc.cxx
index 0b245a078e82..c638cfd3c722 100644
--- a/sal/textenc/textenc.cxx
+++ b/sal/textenc/textenc.cxx
@@ -28,6 +28,9 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sal.hxx"
+#include "sal/config.h"
+
+#include <cstdlib>
/* TODO! This file should not be called textenc.c, because it is not the
implementation of rtl/textenc.h. Rather, it should be called
@@ -36,8 +39,13 @@
#include "tenchelp.h"
#include "rtl/textenc.h"
#include <sal/macros.h>
+#include "boost/noncopyable.hpp"
+#include "osl/diagnose.h"
+#include "osl/module.hxx"
+#include "rtl/instance.hxx"
+#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
-#include "osl/module.h"
+#include "sal/types.h"
#ifndef INCLUDED_STDDEF_H
#include <stddef.h>
@@ -94,21 +102,71 @@ static sal_uInt16 const aImplDoubleByteIdentifierTab[1] = { 0 };
#include "tcvtlat1.tab"
#include "tcvtuni1.tab"
-extern "C" {
- typedef ImplTextEncodingData const *(*TextEncodingFunction) (rtl_TextEncoding nEncoding);
+namespace {
+
+#if defined IOS
+
+extern "C" ImplTextEncodingData const * sal_getFullTextEncodingData(
+ rtl_TextEncoding); // from tables.cxx in sal_textenc library
+
+class FullTextEnocdingData: private boost::noncopyable {
+public:
+ ImplTextEncodingData const * get(rtl_TextEncoding encoding) {
+ return sal_getFullTextEncodingData(encoding);
+ }
};
-// Yes - we should use the unpleasant to use templatized
-// sal:: doublecheckfoo thing here.
-#ifndef IOS
-static TextEncodingFunction pTables;
#else
-extern "C" ImplTextEncodingData *tables_Impl_getTextEncodingData(rtl_TextEncoding);
-#define pTables tables_Impl_getTextEncodingData
+
+extern "C" {
+
+typedef ImplTextEncodingData const * TextEncodingFunction(rtl_TextEncoding);
+
+void SAL_CALL thisModule() {}
+
+};
+
+class FullTextEncodingData: private boost::noncopyable {
+public:
+ FullTextEncodingData() {
+ if (!module_.loadRelative(
+ &thisModule,
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ SAL_MODULENAME("sal_textenc")))))
+ {
+ OSL_TRACE("Loading sal_textenc library failed");
+ std::abort();
+ }
+ function_ = reinterpret_cast< TextEncodingFunction * >(
+ module_.getFunctionSymbol(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "sal_getFullTextEncodingData"))));
+ if (function_ == 0) {
+ OSL_TRACE(
+ "Obtaining sal_getFullTextEncodingData fuction from sal_textenc"
+ " library failed");
+ std::abort();
+ }
+ }
+
+ ImplTextEncodingData const * get(rtl_TextEncoding encoding) {
+ return (*function_)(encoding);
+ }
+
+private:
+ osl::Module module_;
+ TextEncodingFunction * function_;
+};
+
#endif
-#define DOSTRING( x ) #x
-#define STRING( x ) DOSTRING( x )
+struct FullTextEncodingDataSingleton:
+ public rtl::Static< FullTextEncodingData, FullTextEncodingDataSingleton >
+{};
+
+}
ImplTextEncodingData const *
Impl_getTextEncodingData(rtl_TextEncoding nEncoding) SAL_THROW_EXTERN_C()
@@ -142,24 +200,7 @@ Impl_getTextEncodingData(rtl_TextEncoding nEncoding) SAL_THROW_EXTERN_C()
// ----------------------------------------------
#endif
default:
-#ifndef IOS
- if (!pTables)
- {
- static char const pName[] = STRING(PLUGIN_NAME);
- oslModule aModule = osl_loadModuleAscii(pName, SAL_LOADMODULE_DEFAULT);
-
- if(aModule)
- {
- static char const pSymbol[] = "Impl_getTextEncodingData";
- pTables = (TextEncodingFunction)osl_getAsciiFunctionSymbol(aModule, pSymbol);
- }
- }
-#endif
- if (pTables)
- return pTables(nEncoding);
-// else
-// fprintf (stderr, "missing text encoding library for %d\n", nEncoding);
- break;
+ return FullTextEncodingDataSingleton::get().get(nEncoding);
}
return NULL;
}
diff --git a/sal/util/makefile.mk b/sal/util/makefile.mk
index 3a3a164480ee..981f3cbbe632 100644
--- a/sal/util/makefile.mk
+++ b/sal/util/makefile.mk
@@ -152,15 +152,6 @@ SHL1STDLIBS+=-lgcc
.ENDIF
.ENDIF
-SHL4DEPN+=$(SHL1TARGETN)
-SHL4LIBS=$(SLB)$/textenc_tables.lib
-SHL4TARGET=sal_textenc
-SHL4STDLIBS=$(SALLIB)
-SHL4VERSIONMAP=saltextenc.map
-
-SHL4DEF=$(MISC)$/$(SHL4TARGET).def
-DEF4NAME=$(SHL4TARGET)
-
# --- Targets ------------------------------------------------------
.ENDIF # $(header) != ""
diff --git a/sal/util/sal_textenc/makefile.mk b/sal/util/sal_textenc/makefile.mk
new file mode 100644
index 000000000000..96a054098450
--- /dev/null
+++ b/sal/util/sal_textenc/makefile.mk
@@ -0,0 +1,46 @@
+# Version: MPL 1.1 / GPLv3+ / LGPLv3+
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License or as specified alternatively below. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# Major Contributor(s):
+# [ Copyright (C) 2011 Stephan Bergmann, Red Hat Inc. <sbergman@redhat.com>
+# (initial developer) ]
+#
+# All Rights Reserved.
+#
+# For minor contributions see the git repository.
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+# instead of those above.
+
+PRJ = ../..
+PRJNAME = sal
+TARGET = sal_textenc
+
+# Should be VISIBILITY_HIDDEN=TRUE, but sal/textenc contains objects that end up
+# in both sal and sal_textenc libraries, so need to use a map file here for now.
+
+.INCLUDE: settings.mk
+
+# Should be DLLPRE= as it is loaded dynamically, but IOS links against it.
+
+SHL1IMPLIB = i$(SHL1TARGET)
+SHL1LIBS = $(SLB)/textenc_tables.lib
+SHL1RPATH = URELIB
+SHL1STDLIBS = $(SALLIB)
+SHL1TARGET = sal_textenc
+SHL1VERSIONMAP = saltextenc.map
+DEF1NAME = $(SHL1TARGET)
+
+.INCLUDE: target.mk
diff --git a/sal/util/sal_textenc/saltextenc.map b/sal/util/sal_textenc/saltextenc.map
new file mode 100644
index 000000000000..45024c0ccb59
--- /dev/null
+++ b/sal/util/sal_textenc/saltextenc.map
@@ -0,0 +1,32 @@
+# Version: MPL 1.1 / GPLv3+ / LGPLv3+
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License or as specified alternatively below. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# Major Contributor(s):
+# [ Copyright (C) 2011 Stephan Bergmann, Red Hat Inc. <sbergman@redhat.com>
+# (initial developer) ]
+#
+# All Rights Reserved.
+#
+# For minor contributions see the git repository.
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+# instead of those above.
+
+UDK_3_0_0 {
+ global:
+ sal_getFullTextEncodingData;
+ local:
+ *;
+};
diff --git a/sal/util/saltextenc.map b/sal/util/saltextenc.map
deleted file mode 100644
index e88a0af15723..000000000000
--- a/sal/util/saltextenc.map
+++ /dev/null
@@ -1,6 +0,0 @@
-UDK_3_0_0 {
- global:
- Impl_getTextEncodingData;
- local:
- *;
-};