Skip to content

Instantly share code, notes, and snippets.

@ihnorton
ihnorton / libav.jl
Last active December 14, 2015 18:09 — forked from timholy/threelibs.jl
recurs_sym_type(ex::Any) =
(ex==None || typeof(ex)==Symbol || length(ex.args)==1) ? eval(ex) : Expr(ex.head, ex.args[1], recurs_sym_type(ex.args[2]))
macro c(ret_type, func, arg_types, lib)
local _arg_types = Expr(:tuple, [recurs_sym_type(a) for a in arg_types.args]...)
local _ret_type = recurs_sym_type(ret_type)
local _args_in = Any[ symbol(string('a',x)) for x in 1:length(_arg_types.args) ]
local _lib = eval(lib)
quote
$(esc(func))($(_args_in...)) = ccall( ($(string(func)), $(Expr(:quote, _lib)) ), $_ret_type, $_arg_types, $(_args_in...) )