00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "asSColor.h"
00018
00019 #ifdef __COMPILE_WITH_ANGELSCRIPT__
00020
00021 #include "asIrrHelper.h"
00022
00023
00024
00028 void constructor(void *memory)
00029 {
00030 new (memory) SColor();
00031 }
00032
00036 void constructor(u32 clr, void *memory)
00037 {
00038 new (memory) SColor(clr);
00039 }
00040
00044 void constructor(u32 a, u32 r, u32 g, u32 b, void *memory)
00045 {
00046 new (memory) SColor(a, r, g, b);
00047 }
00048
00052 void deconstructor(void *memory)
00053 {
00054 ((SColor*)memory)->~SColor();
00055 }
00056
00059 int compare(const SColor &a, const SColor &b)
00060 {
00061 if( a < b ) return -1;
00062 if( b < a ) return 1;
00063 return 0;
00064 }
00065
00068 void bindSColor(asIScriptEngine *engine)
00069 {
00070
00071 int r;
00072
00073
00074 r = engine->RegisterObjectType("SColor", sizeof(SColor), asOBJ_VALUE | asOBJ_APP_CLASS_CD); assert(r >= 0);
00075
00076
00077
00078 r = engine->RegisterObjectBehaviour("SColor", asBEHAVE_CONSTRUCT, "void f()", asFUNCTIONPR(constructor,
00079 (void*), void), asCALL_CDECL_OBJLAST); assert(r >= 0);
00080
00081 r = engine->RegisterObjectBehaviour("SColor", asBEHAVE_CONSTRUCT, "void f(u32)", asFUNCTIONPR(constructor,
00082 (u32, void*), void), asCALL_CDECL_OBJLAST); assert(r >= 0);
00083
00084 r = engine->RegisterObjectBehaviour("SColor", asBEHAVE_CONSTRUCT, "void f(u32)", asFUNCTIONPR(constructor,
00085 (u32, u32, u32, u32, void*), void), asCALL_CDECL_OBJLAST); assert(r >= 0);
00086
00087 r = engine->RegisterObjectBehaviour("SColor", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(deconstructor),
00088 asCALL_CDECL_OBJLAST); assert(r >= 0);
00089
00090
00091 r = engine->RegisterObjectMethod("SColor", "SColor opAdd(const SColor &in)",
00092 asFUNCTIONPR((add< SColor, SColor, SColor >),
00093 (const SColor&, const SColor&), SColor),
00094 asCALL_CDECL_OBJFIRST); assert(r >= 0);
00095
00096
00097 r = engine->RegisterObjectMethod("SColor", "bool opEquals(const SColor &in)", asFUNCTIONPR(equal<SColor>,
00098 (const SColor&, const SColor&), bool), asCALL_CDECL_OBJFIRST); assert(r >= 0);
00099 r = engine->RegisterObjectMethod("SColor", "bool opCmp(const SColor &in)", asFUNCTIONPR(compare,
00100 (const SColor&, const SColor&), int), asCALL_CDECL_OBJFIRST); assert(r >= 0);
00101
00102
00103 r = engine->RegisterObjectMethod("SColor", "u32 getAlpha()",
00104 asMETHOD(SColor, getAlpha), asCALL_THISCALL); assert(r >= 0);
00105 r = engine->RegisterObjectMethod("SColor", "u32 getAverage()",
00106 asMETHOD(SColor, getAverage), asCALL_THISCALL); assert(r >= 0);
00107 r = engine->RegisterObjectMethod("SColor", "u32 getBlue()",
00108 asMETHOD(SColor, getBlue), asCALL_THISCALL); assert(r >= 0);
00109 r = engine->RegisterObjectMethod("SColor", "u32 getGreen()",
00110 asMETHOD(SColor, getGreen), asCALL_THISCALL); assert(r >= 0);
00111 r = engine->RegisterObjectMethod("SColor", "SColor getInterpolated(const SColor &in, f32)",
00112 asMETHOD(SColor, getInterpolated), asCALL_THISCALL); assert(r >= 0);
00113 r = engine->RegisterObjectMethod("SColor", "SColor getInterpolated_quadratic(const SColor &in, " \
00114 "const SColor &in, f32)", asMETHOD(SColor, getInterpolated_quadratic),
00115 asCALL_THISCALL); assert(r >= 0);
00116 r = engine->RegisterObjectMethod("SColor", "f32 getLuminance()",
00117 asMETHOD(SColor, getLuminance), asCALL_THISCALL); assert(r >= 0);
00118 r = engine->RegisterObjectMethod("SColor", "u32 getRed()",
00119 asMETHOD(SColor, getRed), asCALL_THISCALL); assert(r >= 0);
00120 r = engine->RegisterObjectMethod("SColor", "void set(u32)",
00121 asMETHODPR(SColor, set, (u32), void), asCALL_THISCALL); assert(r >= 0);
00122 r = engine->RegisterObjectMethod("SColor", "void set(u32, u32, u32, u32)",
00123 asMETHODPR(SColor, set, (u32, u32, u32, u32), void), asCALL_THISCALL);
00124 assert(r >= 0);
00125 r = engine->RegisterObjectMethod("SColor", "void setAlpha(u32)",
00126 asMETHOD(SColor, setAlpha), asCALL_THISCALL); assert(r >= 0);
00127 r = engine->RegisterObjectMethod("SColor", "void setBlue(u32)",
00128 asMETHOD(SColor, setBlue), asCALL_THISCALL); assert(r >= 0);
00129 r = engine->RegisterObjectMethod("SColor", "void setGreen(u32)",
00130 asMETHOD(SColor, setGreen), asCALL_THISCALL); assert(r >= 0);
00131 r = engine->RegisterObjectMethod("SColor", "void setRed(u32)",
00132 asMETHOD(SColor, setRed), asCALL_THISCALL); assert(r >= 0);
00133
00134
00135 r = engine->RegisterObjectProperty("SColor", "u32 color", offsetof(SColor, color)); assert(r >= 0);
00136 }
00137
00138 #endif // __COMPILE_WITH_ANGELSCRIPT__
00139
00140