RubyInline 1.0.4 Released! (fwd)

Here is the snippet from example.rb:

  def fastfact(*args)
    inline args, <<-END
    int i, f=1;
    for (i = FIX2INT(argv[0]); i >= 1; i--) { f = f * i; }
    return INT2FIX(f);
    END
  end

Basically, this is the body of the function you'd have to write if you
were to write a "real" extern. This gets extracted, compiled, linked
into a .so, required/loaded, and run in the first call to this
method. The second call to this method (in the same runtime) just runs
the optimized version. Another call in another runtime would jump to
the require/loaded stage unless the script had been edited since last
compile.

···

On 2002-09-10T17:15:25, Pat Eyler wrote:

From: Pat Eyler <pate@red-bean.com>
To: ruby-talk ML <ruby-talk@ruby-lang.org>

maybe someone would like to post a code sample of Inline::C from ruby?

Ryan I downloaded RubyInline and tried it on my Windows XP (Home Edition).
This is what I got:

···


C:>ruby -v example.rb
ruby 1.7.2 (2002-07-02) [i386-mswin32]
RubyInline 1.0.4
Building /tmp/Mod_MyTest_fastfact.so with
'cl -LD -nologo -MD -DNT=1 -Zi -O2b2xg

  • -G5 -I C:/ruby/lib/ruby/1.7/i386-mswin32’
    C:/ruby/lib/ruby/site_ruby/inline.rb:55:in initialize': No such file or directory - "/tmp/Mod_MyTest_fastfact.c" (Errno::ENOENT) from C:/ruby/lib/ruby/site_ruby/inline.rb:55:in new’
    from C:/ruby/lib/ruby/site_ruby/inline.rb:55:in inline' from example.rb:16:in fastfact’
    from example.rb:34
    from example.rb:34:in `each’
    from example.rb:34

C:>cd “Program Files”

C:\Program Files>dir cl.exe /s
Volume in drive C has no label.
Volume Serial Number is 1C37-1503

Directory of C:\Program Files\Microsoft Visual Studio .NET\Vc7\bin

01/05/2002 05:48 AM 81,920 cl.exe
1 File(s) 81,920 bytes


What am I missing ?
TIA,
– Shanko

“Ryan Davis” ryand@ZenSpider.com wrote in message
news:20020910231156.GB15852@greed.zenspider.com

On 2002-09-10T17:15:25, Pat Eyler wrote:

From: Pat Eyler pate@red-bean.com
To: ruby-talk ML ruby-talk@ruby-lang.org

maybe someone would like to post a code sample of Inline::C from ruby?

Here is the snippet from example.rb:

def fastfact(*args)
inline args, <<-END
int i, f=1;
for (i = FIX2INT(argv[0]); i >= 1; i–) { f = f * i; }
return INT2FIX(f);
END
end

Basically, this is the body of the function you’d have to write if you
were to write a “real” extern. This gets extracted, compiled, linked
into a .so, required/loaded, and run in the first call to this
method. The second call to this method (in the same runtime) just runs
the optimized version. Another call in another runtime would jump to
the require/loaded stage unless the script had been edited since last
compile.

Well… I don’t have a windoze box to test out on at all, so you’ll
have to be my eyes and ears on this. The first is that I’m kinda
expecting ruby to deal w/ unix file paths. I don’t know if it does or
what recourse I have available to me if it doesn’t. The second is that
/tmp might not even exist on windoze, I have no idea, so what is the
alternative. This second point is kinda moot, as I really need to
switch it to the user’s home directory. This would involve using the
HOME environment variable on POSIX systems. Is that true for MS
products? I was planning on using HOME/.ruby_inline. Does that even
make sense in your world? Please advise.

···

On Wednesday, Sep 11, 2002, at 04:56 US/Pacific, Shashank Date wrote:

Ryan I downloaded RubyInline and tried it on my Windows XP (Home
Edition).
This is what I got:

According to my autoexec.bat file (this is available under win9x/me… not sure
about win2k and xp):

SET TEMP=C:\WINDOWS\TEMP

···

On September 11, 2002 01:37 pm, Ryan Davis wrote:

The second is that/tmp might not even exist on windoze


To call me “awesome” is an understatement.

Hi,

Well… I don’t have a windoze box to test out on at all, so you’ll
have to be my eyes and ears on this. The first is that I’m kinda
expecting ruby to deal w/ unix file paths. I don’t know if it does or
what recourse I have available to me if it doesn’t. The second is that
/tmp might not even exist on windoze, I have no idea, so what is the
alternative. This second point is kinda moot, as I really need to
switch it to the user’s home directory. This would involve using the
HOME environment variable on POSIX systems. Is that true for MS
products? I was planning on using HOME/.ruby_inline. Does that even
make sense in your world? Please advise.

Win2k(=NT5.0) defines HOMEDRIVE and HOMEPATH but not HOME, and
TEMP to each users own temporary directories. I can’t remind
whether NT4.0 set TEMP in that manner or set to system wide
directory. I don’t know about WinXP(=NT5.1) at all.

Win9x doesn’t set them automatically unless set in autoexec.bat
file.

And, dotted files are not hidden under Windows.

But totally, I don’t guess it’s so useful under Windows, many
Windows users don’t have compilers.

···

At Thu, 12 Sep 2002 02:37:26 +0900, Ryan Davis wrote:


Nobu Nakada

There is a System Variable named TEMP on Windows XP which has the value:
C:\WINDOWS\TEMP

I could not see any “HOME” system variable. But it can be defined if
necessary… what do you want the value to be ?

– Shanko

“nico” n1k0@rogers.com wrote in message
news:200209111506.01632.n1k0@rogers.com

The second is that/tmp might not even exist on windoze

According to my autoexec.bat file (this is available under win9x/me… not
sure

···

On September 11, 2002 01:37 pm, Ryan Davis wrote:
about win2k and xp):

SET TEMP=C:\WINDOWS\TEMP


To call me “awesome” is an understatement.

Shashank Date wrote:

There is a System Variable named TEMP on Windows XP which has the value:
C:\WINDOWS\TEMP

I could not see any “HOME” system variable. But it can be defined if
necessary… what do you want the value to be ?

Are you using WinXP Home? WinXP Pro has %TEMP% pointing to a user-
specific temp folder, and has HOMEDRIVE and HOMEPATH (HOME is the
concatenation of the two)

···


Giuseppe “Oblomov” Bilotta

“E la storia dell’umanità, babbo?”
“Ma niente: prima si fanno delle cazzate,
poi si studia che cazzate si sono fatte”
(Altan)
(“And what about the history of the human race, dad?”
“Oh, nothing special: first they make some foolish things,
then you study which foolish things have been made”)