[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ruby-dl] extern a global variable?

Simon Strandgaard

1/20/2005 8:23:00 PM

I am wrapping ncursesw for ruby.
In ncurses.h it has declared the following variable:
extern int COLORS;

I would like to access COLORS from ruby (if possible).
I have tried extern 'int COLORS' but without luck.


shell> nm -a libncursesw.a
[snip]
00000000 B COLOR_PAIRS
00000004 B COLORS
U curscr
U cur_term
0000001c t default_bg
[snip]


I guess its accessable from the outside.. just how to do it?

Thanks in advance.

--
Simon Strandgaard


5 Answers

Simon Strandgaard

1/20/2005 9:52:00 PM

0

On Thu, 20 Jan 2005 21:22:58 +0100, Simon Strandgaard <neoneye@gmail.com> wrote:
> I am wrapping ncursesw for ruby.
> In ncurses.h it has declared the following variable:
> extern int COLORS;
>
> I would like to access COLORS from ruby (if possible).
> I have tried extern 'int COLORS' but without luck.
>
> shell> nm -a libncursesw.a
> [snip]
> 00000000 B COLOR_PAIRS
> 00000004 B COLORS
> U curscr
> U cur_term
> 0000001c t default_bg
> [snip]
>
> I guess its accessable from the outside.. just how to do it?


I have made some more progress.. but still I cannot access the value..


COLORS = symbol 'COLORS'
Int = struct ["int value"]

...

Later I then can access Curses::COLORS which gives me an PtrData instance.
After I have invoked Curses.start_color I try access the variable.

i = Curses::Int.new(Curses::COLORS).value
p i

It results in 0. Im not sure if this is the right way to access variables?




btw: wouldn't it be easier if one could type extern 'int COLORS' and
accomplish the same?


--
Simon Strandgaard


Florian Gross

1/20/2005 10:07:00 PM

0

Simon Strandgaard wrote:

> I am wrapping ncursesw for ruby.
> In ncurses.h it has declared the following variable:
> extern int COLORS;
>
> I would like to access COLORS from ruby (if possible).
> I have tried extern 'int COLORS' but without luck.

Does this work?

module MyLib
extend DL::Importable
dlload "ncurses.so"

Colors = symbol "COLORS"
end

Simon Strandgaard

1/20/2005 10:24:00 PM

0

On Fri, 21 Jan 2005 07:10:58 +0900, Florian Gross <flgr@ccan.de> wrote:
> Simon Strandgaard wrote:
>
> > I am wrapping ncursesw for ruby.
> > In ncurses.h it has declared the following variable:
> > extern int COLORS;
> >
> > I would like to access COLORS from ruby (if possible).
> > I have tried extern 'int COLORS' but without luck.
>
> Does this work?
>
> module MyLib
> extend DL::Importable
> dlload "ncurses.so"
>
> Colors = symbol "COLORS"
> end

No, it seems to return a PtrData instance.


I have made something that seems to work.. feels ackward though.
I can now access Curses.COLORS and Curses.ESCDELAY.

module Curses
extend DL::Importable
dlload 'libncursesw.so'

Int = struct ["int value"]
COLORS_PTR = symbol 'COLORS'
ESCDELAY_PTR = symbol 'ESCDELAY'
def self.COLORS
Int.new(COLORS_PTR).value
end
def self.ESCDELAY
Int.new(ESCDELAY_PTR).value
end
end


Im curious to if this can be done smarter?

--
Simon Strandgaard


Ralph

9/1/2009 8:23:00 PM

0

