Added Sqrat::ClassType::IsValidInstance static method:
Just to clarify: PushVarR exists to force something to be a reference even when its not, while PushVar can do copies and references
Just to clarify: PushVarR exists to force something to be a reference even when its not
Replaced Sqrat::PushVar to Sqrat::PushVarR in Sqrat::Function Evaluate/Execute methods.
Glad it works!
It works, i think it's safe to say that closing this merge request is the best approach, because this might break too many things.
I'll try this approach and let you know about the results.
About that: ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Called by Sqrat::PushVar to put a class object on the stack /// /// \param vm Target VM /// \param value Value to push on to the VM's stack /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// static void push(HSQUIRRELVM vm, const T& val) { if (ClassType<T>::hasClassData(vm)) ClassType<T>::PushInstanceCopy(vm,...
About that: ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Called by Sqrat::PushVar to put a class object on the stack /// /// \param vm Target VM /// \param value Value to push on to the VM's stack /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// static void push(HSQUIRRELVM vm, const T& val) { if (ClassType<T>::hasClassData(vm)) ClassType<T>::PushInstanceCopy(vm,...
Make sure you are calling Evaluate/Execute with the correct template typenames. Do not let the compiler guess the argument types for you
Make sure you are calling Evaluate/Execute with the correct templates. Do not let the compiler guess them for you
If the current way doesn't work (verifiable using a debugger and some breakpoints to see if its triggering the correct code) and can't be made to work, then I'd be willing to accept this change as long as it doesn't have unforeseen consequences. It looks like it would force everything to be references always, which would definitely cause issues.
Not that it was thoroughly tested, but notice how in sqratTypes.h there are overloads for references, pointers, and even SharedPtr that all use PushInstance rather than PushInstanceCopy. If the template magic is happening correctly, then this should be happening already.
Replaced Sqrat::PushVar to Sqrat::PushVarR in Sqrat::Function Evaluate/Execute methods.
Fixed sqrat not being completely updated to squirrel 3.2
Fixed sqrat not being completely updated to squirrel 3.2
Updated sqrat for squirrel 3.2 version
Updated sqrat for squirrel 3.2 version
.SquirrelProp method for Sqrat::Class
The comment was corrected.
These method(s) are useful when you don't want to add _get & _set just to add raw closures as getter & setter. They can be utilized to make a property that can return multiple data types.
The comment on the one with a getter+setter says it's read-only, but otherwise looks good
Thise method(s) are useful when you don't want to add _get & _set just to add raw closures as getter & setter. They can be utilized to make a property that can return multiple data types.
.SquirrelProp method for Sqrat::Class
Arguments validation for .SquirrelFunc method in Sqrat::Array & Sqrat::Class
Arguments validation for .SquirrelFunc method in Sqrat::Array & Sqrat::Class
Added possibility to bind temporary cpp object
Added possibility to bind temporary cpp object
added missing sq_pop, added #undef GetObject
Now :)
The merge request still has zero commits. Let me know when it has content
added missing sq_pop, added #undef GetObject
Added Sqrat::Var<SQUserPointer> support
Done
Tabs to spaces and should be good :)
Done.
Similarly, maybe moving Sqrat::Var<std::nullpt_t> would also be good idea to this file? What do you think?
Ok, i'll make some adjustments.
Similarly, maybe moving Sqrat::Var<std::nullpt_t> would also be good idea to this file? What do you think?</std::nullpt_t>
That would be more fitting. It'd also make sense to put sqratNull.h in there
No problem, i'll correct it, one question, maybe it would be more fitting to move the code into sqratTypes.h file?
No problem, i'll correct it, one question, maybe it would be more fitting to move it into sqratTypes.h file?
Needs the tabs to be spaces so it matches the current code but then can be merged
Added Sqrat::Var<SQUserPointer> support
Fixed possible compiler error in SqratBytecode.h
Fixed possible compiler error in SqratBytecode.h
Add null support
Add null support
Arguments validation for .SquirrelFunc method
Arguments validation for .SquirrelFunc method
Glad you got it worked out! The way I chose to do errors is pretty weird, but I was trying to make it backwards compatible because Sqrat started off with no error checking at all! (it actually works quite a bit faster too when you compile with error checking off)
Different behavior if calling GetValue before SetValue on table
Glad you got it worked out! The way I chose to do errors is pretty weird, but I was trying to make it backwards compatible because Sqrat started off with no error checking at all!
Hi Wizzard, it looks like I didn't read the API documentation very well. It's setting the error in the VM and it needs to be cleared. Clearing the error between the GetValue and SetValue fixed it: Sqrat::Error::Clear(vm); It's a bit unfortunate you have to know to do this but no change to the code should be needed.
Hi Wizzard. I was able to isolate the problem in the code I was writing to this behavior in Sqrat/squirrel. I haven't taken the time yet to find and fix the issue. I was hoping you had some idea what might be going wrong. I can keep looking at it if you like. Below is the output I got from the test case. In both cases it will call the SetValue but only case A returns the table in the last GetValue call (the one after SetValue). Test Case A =========== Set Get OK Test Case B =========== Set Get F...
Different behavior if calling GetValue before SetValue on table
Can you tell me the output of your example? I'm willing to accept a pull request submitted by you that fixes this behavior and try to help you work through it if needed.
Different behavior if calling GetValue before SetValue on table
HSQAPI and typeof (compile error)
Fix compile error for gcc
type_of should be fine
Fix compile error for gcc
Propably the best name for this function would be: type_of. It kinda breaks the naming rule, but it's the most elegant equivalent that i thought of.
I've discovered a new issue with changes made in this MR. https://sourceforge.net/p/scrat/sqrat/106/ Please, give me some feedback.
HSQAPI and typeof (compile error)
Sqrat::Function fails to release env ref when the obj closure is null
I think you should pass valid functions/closures to Sqrat::Function instead of null. I remember trying to look through this when it was first posted to figure out what the exact behavior should be but getting sidetracked. I'm going to close this for now, but if the behavior could be made more convenient then feel free to submit a pull request with some changes!
I went ahead and merged this. Hopefully incompatibilities are easily resolved!
Added missing function in HSQAPI struct
Added missing function in HSQAPI struct
Sqrat::Function fails to release env ref when the obj closure is null
Function::Evaluate doesn't handle native closures correctly when SCRAT_NO_ERROR_CHECKING is undefined
Fixed by https://sourceforge.net/p/scrat/code/ci/6758c0010cdcabab0bcc033f64a4d01d7ec3a9a9/
Pull request for Issue #103: Function::Evaluate doesn't handle native closures correctly when SCRAT_NO_ERROR_CHECKING is undefined
Pull request for Issue #103: Function::Evaluate doesn't handle native closures correctly when SCRAT_NO_ERROR_CHECKING is undefined
Setting an object equal to itself yields unexpected results
Fixed in https://sourceforge.net/p/scrat/code/ci/36392c35317708a3616f24f6742d163002b8ee7a/
Pull request for Issue #104 fix
Pull request for Issue #104 fix
Sorry, it's a bit more complicated than that: error C2678: binary '!=': no operator found which takes a left-hand operand of type 'HSQOBJECT' (or there is no acceptable conversion)
Yes, this does the trick, thanks!
Nevermind, just saw your reply
This works, but could probably be done better. I'm having to use DefaultVM::Get() because in my project I hit various points where either the left hand object has a null vm or the right hand object has a null vm, and either case will crash. Object& operator=(const Object& so) { if(*this != so) { if(release) { Release(); } vm = so.vm; obj = so.obj; sq_addref(vm, &GetObject()); } return *this; } bool operator!= ( const Object& so ) const { return !( *this == so ); } bool operator== ( const Object&...
I mistook HSQOBJECT to by a typedef to a pointer. As long as every Sqrat::Object has its own unique HSQOBJECT, the following will work as far as I can tell. Object& operator=(const Object& so) { if(this != &so) { if(release) { Release(); } vm = so.vm; obj = so.obj; sq_addref(vm, &GetObject()); } return *this; }
Sorry, it's a bit more complicated than that: error C2678: binary '!=': no operator found which takes a left-hand operand of type 'HSQOBJECT' (or there is no acceptable conversion) SqPlus uses this for operator== bool SquirrelObject::operator == (const SquirrelObject &o) { bool cmp = false; HSQUIRRELVM v = SquirrelVM::GetVMPtr(); int oldtop = (int)sq_gettop(v); sq_pushobject(v, GetObjectHandle()); sq_pushobject(v, o.GetObjectHandle()); if(sq_cmp(v) == 0) cmp = true; sq_settop(v, oldtop); return cmp;...
If you could check if that works and do a pull request it'd be appreciated!
The sq_resetobject call probably needs to stay immediately after the sq_release call (problems were introduced by not following this convention in other places before), and so the issue should be fixed by checking if the object is the same. I also took the liberty of removing the release = so.release part because it felt correct to, but that might be wrong. Object& operator=(const Object& so) { if(obj != so.obj) { if(release) { Release(); } vm = so.vm; obj = so.obj; sq_addref(vm, &GetObject()); }...
if (SQ_SUCCEEDED(sq_getclosureinfo(vm, -2, &nparams, &nfreevars)) && (nparams != 1) && (nparams != 0)) {
This is definitely an issue with Sqrat. You're not really supposed to call sq_getclosureinfo on a native closure. The most correct thing to do would be to ignore this check if it's a native closure. However, it might also suffice just to add a nparams != 0 check to all the Evaluate functions. I'll accept a pull request if you add the checks in and can verify it fixes the issue.
Sorry, meant to say "or the intrinsic sq_resetobject should be rethought."
Setting an object equal to itself yields unexpected results
Function::Evaluate doesn't handle native closures correctly when SCRAT_NO_ERROR_CHECKING is undefined
If you're able to submit a pull request that fixes these compiler-specific warnings without changing any functionality, I'll accept it.
Binding a member float var produces verbose compiler warnings in MSVC 2017
Missing sq->getfloat pointer assignment in sqratimport.cpp
Merged fix by Patrix
#101 Fix (sq->getfloat)
#101 Fix (sq->getfloat)
Missing sq->getfloat pointer assignment in sqratimport.cpp