revamp and simplify swig support, force typed enums for C# and Java for all except the constraint_solver/routing module; port examples; Fix SAT on very large problems

This commit is contained in:
Laurent Perron
2018-12-11 17:03:03 +01:00
parent 1e59a36509
commit fedf3d4ff4
35 changed files with 109 additions and 266 deletions

View File

@@ -1,4 +1,4 @@
// Copyright 2010-2014 Google
// Copyright 2010-2018 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -11,7 +11,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// TODO(user): make this SWIG file comply with the SWIG style guide.
%include "ortools/base/base.i"
%import "ortools/base/integral_types.h"

View File

@@ -29,11 +29,7 @@
// Note(user): for an unknown reason, using the (handy) method PyObjAs()
// defined in base/swig/python-swig.cc seems to cause issues, so we can't
// use a generic, templated type checker.
// Get const std::vector<string>& "in" typemap.
%include "python/std_vector.i"
%include "python/std_map.i"
%include "python/std_set.i"
%include "python/std_list.i"
// Get const std::vector<std::string>& "in" typemap.
%define PY_LIST_OUTPUT_TYPEMAP(type, checker, py_converter)
%typecheck(SWIG_TYPECHECK_POINTER) const std::vector<type>&,
@@ -71,14 +67,12 @@
}
%typemap(in,numinputs=0)
std::vector<type>* OUTPUT (std::vector<type> temp),
std::unordered_set<type>* OUTPUT (std::unordered_set<type> temp),
std::set<type>* OUTPUT (std::set<type> temp) {
$1 = &temp;
}
%typemap(argout)
std::vector<type>* OUTPUT,
std::set<type>* OUTPUT,
std::unordered_set<type>* OUTPUT {
std::set<type>* OUTPUT {
%append_output(list_output_helper($1, &py_converter));
}
%typemap(out) std::vector<type> {
@@ -88,9 +82,6 @@
$result = vector_output_helper($1, &py_converter);
}
%apply std::vector<type>* OUTPUT { std::vector<type>* OUTPUT }
%apply std::set<type>* OUTPUT { std::set<type>* OUTPUT }
%enddef // PY_LIST_OUTPUT_TYPEMAP
PY_LIST_OUTPUT_TYPEMAP(int, PyInt_Check, PyInt_FromLong);
@@ -164,9 +155,6 @@ PY_LIST_OUTPUT_TYPEMAP(double, PyFloat_Check, PyFloat_FromDouble);
}
}
%apply const std::vector<std::vector<type> >& {
const std::vector<std::vector<type> >&
}
%enddef // PY_LIST_LIST_INPUT_TYPEMAP
PY_LIST_LIST_INPUT_TYPEMAP(int64, SwigPyIntOrLong_Check);