Fix custom display function mechanism
Diffstat:
7 files changed, 12 insertions(+), 10 deletions(-)
@@ -17,8 +17,7 @@
target_include_directories(demo PRIVATE ${GENERATE_OUT} ${CMAKE_CURRENT_SOURCE_D
set_target_properties(demo PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
RUNTIME_OUTPUT_DIRECTORY "${GENERATE_OUT}"
)
RUNTIME_OUTPUT_DIRECTORY "${GENERATE_OUT}")
add_custom_command(
OUTPUT ${GENERATE_OUT}/demo_menu.h ${GENERATE_OUT}/demo_menu.c
@@ -40,6 +39,7 @@
set_target_properties(cdemo PROPERTIES
add_executable(dynamic dynamic.cpp)
target_link_libraries(dynamic stamen)
set_target_properties(dynamic PROPERTIES LINKER_LANGUAGE CXX)
set_target_properties(dynamic PROPERTIES
VERSION ${PROJECT_VERSION}
@@ -1,9 +1,8 @@
#include "stamen.hpp"
#include <iostream>
// need to link against stamen library
// in order to use stamen::builtin_display
const stamen::display_f &stamen::display = stamen::builtin_display;
// need to link against stamen library in order to use stamen::builtin_display
const stamen::display_f stamen::stamen_display = stamen::builtin_display;
int finish(int) { exit(1); }
@@ -3,9 +3,8 @@
#include <iostream>
// need to link against stamen library
// in order to use stamen::builtin_display
const stamen::display_f &stamen::display = stamen::builtin_display;
// need to link against stamen library in order to use stamen::builtin_display
const stamen::display_f stamen::stamen_display = stamen::builtin_display;
int operation1(int) {
std::cout << "operation 1" << std::endl;
@@ -32,6 +32,7 @@
class Menu {
display_stub_default = code;
return display_stub(-1);
};
static void read(const std::string &s);
static void print(const std::string &entry) { print(entry, 1); }
static void insert(const std::string &s, callback_f callback) {
@@ -8,6 +8,8 @@
namespace stamen {
const stamen_display_f stamen_display = stamen::builtin_display;
class Generator {
public:
static void generateInclude(std::ostream &os, bool cpp) {
@@ -61,8 +61,7 @@
int Menu::display_stub(int idx) {
if (ml_it != menu_lookup.end()) {
const Menu &menu = ml_it->second;
st.push_back(&menu);
int ret = builtin_display(menu.title.c_str(), menu.getItemv(),
menu.getSize());
int ret = display(menu.title.c_str(), menu.getItemv(), menu.getSize());
st.pop_back();
return ret;
}
@@ -9,6 +9,8 @@
namespace stamen {
const display_f &display = stamen_display;
int dynamic(const char *code) { return Menu::dynamic(code); }
void read(const char *filename) { Menu::read(filename); }
void insert(const char *code, callback_f callback) {