Skip to content

Commit

Permalink
some adjustments to the C type names
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Feb 27, 2013
1 parent a751bac commit 0c4decc
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 54 deletions.
30 changes: 0 additions & 30 deletions base/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ import Core.Array # to add methods
convert(T, x) = convert_default(T, x, convert)
convert(T::Tuple, x::Tuple) = convert_tuple(T, x, convert)

ptr_arg_convert{T}(::Type{Ptr{T}}, x) = convert(T, x)
ptr_arg_convert(::Type{Ptr{Void}}, x) = x

# conversion used by ccall
cconvert(T, x) = convert(T, x)
# use the code in ccall.cpp to safely allocate temporary pointer arrays
cconvert{T}(::Type{Ptr{Ptr{T}}}, a::Array) = a
# TODO: for some reason this causes a strange type inference problem
#cconvert(::Type{Ptr{Uint8}}, s::String) = bytestring(s)

abstract IO

type ErrorException <: Exception
Expand Down Expand Up @@ -120,26 +110,6 @@ object_id(x::ANY) = ccall(:jl_object_id, Uint, (Any,), x)
const isimmutable = x->(isa(x,Tuple) || isa(x,Symbol) ||
isa(typeof(x),BitsKind))

# constants to match JL_RTLD_* in src/julia.h
const RTLD_LOCAL = 0x00000000
const RTLD_GLOBAL = 0x00000001
const RTLD_LAZY = 0x00000002
const RTLD_NOW = 0x00000004
const RTLD_NODELETE = 0x00000008
const RTLD_NOLOAD = 0x00000010
const RTLD_DEEPBIND = 0x00000020
const RTLD_FIRST = 0x00000040

dlsym(hnd, s::String) = ccall(:jl_dlsym, Ptr{Void}, (Ptr{Void}, Ptr{Uint8}), hnd, s)
dlsym(hnd, s::Symbol) = ccall(:jl_dlsym, Ptr{Void}, (Ptr{Void}, Ptr{Uint8}), hnd, s)
dlsym_e(hnd, s::Union(Symbol,String)) = ccall(:jl_dlsym_e, Ptr{Void}, (Ptr{Void}, Ptr{Uint8}), hnd, s)
dlopen(s::String, flags::Integer) = ccall(:jl_load_dynamic_library, Ptr{Void}, (Ptr{Uint8},Uint32), s, flags)
dlopen(s::String) = dlopen(s, RTLD_LAZY | RTLD_DEEPBIND)
dlclose(p::Ptr) = ccall(:uv_dlclose,Void,(Ptr{Void},),p)

cfunction(f::Function, r, a) =
ccall(:jl_function_ptr, Ptr{Void}, (Any, Any, Any), f, r, a)

identity(x) = x

function append_any(xs...)
Expand Down
53 changes: 53 additions & 0 deletions base/c.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# definitions related to C interface

ptr_arg_convert{T}(::Type{Ptr{T}}, x) = convert(T, x)
ptr_arg_convert(::Type{Ptr{Void}}, x) = x

# conversion used by ccall
cconvert(T, x) = convert(T, x)
# use the code in ccall.cpp to safely allocate temporary pointer arrays
cconvert{T}(::Type{Ptr{Ptr{T}}}, a::Array) = a
# TODO: for some reason this causes a strange type inference problem
#cconvert(::Type{Ptr{Uint8}}, s::String) = bytestring(s)

# constants to match JL_RTLD_* in src/julia.h
const RTLD_LOCAL = 0x00000000
const RTLD_GLOBAL = 0x00000001
const RTLD_LAZY = 0x00000002
const RTLD_NOW = 0x00000004
const RTLD_NODELETE = 0x00000008
const RTLD_NOLOAD = 0x00000010
const RTLD_DEEPBIND = 0x00000020
const RTLD_FIRST = 0x00000040

dlsym(hnd, s::String) = ccall(:jl_dlsym, Ptr{Void}, (Ptr{Void}, Ptr{Uint8}), hnd, s)
dlsym(hnd, s::Symbol) = ccall(:jl_dlsym, Ptr{Void}, (Ptr{Void}, Ptr{Uint8}), hnd, s)
dlsym_e(hnd, s::Union(Symbol,String)) = ccall(:jl_dlsym_e, Ptr{Void}, (Ptr{Void}, Ptr{Uint8}), hnd, s)
dlopen(s::String, flags::Integer) = ccall(:jl_load_dynamic_library, Ptr{Void}, (Ptr{Uint8},Uint32), s, flags)
dlopen(s::String) = dlopen(s, RTLD_LAZY | RTLD_DEEPBIND)
dlclose(p::Ptr) = ccall(:uv_dlclose,Void,(Ptr{Void},),p)

cfunction(f::Function, r, a) =
ccall(:jl_function_ptr, Ptr{Void}, (Any, Any, Any), f, r, a)

typealias Cchar Int8
typealias Cuchar Uint8
typealias Cshort Int16
typealias Cushort Uint16
typealias Cint Int32
typealias Cuint Uint32
if OS_NAME === :Windows
typealias Clong Int32
typealias Culong Uint32
else
typealias Clong Int
typealias Culong Uint
end
typealias Cptrdiff_t Int
typealias Csize_t Uint
typealias Clonglong Int64
typealias Culonglong Uint64
typealias Cfloat Float32
typealias Cdouble Float64
#typealias Ccomplex_float Complex64
#typealias Ccomplex_double Complex128
1 change: 0 additions & 1 deletion base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ export
Cdouble,
Ccomplex_float,
Ccomplex_double,
Cstring,

# Exceptions
ArgumentError,
Expand Down
24 changes: 1 addition & 23 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ end

include("base.jl")
include("build_h.jl")
include("c.jl")

# core operations & types
include("range.jl")
Expand All @@ -64,29 +65,6 @@ include("reduce.jl")
include("complex.jl")
include("rational.jl")

typealias Cchar Int8
typealias Cuchar Int8
typealias Cshort Int16
typealias Cushort Uint16
typealias Cint Int32
typealias Cuint Uint32
if OS_NAME == :Windows
typealias Clong Int32
typealias Culong Uint32
else
typealias Clong Int
typealias Culong Int
end
typealias Cptrdiff_t Int
typealias Csize_t Uint
typealias Clonglong Int64
typealias Culonglong Uint64
typealias Cfloat Float32
typealias Cdouble Float64
#typealias Ccomplex_float Complex64
#typealias Ccomplex_double Complex128
typealias Cstring Ptr{Uint8}

# core data structures (used by type inference)
include("abstractarray.jl")
include("subarray.jl")
Expand Down

0 comments on commit 0c4decc

Please sign in to comment.