Skip to content
/ rudy Public

enable and ease writing Ruby native extensions in D language

Notifications You must be signed in to change notification settings

tomash/rudy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RuDy

An effort / library / gem ? to enable and ease writing Ruby native extensions in D programming language.

Why?

Because even native extensions should be written in a modern and pro-productive language. While still being close-to-the-metal and C-fast.

Elements

Currently contains:

  • bcd - ruby.d converted from ruby.h using bcd.gen

  • rudy - current state of the library that’s beyond the bindings

  • dexter - a playground application for testing and experimenting with (now) binding and (later) library

  • examples - small working code snippets for demonstrating RuDy features

See README files in each of the subdirs for explanation and further info.

Current state

RuDy is ready to be used, although lacking some (many) features it needs to be called “1.0”.

  • Bindings (bcd.ruby) working as far as current Dexter functionality and its test coverage is concerned.

  • Early state of RudyObject – a class for references to Ruby objects (VALUEs) that wraps, converts and allows some other magic. Barely usable (tiny feature set) at the moment.

  • d_type! template for converting Ruby VALUEs to native D types; opposite of to_ruby_value; working great, could use some new features (type support)

  • to_ruby_value – opposite to d_type!, a function returning Ruby VALUEs from native D types (some D reflection goodness here); working like a charm, needs a bit of non-critical work (wrapping functions/delegates etc.)

  • def! template for automatically registering D methods into Ruby – working with some cool features, but still lacks auto-wrapping/unwrapping passed arguments and return value

Limitations and areas for development

RuDy currently works on my 32bit Ubuntu, compiling D code with GDC. And that’s basically what “compile” scripts were done for. It definitely needs some smart build system (Makefile/autoconf, extended ruby mkmf, D-based build system – whatever will do the job) in order to start supporting other platforms.

I’d like to focus primarly on supporting:

  • 64bit systems (bindings and VALUE need some work because of int size)

  • other Linux distros

  • Mac OSX

Mostly because they could be all done without changing the compiler (GDC).

RuDY would also welcome support for:

  • Windows (MinGW/GCC family)

  • different D compilers, especially LDC (LLVM D Compiler) as the most promising one

Getting Started (with your own code)

You can find examples I’ve prepared for Euruko2009 conference in examples/ directory. They’re microextensions (with microtests) demonstrating various features of RuDy.

To see some more dirty code that I’m using to test all the new features, use Dexter. Check out dexter directory, namely files dexter.d (using Rudy), dexter_tester.rb (unittests for what’s implemented in dexter.d) and compile (how to compile the stuff as for now).

Plans and aims

  1. Generate complete and working .d files (based on ruby.h) for writing Ruby extensions in D.

  2. Extend mkmf.rb to recognize and generate makefiles (maybe also dsss config files) for extensions written in D. Or any other smart build system (check “limitations” section above)

  3. Create PyD (pyd.dsource.org/) equivalent for Ruby:

  • RudyObject

  • to_ruby_value

  • def!(function)

  • def!(class)

Licensing

The whole RuDy project is licensed under Ruby / MIT license.

Authors:

Post Scriptum

Cpunion! If you’re reading this, please contact me (Tomasz Stachewicz) on email [email protected]. I belive I stumbled upon your blog, but in… Chinese, and while learned Mandarin a bit, I couldn’t figure out a way to contact you.

About

enable and ease writing Ruby native extensions in D language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published