Skip to content

Commit b0895ab

Browse files
author
Marcus Tomlinson
committed
Fixed Windows stuff
1 parent 00493cc commit b0895ab

File tree

6 files changed

+46
-63
lines changed

6 files changed

+46
-63
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ if(UNIX)
1111
endif(UNIX)
1212

1313
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
14-
add_definitions(-DECS_EXPORT)
1514
set(PYTHON_LIBRARIES "C:/Python27/libs/python27.lib")
1615
set(PYTHON_INCLUDE_DIRS "C:/Python27/include")
1716
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")

example/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Simple
5353
float ShowDouble( double message )
5454
{
5555
std::cout << message;
56-
return message;
56+
return (float)message;
5757
}
5858

5959
void ShowLots( unsigned long count, char* message )

include/EcsPython.h

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3232
#ifndef ECSPYTHON_H
3333
#define ECSPYTHON_H
3434

35-
#ifdef _WIN32
36-
37-
#ifdef ECS_EXPORT
38-
#define DLLPORT __declspec(dllexport)
39-
#else
40-
#define DLLPORT __declspec(dllimport)
41-
#endif
42-
43-
#else
44-
45-
#define DLLPORT
46-
47-
#endif
48-
49-
#include <ecspython/EcsMacros.h>
5035
#include <dspatch/DspThread.h>
36+
#include <ecspython/EcsMacros.h>
5137

5238
struct PyMethodDef;
5339

5440
//=================================================================================================
5541
// EcsPython Globals
5642
// =================
5743

58-
struct DLLEXPORT EcsClass
44+
struct EcsClass
5945
{
6046
EcsClass( std::string newPyClassName, const std::type_info& newPyClassType )
6147
: pyClassName( newPyClassName ),
@@ -65,7 +51,7 @@ struct DLLEXPORT EcsClass
6551
const std::type_info& pyClassType;
6652
};
6753

68-
struct DLLEXPORT EcsObject
54+
struct EcsObject
6955
{
7056
EcsObject( char* newPyObject, std::string newPyClassName, std::string newPyObjectName )
7157
: pyObject( newPyObject ),
@@ -77,54 +63,54 @@ struct DLLEXPORT EcsObject
7763
std::string pyObjectName;
7864
};
7965

80-
DLLPORT extern DspMutex EcsPythonCmdMutex; // Mutex for thread-safe python calls
81-
DLLPORT extern std::vector< EcsClass* > EcsPythonClassesDict; // C++ class dictionary
82-
DLLPORT extern std::string EcsPythonClassesDef; // Python definition string for C++ classes
83-
DLLPORT extern std::vector< PyMethodDef > EcsPythonMethods; // Methods for EcsPython python module
84-
DLLPORT extern std::vector< EcsObject* > EcsExposedObjects; // C++ objects exposed to Python
66+
extern DspMutex EcsPythonCmdMutex; // Mutex for thread-safe python calls
67+
extern std::vector< EcsClass* > EcsPythonClassesDict; // C++ class dictionary
68+
extern std::string EcsPythonClassesDef; // Python definition string for C++ classes
69+
extern std::vector< PyMethodDef > EcsPythonMethods; // Methods for EcsPython python module
70+
extern std::vector< EcsObject* > EcsExposedObjects; // C++ objects exposed to Python
8571

8672
#if PY_MAJOR_VERSION >= 3
87-
DLLPORT extern struct PyModuleDef EcsPythonModule; // EcsPython python module
73+
extern struct PyModuleDef EcsPythonModule; // EcsPython python module
8874
#endif
8975

9076
//=================================================================================================
9177
// Initialize EcsPython
9278
// ====================
9379

94-
DLLEXPORT void Ecs_Initialize();
80+
void Ecs_Initialize();
9581

9682
//-------------------------------------------------------------------------------------------------
9783
// Finalize EcsPython
9884
// ==================
9985

100-
DLLEXPORT void Ecs_Finalize();
86+
void Ecs_Finalize();
10187

10288
//-------------------------------------------------------------------------------------------------
10389
// Execute Python Command
10490
// ======================
10591

