7 #ifndef __lua_LuaObject_h__ 8 #define __lua_LuaObject_h__ 18 LuaBaseObject(
void) {}
19 virtual ~LuaBaseObject(
void) {}
20 sp<LuaBaseType > &type(
void) {
return m_spType; }
21 LuaContext *context(
void) {
return m_spType->context(); }
23 sp<LuaBaseType > m_spType;
26 template<
class T, FE_UWORD t
id>
27 class LuaObject :
public LuaBaseObject
30 LuaObject(
void) { feX(
"LuaObject::LuaObject",
"should never call"); }
32 typedef LuaObject<T,tid> t_luott;
33 LuaObject(LuaContext *pContext,
const T &data)
35 m_spType = pContext->lookup(tid);
37 m_spType->pushMetaTable();
38 lua_setmetatable(m_spType->state(), -2);
40 virtual ~LuaObject(
void){}
42 static LuaObject<T,tid> *push(LuaContext *pContext,
const T &data)
44 void *pBlock = lua_newuserdata(pContext->state(),
46 t_luott *pObj =
new(pBlock)t_luott(pContext, data);
49 T &data(
void) {
return m_data; }
50 static int destroy(lua_State *pLuaState)
52 void *pV = lua_touserdata(pLuaState, -1);
53 t_luott *pW = (t_luott *)pV;
57 static t_luott *selfIsFirst(lua_State *pLuaState)
59 if(!lua_isuserdata(pLuaState, 1))
61 LuaContext::error(pLuaState,
"self not first parameter");
64 t_luott *pObj = (t_luott *)lua_touserdata(pLuaState, 1);
65 if(pObj->type() != pObj->context()->lookup(tid))
67 LuaContext::error(pLuaState,
"self not first parameter");
73 static String argType(lua_State *pLuaState,U32 index)
75 if (!lua_getmetatable(pLuaState, 2))
77 return "<no metatable>";
80 lua_rawget(pLuaState, LUA_REGISTRYINDEX);
81 return lua_tostring(pLuaState, -1);
84 String aliasedName(String a_name)
86 LuaContext* pContext=context();
87 return pContext? pContext->aliasedName(a_name): a_name;
96 typedef LuaObject<Record, LuaContext::e_record> t_lua_record;
97 class LuaRecordObject :
public t_lua_record
100 virtual ~LuaRecordObject(
void) {}
101 static int index(lua_State *pLuaState);
102 static int newindex(lua_State *pLuaState);
103 static int isValid(lua_State *pLuaState);
104 static int check(lua_State *pLuaState);
105 static int layout(lua_State *pLuaState);
106 static int clone(lua_State *pLuaState);
111 typedef LuaType<Record, LuaRecordObject> t_lua_record_t;
112 class LuaRecordType :
public t_lua_record_t
115 LuaRecordType(LuaContext *pContext,
const String &mtn);
116 virtual ~LuaRecordType(
void){}
117 virtual void pushNewMetaTable(
void);
123 typedef LuaObject<sp<Layout>, LuaContext::e_layout> t_lua_layout;
124 class LuaLayoutObject :
public t_lua_layout
127 virtual ~LuaLayoutObject(
void) {}
128 static int index(lua_State *pLuaState);
129 static int scope(lua_State *pLuaState);
130 static int populate(lua_State *pLuaState);
131 static int createRecord(lua_State *pLuaState);
132 static int name(lua_State *pLuaState);
135 typedef LuaType<sp<Layout>, LuaLayoutObject> t_lua_layout_t;
136 class LuaLayoutType :
public t_lua_layout_t
139 LuaLayoutType(LuaContext *pContext,
const String &mtn);
140 virtual ~LuaLayoutType(
void){}
145 typedef LuaObject<sp<Scope>, LuaContext::e_scope> t_lua_scope;
146 class LuaScopeObject :
public t_lua_scope
149 virtual ~LuaScopeObject(
void) {}
150 static int index(lua_State *pLuaState);
151 static int declare(lua_State *pLuaState);
152 static int createRecord(lua_State *pLuaState);
155 typedef LuaType<sp<Scope>, LuaScopeObject> t_lua_scope_t;
156 class LuaScopeType :
public t_lua_scope_t
159 LuaScopeType(LuaContext *pContext,
const String &mtn);
160 virtual ~LuaScopeType(
void){}
165 typedef LuaObject<sp<RecordGroup>, LuaContext::e_group> t_lua_group;
166 class LuaGroupObject :
public t_lua_group
169 virtual ~LuaGroupObject(
void) {}
170 static int index(lua_State *pLuaState);
171 static int iterator(lua_State *pLuaState);
172 static int newiterator(lua_State *pLuaState);
173 static int length(lua_State *pLuaState);
174 static int add(lua_State *pLuaState);
175 static int remove(lua_State *pLuaState);
176 static int lookup(lua_State *pLuaState);
177 static int setWeak(lua_State *pLuaState);
178 static int clear(lua_State *pLuaState);
179 static int array(lua_State *pLuaState);
182 typedef LuaType<sp<RecordGroup>, LuaGroupObject> t_lua_group_t;
183 class LuaGroupType :
public t_lua_group_t
186 LuaGroupType(LuaContext *pContext,
const String &mtn);
187 virtual ~LuaGroupType(
void){}
188 virtual void pushNewMetaTable(
void);
193 typedef LuaObject<RecordGroup::iterator, LuaContext::e_groupit> t_lua_groupit;
194 class LuaGroupItObject :
public t_lua_groupit
197 virtual ~LuaGroupItObject(
void) {}
198 static int index(lua_State *pLuaState);
201 typedef LuaType<RecordGroup::iterator, LuaGroupItObject> t_lua_groupit_t;
202 class LuaGroupItType :
public t_lua_groupit_t
205 LuaGroupItType(LuaContext *pContext,
const String &mtn);
206 virtual ~LuaGroupItType(
void){}
211 typedef LuaObject<sp<RecordArray>, LuaContext::e_array> t_lua_array;
212 class LuaArrayObject :
public t_lua_array
215 virtual ~LuaArrayObject(
void) {}
216 static int index(lua_State *pLuaState);
217 static int iterator(lua_State *pLuaState);
218 static int newiterator(lua_State *pLuaState);
219 static int length(lua_State *pLuaState);
220 static int check(lua_State *pLuaState);
221 static int add(lua_State *pLuaState);
222 static int remove(lua_State *pLuaState);
225 typedef LuaType<sp<RecordArray>, LuaArrayObject> t_lua_array_t;
226 class LuaArrayType :
public t_lua_array_t
229 LuaArrayType(LuaContext *pContext,
const String &mtn);
230 virtual ~LuaArrayType(
void){}
231 virtual void pushNewMetaTable(
void);
234 class LuaArrayContext
237 sp<RecordArray> m_spRecordArray;
241 typedef LuaObject<LuaArrayContext, LuaContext::e_arrayit> t_lua_arrayit;
242 class LuaArrayItObject :
public t_lua_arrayit
245 virtual ~LuaArrayItObject(
void) {}
246 static int index(lua_State *pLuaState);
249 typedef LuaType<LuaArrayContext, LuaArrayItObject> t_lua_arrayit_t;
250 class LuaArrayItType :
public t_lua_arrayit_t
253 LuaArrayItType(LuaContext *pContext,
const String &mtn);
254 virtual ~LuaArrayItType(
void){}
259 typedef LuaObject< Array<I32>*, LuaContext::e_intarray> t_lua_intarray;
260 class LuaIntArrayObject :
public t_lua_intarray
263 virtual ~LuaIntArrayObject(
void) {}
264 static int index(lua_State *pLuaState);
265 static int iterator(lua_State *pLuaState);
266 static int newiterator(lua_State *pLuaState);
267 static int length(lua_State *pLuaState);
268 static int add(lua_State *pLuaState);
269 static int resize(lua_State *pLuaState);
272 typedef LuaType< Array<I32>* , LuaIntArrayObject> t_lua_intarray_t;
273 class LuaIntArrayType :
public t_lua_intarray_t
276 LuaIntArrayType(LuaContext *pContext,
const String &mtn);
277 virtual ~LuaIntArrayType(
void) {}
278 virtual void pushNewMetaTable(
void);
281 class LuaIntArrayContext
284 Array<I32>* m_pIntArray;
288 typedef LuaObject<LuaIntArrayContext,
289 LuaContext::e_intarrayit> t_lua_intarrayit;
290 class LuaIntArrayItObject :
public t_lua_intarrayit
293 virtual ~LuaIntArrayItObject(
void) {}
294 static int index(lua_State *pLuaState);
297 typedef LuaType<LuaIntArrayContext, LuaIntArrayItObject> t_lua_intarrayit_t;
298 class LuaIntArrayItType :
public t_lua_intarrayit_t
301 LuaIntArrayItType(LuaContext *pContext,
const String &mtn);
302 virtual ~LuaIntArrayItType(
void) {}
307 typedef LuaObject<float *, LuaContext::e_vector> t_lua_vector;
308 class LuaVectorObject :
public t_lua_vector
311 virtual ~LuaVectorObject(
void) {}
312 static int newindex(lua_State *pLuaState);
313 static int index(lua_State *pLuaState);
316 typedef LuaType<float *, LuaVectorObject> t_lua_vector_t;
317 class LuaVectorType :
public t_lua_vector_t
320 LuaVectorType(LuaContext *pContext,
const String &mtn);
321 virtual ~LuaVectorType(
void){}
322 virtual void pushNewMetaTable(
void);
327 typedef LuaObject< sp<StateCatalog>, LuaContext::e_statecatalog> t_lua_statecatalog;
328 class LuaStateCatalogObject :
public t_lua_statecatalog
331 virtual ~LuaStateCatalogObject(
void) {}
332 static int index(lua_State *pLuaState);
333 static int getState(lua_State *pLuaState);
334 static int setState(lua_State *pLuaState);
337 typedef LuaType< sp<StateCatalog>, LuaStateCatalogObject> t_lua_statecatalog_t;
338 class LuaStateCatalogType :
public t_lua_statecatalog_t
341 LuaStateCatalogType(LuaContext *pContext,
343 virtual ~LuaStateCatalogType(
void){}
346 template<
class T, FE_UWORD t
id>
347 class LuaDeletableObject :
public LuaObject<T,tid>
350 typedef LuaDeletableObject<T,tid> t_luott;
352 LuaDeletableObject(LuaContext *pContext,
353 const T &data, BWORD a_deletable):
354 LuaObject<T,tid>(pContext,data),
355 m_deletable(a_deletable) {}
357 static LuaObject<T,tid> *push(LuaContext *pContext,
const T &data,
358 BWORD a_deletable=FALSE)
360 void *pBlock = lua_newuserdata(pContext->state(),
362 t_luott *pObj =
new(pBlock)t_luott(pContext, data, a_deletable);
366 static int destroy(lua_State *pLuaState)
368 void *pV = lua_touserdata(pLuaState, -1);
369 t_luott *pW = (t_luott *)pV;
385 typedef LuaDeletableObject<SpatialTransform*,
386 LuaContext::e_transform> t_lua_transform;
387 class LuaTransformObject :
public t_lua_transform
390 virtual ~LuaTransformObject(
void) {}
391 static int newindex(lua_State *pLuaState);
392 static int index(lua_State *pLuaState);
393 static int eq(lua_State *pLuaState);
394 static int copy(lua_State *pLuaState);
395 static int set(lua_State *pLuaState);
398 typedef LuaType<SpatialTransform*, LuaTransformObject> t_lua_transform_t;
399 class LuaTransformType :
public t_lua_transform_t
402 LuaTransformType(LuaContext *pContext,
404 virtual ~LuaTransformType(
void){}
405 virtual void pushNewMetaTable(
void);
410 template<
int N,
class T, FE_UWORD t
id>
411 class LuaVectorNObject :
412 public LuaDeletableObject<Vector<N,T>*, tid>
415 virtual ~LuaVectorNObject(
void) {}
416 static int newindex(lua_State *pLuaState);
417 static int index(lua_State *pLuaState);
418 static int eq(lua_State *pLuaState);
419 static int unm(lua_State *pLuaState);
420 static int add(lua_State *pLuaState);
421 static int sub(lua_State *pLuaState);
422 static int mul(lua_State *pLuaState);
423 static int copy(lua_State *pLuaState);
424 static int unit(lua_State *pLuaState);
425 static int normalize(lua_State *pLuaState);
426 static int magnitude(lua_State *pLuaState);
427 static int dot(lua_State *pLuaState);
428 static int cross3(lua_State *pLuaState);
429 static int set(lua_State *pLuaState);
432 template<
int N,
class T, FE_UWORD t
id>
433 int LuaVectorNObject<N,T,tid>::index(lua_State *pLuaState)
435 LuaVectorNObject<N,T,tid> *pObj = (LuaVectorNObject<N,T,tid> *)
436 LuaObject<T,tid>::selfIsFirst(pLuaState);
442 if(lua_isnumber(pLuaState, -1))
444 int index = (int)lua_tonumber(pLuaState, -1);
445 lua_pop(pLuaState, 1);
446 lua_pushnumber(pLuaState, (*pObj->data())[index]);
450 String methodName = lua_tostring(pLuaState, -1);
452 lua_pop(pLuaState, 1);
454 if(!pObj->type()->pushMethod(methodName))
462 template<
int N,
class T, FE_UWORD t
id>
463 int LuaVectorNObject<N,T,tid>::newindex(lua_State *pLuaState)
465 LuaVectorNObject<N,T,tid> *pObj =
466 (LuaVectorNObject<N,T,tid> *)lua_touserdata(pLuaState, 1);
467 if(!pObj|| !lua_isnumber(pLuaState, -2))
472 int index = (int)lua_tonumber(pLuaState, -2);
473 float value = (float)lua_tonumber(pLuaState, -1);
475 setAt(*pObj->data(),index,(Real)value);
477 lua_pushnumber(pLuaState, value);
481 template<
int N,
class T, FE_UWORD t
id>
482 int LuaVectorNObject<N,T,tid>::eq(lua_State *pLuaState)
484 LuaVectorNObject<N,T,tid> *pObj =
485 (LuaVectorNObject<N,T,tid> *)lua_touserdata(pLuaState, 1);
491 LuaVectorNObject<N,T,tid>* pOther;
492 if((pOther=
reinterpret_cast<LuaVectorNObject<N,T,tid>*
> 493 (luaL_checkudata(pLuaState,2,pObj->type()->name().c_str()))))
495 lua_pushboolean(pLuaState,*pObj->data() == *pOther->data());
499 feLog(
"LuaVectorNObject::eq incompatible argType \"%s\"\n",
500 LuaObject<T,tid>::argType(pLuaState,2).c_str());
505 template<
int N,
class T, FE_UWORD t
id>
506 int LuaVectorNObject<N,T,tid>::unm(lua_State *pLuaState)
508 LuaVectorNObject<N,T,tid> *pObj =
509 (LuaVectorNObject<N,T,tid> *)lua_touserdata(pLuaState, 1);
515 Vector<N,T>* pNegative=
new Vector<N,T>(-(*pObj->data()));
516 LuaVectorNObject<N,T,tid>::push(pObj->context(),pNegative,TRUE);
520 template<
int N,
class T, FE_UWORD t
id>
521 int LuaVectorNObject<N,T,tid>::add(lua_State *pLuaState)
523 LuaVectorNObject<N,T,tid> *pObj =
524 (LuaVectorNObject<N,T,tid> *)lua_touserdata(pLuaState, 1);
530 LuaVectorNObject<N,T,tid>* pOther;
531 if((pOther=
reinterpret_cast<LuaVectorNObject<N,T,tid>*
> 532 (luaL_checkudata(pLuaState,2,pObj->type()->name().c_str()))))
534 Vector<N,T>* pSum=
new Vector<N,T>(*pObj->data() + *pOther->data());
535 LuaVectorNObject<N,T,tid>::push(pObj->context(),pSum,TRUE);
539 feLog(
"LuaVectorNObject::add incompatible argType \"%s\"\n",
540 LuaObject<T,tid>::argType(pLuaState,2).c_str());
544 template<
int N,
class T, FE_UWORD t
id>
545 int LuaVectorNObject<N,T,tid>::sub(lua_State *pLuaState)
547 LuaVectorNObject<N,T,tid> *pObj =
548 (LuaVectorNObject<N,T,tid> *)lua_touserdata(pLuaState, 1);
554 LuaVectorNObject<N,T,tid>* pOther;
555 if((pOther=
reinterpret_cast<LuaVectorNObject<N,T,tid>*
> 556 (luaL_checkudata(pLuaState,2,pObj->type()->name().c_str()))))
558 Vector<N,T>* pDiff=
new Vector<N,T>(*pObj->data() - *pOther->data());
559 LuaVectorNObject<N,T,tid>::push(pObj->context(),pDiff,TRUE);
563 feLog(
"LuaVectorNObject::sub incompatible argType \"%s\"\n",
564 LuaObject<T,tid>::argType(pLuaState,2).c_str());
568 template<
int N,
class T, FE_UWORD t
id>
569 int LuaVectorNObject<N,T,tid>::mul(lua_State *pLuaState)
572 LuaVectorNObject<N,T,tid> *pObj =
573 (LuaVectorNObject<N,T,tid> *)lua_touserdata(pLuaState, 1);
577 pObj = (LuaVectorNObject<N,T,tid> *)lua_touserdata(pLuaState, 2);
585 if(lua_isnumber(pLuaState,scalarPos))
587 scalar = (F32)lua_tonumber(pLuaState,scalarPos);
594 Vector<N,T>* pSum=
new Vector<N,T>(*pObj->data() * (Real)scalar);
595 LuaVectorNObject<N,T,tid>::push(pObj->context(),pSum,TRUE);
599 template<
int N,
class T, FE_UWORD t
id>
600 int LuaVectorNObject<N,T,tid>::copy(lua_State *pLuaState)
602 LuaVectorNObject<N,T,tid> *pObj =
603 (LuaVectorNObject<N,T,tid> *)lua_touserdata(pLuaState, 1);
609 Vector<N,T>* pDuplicate=
new Vector<N,T>(*pObj->data());
610 LuaVectorNObject<N,T,tid>::push(pObj->context(),pDuplicate,TRUE);
614 template<
int N,
class T, FE_UWORD t
id>
615 int LuaVectorNObject<N,T,tid>::unit(lua_State *pLuaState)
617 LuaVectorNObject<N,T,tid> *pObj =
618 (LuaVectorNObject<N,T,tid> *)lua_touserdata(pLuaState, 1);
624 Vector<N,T>* pNormal=
new Vector<N,T>(fe::unit(*pObj->data()));
625 LuaVectorNObject<N,T,tid>::push(pObj->context(),pNormal,TRUE);
629 template<
int N,
class T, FE_UWORD t
id>
630 int LuaVectorNObject<N,T,tid>::normalize(lua_State *pLuaState)
632 LuaVectorNObject<N,T,tid> *pObj =
633 (LuaVectorNObject<N,T,tid> *)lua_touserdata(pLuaState, 1);
639 fe::normalize(*pObj->data());
640 LuaVectorNObject<N,T,tid>::push(pObj->context(),pObj->data());
644 template<
int N,
class T, FE_UWORD t
id>
645 int LuaVectorNObject<N,T,tid>::magnitude(lua_State *pLuaState)
647 LuaVectorNObject<N,T,tid> *pObj =
648 (LuaVectorNObject<N,T,tid> *)lua_touserdata(pLuaState, 1);
654 F32 length=fe::magnitude(*pObj->data());
655 lua_pushnumber(pLuaState, length);
659 template<
int N,
class T, FE_UWORD t
id>
660 int LuaVectorNObject<N,T,tid>::dot(lua_State *pLuaState)
662 LuaVectorNObject<N,T,tid> *pObj =
663 (LuaVectorNObject<N,T,tid> *)lua_touserdata(pLuaState, 1);
669 LuaVectorNObject<N,T,tid>* pOther;
670 if((pOther=
reinterpret_cast<LuaVectorNObject<N,T,tid>*
> 671 (luaL_checkudata(pLuaState,2,pObj->type()->name().c_str()))))
673 F32 dot=fe::dot(*pObj->data(),*pOther->data());
674 lua_pushnumber(pLuaState, dot);
678 feLog(
"LuaVectorNObject::dot incompatible argType \"%s\"\n",
679 LuaObject<T,tid>::argType(pLuaState,2).c_str());
683 template<
int N,
class T, FE_UWORD t
id>
684 int LuaVectorNObject<N,T,tid>::cross3(lua_State *pLuaState)
686 LuaVectorNObject<N,T,tid> *pObj =
687 (LuaVectorNObject<N,T,tid> *)lua_touserdata(pLuaState, 1);
693 LuaVectorNObject<N,T,tid>* pOther;
694 if((pOther=
reinterpret_cast<LuaVectorNObject<N,T,tid>*
> 695 (luaL_checkudata(pLuaState,2,pObj->type()->name().c_str()))))
700 Vector<3,T> lhs(*pObj->data());
701 Vector<3,T> rhs(*pOther->data());
702 Vector<3,T> result=fe::cross3(lhs,rhs);
703 Vector<N,T>* pCross=
new Vector<N,T>(result);
705 LuaVectorNObject<N,T,tid>::push(pObj->context(),pCross,TRUE);
709 feLog(
"LuaVectorNObject::cross3 incompatible argType \"%s\"\n",
710 LuaObject<T,tid>::argType(pLuaState,2).c_str());
714 template<
int N,
class T, FE_UWORD t
id>
715 int LuaVectorNObject<N,T,tid>::set(lua_State *pLuaState)
717 LuaVectorNObject<N,T,tid> *pObj =
718 (LuaVectorNObject<N,T,tid> *)lua_touserdata(pLuaState, 1);
724 LuaVectorNObject<N,T,tid>* pOther;
725 if((pOther=
reinterpret_cast<LuaVectorNObject<N,T,tid>*
> 726 (luaL_checkudata(pLuaState,2,pObj->type()->name().c_str()))))
728 *pObj->data()=*pOther->data();
729 LuaVectorNObject<N,T,tid>::push(pObj->context(),pObj->data());
733 Vector<N,T>& rVector = *pObj->data();
736 if(lua_isnumber(pLuaState, 2))
738 rVector[0]=(Real)lua_tonumber(pLuaState, 2);
740 if(N>1 && lua_isnumber(pLuaState, 3))
742 rVector[1]=(Real)lua_tonumber(pLuaState, 3);
744 if(N>2 && lua_isnumber(pLuaState, 4))
746 rVector[2]=(Real)lua_tonumber(pLuaState, 4);
748 if(N>3 && lua_isnumber(pLuaState, 5))
750 rVector[3]=(Real)lua_tonumber(pLuaState, 5);
753 LuaVectorNObject<N,T,tid>::push(pObj->context(),pObj->data());
757 template<
int N,
class T, FE_UWORD t
id>
758 class LuaVectorNType:
759 public LuaType< Vector<N,T>*, LuaVectorNObject<N,T,tid> >
762 LuaVectorNType(LuaContext *pContext,
const String &mtn);
763 virtual ~LuaVectorNType(
void){}
764 virtual void pushNewMetaTable(
void);
767 template<
int N,
class T, FE_UWORD t
id>
768 inline LuaVectorNType<N,T,tid>::LuaVectorNType(
769 LuaContext *pContext,
const String &mtn):
770 LuaType< Vector<N,T>*, LuaVectorNObject<N,T,tid> >(pContext, mtn)
773 LuaBaseType::setMethod(
"copy", LuaVectorNObject<N,T,tid>::copy);
774 LuaBaseType::setMethod(
"unit", LuaVectorNObject<N,T,tid>::unit);
775 LuaBaseType::setMethod(
"normalize", LuaVectorNObject<N,T,tid>::normalize);
776 LuaBaseType::setMethod(
"magnitude", LuaVectorNObject<N,T,tid>::magnitude);
777 LuaBaseType::setMethod(
"dot", LuaVectorNObject<N,T,tid>::dot);
778 LuaBaseType::setMethod(
"cross3", LuaVectorNObject<N,T,tid>::cross3);
779 LuaBaseType::setMethod(
"set", LuaVectorNObject<N,T,tid>::set);
782 template<
int N,
class T, FE_UWORD t
id>
783 void LuaVectorNType<N,T,tid>::pushNewMetaTable(
void)
785 lua_State *pLuaState = LuaVectorNType<N,T,tid>::m_pContext->state();
788 luaL_newmetatable(pLuaState,LuaVectorNType<N,T,tid>::m_mtname.c_str());
792 lua_pushstring(pLuaState,
"__gc");
793 lua_pushcfunction(pLuaState, (LuaVectorNObject<N,T,tid>::destroy));
794 lua_settable(pLuaState, -3);
796 lua_pushstring(pLuaState,
"__index");
797 lua_pushcfunction(pLuaState, (LuaVectorNObject<N,T,tid>::index));
798 lua_settable(pLuaState, -3);
800 lua_pushstring(pLuaState,
"__newindex");
801 lua_pushcfunction(pLuaState, (LuaVectorNObject<N,T,tid>::newindex));
802 lua_settable(pLuaState, -3);
804 lua_pushstring(pLuaState,
"__eq");
805 lua_pushcfunction(pLuaState, (LuaVectorNObject<N,T,tid>::eq));
806 lua_settable(pLuaState, -3);
808 lua_pushstring(pLuaState,
"__unm");
809 lua_pushcfunction(pLuaState, (LuaVectorNObject<N,T,tid>::unm));
810 lua_settable(pLuaState, -3);
812 lua_pushstring(pLuaState,
"__add");
813 lua_pushcfunction(pLuaState, (LuaVectorNObject<N,T,tid>::add));
814 lua_settable(pLuaState, -3);
816 lua_pushstring(pLuaState,
"__sub");
817 lua_pushcfunction(pLuaState, (LuaVectorNObject<N,T,tid>::sub));
818 lua_settable(pLuaState, -3);
820 lua_pushstring(pLuaState,
"__mul");
821 lua_pushcfunction(pLuaState, (LuaVectorNObject<N,T,tid>::mul));
822 lua_settable(pLuaState, -3);
827 typedef LuaVectorNObject<4,Real,LuaContext::e_vector4> t_lua_vector4;
828 class LuaVector4Object :
public t_lua_vector4
831 virtual ~LuaVector4Object(
void) {}
834 typedef LuaVectorNType<4,Real,LuaContext::e_vector4> t_lua_vector4_t;
835 class LuaVector4Type :
public t_lua_vector4_t
838 LuaVector4Type(LuaContext *pContext,
const String &mtn):
839 LuaVectorNType<4,Real,LuaContext::e_vector4>(
845 typedef LuaVectorNObject<4,float,LuaContext::e_vector4f> t_lua_vector4f;
846 class LuaVector4fObject :
public t_lua_vector4f
849 virtual ~LuaVector4fObject(
void) {}
852 typedef LuaVectorNType<4,float,LuaContext::e_vector4f> t_lua_vector4f_t;
853 class LuaVector4fType :
public t_lua_vector4f_t
856 LuaVector4fType(LuaContext *pContext,
const String &mtn):
857 LuaVectorNType<4,float,LuaContext::e_vector4f>(
863 typedef LuaVectorNObject<3,float,LuaContext::e_vector3> t_lua_vector3;
864 class LuaVector3Object :
public t_lua_vector3
867 virtual ~LuaVector3Object(
void) {}
870 typedef LuaVectorNType<3,float,LuaContext::e_vector3> t_lua_vector3_t;
871 class LuaVector3Type :
public t_lua_vector3_t
874 LuaVector3Type(LuaContext *pContext,
const String &mtn):
875 LuaVectorNType<3,float,LuaContext::e_vector3>(
881 typedef LuaVectorNObject<2,float,LuaContext::e_vector2> t_lua_vector2;
882 class LuaVector2Object :
public t_lua_vector2
885 virtual ~LuaVector2Object(
void) {}
888 typedef LuaVectorNType<2,float,LuaContext::e_vector2> t_lua_vector2_t;
889 class LuaVector2Type :
public t_lua_vector2_t
892 LuaVector2Type(LuaContext *pContext,
const String &mtn):
893 LuaVectorNType<2,float,LuaContext::e_vector2>(
kernel
Definition: namespace.dox:3