Skip to content

Commit 2267d70

Browse files
committed
Start refactoring examples
Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
1 parent 3e879fe commit 2267d70

17 files changed

Lines changed: 47 additions & 33 deletions

File tree

cpp/csp/adapters/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,4 @@ if(CSP_BUILD_WS_CLIENT_ADAPTER)
1111
add_subdirectory(websocket)
1212
endif()
1313

14-
15-
add_subdirectory(c)
1614
add_subdirectory(utils)

cpp/csp/adapters/c/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

cpp/csp/python/adapters/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,3 @@ if(CSP_BUILD_WS_CLIENT_ADAPTER)
4646
target_link_libraries(websocketadapterimpl csp_core csp_engine cspimpl csp_websocket_client_adapter)
4747
install(TARGETS websocketadapterimpl RUNTIME DESTINATION ${CSP_RUNTIME_INSTALL_SUBDIR})
4848
endif()
49-
50-
add_subdirectory(c)

cpp/csp/python/adapters/c/CMakeLists.txt

Lines changed: 0 additions & 28 deletions
This file was deleted.

examples/05_cpp/1_cpp_node/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ Output:
2424
2020-01-01 00:00:05 input:fun
2525
2020-01-01 00:00:05 output:UNFAY
2626
```
27+
28+
> [!WARNING]
29+
> This example is for demonstration, and is a pattern CSP uses internally for fast nodes.
30+
> It is not recommended to use as the C++ API is not stable and may change without notice. Use at your own risk.
31+
> For adapters, we have a stable C API that is recommended to use instead. See [C API Adapter](../4_c_api_adapter/README.md) example for more details.

examples/05_cpp/2_cpp_node_with_struct/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ Run:
1313
```bash
1414
python -m mystruct
1515
```
16+
17+
> [!WARNING]
18+
> This example is for demonstration, and is a pattern CSP uses internally for fast nodes.
19+
> It is not recommended to use as the C++ API is not stable and may change without notice. Use at your own risk.
20+
> For adapters, we have a stable C API that is recommended to use instead. See [C API Adapter](../4_c_api_adapter/README.md) example for more details.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Custom C++ Adapter
2+
3+
> [!WARNING]
4+
> This example is for demonstration, and is a pattern CSP uses internally for adapters.
5+
> It is not recommended to use as the C++ API is not stable and may change without notice. Use at your own risk.
6+
> For adapters, we have a stable C API that is recommended to use instead. See [C API Adapter](../4_c_api_adapter/README.md) example for more details.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Custom C++ Adapter via C API

cpp/csp/adapters/c/example/CMakeLists.txt renamed to examples/05_cpp/4_c_api_adapter/cpp/CMakeLists.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,32 @@ install(TARGETS csp_c_example_adapter
3636
RUNTIME DESTINATION ${CSP_RUNTIME_INSTALL_SUBDIR}
3737
LIBRARY DESTINATION lib/
3838
)
39+
40+
# Python bindings for example C adapters
41+
42+
# This creates a Python extension module
43+
Python_add_library(_exampleadapterimpl MODULE exampleadapterimpl.c)
44+
45+
# Link with the example adapter library
46+
target_link_libraries(_exampleadapterimpl PRIVATE
47+
csp_c_example_adapter
48+
)
49+
50+
# Include directories
51+
target_include_directories(_exampleadapterimpl PRIVATE
52+
${CMAKE_SOURCE_DIR}/cpp
53+
${Python_INCLUDE_DIRS}
54+
)
55+
56+
# Set output name without lib prefix
57+
set_target_properties(_exampleadapterimpl PROPERTIES
58+
PREFIX ""
59+
C_STANDARD 11
60+
C_STANDARD_REQUIRED ON
61+
)
62+
63+
# Install to the Python package location
64+
install(TARGETS _exampleadapterimpl
65+
LIBRARY DESTINATION ${CSP_RUNTIME_INSTALL_SUBDIR}
66+
RUNTIME DESTINATION ${CSP_RUNTIME_INSTALL_SUBDIR}
67+
)

cpp/csp/adapters/c/example/ExampleManagedAdapter.c renamed to examples/05_cpp/4_c_api_adapter/cpp/ExampleManagedAdapter.c

File renamed without changes.

0 commit comments

Comments
 (0)