create a C/C++ plugin system for pybullet / C-API.
This commit is contained in:
37
examples/SharedMemory/plugins/b3PluginAPI.h
Normal file
37
examples/SharedMemory/plugins/b3PluginAPI.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef B3_PLUGIN_API_H
|
||||
#define B3_PLUGIN_API_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#define B3_SHARED_API __declspec(dllexport)
|
||||
#elif defined (__GNUC__)
|
||||
#define B3_SHARED_API __attribute__((visibility("default")))
|
||||
#else
|
||||
#define B3_SHARED_API
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define B3_API_ENTRY
|
||||
#define B3_API_CALL __stdcall
|
||||
#define B3_CALLBACK __stdcall
|
||||
#else
|
||||
#define B3_API_ENTRY
|
||||
#define B3_API_CALL
|
||||
#define B3_CALLBACK
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* Plugin API */
|
||||
typedef B3_API_ENTRY int (B3_API_CALL * PFN_INIT)();
|
||||
typedef B3_API_ENTRY void (B3_API_CALL * PFN_EXIT)();
|
||||
typedef B3_API_ENTRY int (B3_API_CALL * PFN_EXECUTE)();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //B3_PLUGIN_API_H
|
||||
42
examples/SharedMemory/plugins/testPlugin/premake4.lua
Normal file
42
examples/SharedMemory/plugins/testPlugin/premake4.lua
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
|
||||
project ("pybullet_testplugin")
|
||||
language "C++"
|
||||
kind "SharedLib"
|
||||
|
||||
includedirs {".","../../../../src", "../../../../examples",
|
||||
"../../../ThirdPartyLibs"}
|
||||
defines {"PHYSICS_IN_PROCESS_EXAMPLE_BROWSER"}
|
||||
hasCL = findOpenCL("clew")
|
||||
|
||||
links{"BulletFileLoader", "Bullet3Common", "LinearMath"}
|
||||
|
||||
|
||||
if os.is("MacOSX") then
|
||||
-- targetextension {"so"}
|
||||
links{"Cocoa.framework","Python"}
|
||||
end
|
||||
|
||||
|
||||
files {
|
||||
"testplugin.cpp",
|
||||
"../../PhysicsClient.cpp",
|
||||
"../../PhysicsClient.h",
|
||||
"../../PhysicsClientSharedMemory.cpp",
|
||||
"../../PhysicsClientSharedMemory.h",
|
||||
"../../PhysicsClientSharedMemory_C_API.cpp",
|
||||
"../../PhysicsClientSharedMemory_C_API.h",
|
||||
"../../PhysicsClientC_API.cpp",
|
||||
"../../PhysicsClientC_API.h",
|
||||
"../../Win32SharedMemory.cpp",
|
||||
"../../Win32SharedMemory.h",
|
||||
"../../PosixSharedMemory.cpp",
|
||||
"../../PosixSharedMemory.h",
|
||||
"../../../Utils/b3Clock.cpp",
|
||||
"../../../Utils/b3Clock.h",
|
||||
"../../../Utils/b3ResourcePath.cpp",
|
||||
"../../../Utils/b3ResourcePath.h",
|
||||
}
|
||||
|
||||
|
||||
|
||||
22
examples/SharedMemory/plugins/testPlugin/testplugin.cpp
Normal file
22
examples/SharedMemory/plugins/testPlugin/testplugin.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
#include "testplugin.h"
|
||||
#include "../../SharedMemoryPublic.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
B3_SHARED_API int initPlugin()
|
||||
{
|
||||
printf("hi!\n");
|
||||
return SHARED_MEMORY_MAGIC_NUMBER;
|
||||
}
|
||||
|
||||
B3_SHARED_API int executePluginCommand()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
|
||||
|
||||
B3_SHARED_API void exitPlugin()
|
||||
{
|
||||
printf("bye!\n");
|
||||
}
|
||||
19
examples/SharedMemory/plugins/testPlugin/testplugin.h
Normal file
19
examples/SharedMemory/plugins/testPlugin/testplugin.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef TEST_PLUGIN_H
|
||||
#define TEST_PLUGIN_H
|
||||
|
||||
#include "../b3PluginAPI.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
B3_SHARED_API int initPlugin();
|
||||
B3_SHARED_API void exitPlugin();
|
||||
B3_SHARED_API int executePluginCommand();
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif//#define TEST_PLUGIN_H
|
||||
Reference in New Issue
Block a user