Skip to content

Commit a41050c

Browse files
committed
Fix websocket javascript client. Add FindIod.cmake
1 parent 8bd572f commit a41050c

File tree

4 files changed

+64
-5
lines changed

4 files changed

+64
-5
lines changed

cmake/FindIod.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Locate the iod library
2+
# define IOD_INCLUDE_DIR
3+
4+
FIND_PATH(IOD_INCLUDE_DIR iod/sio.hh
5+
$ENV{HOME}/local/include
6+
/usr/include
7+
/usr/local/include
8+
/sw/include
9+
/opt/local/include
10+
DOC "Iod include dir")

examples/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
cmake_minimum_required(VERSION 2.8)
2+
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
3+
${CMAKE_SOURCE_DIR}/../cmake)
24

5+
find_package( Iod )
36
find_package( Boost COMPONENTS system thread date_time program_options filesystem chrono)
47

58
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/.. ${IOD_INCLUDE_DIR}

silicon/clients/javascript_client.hh

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,53 @@ namespace sl
113113
inline std::string return_type_string(std::string*) { return "string"; }
114114
template <typename... T>
115115
std::string return_type_string(sio<T...>*) { return "object"; }
116+
117+
template <typename P, typename Ro, typename W>
118+
void generate_procedure(P p, Ro route, std::string tpl, W& write, path_generator path)
119+
{
120+
typedef std::remove_reference_t<decltype(p.value().content.function())> F;
121+
typedef std::remove_reference_t<std::remove_const_t<callable_return_type_t<F>>> R;
122+
123+
tpl_generator(
124+
tpl, write,
125+
126+
"procedure_path", [&] (const char*&) {
127+
write(path(p.symbol().name()));
128+
},
129+
"procedure_description", [&] (const char*&) {
130+
write(procedure_description(p.value().route, p.value().content));
131+
},
132+
"procedure_url_string", [&] (const char*&) {
133+
write(path(p.symbol().name(), "/", true));
134+
},
135+
"procedure_url", [&] (const char*&) {
136+
auto url = p.value().route;
137+
write("{");
138+
foreach(url.path) | [&] (auto e)
139+
{
140+
std::string name =
141+
static_if<is_symbol<decltype(e)>::value>(
142+
[&] (auto e) { return e.name(); },
143+
[&] (auto e) { return e.symbol().name(); }, e);
144+
145+
write(name + ": { is_param: " +
146+
(!is_symbol<decltype(e)>::value ? "true" : "false") + "},");
147+
};
148+
write("}");
149+
},
150+
151+
"return_type", [&] (const char*&) {
152+
write(return_type_string((R*)0));
153+
},
154+
"root_scope", [&] (const char*&) {
155+
write(path.root());
156+
}
157+
158+
);
159+
}
116160

117-
template <typename P, typename W>
118-
void generate_procedure(P p, std::string tpl, W& write, path_generator path)
161+
template <typename P, typename... Ro, typename W>
162+
void generate_procedure(P p, const http_route<Ro...>& route, std::string tpl, W& write, path_generator path)
119163
{
120164
typedef std::remove_reference_t<decltype(p.value().content.function())> F;
121165
typedef std::remove_reference_t<std::remove_const_t<callable_return_type_t<F>>> R;
@@ -197,7 +241,7 @@ namespace sl
197241
[] (auto m) {
198242
},
199243
[&] (auto m) {
200-
generate_procedure(m, proc_tpl, write, path);
244+
generate_procedure(m, m.value().route, proc_tpl, write, path);
201245
}, m);
202246
};
203247

tests/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
cmake_minimum_required(VERSION 2.8)
2+
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
3+
${CMAKE_SOURCE_DIR}/../cmake)
24

35
enable_testing()
46

5-
7+
find_package( Iod )
68
find_package( OpenSSL )
79
find_package( Threads )
810
find_package( Boost COMPONENTS system thread date_time program_options filesystem chrono)
@@ -19,7 +21,7 @@ if (OPENSSL_FOUND)
1921
include_directories(${OPENSSL_INCLUDE_DIR})
2022
endif (OPENSSL_FOUND)
2123

22-
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
24+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/.. $ENV{HOME}/local/include)
2325
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../third_party/mimosa/
2426
${CMAKE_CURRENT_SOURCE_DIR}/../third_party/websocketpp/
2527
${CMAKE_CURRENT_SOURCE_DIR}/../third_party/install/include

0 commit comments

Comments
 (0)