Skip to content

Use reference to convert object to lua - #78

Open
therustmonk wants to merge 1 commit into
jcmoyer:masterfrom
therustmonk:tolua-ref
Open

Use reference to convert object to lua#78
therustmonk wants to merge 1 commit into
jcmoyer:masterfrom
therustmonk:tolua-ref

Conversation

@therustmonk

@therustmonktherustmonk commented Mar 3, 2017

Copy link
Copy Markdown
Contributor

Current push declaration is:

implState{fnpush<T:ToLua>(&mutself,value:T)}

But ToLua satisfied with the reference &self (it doesn't need to own the instance).

traitToLua{fnto_lua(&self,state:&mutState)}

I don't see any reason to own the value inside push.
But owning makes hard to push nested structs with this generic push method, because we have convert nested items to owned (clone) to satisfy push declaration.

This PR makes tiny backward-incompatible change and uses reference only to push objects ToLua.

implState{fnpush<T:ToLua>(&mutself,value:&T)}

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@therustmonk