106-
DLLEXPORT void Ecs_Python_Cmd( std::string pythonCmdString );
92+
void Ecs_Python_Cmd( std::string pythonCmdString );
10793

10894
//-------------------------------------------------------------------------------------------------
10995
// Execute Python File
11096
// ===================
11197

112-
DLLEXPORT void Ecs_Python_File( std::string pythonScriptPath );
98+
void Ecs_Python_File( std::string pythonScriptPath );
11399

114100
//-------------------------------------------------------------------------------------------------
115101
// Get Object Value From Python
116102
// ============================
117103

118-
DLLEXPORT std::string Ecs_Get_Value( std::string pyObjectName );
104+
std::string Ecs_Get_Value( std::string pyObjectName );
119105

120106
//-------------------------------------------------------------------------------------------------
121107
// Expose Class Instance To Python
122108
// ===============================
123109

124-
DLLEXPORT void _Ecs_Expose_Object( char* pyObject, std::string pyClassName, std::string pyObjectName );
110+
void _Ecs_Expose_Object( char* pyObject, std::string pyClassName, std::string pyObjectName );
125111

126112
template< class ObjectType >
127-
DLLEXPORT void Ecs_Expose_Object( ObjectType* object, std::string pyObjectName )
113+
void Ecs_Expose_Object( ObjectType* object, std::string pyObjectName )
128114
{
129115
for( unsigned long i = 0; i < EcsPythonClassesDict.size(); i++ )
130116
{

include/ecspython/EcsMacros.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,25 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3636
#include <typeinfo>
3737
#include <string>
3838

39-
#include <dspatch/DspThread.h>
40-
4139
//=================================================================================================
4240

4341
typedef struct _object PyObject;
4442
typedef PyObject* (*PyCFunction)( PyObject *, PyObject * );
4543

46-
DLLPORT extern int (*_Ecs_ParseTuple)( PyObject *, const char *, ... );
44+
extern int (*_Ecs_ParseTuple)( PyObject *, const char *, ... );
4745

4846
//=================================================================================================
4947

50-
DLLEXPORT void _EcsAddNewMethod( const char *methodName, PyCFunction methodPointer, int methodFlags );
48+
void _EcsAddNewMethod( const char *methodName, PyCFunction methodPointer, int methodFlags );
5149

5250
//-------------------------------------------------------------------------------------------------
5351

5452
template< class Type >
55-
DLLEXPORT PyObject* _Ecs_ToPyObject( const Type& Value );
53+
PyObject* _Ecs_ToPyObject( const Type& Value );
5654

5755
//-------------------------------------------------------------------------------------------------
5856

59-
DLLEXPORT PyObject* _Ecs_GetPythonNull();
57+
PyObject* _Ecs_GetPythonNull();
6058

6159
//=================================================================================================
6260
// COMMON TOOLS
@@ -94,7 +92,7 @@ static void _Ecs_AppendPythonArgType( std::string& pyTypes )
9492
else if( typeid( Type ) == typeid( bool ) )
9593
append = "i";
9694
else if( typeid( Type ) == typeid( double ) )
97-
append = "d";
95+
append = "f";
9896
else if( typeid( Type ) == typeid( float ) )
9997
append = "f";
10098
else if( typeid( Type ) == typeid( void* ) )
@@ -113,7 +111,7 @@ void _Ecs_FromPyObject( char* in, Type& out )
113111

114112
inline void _Ecs_FromPyObject( char* in, double& out )
115113
{
116-
out = *(double*)&in;
114+
out = *(float*)&in;
117115
}
118116

119117
inline void _Ecs_FromPyObject( char* in, float& out )

src/EcsMacros.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,27 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3737

3838
//=================================================================================================
3939

40-
DLLPORT int (*_Ecs_ParseTuple)( PyObject *, const char *, ... ) = NULL;
40+
int (*_Ecs_ParseTuple)( PyObject *, const char *, ... ) = NULL;
4141

4242
typedef char* charptr;
4343
typedef void* voidptr;
4444

45-
template DLLEXPORT PyObject* _Ecs_ToPyObject( const charptr& );
46-
template DLLEXPORT PyObject* _Ecs_ToPyObject( const std::string& );
47-
template DLLEXPORT PyObject* _Ecs_ToPyObject( const char& );
48-
template DLLEXPORT PyObject* _Ecs_ToPyObject( const unsigned char& );
49-
template DLLEXPORT PyObject* _Ecs_ToPyObject( const short& );
50-
template DLLEXPORT PyObject* _Ecs_ToPyObject( const unsigned short& );
51-
template DLLEXPORT PyObject* _Ecs_ToPyObject( const int& );
52-
template DLLEXPORT PyObject* _Ecs_ToPyObject( const unsigned int& );
53-
template DLLEXPORT PyObject* _Ecs_ToPyObject( const long& );
54-
template DLLEXPORT PyObject* _Ecs_ToPyObject( const unsigned long& );
55-
template DLLEXPORT PyObject* _Ecs_ToPyObject( const long long& );
56-
template DLLEXPORT PyObject* _Ecs_ToPyObject( const unsigned long long& );
57-
template DLLEXPORT PyObject* _Ecs_ToPyObject( const bool& );
58-
template DLLEXPORT PyObject* _Ecs_ToPyObject( const double& );
59-
template DLLEXPORT PyObject* _Ecs_ToPyObject( const float& );
60-
template DLLEXPORT PyObject* _Ecs_ToPyObject( const voidptr& );
45+
template PyObject* _Ecs_ToPyObject( const charptr& );
46+
template PyObject* _Ecs_ToPyObject( const std::string& );
47+
template PyObject* _Ecs_ToPyObject( const char& );
48+
template PyObject* _Ecs_ToPyObject( const unsigned char& );
49+
template PyObject* _Ecs_ToPyObject( const short& );
50+
template PyObject* _Ecs_ToPyObject( const unsigned short& );
51+
template PyObject* _Ecs_ToPyObject( const int& );
52+
template PyObject* _Ecs_ToPyObject( const unsigned int& );
53+
template PyObject* _Ecs_ToPyObject( const long& );
54+
template PyObject* _Ecs_ToPyObject( const unsigned long& );
55+
template PyObject* _Ecs_ToPyObject( const long long& );
56+
template PyObject* _Ecs_ToPyObject( const unsigned long long& );
57+
template PyObject* _Ecs_ToPyObject( const bool& );
58+
template PyObject* _Ecs_ToPyObject( const double& );
59+
template PyObject* _Ecs_ToPyObject( const float& );
60+
template PyObject* _Ecs_ToPyObject( const voidptr& );
6161

6262
//=================================================================================================
6363

src/EcsPython.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ PyMODINIT_FUNC _Ecs_PyInit();
4343
// EcsPython Globals
4444
// =================
4545

46-
DLLPORT DspMutex EcsPythonCmdMutex; // Mutex for thread-safe python calls
47-
DLLPORT std::vector< EcsClass* > EcsPythonClassesDict; // C++ class dictionary
48-
DLLPORT std::string EcsPythonClassesDef; // Python definition string for C++ classes
49-
DLLPORT std::vector< PyMethodDef > EcsPythonMethods; // Methods for EcsPython python module
50-
DLLPORT std::vector< EcsObject* > EcsExposedObjects; // C++ objects exposed to Python
46+
DspMutex EcsPythonCmdMutex; // Mutex for thread-safe python calls
47+
std::vector< EcsClass* > EcsPythonClassesDict; // C++ class dictionary
48+
std::string EcsPythonClassesDef; // Python definition string for C++ classes
49+
std::vector< PyMethodDef > EcsPythonMethods; // Methods for EcsPython python module
50+
std::vector< EcsObject* > EcsExposedObjects; // C++ objects exposed to Python
5151

5252
#if PY_MAJOR_VERSION >= 3
53-
DLLPORT struct PyModuleDef EcsPythonModule; // EcsPython python module
53+
struct PyModuleDef EcsPythonModule; // EcsPython python module
5454
#endif
5555

5656
//=================================================================================================

0 commit comments

Comments
 (0)