[Finished] [RGSS] Ruby/C++ Interfaces

Started by Blizzard, March 15, 2011, 03:50:54 pm

Previous topic - Next topic

ForeverZer0

Could we simply add a "gc_mark" method to it as well. This can check when it is no longer referenced on the Ruby side, then it can be deleted accordingly by the garbage collector.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Ryex

ah, I see. Data_Wrap_Struct has two arguments 'mark' and 'free' that point to functions called during garbage collection. I'de rather wait till Blizz dose an example of it though.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

ForeverZer0

Yeah, I thought of attempting to do it, but I have a feeling I would screw it up somehow. I figured he will explain it when we get to that part.   :P
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

Yes, gc_mark is the thing that should be used for that and gc_free (the parameter after gc_mark in Data_Make_Struct). I'll handle that for the first class. When I have figured it out completely, you guys can do the rest. But you figured that already out. xD
Check out our game brands:

Daygames
Game Night Games
Chugnar Games

Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

ForeverZer0

I'm gonna begin to interface the Tilemap class now.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Ryex

I'm going to work on plane. after that we should have at the interfaces done at least
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Blizzard

Alright. Once you are done, move this topic. I was busy today so I couldn't work on the Bitmap implementation. I'll see if I can do it tomorrow.
Check out our game brands:

Daygames
Game Night Games
Chugnar Games

Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

ForeverZer0

Quote from: Ryex on March 21, 2011, 06:16:13 pm
I'm going to work on plane. after that we should have at the interfaces done at least


We actually still have Font, RGSSError, and Viewport.

G_G is working on Viewport as far as I know, so I will do Font tonight. If I have time and are up to it, I may try to do RGSSError as well. I think it only has like three methods anyway.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

G_G

I have it like half done. Will do rest after homework. .-. completely spaced my mind today, had plenty of time to work on it. Sorry.

Ryex

- interfaced the Plane class
I did a check and I was wrong it seems
so far the classes left to be interfaces are Font, RGSSError, and Viewport

G_G wanted to work on Viewport if I remember right but I think he is having trouble getting on the the computer so if he doesn't finish it soon lets just do it for him and move on. (Sorry G_G)

EDIT: lol right as I went to post this you posted Zer0

EDIT: while I did my edit G_G posted LOL!
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

ForeverZer0

I interfaced RGSSError and Font, and committed both.

Now all we need is Viewport.... * looks at G_G *

Just joking G_G, take your time, we got no other tasks at the moment.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

Yeah, I can make Bitmap and Sprite work without needing Viewport. I'll see how much I can get done today. I should at least be able to make them work enough to be able to load a actual image and draw it properly.
Check out our game brands:

Daygames
Game Night Games
Chugnar Games

Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Ryex

Man it sure looks cool with that ARC logo moving about. we really have progress here
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Blizzard

March 27, 2011, 07:51:28 am #33 Last Edit: March 27, 2011, 07:54:50 am by Blizzard
Quote from: ForeverZer0 on March 22, 2011, 10:37:44 pm
Now all we need is Viewport.... * looks at G_G *


This.

Quote from: ForeverZer0 on March 22, 2011, 10:37:44 pm
Just joking G_G, take your time, we got no other tasks at the moment.


D:
I know you can find some time. C'mon, G_G. ._.
This task is almost done and I'd like to mark it as finished.

BTW, not only the Viewport class needs to be finished! I have noticed that a portion of the Sprite class is also missing. Somebody of your guys take care of that, it's not much work.

Also, I have fully implemented Font yesterday. There is only one thing that bothers me and that is defaultColor. Since it's an object, it might be wiped by the garbage collector. But because it is a static variable, we have no real means to make sure it gets marked via gc_mark. ._. Does anybody have a suggestion for this? I thought that a possible solution could be that we try to make it a class variable and manually set it to the color. But I had some problems with that and no time to work on it.
Check out our game brands:

Daygames
Game Night Games
Chugnar Games

Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

March 27, 2011, 09:32:25 am #34 Last Edit: March 27, 2011, 09:39:21 am by game_guy
I've almost got it done -_- Procrastination is my greatest skill and weakness.

EDIT: I'm working on it now. Won't stop til its done. Sorry. :((((((

Blizzard

Lol, there is no need to apologize.
Check out our game brands:

Daygames
Game Night Games
Chugnar Games

Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

Alright so I looked at this line right here in color.
color->alpha = (NIL_P(a) ? 255.0f : hclamp((float)NUM2DBL(a), 0.0f, 255.0f));


Basically I'm understating once a user creates a new color object, then sets alpha to say 120 then calls the set method and does not define alpha, it automatically sets it to 255.

Blizzard

Yes. There's quite a bit going on in that line. If the alpha is omitted, then a will be Qnil (is NIL_P a fast check for Qnil). If there is an alpha, it is converted to the C type double, cast to float (since all values are float and the compiler gives warning when you don't cast stuff like this) and it will be clamped between 0 and 255.

If you have more questions, feel free to ask.
Check out our game brands:

Daygames
Game Night Games
Chugnar Games

Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

I'm looking through the docs but I'm wondering how we return a class? I'm doing the rb_getColor method for Viewport and I'm wondering how we revert the color back to a ruby class. Do we simply just return "viewport->color" or do we have to convert it back to ruby?

Blizzard

That's what the wrap method is for. If you want to return the viewport's color as Ruby class, you use "viewport->color->wrap()".

Also, take a look how I implemented Font::color and Font::rb_color if you want to implement the initializer as well. There are a few things that have to be taken into account because of Ruby/C++.
I also implemented a static create method that creates an instance of a Ruby class within C++ code. Any other way wouldn't properly invoke the GC as far as I know. If you want, you can implement the create method in all classes (actually you should, we will need them). It's basically copy-paste and changing the names of the classes/variables. I have implemented that method in Color and Font.
Check out our game brands:

Daygames
Game Night Games
Chugnar Games

Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.