lib/gecoder/bindings/bindings.rb in gecoder-0.6.0 vs lib/gecoder/bindings/bindings.rb in gecoder-0.6.1

- old
+ new

@@ -46,19 +46,42 @@ return intargs; } @ +custom_mark_definitions =<<-"end_custom_definition" + static void Gecode_MSpace_custom_mark(void *p) { + Gecode_MSpace_mark(p); + ((Gecode::MSpace*)p)->gc_mark(); + } + + static void Gecode_MIntVarArray_custom_mark(void *p) { + Gecode_MIntVarArray_mark(p); + ((Gecode::MIntVarArray*)p)->gc_mark(); + } + + static void Gecode_MBoolVarArray_custom_mark(void *p) { + Gecode_MBoolVarArray_mark(p); + ((Gecode::MBoolVarArray*)p)->gc_mark(); + } + + static void Gecode_MSetVarArray_custom_mark(void *p) { + Gecode_MSetVarArray_mark(p); + ((Gecode::MSetVarArray*)p)->gc_mark(); + } +end_custom_definition + Rust::Bindings::create_bindings Rust::Bindings::LangCxx, "gecode" do |b| b.include_header 'gecode/kernel.hh', Rust::Bindings::HeaderGlobal b.include_header 'gecode/int.hh', Rust::Bindings::HeaderGlobal b.include_header 'gecode/search.hh', Rust::Bindings::HeaderGlobal b.include_header 'gecode/minimodel.hh', Rust::Bindings::HeaderGlobal b.include_header 'missing.h', Rust::Bindings::HeaderLocal b.add_custom_definition ruby2intargs + b.add_custom_definition custom_mark_definitions # Is it possible to use namespaces with multiple levels in Rust? I.e. use # Gecode::Raw instead of GecodeRaw here (and avoid the hidious renaming) # when requiring them. b.add_namespace "GecodeRaw", "Gecode" do |ns| @@ -144,10 +167,12 @@ enum.add_value "AVAL_MAX" end ns.add_cxx_class "MIntVarArray" do |klass| klass.bindname = "IntVarArray" + klass.function_mark = 'Gecode_MIntVarArray_custom_mark' + klass.add_constructor klass.add_constructor do |func| func.add_parameter "Gecode::MSpace *", "home" func.add_parameter "int", "n" end @@ -176,19 +201,26 @@ klass.add_operator "[]=", "Gecode::IntVar&" do |method| method.add_parameter "int", "index" method.add_parameter "Gecode::IntVar", "val" end + klass.add_method "enlargeArray" do |method| + method.add_parameter "Gecode::MSpace *", "home" + method.add_parameter "int", "n" + end + klass.add_method "size", "int" klass.add_method "debug" end ns.add_cxx_class "MBoolVarArray" do |klass| klass.bindname = "BoolVarArray" + klass.function_mark = 'Gecode_MBoolVarArray_custom_mark' + klass.add_constructor klass.add_constructor do |func| func.add_parameter "Gecode::MSpace *", "home" func.add_parameter "int", "n" end @@ -204,18 +236,25 @@ klass.add_operator "[]=", "Gecode::BoolVar&" do |method| method.add_parameter "int", "index" method.add_parameter "Gecode::BoolVar", "val" end + klass.add_method "enlargeArray" do |method| + method.add_parameter "Gecode::MSpace *", "home" + method.add_parameter "int", "n" + end + klass.add_method "size", "int" klass.add_method "debug" end ns.add_cxx_class "MSetVarArray" do |klass| klass.bindname = "SetVarArray" + klass.function_mark = 'Gecode_MSetVarArray_custom_mark' + klass.add_constructor klass.add_constructor do |method| method.add_parameter "Gecode::MSpace *", "home" method.add_parameter "int", "n" @@ -272,10 +311,15 @@ klass.add_operator "[]=", "Gecode::SetVar&" do |method| method.add_parameter "int", "index" method.add_parameter "Gecode::SetVar", "val" end + klass.add_method "enlargeArray" do |method| + method.add_parameter "Gecode::MSpace *", "home" + method.add_parameter "int", "n" + end + klass.add_method "size", "int" klass.add_method "debug" end @@ -286,10 +330,11 @@ klass.add_method "size", "int" end ns.add_cxx_class "MSpace" do |klass| klass.bindname = "Space" + klass.function_mark = 'Gecode_MSpace_custom_mark' klass.add_constructor klass.add_method "debug" @@ -1426,9 +1471,16 @@ # param.custom_conversion = "*ruby2Gecode_MIntVarArrayPtr(argv[1], 2)->ptr()" # end # func.add_parameter "Gecode::DFA", "dfa" # TODO: add class DFA # func.add_parameter "Gecode::IntConLevel", "icl", true # end + + ns.add_function "bab", "Gecode::MSpace*" do |func| + func.add_parameter "Gecode::MSpace*", "home" + func.add_parameter "int", "c_d" + func.add_parameter "int", "a_d" + func.add_parameter "Gecode::Search::MStop *", "st" + end ns.add_function "rel" do |func| func.add_parameter "Gecode::MSpace*", "home" func.add_parameter "Gecode::IntVar", "x0" func.add_parameter "Gecode::IntRelType", "r"