lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

It would be great ffi.load could let use specify name transformation function (callback):

  -- function removing gl prefix and changing case,
  -- returning transformed name or nil if we want to skip some symbol
  -- i.e. glDrawArrays -> drawarrays
  local function transform(name, type) […] 
  
  local gl = ffi.load("GL", false, transform)

So it allows us to write:

  gl.begin(gl.VERTEX)

Instead of:

  gl.glBegin(gl.GL_VERTEX)

(Having that we change all cdef GL_VALUE enum entries into VALUE entries)

WDYT? Would such extension sacrifice performance? It would save a lot of typing for sure especially for libs using long prefixes.

Also it would be nice if we could enumerate symbols specified by cdef present in particular library. This would give us possibility also to check presence of particular symbol without raising error.

  for obj, name, type in ffi.symbols(gl) do
    -- do something
  end

Regards,
-- 
Adam Strzelecki