Comments (2)
I will consider it but there the problem of how SLB should treat the memory of
object "f", for example:
{
Foo f;
m->set("Bar", ... , &f);
}
after the block f is no longer a valid pointer... but this, can lead to memory
leaks:
{
Foo *f = new Foo();
m->set("Bar", ... , &f);
}
So, in the end its better to wrap Foo class with SLB and make some sort of
wrapper around a given object instead. I will consider how to do it, but if you
have any insight about the management of the memory it would be great to know.
Original comment by [email protected]
on 19 Feb 2012 at 1:00
- Changed state: Accepted
from slb.
It is a tricky problem. I think the only options are to force the user to make
sure they don't do silly things like that and hope they manage their memory
correctly, OR do something like you have mentioned and have a wrapper that SLB
uses to manage the lifetime of the object. The user then might do something
like (if they wanted to manually remove the binding and clean the memory being
used):
m->unset("Bar");
However, this doesn't stop them from doing silly things like this:
{
Foo *f = new Foo();
m->set("Bar", ... , &f);
delete f;
m->unset("Bar"); // potential crash
}
I don't think this is a major concern though as the user should still be
responsible for overall management.
In any case, I think adding member function support would be really useful
feature. I just moved over to SLB from luabind and I'm really liking it. The
member function ability is the only thing I feel it is lacking at the moment.
Nice work so far!
Original comment by [email protected]
on 19 Feb 2012 at 9:59
from slb.
Related Issues (20)
- unable to call a const std::string foo() const; method. HOT 7
- doesn't work with bool HOT 2
- compilation fails with clang-2.9 HOT 2
- call base class's functions from a 3rd level derived class does not resolve HOT 2
- Default error handler doesn't clear the buffer HOT 2
- SLB::Script::setPrintCallback undefined HOT 1
- Error messages get stomped when loading files HOT 1
- Unable to register variadic (/vararg/ellipsis) C functions using SLB::Manager HOT 1
- Wrong function called in __Self &__eq( bool (*func)(T1,T2) ) in Class.hpp HOT 1
- Missing stdlib include causes malloc to not be linked properly HOT 1
- HG 2013-03-19 Linux Compilation Issues
- [REQ] Add support for object properties HOT 2
- Parameter checking
- Doesn't compile on gcc4.7 when c++11 is enabled (fix attached)
- [REQ] Add property for class from SLB2
- Trailing comma in enum HOT 2
- Warnings with VS2010 /W4 HOT 2
- Could not HOT 1
- Could not complie on android ndk r5 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slb.