Skip to content

Commit

Permalink
Add support for Irrational
Browse files Browse the repository at this point in the history
  • Loading branch information
barche committed Jul 11, 2017
1 parent de26eef commit 9b5be12
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions deps/src/jlcxx/examples/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ void init_test_module(jlcxx::Module& mod)
mod.method("real_part", [](std::complex<double> c) { return c.real(); } );
mod.method("imag_part", [](const std::complex<double>& c) { return c.imag(); } );
mod.method("make_complex", [](const float a, const float b) { return std::complex<float>(a,b); });

// Irrational
mod.method("process_irrational", [] (const double irr, const double fact) { return irr*fact; });
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/CxxWrap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}]
Expand Down
2 changes: 2 additions & 0 deletions test/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9b5be12

Please sign in to comment.