Plugin-exported functions now actually work.

develop
Alexander Gavrilov 2012-03-15 14:06:50 +04:00
parent 87f925e72e
commit 605ee9669a
5 changed files with 17 additions and 13 deletions

@ -216,10 +216,11 @@ ENDIF()
ADD_LIBRARY(dfhack SHARED ${PROJECT_SOURCES}) ADD_LIBRARY(dfhack SHARED ${PROJECT_SOURCES})
ADD_DEPENDENCIES(dfhack generate_headers) ADD_DEPENDENCIES(dfhack generate_headers)
ADD_EXECUTABLE(dfhack-run dfhack-run.cpp ADD_LIBRARY(dfhack-client SHARED RemoteClient.cpp ColorText.cpp MiscUtils.cpp
RemoteClient.cpp ColorText.cpp MiscUtils.cpp proto/CoreProtocol.pb.cc)
${PROJECT_PROTO_SRCS}) ADD_DEPENDENCIES(dfhack-client dfhack)
ADD_DEPENDENCIES(dfhack-run dfhack)
ADD_EXECUTABLE(dfhack-run dfhack-run.cpp)
IF(BUILD_EGGY) IF(BUILD_EGGY)
SET_TARGET_PROPERTIES(dfhack PROPERTIES OUTPUT_NAME "egg" ) SET_TARGET_PROPERTIES(dfhack PROPERTIES OUTPUT_NAME "egg" )
@ -231,10 +232,10 @@ endif()
IF(WIN32) IF(WIN32)
SET_TARGET_PROPERTIES(dfhack PROPERTIES COMPILE_FLAGS "/FI\"Export.h\"" ) SET_TARGET_PROPERTIES(dfhack PROPERTIES COMPILE_FLAGS "/FI\"Export.h\"" )
SET_TARGET_PROPERTIES(dfhack-run PROPERTIES COMPILE_FLAGS "/FI\"Export.h\"" ) SET_TARGET_PROPERTIES(dfhack-client PROPERTIES COMPILE_FLAGS "/FI\"Export.h\"" )
ELSE() ELSE()
SET_TARGET_PROPERTIES(dfhack PROPERTIES COMPILE_FLAGS "-include Export.h" ) SET_TARGET_PROPERTIES(dfhack PROPERTIES COMPILE_FLAGS "-include Export.h" )
SET_TARGET_PROPERTIES(dfhack-run PROPERTIES COMPILE_FLAGS "-include Export.h" ) SET_TARGET_PROPERTIES(dfhack-client PROPERTIES COMPILE_FLAGS "-include Export.h" )
ENDIF() ENDIF()
#effectively disables debug builds... #effectively disables debug builds...
@ -243,7 +244,8 @@ SET_TARGET_PROPERTIES(dfhack PROPERTIES DEBUG_POSTFIX "-debug" )
TARGET_LINK_LIBRARIES(dfhack protobuf-lite clsocket ${PROJECT_LIBS}) TARGET_LINK_LIBRARIES(dfhack protobuf-lite clsocket ${PROJECT_LIBS})
SET_TARGET_PROPERTIES(dfhack PROPERTIES LINK_INTERFACE_LIBRARIES "") SET_TARGET_PROPERTIES(dfhack PROPERTIES LINK_INTERFACE_LIBRARIES "")
TARGET_LINK_LIBRARIES(dfhack-run protobuf-lite clsocket) TARGET_LINK_LIBRARIES(dfhack-client protobuf-lite clsocket)
TARGET_LINK_LIBRARIES(dfhack-run dfhack-client)
IF(UNIX) IF(UNIX)
# On linux, copy our version of the df launch script which sets LD_PRELOAD # On linux, copy our version of the df launch script which sets LD_PRELOAD
@ -277,7 +279,7 @@ install(FILES xml/symbols.xml
install(FILES ../dfhack.init-example install(FILES ../dfhack.init-example
DESTINATION ${DFHACK_BINARY_DESTINATION}) DESTINATION ${DFHACK_BINARY_DESTINATION})
install(TARGETS dfhack-run install(TARGETS dfhack-run dfhack-client
LIBRARY DESTINATION ${DFHACK_LIBRARY_DESTINATION} LIBRARY DESTINATION ${DFHACK_LIBRARY_DESTINATION}
RUNTIME DESTINATION ${DFHACK_LIBRARY_DESTINATION}) RUNTIME DESTINATION ${DFHACK_LIBRARY_DESTINATION})

@ -215,7 +215,7 @@ bool RemoteClient::bind(color_ostream &out, RemoteFunctionBase *function,
in->set_output_msg(function->p_out_template->GetTypeName()); in->set_output_msg(function->p_out_template->GetTypeName());
} }
if (bind_call.execute(out) != CR_OK) if (bind_call(out) != CR_OK)
return false; return false;
function->p_client = this; function->p_client = this;
@ -239,7 +239,7 @@ command_result RemoteClient::run_command(color_ostream &out, const std::string &
for (size_t i = 0; i < args.size(); i++) for (size_t i = 0; i < args.size(); i++)
runcmd_call.in()->add_arguments(args[i]); runcmd_call.in()->add_arguments(args[i]);
return runcmd_call.execute(out); return runcmd_call(out);
} }
void RPCFunctionBase::reset(bool free) void RPCFunctionBase::reset(bool free)

