Salome HOME
Avoid copy of buffer at unpickling time by using PyMemoryView_FromMemory instead...
[modules/yacs.git] / src / runtime / CppContainer.cxx
index 5f33db49f9466c75fe7a4f9dd9f1dac39123bba7..4b32ba08c915fd98918574a38b69cf94433b4a2e 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006-2015  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2019  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -126,7 +126,7 @@ bool CppContainer::loadComponentLibrary(const std::string & componentName) throw
   return false;
     }
 
-CppComponent * CppContainer::createComponentInstance(const std::string & componentName, int /* studyID */)
+CppComponent * CppContainer::createComponentInstance(const std::string & componentName)
 {
   DEBTRACE("CppContainer::createComponentInstance");
   if (_trueCont)
@@ -324,7 +324,11 @@ LocalLibrary  LocalContainer::loadComponentLibrary(const std::string & aCompName
     }
   
 #ifndef WIN32
+#ifdef __APPLE__
+  std::string impl_name = std::string ("lib") + aCompName + std::string("Local.dylib");
+#else
   std::string impl_name = std::string ("lib") + aCompName + std::string("Local.so");
+#endif
   if(sprefix != "")
     impl_name = sprefix + std::string("/") + impl_name;
 #else
@@ -335,7 +339,15 @@ LocalLibrary  LocalContainer::loadComponentLibrary(const std::string & aCompName
     
 #if defined( WIN32 )
   HMODULE handle;
-  handle = dlopen( impl_name.c_str() ) ;
+#if defined(UNICODE)
+  size_t length = strlen(impl_name.c_str()) + sizeof(char);
+  wchar_t* aPath = new wchar_t[length + 1];
+  memset(aPath, '\0', length);
+  mbstowcs(aPath, impl_name.c_str(), length);
+#else
+  const char* aPath = fullLibName.c_str();
+#endif
+  handle = dlopen( aPath ) ;
 #else
   void* handle;
   handle = dlopen( impl_name.c_str() , RTLD_LAZY ) ;