I create example https://github.com/letarg0/Dziwne
how create a function
extern "C" VALUE t_ar()
{
return here_Dziwne_object;
}
Anybody can help me to write rb_dziwne_new(); similar rb_ary_new or rb_str_new() function?
I create example https://github.com/letarg0/Dziwne
how create a function
extern "C" VALUE t_ar()
{
return here_Dziwne_object;
}
Anybody can help me to write rb_dziwne_new(); similar rb_ary_new or rb_str_new() function?
Quoting fab1an (fab1an@onet.pl):
I create example [1]GitHub - letarg0/Dziwne
how create a function
extern "C" VALUE t_ar()
{
return here_Dziwne_object;
}
Anybody can help me to write rb_dziwne_new(); similar rb_ary_new or
rb_str_new() function?
I have had a heavy day, and I must go to bed soon. I try to give some
quick indication. C++ irritates me a bit, so I'll try not to look at
it too much.
The problem here is to understand the utility of what you are trying
to do. You generally have no need to create ruby objects from C - and
if you do, to manage the references to be used by the garbage
collector can be a hairy problem. Can be done, but it is rarely
necessary.
From C, if you need to manipulate Ruby objects, you generally prefer
to receive them from the Ruby environment, so the GC mess is
avoided. And then, 99% of the cases are represented by numbers,
strings, arrays and hashes. You bring the values from Ruby to C, do
your nice algorithmic magic, and then prepare a VALUE with what you
want your Ruby caller to receive.
You may want to keep some stash of C variables associated to your ruby
objects. This you do with functions like TypedData_Make_Struct. There
are several examples in the Ruby source code. But there, too, it is
better to create the objects from Ruby.
What I am trying to say here is that there could be an easier way to
solve your problem, that does not include the necessity to create Ruby
objects from C. Once you learn the tricks, it is easy and powerful to
move from C to Ruby and back, but I for one try to limit as much as
possible the data I have to pass from one world to the other.
Carlo
Subject: example
Date: gio 18 gen 18 08:23:38 +0100
--
* Se la Strada e la sua Virtu' non fossero state messe da parte,
* K * Carlo E. Prelz - fluido@fluido.as che bisogno ci sarebbe
* di parlare tanto di amore e di rettitudine? (Chuang-Tzu)
The problem here is to understand the utility of what you are trying
to do.
I must create a new instance
I create a obiect
t = Dziwne.new
and function
def return_array
return [Dziwne obiect]
end
I need this function
This code using C++ but all code is in C.
How I can create new obiect Dziwne with my own: struct moje
Meybe I must search 'Dziwne' id in vm , I dont know.
Quoting fab1an (fab1an@onet.pl):
I must create a new instance
I create a obiectt = Dziwne.new
and function
def return_array
return [Dziwne obiect]
endI need this function
This code using C++ but all code is in C.
How I can create new obiect Dziwne with my own: struct moje
Meybe I must search 'Dziwne' id in vm , I dont know.
Sorry I must go to work now. Your question is still way too confused
to allow me to try and give a quick reply. Do you need a function to
return an array with one object? In C? Why?
Sorry - time is limited...
Carlo
Subject: Re: Re: example
Date: Thu 18 Jan 18 09:04:15PM +0100
--
* Se la Strada e la sua Virtu' non fossero state messe da parte,
* K * Carlo E. Prelz - fluido@fluido.as che bisogno ci sarebbe
* di parlare tanto di amore e di rettitudine? (Chuang-Tzu)
Do you need a function to
return an array with one object? In C? Why?
Yes
My english is to little to explain this
Please, stop spamming the list with broken replies. Your replies do not
thread properly, reconfigure your mail client. This way it is completely
unreadable, each of your messages starts a new thread!
Marvin
--
Blog: https://mg.guelker.eu
PGP/GPG ID: F1D8799FBCC8BC4F