daily pastebin goal
13%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %typemap(in) (int argc, t_atom *argv)
  2. {
  3.     if (!lua_istable(L, $input)) {
  4.       SWIG_exception(SWIG_RuntimeError, "argument mismatch: table expected");
  5.     }
  6.     lua_len(L, $input);
  7.     $1 = lua_tointeger(L, -1);
  8.  
  9.     if (!$1) {
  10.         SWIG_exception(SWIG_RuntimeError, "table is empty");
  11.     }
  12.     $2 = (t_atom *)getbytes($1 * sizeof(t_atom));
  13.  
  14.     for (int i=0; i<$1; ++i) {
  15.  
  16.         lua_pushinteger(L, i+1);
  17.         lua_gettable(L, $input);
  18.  
  19.         if (lua_isnumber(L, -1)) {
  20.             $2[i].a_type = A_FLOAT;
  21.             $2[i].a_w.w_float = lua_tonumber(L, -1);
  22.         }          
  23.         else if (lua_isstring(L, -1)) {
  24.             $2[i].a_type = A_SYMBOL;
  25.             $2[i].a_w.w_symbol = gensym(lua_tostring(L, -1));
  26.         }
  27.         else {
  28.             SWIG_exception(SWIG_RuntimeError, "unhandled argument type");
  29.         }
  30.     }
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top