support int64_t transition in c#

This commit is contained in:
Laurent Perron
2018-12-10 12:57:27 +01:00
parent 413e07b6fb
commit 27f9c4f95e
6 changed files with 41 additions and 7 deletions

View File

@@ -195,6 +195,11 @@ $(GEN_DIR)/ortools/constraint_solver/constraint_solver_csharp_wrap.cc: \
$(SED) -i -e 's/CSharp_Constraint/CSharp_CpConstraint/g' \
$(GEN_PATH)$Sortools$Sconstraint_solver$S*cs \
$(GEN_PATH)$Sortools$Sconstraint_solver$Sconstraint_solver_csharp_wrap.*
$(SED) -i -e 's/< long long >/< int64 >/g' \
$(GEN_PATH)$Sortools$Sconstraint_solver$Sconstraint_solver_csharp_wrap.cc
$(SED) -i -e 's/< long long,long long >/< int64, int64 >/g' \
$(GEN_PATH)$Sortools$Sconstraint_solver$Sconstraint_solver_csharp_wrap.cc
$(OBJ_DIR)/swig/constraint_solver_csharp_wrap.$O: \
$(GEN_DIR)/ortools/constraint_solver/constraint_solver_csharp_wrap.cc \
@@ -216,6 +221,9 @@ $(GEN_DIR)/ortools/algorithms/knapsack_solver_csharp_wrap.cc: \
-dllimport "$(OR_TOOLS_NATIVE_ASSEMBLY_NAME).$(SWIG_DOTNET_LIB_SUFFIX)" \
-outdir $(GEN_PATH)$Sortools$Salgorithms \
$(SRC_DIR)$Sortools$Salgorithms$Scsharp$Sknapsack_solver.i
$(SED) -i -e 's/< long long >/< int64_t >/g' \
$(GEN_PATH)$Sortools$Salgorithms$Sknapsack_solver_csharp_wrap.cc
$(OBJ_DIR)/swig/knapsack_solver_csharp_wrap.$O: \
$(GEN_DIR)/ortools/algorithms/knapsack_solver_csharp_wrap.cc \

View File

@@ -13,6 +13,9 @@
// TODO(user): Refactor this file to adhere to the SWIG style guide.
%include <stdint.i>
%include <std_vector.i>
%include "ortools/base/base.i"
/* allow partial c# classes */
@@ -23,7 +26,8 @@
#include "ortools/algorithms/knapsack_solver.h"
%}
%include "std_vector.i"
typedef int64_t int64;
typedef uint64_t uint64;
// See the comment in
// ../../constraint_solver/csharp/constraint_solver.i about naming

View File

@@ -19,12 +19,15 @@ using System.Runtime.InteropServices;
using System.Collections;
%}
%include "exception.i"
%include "std_vector.i"
%include <stdint.i>
%include <exception.i>
%include <std_vector.i>
%include "ortools/base/base.i"
%include "ortools/util/csharp/tuple_set.i"
%include "ortools/util/csharp/functions.i"
%include "ortools/util/csharp/proto.i"
// We need to forward-declare the proto here, so that PROTO_INPUT involving it
// works correctly. The order matters very much: this declaration needs to be
// before the %{ #include ".../constraint_solver.h" %}.
@@ -78,6 +81,9 @@ struct FailureProtect {
};
%}
typedef int64_t int64;
typedef uint64_t uint64;
/* allow partial c# classes */
%typemap(csclassmodifiers) SWIGTYPE "public partial class"
@@ -137,9 +143,9 @@ PROTECT_FROM_FAILURE(Solver::Fail(), arg1);
// files end up being compiled into the same .dll, we must name the
// vector template differently.
%template(CpIntVector) std::vector<int>;
%template(CpInt64Vector) std::vector<int64>;
%template(CpInt64Vector) std::vector<int64_t>;
%template(CpIntVectorVector) std::vector<std::vector<int> >;
%template(CpInt64VectorVector) std::vector<std::vector<int64> >;
%template(CpInt64VectorVector) std::vector<std::vector<int64_t> >;
%define CS_TYPEMAP_STDVECTOR_OBJECT(CTYPE, TYPE)
SWIG_STD_VECTOR_ENHANCED(operations_research::CTYPE*);

View File

@@ -22,6 +22,8 @@
// - examples/csharp/assignment.cs
// - examples/csharp/csflow.cs
%include <stdint.i>
%include "ortools/base/base.i"
%import "ortools/graph/ebert_graph.h"
@@ -32,6 +34,9 @@
#include "ortools/graph/min_cost_flow.h"
%}
typedef int64_t int64;
typedef uint64_t uint64;
// ############ max_flow.h ############
%ignoreall
@@ -39,7 +44,7 @@
%unignore operations_research;
%rename (MaxFlow) operations_research::SimpleMaxFlow;
%unignore operations_research::SimpleMaxFlow::SimpleMaxFlow;
// %unignore operations_research::SimpleMaxFlow::~SimpleMaxFlow;
%unignore operations_research::SimpleMaxFlow::~SimpleMaxFlow;
%unignore operations_research::SimpleMaxFlow::AddArcWithCapacity;
%unignore operations_research::SimpleMaxFlow::Solve;
%unignore operations_research::SimpleMaxFlow::NumNodes;

View File

@@ -28,14 +28,20 @@
// - examples/csharp/cslinearprogramming.cs
// - examples/csharp/csintegerprogramming.cs
%include <stdint.i>
%include <std_vector.i>
%include "ortools/base/base.i"
%include "std_vector.i"
%{
#include "ortools/linear_solver/linear_solver.h"
#include "ortools/linear_solver/linear_solver.pb.h"
%}
typedef int64_t int64;
typedef uint64_t uint64;
// We need to forward-declare the proto here, so that the PROTO_* macros
// involving them work correctly. The order matters very much: this declaration
// needs to be before the %{ #include ".../linear_solver.h" %}.

View File

@@ -17,6 +17,8 @@ using System.Runtime.InteropServices;
using System.Collections;
%}
%include <stdint.i>
%include "ortools/base/base.i"
%include "ortools/util/csharp/proto.i"
@@ -26,6 +28,9 @@ using System.Collections;
#include "ortools/sat/swig_helper.h"
%}
typedef int64_t int64;
typedef uint64_t uint64;
%module(directors="1") operations_research_sat
PROTO_INPUT(operations_research::sat::CpModelProto,