Update of /cvsroot/monetdb/clients/src/ruby/Cimpl
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv3180/ruby/Cimpl

Added Files:
        Makefile.ag MapiLib.ruby.i example.rb 
Log Message:
We now have a first version of MapiLib wrapped by swig for ruby.
Anybody interested in this language may pick it up and add the
DBI like interface(s).


--- NEW FILE: Makefile.ag ---
# The contents of this file are subject to the MonetDB Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
# under the License.
#
# The Original Code is the MonetDB Database System.
#
# The Initial Developer of the Original Code is CWI.
# Portions created by CWI are Copyright (C) 1997-2007 CWI.
# All Rights Reserved.

MTSAFE

SWIGFLAGS = -I../..
INCLUDES = -I../.. $(MONETDB_INCS) $(RUBY_INCS)

# we need this flag to allow for a name that does not start with "lib"
MapiLib_la_LDFLAGS = -module

#  Both GNU's gcc and Intel's icc do not like to compile swig-generated code
#  with our strict X_CFLAGS.
#  Instead of diabling the strict X_CFLAGS completely,
#  we use GCC_SWIG_CFLAGS and ICC_SWIG_CFLAGS, respectively,
#  to disable only the problematic warnings/errors as locally as possbile.
#  See buildtools/conf/MonetDB.m4 for details.
#CFLAGS = $(GCC_SWIG_CFLAGS) $(ICC_SWIG_CFLAGS)
#
#  However, there are situations where user-chosen CFLAGS and/or X_CFLAGS
#  are beyond our control. Hence, for the sake of a smooth compilation, we
#  have to take the freedom to overrule the user's deliberate choice for
#  X_CFLAGS by locally disabling them indifferently.
X_CFLAGS =

lib_MapiLib = {
        PREFIX =
        NAME = MapiLib
        SOURCES = MapiLib.ruby.i
        LIBS = ../../mapilib/libMapi $(RUBY_LIBS) $(MATH_LIBS) $(DL_LIBS) 
$(PTHREAD_LIBS)
        DIR = $(prefix)/$(RUBY_LIBDIR)
}

--- NEW FILE: example.rb ---
include MapiLib

m = mapi_connect("localhost", 50000, "monetdb", "monetdb", "sql","demo")
q = mapi_prepare(m, "select * from tables;");
r = mapi_execute(q);
q = mapi_prepare(m, "select * from tables;")
r = mapi_execute(q)

while (nrcols = mapi_fetch_row(q)) > 0
        0.step(nrcols, 1) { |i| p=mapi_fetch_field(q, i); print p; print "\t" }
        print "\n"
end

--- NEW FILE: MapiLib.ruby.i ---
// The contents of this file are subject to the MonetDB Public License
// Version 1.1 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
// http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html
//
// Software distributed under the License is distributed on an "AS IS"
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
// License for the specific language governing rights and limitations
// under the License.
//
// The Original Code is the MonetDB Database System.
//
// The Initial Developer of the Original Code is CWI.
// Portions created by CWI are Copyright (C) 1997-2007 CWI.
// All Rights Reserved.

%module MapiLib
%include "ruby/typemaps.i"
%include "exception.i"

%{
#include "mapilib/Mapi.h"
%}

// don't care for the guard symbol
%ignore _MAPI_H_INCLUDED;

// unimplementable in ruby
%ignore mapi_bind;
%ignore mapi_bind_var;
%ignore mapi_bind_numeric;
%ignore mapi_clear_bindings;
%ignore mapi_param;
%ignore mapi_param_type;
%ignore mapi_param_numeric;
%ignore mapi_param_string;
%ignore mapi_clear_params;
%ignore mapi_store_field;
%ignore mapi_quote;
%ignore mapi_unquote;

%apply (char *STRING, int LENGTH) {(const char *cmd, size_t size)}; 

// options string arg, i.e. arg can be a string or NULL (in Ruby: None).
%typemap(in,parse="z") char *OPTSTRING "";

%apply char *OPTSTRING {char *lang};
%apply char *OPTSTRING {char *password};
%apply char *OPTSTRING {char *username};
%apply char *OPTSTRING {char *host};

%apply char *OPTSTRING {char *cmd};

%include "mapilib/Mapi.h"


-------------------------------------------------------------------------
SF.Net email is sponsored by: 
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to