From 9b5be121ce09047add2309bdcfe1797e582b6322 Mon Sep 17 00:00:00 2001 From: Bart Janssens Date: Tue, 11 Jul 2017 08:42:40 +0200 Subject: [PATCH] Add support for Irrational --- deps/src/jlcxx/examples/functions.cpp | 3 +++ src/CxxWrap.jl | 2 +- test/functions.jl | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/deps/src/jlcxx/examples/functions.cpp b/deps/src/jlcxx/examples/functions.cpp index 10ffb93..69b1d70 100644 --- a/deps/src/jlcxx/examples/functions.cpp +++ b/deps/src/jlcxx/examples/functions.cpp @@ -230,6 +230,9 @@ void init_test_module(jlcxx::Module& mod) mod.method("real_part", [](std::complex c) { return c.real(); } ); mod.method("imag_part", [](const std::complex& c) { return c.imag(); } ); mod.method("make_complex", [](const float a, const float b) { return std::complex(a,b); }); + + // Irrational + mod.method("process_irrational", [] (const double irr, const double fact) { return irr*fact; }); } } diff --git a/src/CxxWrap.jl b/src/CxxWrap.jl index 979ffc1..18cc2ea 100644 --- a/src/CxxWrap.jl +++ b/src/CxxWrap.jl @@ -211,7 +211,7 @@ end else argument_overloads(t::Type{Cuint}) = [Int] end -argument_overloads(t::Type{Float64}) = [Int] +argument_overloads(t::Type{Float64}) = [Int, Irrational] function argument_overloads(t::Type{Array{AbstractString,1}}) @static if VERSION < v"0.5-dev" return [Array{ASCIIString,1}] diff --git a/test/functions.jl b/test/functions.jl index e2393d3..b4f868e 100644 --- a/test/functions.jl +++ b/test/functions.jl @@ -108,6 +108,8 @@ unsafe_store!(cppdref, 1.0) @test CppTestFunctions.make_complex(Float32(3.0), Float32(4.0)) == 3.0 + 4.0*im @test typeof(CppTestFunctions.make_complex(Float32(3.0), Float32(4.0))) == Complex{Float32} +@test CppTestFunctions.process_irrational(φ, 2) == 2*φ + # Performance tests const test_size = Sys.ARCH == :armv7l ? 1000000 : 50000000 const numbers = rand(test_size)