49#if OO_SHADERS || defined(OO_DEBUG_MONITOR_ENABLED)
54static const char* sTemplates[kOOShaderUniformTypeCount];
56static void InitTemplates(
void);
57static const char* CopyTemplateForSelector(
SEL selector);
59OOShaderUniformType OOShaderUniformTypeFromMethodSignature(NSMethodSignature* signature)
62 const char* typeCode = NULL;
67 typeCode = [signature methodReturnType];
69 return kOOShaderUniformTypeInvalid;
71 for (i = kOOShaderUniformTypeInvalid + 1; i != kOOShaderUniformTypeCount; ++i) {
72 if (sTemplates[i] != NULL && strcmp(sTemplates[i], typeCode) == 0)
76 return kOOShaderUniformTypeInvalid;
79@interface OOShaderUniformTypeMethodSignatureTemplateClass : NSObject
82- (double)doubleMethod;
83- (
signed char)signedCharMethod;
84- (
unsigned char)unsignedCharMethod;
85- (
signed short)signedShortMethod;
86- (
unsigned short)unsignedShortMethod;
87- (
signed int)signedIntMethod;
88- (
unsigned int)unsignedIntMethod;
89- (
signed long)signedLongMethod;
90- (
unsigned long)unsignedLongMethod;
95- (NSPoint)pointMethod;
100static void InitTemplates(
void)
102#define GET_TEMPLATE(enumValue, sel) \
104 sTemplates[enumValue] = CopyTemplateForSelector(@selector(sel)); \
107 GET_TEMPLATE(kOOShaderUniformTypeChar, signedCharMethod);
108 GET_TEMPLATE(kOOShaderUniformTypeUnsignedChar, unsignedCharMethod);
109 GET_TEMPLATE(kOOShaderUniformTypeShort, signedShortMethod);
110 GET_TEMPLATE(kOOShaderUniformTypeUnsignedShort, unsignedShortMethod);
111 GET_TEMPLATE(kOOShaderUniformTypeInt, signedIntMethod);
112 GET_TEMPLATE(kOOShaderUniformTypeUnsignedInt, unsignedIntMethod);
113 GET_TEMPLATE(kOOShaderUniformTypeLong, signedLongMethod);
114 GET_TEMPLATE(kOOShaderUniformTypeUnsignedLong, unsignedLongMethod);
115 GET_TEMPLATE(kOOShaderUniformTypeFloat, floatMethod);
116 GET_TEMPLATE(kOOShaderUniformTypeDouble, doubleMethod);
117 GET_TEMPLATE(kOOShaderUniformTypeVector, vectorMethod);
118 GET_TEMPLATE(kOOShaderUniformTypeHPVector, hpvectorMethod);
119 GET_TEMPLATE(kOOShaderUniformTypeQuaternion, quaternionMethod);
120 GET_TEMPLATE(kOOShaderUniformTypeMatrix, matrixMethod);
121 GET_TEMPLATE(kOOShaderUniformTypePoint, pointMethod);
122 GET_TEMPLATE(kOOShaderUniformTypeObject, idMethod);
127static const char* CopyTemplateForSelector(
SEL selector)
129 NSMethodSignature* signature =
nil;
130 const char* typeCode = NULL;
132 signature = [OOShaderUniformTypeMethodSignatureTemplateClass instanceMethodSignatureForSelector:selector];
133 typeCode = [signature methodReturnType];
138 return typeCode ? strdup(typeCode) : NULL;
141@implementation OOShaderUniformTypeMethodSignatureTemplateClass : NSObject
143- (
signed char)signedCharMethod
148- (
unsigned char)unsignedCharMethod
153- (
signed short)signedShortMethod
158- (
unsigned short)unsignedShortMethod
163- (
signed int)signedIntMethod
168- (
unsigned int)unsignedIntMethod
173- (
signed long)signedLongMethod
178- (
unsigned long)unsignedLongMethod
188- (double)doubleMethod
216- (NSPoint)pointMethod
228long long OOCallIntegerMethod(
id object,
SEL selector, IMP method, OOShaderUniformType type)
231 case kOOShaderUniformTypeChar:
232 return ((CharReturnMsgSend)method)(object, selector);
234 case kOOShaderUniformTypeUnsignedChar:
235 return ((UnsignedCharReturnMsgSend)method)(object, selector);
237 case kOOShaderUniformTypeShort:
238 return ((ShortReturnMsgSend)method)(object, selector);
240 case kOOShaderUniformTypeUnsignedShort:
241 return ((UnsignedShortReturnMsgSend)method)(object, selector);
243 case kOOShaderUniformTypeInt:
244 return ((IntReturnMsgSend)method)(object, selector);
246 case kOOShaderUniformTypeUnsignedInt:
247 return ((UnsignedIntReturnMsgSend)method)(object, selector);
249 case kOOShaderUniformTypeLong:
250 return ((LongReturnMsgSend)method)(object, selector);
252 case kOOShaderUniformTypeUnsignedLong:
253 return ((UnsignedLongReturnMsgSend)method)(object, selector);
255 case kOOShaderUniformTypeLongLong:
256 return ((LongLongReturnMsgSend)method)(object, selector);
258 case kOOShaderUniformTypeUnsignedLongLong:
259 return ((UnsignedLongLongReturnMsgSend)method)(object, selector);
266double OOCallFloatMethod(
id object,
SEL selector, IMP method, OOShaderUniformType type)
269 case kOOShaderUniformTypeFloat:
270 return ((FloatReturnMsgSend)method)(object, selector);
272 case kOOShaderUniformTypeDouble:
273 return ((DoubleReturnMsgSend)method)(object, selector);
const OOMatrix kZeroMatrix
struct Quaternion Quaternion
typedef long(ZCALLBACK *tell_file_func) OF((voidpf opaque
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque