Skip to content

Commit

Permalink
Fix websocket javascript client. Add FindIod.cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-42 committed Mar 20, 2016
1 parent 8bd572f commit a41050c
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 5 deletions.
10 changes: 10 additions & 0 deletions cmake/FindIod.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Locate the iod library
# define IOD_INCLUDE_DIR

FIND_PATH(IOD_INCLUDE_DIR iod/sio.hh
$ENV{HOME}/local/include
/usr/include
/usr/local/include
/sw/include
/opt/local/include
DOC "Iod include dir")
3 changes: 3 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
cmake_minimum_required(VERSION 2.8)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
${CMAKE_SOURCE_DIR}/../cmake)

find_package( Iod )
find_package( Boost COMPONENTS system thread date_time program_options filesystem chrono)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/.. ${IOD_INCLUDE_DIR}
Expand Down
50 changes: 47 additions & 3 deletions silicon/clients/javascript_client.hh
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,53 @@ namespace sl
inline std::string return_type_string(std::string*) { return "string"; }
template <typename... T>
std::string return_type_string(sio<T...>*) { return "object"; }

template <typename P, typename Ro, typename W>
void generate_procedure(P p, Ro route, std::string tpl, W& write, path_generator path)
{
typedef std::remove_reference_t<decltype(p.value().content.function())> F;
typedef std::remove_reference_t<std::remove_const_t<callable_return_type_t<F>>> R;

tpl_generator(
tpl, write,

"procedure_path", [&] (const char*&) {
write(path(p.symbol().name()));
},
"procedure_description", [&] (const char*&) {
write(procedure_description(p.value().route, p.value().content));
},
"procedure_url_string", [&] (const char*&) {
write(path(p.symbol().name(), "/", true));
},
"procedure_url", [&] (const char*&) {
auto url = p.value().route;
write("{");
foreach(url.path) | [&] (auto e)
{
std::string name =
static_if<is_symbol<decltype(e)>::value>(
[&] (auto e) { return e.name(); },
[&] (auto e) { return e.symbol().name(); }, e);

write(name + ": { is_param: " +
(!is_symbol<decltype(e)>::value ? "true" : "false") + "},");
};
write("}");
},

"return_type", [&] (const char*&) {
write(return_type_string((R*)0));
},
"root_scope", [&] (const char*&) {
write(path.root());
}

);
}

template <typename P, typename W>
void generate_procedure(P p, std::string tpl, W& write, path_generator path)
template <typename P, typename... Ro, typename W>
void generate_procedure(P p, const http_route<Ro...>& route, std::string tpl, W& write, path_generator path)
{
typedef std::remove_reference_t<decltype(p.value().content.function())> F;
typedef std::remove_reference_t<std::remove_const_t<callable_return_type_t<F>>> R;
Expand Down Expand Up @@ -197,7 +241,7 @@ namespace sl
[] (auto m) {
},
[&] (auto m) {
generate_procedure(m, proc_tpl, write, path);
generate_procedure(m, m.value().route, proc_tpl, write, path);
}, m);
};

Expand Down
6 changes: 4 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
cmake_minimum_required(VERSION 2.8)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
${CMAKE_SOURCE_DIR}/../cmake)

enable_testing()


find_package( Iod )
find_package( OpenSSL )
find_package( Threads )
find_package( Boost COMPONENTS system thread date_time program_options filesystem chrono)
Expand All @@ -19,7 +21,7 @@ if (OPENSSL_FOUND)
include_directories(${OPENSSL_INCLUDE_DIR})
endif (OPENSSL_FOUND)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/.. $ENV{HOME}/local/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../third_party/mimosa/
${CMAKE_CURRENT_SOURCE_DIR}/../third_party/websocketpp/
${CMAKE_CURRENT_SOURCE_DIR}/../third_party/install/include
Expand Down

0 comments on commit a41050c

Please sign in to comment.