__precompile__(false)
module IBKRCore

using CxxWrap
using CxxWrap.CxxWrapCore
using CxxWrap.CxxWrapCore: CxxInt, CxxLong
using MacroTools

using ...Emporos: PACKAGE_ROOT, @debugcb

const TWS_DEFAULT_PORT = 7497

include("types.jl")

# NOTE: Functions called after @wrapmodule extend those defined in 
# @wrapmodule while those defined before can be referenced in C
@wrapmodule(abspath(joinpath(PACKAGE_ROOT, "../result/lib", "libIBApiWrapper")))
Base.convert(::Type{Any}, x::CxxWrap.CxxWrapCore.SmartPointer{DerivedT}) where {BaseT, DerivedT<:BaseT} = x

function __init__()
    @initcxx
end

# TODO See: https://github.com/JuliaInterop/CxxWrap.jl/issues/301
Base.convert(::Type{Any}, x::CxxWrap.CxxWrapCore.SmartPointer{DerivedT}) where {BaseT, DerivedT<:BaseT} = x

include("jlclient.jl")
include("ibclient.jl")

# Generated
include("generated/ComboLeg.jl")
include("generated/Contract.jl")

end