Danwood wrote:
> grisha wrote:
>> On Aug 31, 7:08 pm, Danwood <dw...@bellsouth.net> wrote:
>>> Free Lunch wrote:
>>>> On Mon, 31 Aug 2009 11:51:56 -0400, Danwood <dw...@bellsouth.net> wrote
>>>> in alt.talk.creationism:
>>>>> Cory Albrecht wrote:
>>>>>> Danwood wrote, on 09-08-30 09:41 PM:
>>>>>>> Matt Silberstein wrote:
>>>>>>>> On Sun, 30 Aug 2009 11:06:36 -0400, in alt.talk.creationism ,
>>>>>>>> Danwood
>>>>>>>> <dw...@bellsouth.net> in <4A9A957C.5070...@bellsouth.net> wrote:
>>>>>>>>> Matt Silberstein wrote:
>>>>>>>>>> On Sun, 23 Aug 2009 01:22:46 -0400, in alt.talk.creationism ,
>>>>>>>>>> Danwood
>>>>>>>>>> <danw...@bellsouth.net> in <4A90D226.1000...@bellsouth.net>
>>>>>>>>>> wrote:
>>>>>>>>>> [snip]
>>>>>>>>>>> According to Paul Davies physicist can look back into the
>>>>>>>>>>> history
>>>>>>>>>>> of the universe a fraction of a second after the Big Bang.
>>>>>>>>>>> with a
>>>>>>>>>>> high degree of certanity. Martin Rees states, that he is 99
>>>>>>>>>>> percent
>>>>>>>>>>> certain that the
>>>>>>>>>>> Big Bang happened. So, if life was the final result from a long
>>>>>>>>>>> organized and designed process one could argue it was all
>>>>>>>>>>> planned
>>>>>>>>>>> from the very beginning.
>>>>>>>>>> Even if I give you the "designed" part, why do you look at the
>>>>>>>>>> Universe we have today and say that life was the goal?
>>>>>>>>> The idea did _not_ originate with me.
>>>>>>>> I know that, but you are asserting the claim, so defend it.
>>>>>>> One example, from Hawking. (Exact quote unavailable at the moment)
>>>>>>> The laws, as we know them contain many fundamental numbers, like the
>>>>>>> size of the electric charge of the electron and the ratio of the
>>>>>>> of the masses of the proton and the electron. The values at present
>>>>>>> are unpredictable from theory, but are found through observation.
>>>>>>> Someday we may find a unified theory which predicts them, it's maybe
>>>>>>> that they can vary from universe to universe or maybe even in a
>>>>>>> single
>>>>>>> universe.
>>>>>>> The remarkable fact is that the values of these numbers seem to have
>>>>>>> been finely adjusted to make possible the development of life.
>>>>>>> (While this is not an exact quote it's very close especially the
>>>>>>> last sentence)
>>>>>> Then if it's not a quote, how do you (and we) know that you are not
>>>>>> a) deliberately misrepresenting Dr. Hawking to make your point
>>>>>> or
>>>>>> b) unintentionally misremembering it in a manner that supports
>>>>>> your own
>>>>>> preconceptions.
>>>>> I didn't have the book available when I wrote the above. However, I do
>>>>> now. This is the exact quote from Hawking.
>>>>> "The laws of science, as we know them at present, contain many
>>>>> fundamental numbers, like the size of the electric charge of the
>>>>> electron and the ratio of the masses of the proton and the
>>>>> electron. We cannot, at the moment at least, predict the values of
>>>>> these numbers from theory - we have to find them by observation.
>>>>> It may be that one day we shall discover a complete unified theory
>>>>> that predicts them all, but it is also possible that some or all of
>>>>> them vary from universe to universe to universe or within a single
>>>>> universe.
>>>>> The remarkable is that the values of these numbers seem to have been
>>>>> very finely adjusted to make possible the development of life."
>>>>> Ref: A Brief History of Life, 1988, by Stephen W. Hawking, page 125.
>>>> The book is "A Brief History of Time". Don't confuse old magazines.
>>> Why do you feel it necessary to point this out? I'm just curious!
>>> I have the book.
>>>
>>>> I guess you couldn't be bothered to read the rest of his discussion
>>>> about the strong anthropic principle.
>>> I read everything he wrote in this book. Like others who has atheist
>>> tendencies, he appeals to these imaginary other universes. I have dealt
>>> with these Alice in Wonderland worlds in earlier post. Do you know
>>> anything other than these multiverses Hawking etc are advocating as
>>> a way out? I know Hawking is trying to derive a theory of everything and
>>> maybe he is close to his goal.
>>> >> for it. You need to read an entire discussion before you jump to
>>>> conclusions about what he thinks.
>>> I have read Hawking's book a couple of times, Twenty years ago and
>>> again this year. I also have a book by John Boslough entitled
>>> "Stephen Hawking's Universe". Which is about the man and based
>>> upon discussions and interviews with Hawking.
>>>
>>>
>>>
>>>>>> Me, I find the whole strong anthropic principle nothing more than as
>>>>>> massive argument from incredulity. The hole shows no evidence of
>>>>>> having
>>>>>> been specially made to fit the puddle's underside.
>>>>> Creationist are often accused of using the same old tired arguments
>>>>> over and over again. How many times has this same puddle argument been
>>>>> used, yet, no one has shown that it is in any way analogous or has any
>>>>> bearing to the "fine-tuned" properties of the universe. It is only an
>>>>> attempt to avoid confronting the issue - an escape.
>>>> The argument for fine tuning is a post hoc ergo propter hoc logical
>>>> fallacy.
>>>>>>>>> Furthermore, no one including
>>>>>>>>> me stated this as an absolute impeachable fact.
>>>>>>>> "Absolute impeachable fact"? I'm trying to see if it is more than a
>>>>>>>> vague meaningless statement. Can you provide any specificity to the
>>>>>>>> claim, any evidence to back it up?
>>>>>>> Here I was in reference to the "fine tuned" properties.
>>>>>>>>> It's only an implication based upon the end result and the
>>>>>>>>> sequence
>>>>>>>>> of events leading up to the
>>>>>>>>> life.
>>>>>>>> That is hand waving, not argument. Specify which of the sequences
>>>>>>>> leading to life you think had designers involved and tell me
>>>>>>>> something, anything at all, about those designers or the process of
>>>>>>>> design. For this discussion I am accepting that the Universe was
>>>>>>>> designed, so now show me something that says that life was
>>>>>>>> designed or
>>>>>>>> something about the design process. Do you have anything at all?
>>>>>>>>> Life might be
>>>>>>>>>> the unfortunate debris at the edge and, say, vacuum was the
>>>>>>>>>> goal. Or
>>>>>>>>>> maybe it was planets with really neat looking circular storms
>>>>>>>>>> and we
>>>>>>>>>> are just #3 or so for the solar system.
>>>>>>>>>>> The physicist, Freeman Dyson at the Advanced Studies in
>>>>>>>>>>> Princeton,
>>>>>>>>>>> stated, the strong anthropic principle implies 'that the
>>>>>>>>>>> universe
>>>>>>>>>>> knew we were coming'.
>>>>>>>>>> He is wrong, but Dyson is and always has been a strongly
>>>>>>>>>> committed
>>>>>>>>>> Christian. else?
>>>>>>>>> So, being a Christian, discredits his conclusion with which you
>>>>>>>>> disagree?
>>>>>>>> No, being a committed Christian helps explain his statements about
>>>>>>>> this that are not in his scientific works. You were going for his
>>>>>>>> authority as a physicist, I was pointing out that he was stepping
>>>>>>>> outside his role as a scientist to make these claims. Otherwise you
>>>>>>>> would point to peer reviewed scientific papers on the topic (and
>>>>>>>> there
>>>>>>>> aren't any).
>>>>>>>>> Where is that quote from, a science paper or something
>>>>>>>>> <snip>
>>>>>>>>> It's from an article entitled, "Universe Built for Us", in the
>>>>>>>>> December issue of Discovery magazine.
>>>>>>>> So he was not talking as a scientist and so his commitment to a
>>>>>>>> religion is a relevant aspect of the content. Let me repeat: that
>>>>>>>> Dyson says this outside of his published work is no more
>>>>>>>> authoritative
>>>>>>>> than anyone else saying it or saying the opposite. It is simply a
>>>>>>>> person's view, no more.
>>>>>>>>> His personal views are just his personal views, they are not
>>>>>>>>>> some authoritative claim because he can also do physics.
>>>>>>>>> You claim he is wrong.
>>>>>>>> I claim that the statement is meaningless. I claim that the
>>>>>>>> statement
>>>>>>>> is unsupported in any way. I claim that "it was designed' is too
>>>>>>>> vague
>>>>>>>> and undefined to be wrong.
>>>>>>>>> Who are you that you feel qualified to challenge his expressed
>>>>>>>>> opinion?
>>>>>>>> That no one can actually present the argument, that no one can
>>>>>>>> actually say a thing about all of those designers. I have a damn
>>>>>>>> good
>>>>>>>> scientific explanation, you need to provide something that does a
>>>>>>>> better job. And you don't provide anything other than "well, maybe
>>>>>>>> some time or other some things did something or other with some
>>>>>>>> result
>>>>>>>> that affected life". Feel free to show that I am wrong by providing
>>>>>>>> some specificity, any specificity at all.
>>>>>>> Specificity is exactly what the "fine-tuned" scenario is about.
>>>>>>> The laws of physics are tuned so as to allow life to develop on
>>>>>>> at least one planet, and maybe more, but at present only life on
>>>>>>> earth is know.
>>>>>>> The writer in Discovery, writes, "dark energy", and its effect
>>>>>>> upon the
>>>>>>> expansion of the universe says this, "The observable amount of dark
>>>>>>> energy appears to be another of those strange anthropic properties,
>>>>>>> calibrated to allow planets, stars and us. If dark energy had
>>>>>>> been more,
>>>>>>> there would have enough energy to overwhelm the gravity that drew
>>>>>>> the
>>>>>>> galaxies together, drew the stars together and drew the earth
>>>>>>> together.
>>>>>>> It's one of the greatest mysteries in physics. All we know is
>>>>>>> that if it
>>>>>>> were much bigger we wouldn't be here to talk about it. He calls
>>>>>>> this one
>>>>>>> of the greatest mysteries in physics.
>>>>>>> Stephen Weinberg agrees, he writes, "This is one fine-tuning that
>>>>>>> seems
>>>>>>> to be extreme, far beyond what you could imagine just having to
>>>>>>> accept
>>>>>>> as a mere accident".
>>>>>>>>> When I offer an quote from a reputable physicist which supports my
>>>>>>>>> view, and all you have to do is assert "he is wrong" - and that
>>>>>>>>> _it_
>>>>>>>>> - no
>>>>>>>>> further explanation is necessary?
>>>>>>>> No, that is not all I did. Read it again. I *also* challenged the
>>>>>>>> attempt to use his authority as a physicist to support his
>>>>>>>> claims that
>>>>>>>> were not made as a physicist.
>>>>>>> I suppose Stephen Weinberg is wrong too.
>>
>> Idea of multiple universes is quite far out indeed, but do you think
>> that an idea of a holy creator is more plausible?
> >
> Yes, one may say that multiverses are Alice in Wonderland worlds.
> Since there are numerous very finely adjusted properties which makes
> our universe and life itself possible, this is evidence. What this
> evidence indicates is the real issue. This as far as I am concerned
> points to an active intelligence that made these adjustments very
> early in the history of the universe.

They are a step above the hypothesis of god.




> You used the term "holy creator"? This is a term I do not use since it
> has no importance where the fine tuned properties are being discussed.
> Furthermore, none of what I've read or posted is from the Bible, book of
> Mormon, Koran or any other religious work. So why would you introduce
> it?


Don't play games, Dan, it is like lying and you know your god wouldn't
like that.


Ralph

9/1/2009 8:25:00 PM

0

Danwood wrote:
> grisha wrote:
>> On Aug 31, 10:08 pm, Danwood <dw...@bellsouth.net> wrote:
>>> Tim Miller wrote:
>>>> Ralph wrote:
>>>>> Danwood wrote:
>>>>>> Tim Miller wrote:
>>>>>>> Danwood wrote:
>>>>>>>> The remarkable fact is that the values of these numbers seem to
>>>>>>>> have
>>>>>>>> been finely adjusted to make possible the development of life.
>>>>>>> Well, no, they don't. Only people who don't really understand
>>>>>>> the science make that claim.
>>>>>> Why did you neglect to mention this quote was from Stephen Hawking?
>>>>>> Who are you, that you feel qualified to pass judgment on his
>>>>>> understanding of science? Perhaps, you don't know of Hawking?
>>>>>> Obviously, not. So why should anyone accept your view of this
>>>>>> subject?
>>>>>> For your information, Stephen Hawking is considered one of the worlds
>>>>>> greatest scientist. Yet, you can challenge his statement. These are
>>>>>> his _exact_ words from his book. "A Brief History of Time".
>>>>> I have several books by Hawking and I don't think he accepts your
>>>>> version of 'fine-tuning'. As I have attempted to tell you many times,
>>>>> we all know that certain parameters exist that allowed life to develop
>>>>> on this planet. What we don't accept is that these parameters were
>>>>> defined for the sole reason of our existence. If you can show me where
>>>>> Hawking accepts this I will be greatly surprised.
>>>> If he can show that it's the ONLY POSSIBLE combination, I'll be
>>>> greatly surprised.
>>> >
>>> Did you not read the statement above where he states that "the values of
>>> these numbers seem to be finely adjusted to make life possible"?
>>>
>>> To be sure, as an atheist, Dr. Hawking is not happy about any of it.
>>> He appeals to the countless other universes (imaginary) as a way out.
>>> He is also working dilligently to discover a "theory of everything"
>>> in order to explain these facts.
>>
>> You know, it is what scientists do.
> >
> Yes, but if they are atheist scientist, they will try to invent
> alternative explanations even imaginary mythological constructs
> rather than entertain any possibility of going wherever the evidence
> takes them. They want truth, but only if it's within the boundaries
> their set reservation. Most will not go off the reservation.


You keep saying that Dan but can you be a little more specific? Do you
expect them to look for your god? They would rather leave that to true
believers in order to use their time more wisely.