Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: ysc3839 on Jun 22, 2016, 09:38 AM

Title: Destructors in Squirrel?
Post by: ysc3839 on Jun 22, 2016, 09:38 AM
Does Squirrel have class destructors?
Title: Re: Destructors in Squirrel?
Post by: Xmair on Jun 22, 2016, 10:05 AM
I think no.
Title: Re: Destructors in Squirrel?
Post by: ysc3839 on Jun 22, 2016, 10:08 AM
Also can I make destructors using squirrel plugin?
Title: Re: Destructors in Squirrel?
Post by: Finch Real on Jun 22, 2016, 10:11 AM
I think Yes
Title: Re: Destructors in Squirrel?
Post by: . on Jun 22, 2016, 10:57 AM
Quote from: ysc3839 on Jun 22, 2016, 09:38 AMDoes Squirrel have class destructors?

No, Squirrel does not have any concept of destructors.

Quote from: ysc3839 on Jun 22, 2016, 10:08 AMAlso can I make destructors using squirrel plugin?

Yes, but not for script types. For your registered types.
Title: Re: Destructors in Squirrel?
Post by: ysc3839 on Jun 22, 2016, 02:18 PM
Quote from: . on Jun 22, 2016, 10:57 AM
Quote from: ysc3839 on Jun 22, 2016, 09:38 AMDoes Squirrel have class destructors?

No, Squirrel does not have any concept of destructors.

Quote from: ysc3839 on Jun 22, 2016, 10:08 AMAlso can I make destructors using squirrel plugin?

Yes, but not for script types. For your registered types.
Thanks. I want to know if I registered a class using plugin, can it support destructors?
Also, is there any sample code?
Title: Re: Destructors in Squirrel?
Post by: . on Jun 22, 2016, 02:46 PM
Register it how? With Sqrat the binding utility or manually through the provided API?
Title: Re: Destructors in Squirrel?
Post by: ysc3839 on Jun 22, 2016, 03:05 PM
Quote from: . on Jun 22, 2016, 02:46 PMRegister it how? With Sqrat the binding utility or manually through the provided API?
Thanks. I'll see sqrat.
Solved.
Title: Re: Destructors in Squirrel?
Post by: . on Jun 22, 2016, 03:22 PM
Quote from: ysc3839 on Jun 22, 2016, 03:05 PMThanks. I'll see sqrat.
Solved.

Using Sqrat in modules for the official plugin could prove to be a bit difficult without compiling Squirrel into your module again (must be same version). You might be able to trick Sqrat and use it without having to link your program to Squirrel.
Title: Re: Destructors in Squirrel?
Post by: ysc3839 on Jun 22, 2016, 03:37 PM
Quote from: . on Jun 22, 2016, 03:22 PM
Quote from: ysc3839 on Jun 22, 2016, 03:05 PMThanks. I'll see sqrat.
Solved.

Using Sqrat in modules for the official plugin could prove to be a bit difficult without compiling Squirrel into your module again (must be same version). You might be able to trick Sqrat and use it without having to link your program to Squirrel.
Thanks. I'm seeing 0.4 Socket.
Title: Re: Destructors in Squirrel?
Post by: . on Jun 22, 2016, 03:50 PM
Quote from: ysc3839 on Jun 22, 2016, 03:37 PMThanks. I'm seeing 0.4 Socket.

Well, that's because it compiles Squirrel again into the module. You should find the actual Squirrel source in there with the module. Which is not ideal. because you will end up having a VM that will receive memory allocations from both the main plugin and your module. Either way, you're in for some subtle crashes if you follow the same approach.

You could look at how I made Sqrat think that Squirrel is compiled into my modules here (https://github.com/iSLC/VCMP-SqMod/tree/master/shared). Although, it involved making some modifications to Sqrat (regarding what headers it should include). Actually, I did a lot of other modifications to Sqrat as well. But that's ok since Sqrat is no longer updated. This (https://github.com/iSLC/VCMP-SqMod/blob/master/shared/SqMod.inl) is what should interest you. And this (https://github.com/iSLC/VCMP-SqMod/blob/master/shared/SqAPI.h).
Title: Re: Destructors in Squirrel?
Post by: ysc3839 on Jun 23, 2016, 03:31 AM
Quote from: . on Jun 22, 2016, 03:50 PM
Quote from: ysc3839 on Jun 22, 2016, 03:37 PMThanks. I'm seeing 0.4 Socket.

Well, that's because it compiles Squirrel again into the module. You should find the actual Squirrel source in there with the module. Which is not ideal. because you will end up having a VM that will receive memory allocations from both the main plugin and your module. Either way, you're in for some subtle crashes if you follow the same approach.

You could look at how I made Sqrat think that Squirrel is compiled into my modules here (https://github.com/iSLC/VCMP-SqMod/tree/master/shared). Although, it involved making some modifications to Sqrat (regarding what headers it should include). Actually, I did a lot of other modifications to Sqrat as well. But that's ok since Sqrat is no longer updated. This (https://github.com/iSLC/VCMP-SqMod/blob/master/shared/SqMod.inl) is what should interest you. And this (https://github.com/iSLC/VCMP-SqMod/blob/master/shared/SqAPI.h).
I don't know what you mean. 0.4 Socket source code don't include Squirrel. It uses main plugin's Squirrel VM.