Add project files.

This commit is contained in:
alejo committed 2026-09-12 00:08:03 -03:00
commit 3087fcea8a
71 files changed
+8325

No files matched your search

@@ -0,0 +1,24 @@
# See ../PluginV1/CMakeLists.txt for why this is hand-written instead
# of add_lib_module() -- this is that same explanation's other half:
# PluginV2 exports the identical extern "C" names as PluginV1 (see
# ../Shared/PluginApi.h) with a different implementation standing in
# for "the same file, after your edit" in this demo's story.
if(BUILD_EXAMPLES)
add_library(hotreload_demo_plugin_v2 SHARED src/Plugin.cpp src/CppWidget.cpp)
else()
add_library(hotreload_demo_plugin_v2 SHARED EXCLUDE_FROM_ALL src/Plugin.cpp src/CppWidget.cpp)
endif()
target_include_directories(hotreload_demo_plugin_v2 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../Shared)
set_target_properties(hotreload_demo_plugin_v2 PROPERTIES
OUTPUT_NAME "hotreload_demo_plugin_v2"
WINDOWS_EXPORT_ALL_SYMBOLS ON)
_set_output_dirs(hotreload_demo_plugin_v2
"${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_SUBDIR}/examples"
"${CMAKE_BINARY_DIR}/${LIBRARY_OUTPUT_SUBDIR}/examples")
_apply_compile_options(hotreload_demo_plugin_v2)
hot_reload_enable_patchable_functions(hotreload_demo_plugin_v2)
_register_module_target(EXAMPLE hotreload_demo_plugin_v2)
add_dependencies(all_examples hotreload_demo_plugin_v2)
@@ -0,0 +1,31 @@
/* CppWidget V2 -- "after your edit". See PluginV1/src/CppWidget.cpp
* for "before".
*/
#include "CppWidgetApi.h"
#include <cstdio>
int CppWidget::virtualTick(int input)
{
int result = input * 3;
std::printf(" CppWidget::virtualTick(%d) -> %d [V2: input * 3, via vtable]\n", input, result);
return result;
}
int CppWidget::tick(int input)
{
int result = input * 3;
std::printf(" CppWidget::tick(%d) -> %d [V2: input * 3, via mangled-name lookup]\n", input, result);
return result;
}
CppWidget CppWidget::operator+(const CppWidget& /*other*/) const
{
std::printf(" CppWidget::operator+ [V2]\n");
return CppWidget();
}
extern "C" CppWidget* make_cpp_widget()
{
return new CppWidget();
}
@@ -0,0 +1,33 @@
/* PluginV2 -- "after your edit". See PluginV1/src/Plugin.cpp for
* "before". plugin_tick's behavior changed, plugin_legacy_feature was
* deleted, and plugin_new_feature was added -- exactly the three kinds
* of change hot_reload.h's HotReloadSymbolEvent enum distinguishes.
*/
#include "PluginApi.h"
#include <cstdio>
int plugin_tick(int input)
{
int result = input * 3;
std::printf(" plugin_tick(%d) -> %d [V2: input * 3]\n", input, result);
return result;
}
/* plugin_legacy_feature deliberately does not exist in V2 anymore. */
int plugin_new_feature(int input)
{
int result = input * 10;
std::printf(" plugin_new_feature(%d) -> %d [V2: brand new]\n", input, result);
return result;
}
#if defined(__GNUC__) || defined(__clang__)
int plugin_tiny_function(int input)
{
return input + 2;
}
#endif
int plugin_build_marker = 2;