mirror of
https://github.com/boostorg/python.git
synced 2026-01-19 16:32:16 +00:00
@@ -38,7 +38,6 @@ lib boost_python
|
||||
str.cpp
|
||||
slice.cpp
|
||||
|
||||
aix_init_module.cpp
|
||||
converter/from_python.cpp
|
||||
converter/registry.cpp
|
||||
converter/type_id.cpp
|
||||
|
||||
@@ -95,10 +95,6 @@ LINK32=link.exe
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\aix_init_module.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\converter\arg_to_python_base.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -214,10 +210,6 @@ SOURCE=..\..\src\exec.cpp
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\boost\python\detail\aix_init_module.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\boost\python\detail\api_placeholder.hpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -1,141 +0,0 @@
|
||||
// Copyright David Abrahams 2002.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
#ifdef _AIX
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
}
|
||||
|
||||
# include <string>
|
||||
# include <boost/python/detail/wrap_python.hpp>
|
||||
# include <boost/python/errors.hpp>
|
||||
# include <boost/python/detail/aix_init_module.hpp>
|
||||
# include <boost/python/module.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace detail {
|
||||
|
||||
namespace
|
||||
{
|
||||
static PyMethodDef initial_methods[] = { { 0, 0, 0, 0 } };
|
||||
extern "C" void initlibboost_python()
|
||||
{
|
||||
Py_InitModule("libboost_python", initial_methods);
|
||||
}
|
||||
|
||||
struct find_and_open_file
|
||||
{
|
||||
FILE* fp;
|
||||
std::string libpath; // -- search path
|
||||
std::string filename; // -- filename to look for
|
||||
std::string fullpath; // -- full path to file
|
||||
|
||||
find_and_open_file(
|
||||
const std::string& libpath_env
|
||||
, const std::string& file);
|
||||
};
|
||||
|
||||
find_and_open_file::find_and_open_file(
|
||||
const std::string& libpath_env
|
||||
, const std::string& file)
|
||||
: fp(0)
|
||||
{
|
||||
char* value = std::getenv(libpath_env.c_str());
|
||||
|
||||
if(value == 0)
|
||||
return;
|
||||
|
||||
libpath = value;
|
||||
|
||||
if (libpath == "")
|
||||
return;
|
||||
|
||||
std::string::size_type pos = 0, prev_pos = 0;
|
||||
|
||||
// -- loop through all search paths looking for file
|
||||
while((pos = libpath.find_first_of(":",pos)) != std::string::npos)
|
||||
{
|
||||
fullpath = libpath.substr(prev_pos,pos - prev_pos) + "/" + file;
|
||||
if (::access(fullpath.c_str(), R_OK) == 0)
|
||||
{
|
||||
struct stat filestat;
|
||||
::stat(fullpath.c_str(), &filestat);
|
||||
if (!S_ISDIR(filestat.st_mode))
|
||||
{
|
||||
fp = std::fopen(fullpath.c_str(), "r");
|
||||
if (fp)
|
||||
{
|
||||
filename = file;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
prev_pos = ++pos;
|
||||
}
|
||||
|
||||
// -- mop up odd path
|
||||
if (libpath.find_first_of(":", prev_pos) == std::string::npos)
|
||||
{
|
||||
fullpath = libpath.substr(prev_pos, libpath.size() - prev_pos) + "/" + file;
|
||||
if (::access(fullpath.c_str(), R_OK) == 0)
|
||||
{
|
||||
struct stat filestat;
|
||||
::stat(fullpath.c_str(),&filestat);
|
||||
if (!S_ISDIR(filestat.st_mode))
|
||||
{
|
||||
fp = std::fopen(fullpath.c_str(), "r");
|
||||
filename = file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void aix_init_module(
|
||||
so_load_function load_dynamic_module
|
||||
, char const* module_name
|
||||
, void (*init_module)())
|
||||
{
|
||||
static bool initialized;
|
||||
if (!initialized)
|
||||
{
|
||||
char const* const name = "libboost_python.so";
|
||||
find_and_open_file dynlib("LIBPATH", name);
|
||||
if (dynlib.fp == 0)
|
||||
{
|
||||
fprintf(stderr, " Error: could not find %s\n", name);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string::size_type pos = pos = dynlib.filename.rfind(".so");
|
||||
if (pos != dynlib.filename.size() - 3)
|
||||
{
|
||||
fprintf(stderr, "dynamic library %s must end with .so\n", dynlib.filename.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
PyObject* m =
|
||||
load_dynamic_module(
|
||||
const_cast<char*>(dynlib.filename.substr(0,pos).c_str()),
|
||||
const_cast<char*>(dynlib.fullpath.c_str()),
|
||||
dynlib.fp);
|
||||
|
||||
if (m == 0)
|
||||
{
|
||||
fprintf(stderr, "failed to load library %s\n", name);
|
||||
return;
|
||||
}
|
||||
Py_DECREF(m);
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
python::detail::init_module(module_name, init_module);
|
||||
}
|
||||
|
||||
}}} // namespace boost::python
|
||||
#endif
|
||||
Reference in New Issue
Block a user