Skip to content

Instantly share code, notes, and snippets.

@TsurHerman
TsurHerman / mfunc.jl
Created May 31, 2018 21:01
Help with a macro
abstract type ContextCall{FN,MOD,C} end
abstract type Context{C} end
Context{C}(x) where C = x
# desired output for macro
# @mfunction AAA(a::Int64,b::Int64) = a+b
#
@generated ContextCall{:AAA,:Main,C}(a::Int64,b::Int64) where C = begin
code = quote
using ModernGL
function gen_buffer(f,n::Integer)
res = Array{GLuint}(n)
f(n,res)
if any(res .<= 0)
error("invalid id. OpenGL Context active?")
end
return res
end
function parseini(fname::String)
initxt = Dict{String,Dict{String,Any}}();
fid = open(fname)
blockname = "default"
seekstart(fid)
lines = eachline(fid)
lastkey = ""
for line in lines
# skip comments and newlines
@TsurHerman
TsurHerman / gist:4f5df9a89662f8428c6391c27f360c8d
Created March 13, 2017 12:14
julia Ini file reader and writer
function parseini(fname::String)
initxt = Dict{String,Dict{String,Any}}();
fid = open(fname)
blockname = "default"
seekstart(fid)
lines = eachline(fid)
lastkey = ""
for line in lines
# skip comments and newlines