WSL/SLF GitLab Repository

Commit 059f9d66 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Fixed some bad naming in DynamicLibrary, silenced an unnecessary warning from...

Fixed some bad naming in DynamicLibrary, silenced an unnecessary warning from Visual C++ (urging us to use non standard library calls), fixed some DLL exports for Visual C++.
parent 8f6a7552
......@@ -35,7 +35,7 @@ IF(UNIX)
ENDIF(APPLE)
ELSE(UNIX)
IF(WIN32)
set(PLATFORM "-DWIN32 -U__STRICT_ANSI__ -D_USE_MATH_DEFINES")
set(PLATFORM "-DWIN32 -U__STRICT_ANSI__ -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNING")
# see IF(MSVC) "/MD /MDd"
set(EXTRA_WARNINGS "-ansi")
ENDIF(WIN32)
......
......@@ -20,33 +20,33 @@
namespace mio {
#ifdef _WIN32
DynamicLibrary::DynamicLibrary(HINSTANCE objFile) : i_objFile(objFile){}
DynamicLibrary::DynamicLibrary(HINSTANCE i_objFile) : objFile(i_objFile){}
#else
DynamicLibrary::DynamicLibrary(void* objFile) : i_objFile(objFile){}
DynamicLibrary::DynamicLibrary(void* i_objFile) : objFile(i_objFile){}
#endif
DynamicLibrary::~DynamicLibrary(void)
{
#ifdef _WIN32
FreeLibrary(i_objFile);
FreeLibrary(objFile);
#else
dlclose(i_objFile);
dlclose(objFile);
#endif
}
PluginObject* DynamicLibrary::newObject(const std::string& name, const Config& cfg)
{
// If there is no valid library, return null
if(i_objFile == NULL) {
if(objFile == NULL) {
return NULL;
}
// Get the loadObject() function. If it doesn't exist, return NULL.
#ifdef _WIN32
#pragma warning(disable:4191) //GetProcAddress does NOT return a FARPROC, the warning misses it...
const void (*loadSym)(const std::string&, const Config&) = (const void (*)(const std::string&, const Config&))GetProcAddress(i_objFile, "loadObject");
const void (*loadSym)(const std::string&, const Config&) = (const void (*)(const std::string&, const Config&))GetProcAddress(objFile, "loadObject");
#else
const void* loadSym = dlsym(i_objFile, "loadObject");
const void* loadSym = dlsym(objFile, "loadObject");
#endif
if(loadSym == NULL) {
......@@ -87,13 +87,13 @@ std::string DynamicLoader::getErrorMessage(){
#endif
}
PluginObject::PluginObject(void (*delObj)(void*)) : _deleteObject(delObj){}
PluginObject::PluginObject(void (*i_delObj)(void*)) : deleteObject(i_delObj){}
PluginObject::~PluginObject(void){}
void PluginObject::deleteSelf(void)
{
(*_deleteObject)(reinterpret_cast<void*>(this));
(*deleteObject)(reinterpret_cast<void*>(this));
}
} //namespace
......@@ -49,10 +49,10 @@ namespace mio {
class PluginObject {
private:
// Callback function that should be called to delete dynamic object
void (*_deleteObject)(void*);
void (*deleteObject)(void*);
public:
// The constructor sets the callback function to use
PluginObject(void (*delObj)(void*));
PluginObject(void (*i_delObj)(void*));
// The destructor
virtual ~PluginObject(void);
......@@ -72,9 +72,9 @@ class DynamicLibrary {
protected:
// The handle to the shared library that was opened
#ifdef _WIN32
HINSTANCE i_objFile;
HINSTANCE objFile;
#else
void *i_objFile;
void *objFile;
#endif
// Since an instance of DynamicLibrary manages lifetime of an open
......@@ -87,9 +87,9 @@ class DynamicLibrary {
// in. Protected so that only the DynamicLoader can create an
// instance (since it is declared friend.
#ifdef _WIN32
DynamicLibrary(HINSTANCE objFile);
DynamicLibrary(HINSTANCE i_objFile);
#else
DynamicLibrary(void* objFile);
DynamicLibrary(void* i_objFile);
#endif
public:
......
......@@ -16,7 +16,6 @@
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ARCIO.h"
#include "exports.h"
using namespace std;
......@@ -313,6 +312,9 @@ void ARCIO::write2DGrid(const Grid2DObject& grid_in, const std::string& name)
#ifndef _METEOIO_JNI
extern "C"
{
#define COMPILE_PLUGIN
#include "exports.h"
METEOIO_EXPORT void deleteObject(void* obj) {
delete reinterpret_cast<PluginObject*>(obj);
}
......
......@@ -16,7 +16,6 @@
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ARPSIO.h"
#include "exports.h"
using namespace std;
......@@ -378,6 +377,9 @@ void ARPSIO::moveToMarker(const std::string& marker)
#ifndef _METEOIO_JNI
extern "C"
{
#define COMPILE_PLUGIN
#include "exports.h"
METEOIO_EXPORT void deleteObject(void* obj) {
delete reinterpret_cast<PluginObject*>(obj);
}
......
......@@ -16,7 +16,6 @@
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include "BormaIO.h"
#include "exports.h"
using namespace std;
......@@ -530,6 +529,9 @@ void BormaIO::convertUnits(MeteoData& meteo)
#ifndef _METEOIO_JNI
extern "C"
{
#define COMPILE_PLUGIN
#include "exports.h"
METEOIO_EXPORT void deleteObject(void* obj) {
delete reinterpret_cast<PluginObject*>(obj);
}
......
......@@ -15,7 +15,6 @@
You should have received a copy of the GNU Lesser General Public License
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include "exports.h"
#include "CosmoXMLIO.h"
#include <meteoio/meteolaws/Atmosphere.h>
#include <sstream>
......@@ -508,6 +507,9 @@ void CosmoXMLIO::cleanup() throw()
#ifndef _METEOIO_JNI
extern "C"
{
#define COMPILE_PLUGIN
#include "exports.h"
METEOIO_EXPORT void deleteObject(void* obj) {
delete reinterpret_cast<PluginObject*>(obj);
}
......
......@@ -16,7 +16,6 @@
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include "GSNIO.h"
#include "exports.h"
using namespace std;
......@@ -405,6 +404,9 @@ void GSNIO::convertUnits(MeteoData& meteo)
extern "C"
{
#define COMPILE_PLUGIN
#include "exports.h"
METEOIO_EXPORT void deleteObject(void* obj) {
delete reinterpret_cast<PluginObject*>(obj);
}
......
......@@ -16,7 +16,6 @@
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include "GeotopIO.h"
#include "exports.h"
using namespace std;
......@@ -541,6 +540,9 @@ void GeotopIO::convertUnits(MeteoData& meteo)
#ifndef _METEOIO_JNI
extern "C"
{
#define COMPILE_PLUGIN
#include "exports.h"
METEOIO_EXPORT void deleteObject(void* obj) {
delete reinterpret_cast<PluginObject*>(obj);
}
......
......@@ -16,7 +16,6 @@
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include "GrassIO.h"
#include "exports.h"
using namespace std;
......@@ -275,6 +274,9 @@ void GrassIO::write2DGrid(const Grid2DObject& grid_in, const std::string& name)
#ifndef _METEOIO_JNI
extern "C"
{
#define COMPILE_PLUGIN
#include "exports.h"
METEOIO_EXPORT void deleteObject(void* obj) {
delete reinterpret_cast<PluginObject*>(obj);
}
......
......@@ -16,7 +16,6 @@
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ImisIO.h"
#include "exports.h"
using namespace std;
using namespace oracle;
......@@ -988,6 +987,9 @@ void ImisIO::cleanup() throw()
#ifndef _METEOIO_JNI
extern "C"
{
#define COMPILE_PLUGIN
#include "exports.h"
//using namespace MeteoIO;
METEOIO_EXPORT void deleteObject(void* obj) {
delete reinterpret_cast<PluginObject*>(obj);
......
......@@ -16,7 +16,6 @@
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include "PGMIO.h"
#include "exports.h"
using namespace std;
......@@ -271,6 +270,9 @@ void PGMIO::cleanup() throw()
#ifndef _METEOIO_JNI
extern "C"
{
#define COMPILE_PLUGIN
#include "exports.h"
METEOIO_EXPORT void deleteObject(void* obj) {
delete reinterpret_cast<PluginObject*>(obj);
}
......
......@@ -16,7 +16,6 @@
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include "SMETIO.h"
#include "exports.h"
#include <meteoio/IOUtils.h>
using namespace std;
......@@ -919,6 +918,9 @@ void SMETIO::write2DGrid(const Grid2DObject& /*grid_in*/, const std::string& /*n
#ifndef _METEOIO_JNI
extern "C"
{
#define COMPILE_PLUGIN
#include "exports.h"
METEOIO_EXPORT void deleteObject(void* obj) {
delete reinterpret_cast<PluginObject*>(obj);
}
......
......@@ -16,7 +16,6 @@
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include "SNIO.h"
#include "exports.h"
#include <meteoio/meteolaws/Atmosphere.h>
using namespace std;
......@@ -591,6 +590,9 @@ void SNIO::convertUnits(MeteoData& meteo)
#ifndef _METEOIO_JNI
extern "C"
{
#define COMPILE_PLUGIN
#include "exports.h"
METEOIO_EXPORT void deleteObject(void* obj) {
delete reinterpret_cast<PluginObject*>(obj);
}
......
......@@ -18,7 +18,7 @@
#if defined(_MSC_VER)
#if defined(OSG_LIBRARY_STATIC)
#define METEOIO_EXPORT
#elif defined(METEOIO_LIBRARY)
#elif defined(COMPILE_PLUGIN)
#define METEOIO_EXPORT __declspec(dllexport)
#else
#define METEOIO_EXPORT __declspec(dllimport)
......
......@@ -16,7 +16,6 @@
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include "template.h"
#include "exports.h"
using namespace std;
......@@ -123,6 +122,9 @@ void TEMPLATE::cleanup() throw()
#ifndef _METEOIO_JNI
extern "C"
{
#define COMPILE_PLUGIN
#include "exports.h"
METEOIO_EXPORT void deleteObject(void* obj) {
delete reinterpret_cast<PluginObject*>(obj);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment