GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - kornerr/cpp-callback-script: A C++ application with Lua scripting support to do callbacks

BranchesTags
Open more actions menu

Latest commit

 

History

30 Commits
30 Commits

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
.gitignore
.gitignore
 
 
CMakeLists.txt
CMakeLists.txt
 
 
README.md
README.md
 
 
script.lua
script.lua
 
 

Repository files navigation

Overview

cpp-callback-script is a sample C++ application that is extended by a Lua script.

Dependencies

To run the sample, you need to have the following libraries installed:

  • Lua
  • Sol2

Structure

The sample application provides an abstraction to separate functionality into several modules with the help of Environment and EnvironmentClient classes.

Such a separation allows one to provide parts of the application either as a C++ code, or a Lua one.

Environment

The application has Environment that provides a member function with the following signature: Strings call(const String &key, const Strings &values).

The function passes a list of string values (std::vector) to the specified key and returns a result as another list of string values.

EnvironmentClient

The application also has EnvironmentClient that serves as a callback container for third parties wishing to interact indirectly through Environment.

EnvironmentClient has the following callbacks:

  • callbackRespondsToKey returns a list keys this particular EnvironmentClient instance responds to
  • callbackCall returns a list of keys as a result of running provided callback

The callbacks use std::function to remove the need for third parties to inherit EnvironmentClient to specify custom behaviour.

C++ side

runCPP function inside main.cpp registers two EnvironmentClient instances that respond to different keys.

Lua side

runSol function inside main.cpp registers Environment, EnvironmentClient with Lua (using Sol2), and then runs script.lua.

script.lua, in its turn, creates an instance of EnvironmentClient that responds to a new key.

About

A C++ application with Lua scripting support to do callbacks

Topics

callbackcppluascriptsol2

Resources

Readme
Activity

Stars

1 star

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.