From bd89c88e67399fb610305ce51b41d778171816b7 Mon Sep 17 00:00:00 2001 From: rcyeske Date: Wed, 12 Dec 2001 03:12:25 +0000 Subject: Add ruby bindings. From Doug Kearns . --- ChangeLog | 5 +++++ contrib/genrpbindings | 39 ++++++++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 95aec17..2e1fb42 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-12-11 Ryan C Yeske + + * contrib/genrpbindings: Add ruby bindings. From Doug Kearns + . + 2001-12-08 shawn * src/events.c (handle_key): revert the focus immediately after diff --git a/contrib/genrpbindings b/contrib/genrpbindings index 250e03d..e1d8a0b 100755 --- a/contrib/genrpbindings +++ b/contrib/genrpbindings @@ -5,9 +5,9 @@ # Tue Dec 4 16:15:53 PST 2001 # # currently generates bindings for: -# * Perl (Ratpoison.pm) -# * Emacs Lisp (ratpoison-cmd.el) -# +# * Perl (Ratpoison.pm) +# * Emacs Lisp (ratpoison-cmd.el) +# * Ruby (ratpoison.rb) [Doug Kearns ] # add more languages! # # Bindings are just very thin wrappers, no argument checking is done. @@ -22,6 +22,11 @@ # ;;; elisp # (require 'ratpoison-cmd) # (ratpoison-echo "hello world") +# +# #!ruby +# require "ratpoison" +# Ratpoison.echo ("hello world") +# $\="\n"; @@ -35,13 +40,15 @@ open ACTIONS_C or die "Can't open $ACTIONS_C"; # open target files $PERL_FILE="./Ratpoison.pm"; $ELISP_FILE="./ratpoison-cmd.el"; +$RUBY_FILE="./ratpoison.rb"; open PERL, ">$PERL_FILE" or die "Can't create $PERL_FILE"; open ELISP, ">$ELISP_FILE" or die "Can't create $ELISP_FILE"; +open RUBY, ">$RUBY_FILE" or die "Can't create $RUBY_FILE"; # PERL preamble print PERL 'package Ratpoison;'; print PERL '$RATPOISON="',$RATPOISON,'";'; -print PERL 'sub rp_cmd { return `$RATPOISON -c "@_"`; }'; +print PERL 'sub command { return `$RATPOISON -c "@_"`; }'; # ELISP preamble print ELISP '(defvar ratpoison-program "',$RATPOISON,'")'; @@ -66,6 +73,18 @@ print ELISP <) { if (m!/\*\@begin !) { @@ -74,8 +93,12 @@ while () { last if (m!/\*\@end !); if (/{\"(.+)\".+},/) { $nbindings++; - print PERL "sub $1 { return rp_cmd (\"$1\", \@_); }"; + print PERL "sub $1 { return command (\"$1\", \@_); }"; print ELISP "(defun-ratpoison $1)"; + print RUBY " def $1 (*args)"; + print RUBY " return command (\"$1\", args)"; + print RUBY " end"; + print RUBY " module_function :$1\n"; } } } @@ -83,11 +106,17 @@ while () { print "$nbindings bindings."; # PERL postamble +# nothing # ELISP postamble print ELISP '(provide \'ratpoison-cmd)'; +# RUBY postamble +print RUBY "end"; + close PERL; print "Created $PERL_FILE"; close ELISP; print "Created $ELISP_FILE"; +close RUBY; +print "Created $RUBY_FILE"; -- cgit v1.2.3