@ -192,6 +192,7 @@ ServerFunctionBase *ServerConnection::findFunction(color_ostream &out, const std
return NULL; return NULL;
} }
svc->finalize(this, &functions);
plugin_services[plugin] = svc; plugin_services[plugin] = svc;
} }
} }

@ -171,7 +171,7 @@ namespace DFHack
RemoteFunction() : RemoteFunctionBase(&In::default_instance(), &Out::default_instance()) {} RemoteFunction() : RemoteFunctionBase(&In::default_instance(), &Out::default_instance()) {}
command_result execute(color_ostream &stream) { command_result operator() (color_ostream &stream) {
return RemoteFunctionBase::execute(stream, in(), out()); return RemoteFunctionBase::execute(stream, in(), out());
} }
command_result operator() (color_ostream &stream, const In *input, Out *output) { command_result operator() (color_ostream &stream, const In *input, Out *output) {
@ -187,7 +187,7 @@ namespace DFHack
RemoteFunction() : RemoteFunctionBase(&In::default_instance(), &EmptyMessage::default_instance()) {} RemoteFunction() : RemoteFunctionBase(&In::default_instance(), &EmptyMessage::default_instance()) {}
command_result execute(color_ostream &stream) { command_result operator() (color_ostream &stream) {
return RemoteFunctionBase::execute(stream, in(), out()); return RemoteFunctionBase::execute(stream, in(), out());
} }
command_result operator() (color_ostream &stream, const In *input) { command_result operator() (color_ostream &stream, const In *input) {

@ -53,7 +53,8 @@ STRING(REPLACE ".proto" ".pb.h" PROJECT_PROTO_HDRS "${PROJECT_PROTOS}")
ADD_CUSTOM_COMMAND( ADD_CUSTOM_COMMAND(
OUTPUT ${PROJECT_PROTO_SRCS} ${PROJECT_PROTO_HDRS} OUTPUT ${PROJECT_PROTO_SRCS} ${PROJECT_PROTO_HDRS}
COMMAND protoc-bin -I=${dfhack_SOURCE_DIR}/proto/ -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/ COMMAND protoc-bin -I=${dfhack_SOURCE_DIR}/library/proto/
-I=${CMAKE_CURRENT_SOURCE_DIR}/proto/
--cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/proto/ --cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/proto/
${PROJECT_PROTOS} ${PROJECT_PROTOS}
DEPENDS protoc-bin ${PROJECT_PROTOS} DEPENDS protoc-bin ${PROJECT_PROTOS}