Ignore:
Timestamp:
Feb 6, 2013, 11:32:15 AM (12 years ago)
Author:
gah
Message:

fixes for 1.9 ruby and java builds

Location:
branches/Rappture 1.2/lang
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/Rappture 1.2/lang/Makefile.in

    r3065 r3283  
    1515CC              = @CC@
    1616CXX             = @CXX@
    17 RUBY            = @HAVE_RUBY_DEVEL@
     17HAVE_RUBY_H     = @HAVE_RUBY_H@
     18RUBY            = @RUBY@
    1819PERL            = @PERL@
    1920TCLSH           = @TCLSH@
     
    3435endif
    3536ifeq ($(RUBY),yes)
    36   LANGS += ruby
     37  ifeq ($(HAVE_RUBY_H),yes)
     38    LANGS += ruby
     39  endif
    3740endif
    3841ifneq ($(MEX),)
  • branches/Rappture 1.2/lang/ruby/Makefile.in

    r1944 r3283  
    1414
    1515
    16 HAVE_RUBY_DEVEL = @HAVE_RUBY_DEVEL@
    1716RUBY            = @RUBY@
    18 RUBY_VERSION    = @RUBY_VERSION@
    1917RUBY_CPPFLAGS   = @RUBY_CPPFLAGS@
    20 RUBY_EXTRA_LIBS = @RUBY_EXTRA_LIBS@
    2118RUBY_LDFLAGS    = @RUBY_LDFLAGS@
    22 RUBY_SITE_PKG   = @RUBY_SITE_PKG@
    23 RUBY_VERSION_RV = @RUBY_VERSION_RV@
    24 RUBY_PLATFORM   = @RUBY_PLATFORM@
     19RUBY_LIBRUBYARG = @RUBY_LIBRUBYARG@
    2520destdir         = $(libdir)/ruby
    2621rubydir         = $$RAPPTURE_INSTALL_DIR/lib/ruby
     
    3328SHLIB_LD        = @SHLIB_LD@
    3429SHLIB_CFLAGS    = @SHLIB_CFLAGS@
    35 SHLIB_LDFLAGS   = @SHLIB_LDFLAGS@ $(RUBY_LDFLAGS)
     30SHLIB_LDFLAGS   = @SHLIB_LDFLAGS@
    3631SHLIB_SUFFIX    = @SHLIB_SUFFIX@
    3732CFLAGS_DEFAULT  = @CFLAGS_DEFAULT@
     
    5550LIBS            = \
    5651                -L../../src/core -lrappture \
    57                 $(RUBY_LDFLAGS)
     52                $(RUBY_LIBRUBYARG)
    5853
    5954CXX_SWITCHES    = $(CFLAGS) $(CFLAGS_DEBUG) $(INCLUDES) $(DEFINES)
     
    6964$(lib): $(OBJS)
    7065        $(SHLIB_LD) $(SHLIB_LDFLAGS) -o $@ $(OBJS) \
    71                 $(LIB_SEARCH_DIRS) $(LIBS)
     66                $(LIB_SEARCH_DIRS) $(LIBS) 
    7267install: $(lib)
    7368        $(MKDIR_P) -m 0755 $(destdir)
  • branches/Rappture 1.2/lang/ruby/Ruby_Rappture.cc

    r3177 r3283  
    2727#include "RpUnits.h"     /* RpUnits::convert() */
    2828#include "ruby.h"        /* VALUE, rb_*(), Data_*_Struct(), NUM2INT(),
    29                             INT2NUM(), NUM2DBL(), STR2CSTR(), ANYARGS */
     29                            INT2NUM(), NUM2DBL(), Str2Cstr(), ANYARGS */
    3030
    3131/******************************************************************************
     
    4040
    4141extern "C" void Init_Rappture(void);
     42
     43static std::string
     44GetStdString(VALUE value)
     45{
     46    VALUE strValue;
     47
     48    strValue = StringValue(value);
     49    return std::string(RSTRING_PTR(strValue), RSTRING_LEN(strValue));
     50}
     51
     52static const char *
     53GetString(VALUE value)
     54{
     55    return StringValuePtr(value);
     56}
    4257
    4358/******************************************************************************
     
    6176{
    6277   RpLibrary *lib;
    63    std::string str;
     78   std::string result;
    6479
    6580   /* Extract the pointer to the Rappture object, lib, from the Ruby object,
     
    6782   Data_Get_Struct(self, RpLibrary, lib);
    6883
     84
    6985   /* Read the data from path in lib as a C++ std::string. */
    70    str = lib->getString(STR2CSTR(path));
     86   result = lib->getString(GetStdString(path));
    7187     
    7288   /* Return a Ruby VALUE */
    73    return rb_str_new2(str.c_str());
     89   return rb_str_new2(result.c_str());
    7490
    7591}  /* end RbRp_GetString */
     
    95111
    96112   /* Read the data from path in lib as a C++ std::string. */
    97    buf = lib->getData(STR2CSTR(path));
     113   buf = lib->getData(GetStdString(path));
    98114     
    99115   /* Return a Ruby VALUE */
     
    142158   {
    143159      case T_STRING:
    144          lib->put(STR2CSTR(path), STR2CSTR(value), "", NUM2INT(append));
     160          /* Read the data from path in lib as a C++ std::string. */
     161          lib->put(GetStdString(path), GetStdString(value), "",
     162                NUM2INT(append));
    145163         break;
    146164      case T_FIXNUM:
    147165         intVal = NUM2INT(value);
    148          lib->putData(STR2CSTR(path), (const char *)&intVal, sizeof(int),
     166         lib->putData(GetStdString(path), (const char *)&intVal, sizeof(int),
    149167                      NUM2INT(append));
    150168         break;
    151169      case T_FLOAT:
    152          lib->put(STR2CSTR(path), NUM2DBL(value), "", NUM2INT(append));
     170         lib->put(GetStdString(path), NUM2DBL(value), "", NUM2INT(append));
    153171         break;
    154172      default:
     
    156174         rb_raise(rb_eRuntimeError,
    157175                  "Unable to put object %s to Rappture: unknown type",
    158                   STR2CSTR(rbStrName));
     176                  GetString(rbStrName));
    159177#endif
    160178         break;
     
    199217   if (T_STRING == TYPE(value))
    200218   {
    201       long int nbytes;
    202       char *bytes = rb_str2cstr(value, &nbytes);
    203 
    204       lib->putData(STR2CSTR(path), bytes, nbytes, NUM2INT(append));
     219       VALUE strValue;
     220
     221       strValue = StringValue(value);
     222       lib->putData(GetStdString(path),
     223                    RSTRING_PTR(strValue), RSTRING_LEN(strValue),
     224                    NUM2INT(append));
    205225   }
    206226#ifdef RAISE_EXCEPTIONS
     
    209229      rb_raise(rb_eRuntimeError,
    210230               "Unable to put data \"%s\" to Rappture: unknown type",
    211                STR2CSTR(rbStrName));
     231               GetString(rbStrName));
    212232   }
    213233#endif
     
    257277      if (Qtrue == rb_funcall(ft, id_filetest, 1, filename))  /* valid filename */
    258278      {
    259          lib->putFile(STR2CSTR(path), STR2CSTR(filename), NUM2INT(compress),
    260                       NUM2INT(append));
     279         lib->putFile(GetStdString(path), GetStdString(filename),
     280                NUM2INT(compress), NUM2INT(append));
    261281      }
    262282#ifdef RAISE_EXCEPTIONS
     
    264284      {
    265285         rb_raise(rb_eRuntimeError, "%s is not a valid file",
    266                   STR2CSTR(rbStrName));
     286                  GetString(rbStrName));
    267287      }
    268288#endif
     
    270290#ifdef RAISE_EXCEPTIONS
    271291   else
    272       rb_raise(rb_eRuntimeError, "Bad file name: %s", STR2CSTR(rbStrName));
     292       rb_raise(rb_eRuntimeError, "Bad file name: %s",
     293                GetString(rbStrName));
    273294#endif
    274295
     
    360381
    361382   /* Write the message */
    362    (void)Rappture::Utils::progress(NUM2INT(percent), STR2CSTR(message));
     383    (void)Rappture::Utils::progress(NUM2INT(percent),
     384                                    GetString(message));
    363385
    364386   /* Return a Ruby VALUE */
     
    385407{
    386408   VALUE retVal = Qnil;
    387    RpLibrary *lib;
    388409   std::string strRetVal;
    389410   int result;
    390411
    391    /* Extract the pointer to the Rappture object, lib, from the Ruby
    392       object, self */
    393    Data_Get_Struct(self, RpLibrary, lib);
    394 
    395412   /* Convert */
    396    strRetVal = RpUnits::convert(STR2CSTR(fromVal), STR2CSTR(toUnitsName),
    397                                 NUM2INT(showUnits), &result);
     413   strRetVal = RpUnits::convert(GetStdString(fromVal),
     414                GetStdString(toUnitsName), NUM2INT(showUnits), &result);
    398415   /* Return value */
    399416   if (0 == result)
     
    409426   else
    410427      rb_raise(rb_eRuntimeError, "Unable to convert \"%s\" to \"%s\"",
    411                STR2CSTR(fromVal), STR2CSTR(toUnitsName));
     428               GetString(fromVal), GetString(toUnitsName));
    412429#endif
    413430   return retVal;
     
    473490{
    474491   /* Create the Rappture object from the XML driver file. */
    475    RpLibrary *lib = new RpLibrary(STR2CSTR(driver));
     492   RpLibrary *lib = new RpLibrary(GetStdString(driver));
    476493     
    477494   /* Data_Wrap_Struct() creates a new Ruby object which associates the
Note: See TracChangeset for help on using the changeset viewer.