Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data bindings for lua plugin #146

Merged
merged 1 commit into from
Nov 8, 2020
Merged

Conversation

cloudwu
Copy link
Contributor

@cloudwu cloudwu commented Nov 8, 2020

It may be a good start for data binding lua plugin. (#145)

It only support string/bool/int/double data binding now, but I think it's easy to extend.

About lifespan mangement :

context:OpenLuaDataModel will create a DataModel userdata in lua, and we can set and get scalar by it . See Samples/luainvaders/lua/start.lua

We should ensure it lives before C++ DataModel object, and should call CloseLuaDataModel after C++ DataModel released.

btw, PushVariant and GetVariant may have similar implementation in offical lua plugin.

@mikke89
Copy link
Owner

mikke89 commented Nov 8, 2020

This is very cool! Very much appreciate the contribution.

The lifetime sounds a bit like an issue. Perhaps hooking into Plugin::OnContextDestroy could be helpful, and then close all the LuaDataModels, including their underlying data models. Or perhaps we could make a new plugin API to capture destruction of data models. I'll merge this for now, and then we can think about a solution for later.

Thanks again!

@mikke89 mikke89 added the Lua Lua binding issues label Nov 8, 2020
@mikke89 mikke89 merged this pull request into mikke89:data_binding Nov 8, 2020
@cloudwu
Copy link
Contributor Author

cloudwu commented Nov 8, 2020

For the lifetime issue, we can create a table associate to LuaContext object , and putting every LuaDataModels into the table.

Another issue is that Context:OpenLuaDataModel can open one DataModel object multiple times now, it can be avoid by this table.

When the Context destroy, we can simply close all the LuaDataModels.

I don’t implement these yet, because I tend to put these into lua side.It’s easier but at first we need a lua layer for the plugin framework rather than putting most things in C++ side. That is to say , the api context:OpenLuaDataModel could be a Lua function rather than a C function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data binding Lua Lua binding issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants