allow lua to access array at an offset
[ardour.git] / libs / lua / LuaBridge / detail / CFunctions.h
index 6f439192163948f6ab3acec5d907df58f3f3c24b..15bc7022b3d1d85bbcc5d7fe3014340d7335ed28 100644 (file)
@@ -969,6 +969,14 @@ struct CFunc
     return 0;
   }
 
+  // return same array at an offset
+  template <typename T>
+  static int offsetArray (lua_State* L) {
+    T *v = luabridge::Stack<T*>::get (L, 1);
+    const unsigned int i = luabridge::Stack<unsigned int>::get (L, 2);
+    Stack <T*>::push (L, &v[i]);
+    return 1;
+  }
 
   //--------------------------------------------------------------------------
   /**