From: Bob X Date: 2003-06-11T05:27:32+09:00 Subject: Metakit [ first swipe ] From Mr. Fletcher: ==== I have made quite a lot of progress with binding Metakit, using SWIG (http://www.swig.org/). All that this needs, once you have SWIG, is to make a local copy of the Metakit header and run this SWIG file ----------------------- /* File : mk4.i */ %module mk4 %{ #include "mk4.h" %} /* First attempt at mk4 interface */ %include "mk4.h" ---------------------- Here is a translation of part of the Metakit demo. Notice (1) that all the Metakit classes have an initial capital letter. This is a requirement of Ruby and the translation is done by SWIG, which also gives a warning. (2) In this simple version some functionality is lost, in particular [ ] operations on the view. Some of this can be restored by adding things to the SWIG interface. I was concerned to get something operational. (3) I have only tried this on Linux using SWIG 1.3.16 and gcc 3.2. ---------------------------- # test file for ruby interface for Metakit # load the package, which must have a lower case name. require 'mk4' include Mk4 puts "A first test of Metakit running via Ruby" puts "John Fletcher June 2003 J.P.Fletcher@aston.ac.uk" puts "This is intended as a translation of demo.cpp" pName = C4_StringProp.new("name") pCountry = C4_StringProp.new("country") storage = C4_Storage.new("myfile.dat",1) vAddress = storage.GetAs("address[name:S,country:S]") row = C4_Row.new() # These do not translate directly #pName (row) = "John Williams" #pCountry (row) = "UK" #row = pName["John Williams"] #row.pName = "John Williams" # This has to be used instead. pName.Set(row,"John Williams") pCountry.Set(row,"UK") vAddress.Add(row) pName.Set(row,"Paco Pena") pCountry.Set(row,"Spain") vAddress.Add(row) # This has added two records. # Here is how to get data back again s1 = pName.Get(vAddress.GetAt(1)) s2 = pCountry.Get(vAddress.GetAt(1)) puts "The country of #{s1} is #{s2}" storage.Commit() ------------------- Example output: A first test of Metakit running via Ruby John Fletcher June 2003 J.P.Fletcher@aston.ac.uk This is intended as a translation of demo.cpp The country of Paco Pena is Spain ==== If anyone can help him I am sure he would appreciate it very much. : )