Skip to content
Snippets Groups Projects
Commit f9f800e6 authored by Christian Nowke's avatar Christian Nowke
Browse files

proudly presenting the nett-python bindings!

parent b3f535b0
No related branches found
No related tags found
No related merge requests found
...@@ -4,8 +4,24 @@ macro (add_event arg1 event_name dir dir_out) ...@@ -4,8 +4,24 @@ macro (add_event arg1 event_name dir dir_out)
exec_program( "protoc" "${PROTOBUF_BIN}" ARGS "${dir}/${event_name}.proto" "--proto_path=${dir}" "--python_out=${dir_out}" OUTPUT_VARIABLE output ) exec_program( "protoc" "${PROTOBUF_BIN}" ARGS "${dir}/${event_name}.proto" "--proto_path=${dir}" "--python_out=${dir_out}" OUTPUT_VARIABLE output )
list (APPEND ${arg1}_EVENT_SOURCE_FILES "${dir}/${event_name}.pb.h" "${dir}/${event_name}.pb.cc") list (APPEND ${arg1}_EVENT_SOURCE_FILES "${dir}/${event_name}.pb.h" "${dir}/${event_name}.pb.cc")
list (APPEND EVENT_NAME_LIST ${event_name})
# message ("output off protoc is: ${output}") # message ("output off protoc is: ${output}")
# message ("${dir}") # message ("${dir}")
# message ("${dir_out}") # message ("${dir_out}")
endmacro() endmacro()
macro ( generate_specializations )
foreach ( entry ${EVENT_NAME_LIST} )
set (_EVENT_NAMES "${_EVENT_NAMES}\nSPECIALIZE_MESSAGE_TYPE( ${entry} )" )
endforeach()
configure_file(
src/nett-python/specializations_template.h
specializations.h
@ONLY )
message ( "successfully generated python_slot specializations" )
endmacro()
\ No newline at end of file
...@@ -36,8 +36,10 @@ include_directories (${NETT_INCLUDE_DIR}) ...@@ -36,8 +36,10 @@ include_directories (${NETT_INCLUDE_DIR})
include_directories (${BOOST_INCLUDE_DIR}) include_directories (${BOOST_INCLUDE_DIR})
include_directories (${PYTHON_INCLUDE_DIR}) include_directories (${PYTHON_INCLUDE_DIR})
include_directories (${PROTOBUF_INCLUDE_DIR}) include_directories (${PROTOBUF_INCLUDE_DIR})
include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/include")
include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/include") #included for generated specialization header file
include_directories ("${CMAKE_CURRENT_BINARY_DIR}")
add_event ( nett_python routing_message ${NETT_SCHEMA_DIR} ${PROJECT_BINARY_DIR} ) add_event ( nett_python routing_message ${NETT_SCHEMA_DIR} ${PROJECT_BINARY_DIR} )
add_event ( nett_python string_message ${NETT_SCHEMA_DIR} ${PROJECT_BINARY_DIR} ) add_event ( nett_python string_message ${NETT_SCHEMA_DIR} ${PROJECT_BINARY_DIR} )
...@@ -69,3 +71,5 @@ add_custom_command( TARGET nett_python ...@@ -69,3 +71,5 @@ add_custom_command( TARGET nett_python
COMMENT "copying dll to pyd module extension" COMMENT "copying dll to pyd module extension"
) )
endif() endif()
generate_specializations()
set( RelativeDir "include/nett-python" )
set( RelativeSourceGroup "include/nett-python" )
set( DirFiles
# _SourceFiles.cmake
)
set( DirFiles_SourceGroup "${RelativeSourceGroup}" )
set( LocalSourceGroupFiles )
foreach( File ${DirFiles} )
list( APPEND LocalSourceGroupFiles "${RelativeDir}/${File}" )
list( APPEND ProjectSources "${RelativeDir}/${File}" )
endforeach()
source_group( ${DirFiles_SourceGroup} FILES ${LocalSourceGroupFiles} )
set( SubDirFiles "" )
foreach( Dir ${SubDirs} )
list( APPEND SubDirFiles "${RelativeDir}/${Dir}/_SourceFiles.cmake" )
endforeach()
foreach( SubDirFile ${SubDirFiles} )
include( ${SubDirFile} )
endforeach()
...@@ -68,18 +68,22 @@ private: ...@@ -68,18 +68,22 @@ private:
std::shared_ptr < nett::slot_in < event_type > > slot_; std::shared_ptr < nett::slot_in < event_type > > slot_;
}; };
#define SPECIALIZE_MESSAGE_TYPE( message_name ) \
class_< python_slot_out < ##message_name > >( "slot_out_"#message_name"", init<std::string>() ) \
.def( "send", &python_slot_out< ##message_name >::send ) \
; \
\
class_< python_slot_in < ##message_name > >( "slot_in_"#message_name"" ) \
.def( "connect", &python_slot_in< ##message_name >::connect ) \
.def( "receive", &python_slot_in< ##message_name >::receive ) \
;
BOOST_PYTHON_MODULE(nett_python) BOOST_PYTHON_MODULE(nett_python)
{ {
def( "initialize", &nett::initialize ); def( "initialize", &nett::initialize );
//def( "shutdown", &nett::shutdown); //def( "shutdown", &nett::shutdown);
class_< python_slot_out < string_message > >( "slot_out_string", init<std::string>() ) //include auto-generated definitions
.def( "send", &python_slot_out< string_message >::send) #include "specializations.h"
;
class_< python_slot_in < string_message > >( "slot_in_string" )
.def( "connect", &python_slot_in< string_message >::connect )
.def( "receive", &python_slot_in< string_message >::receive)
;
} }
\ No newline at end of file
@_EVENT_NAMES@
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment