Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OOShaderUniformMethodType.m File Reference
+ Include dependency graph for OOShaderUniformMethodType.m:

Go to the source code of this file.

Classes

class  OOShaderUniformTypeMethodSignatureTemplateClass
 

Macros

#define GET_TEMPLATE(enumValue, sel)
 

Functions

static void InitTemplates (void)
 
static const char * CopyTemplateForSelector (SEL selector)
 
OOShaderUniformType OOShaderUniformTypeFromMethodSignature (NSMethodSignature *signature)
 
long long OOCallIntegerMethod (id object, SEL selector, IMP method, OOShaderUniformType type)
 
double OOCallFloatMethod (id object, SEL selector, IMP method, OOShaderUniformType type)
 

Variables

static BOOL sInited = NO
 
static const char * sTemplates [kOOShaderUniformTypeCount]
 
 __pad0__
 

Macro Definition Documentation

◆ GET_TEMPLATE

#define GET_TEMPLATE ( enumValue,
sel )
Value:
do { \
sTemplates[enumValue] = CopyTemplateForSelector(@selector(sel)); \
} while (0)
static const char * CopyTemplateForSelector(SEL selector)
static const char * sTemplates[kOOShaderUniformTypeCount]

Referenced by InitTemplates().

Function Documentation

◆ CopyTemplateForSelector()

static const char * CopyTemplateForSelector ( SEL selector)
static

Definition at line 130 of file OOShaderUniformMethodType.m.

131{
132 NSMethodSignature *signature = nil;
133 const char *typeCode = NULL;
134
135 signature = [OOShaderUniformTypeMethodSignatureTemplateClass instanceMethodSignatureForSelector:selector];
136 typeCode = [signature methodReturnType];
137
138 /* typeCode is *probably* a constant, but this isn't formally guaranteed
139 as far as I'm aware, so we make a copy of it.
140 */
141 return typeCode ? strdup(typeCode) : NULL;
142}
return nil

References nil.

◆ InitTemplates()

static void InitTemplates ( void )
static

Definition at line 103 of file OOShaderUniformMethodType.m.

104{
105 #define GET_TEMPLATE(enumValue, sel) do { \
106 sTemplates[enumValue] = CopyTemplateForSelector(@selector(sel)); \
107 } while (0)
108
109 GET_TEMPLATE(kOOShaderUniformTypeChar, signedCharMethod);
111 GET_TEMPLATE(kOOShaderUniformTypeShort, signedShortMethod);
113 GET_TEMPLATE(kOOShaderUniformTypeInt, signedIntMethod);
115 GET_TEMPLATE(kOOShaderUniformTypeLong, signedLongMethod);
125
126 sInited = YES;
127}
@ kOOShaderUniformTypeQuaternion
@ kOOShaderUniformTypeMatrix
@ kOOShaderUniformTypeVector
@ kOOShaderUniformTypeLong
@ kOOShaderUniformTypeUnsignedChar
@ kOOShaderUniformTypeShort
@ kOOShaderUniformTypePoint
@ kOOShaderUniformTypeUnsignedLong
@ kOOShaderUniformTypeFloat
@ kOOShaderUniformTypeUnsignedInt
@ kOOShaderUniformTypeUnsignedShort
@ kOOShaderUniformTypeDouble
@ kOOShaderUniformTypeObject
@ kOOShaderUniformTypeHPVector
@ kOOShaderUniformTypeInt
@ kOOShaderUniformTypeChar
static BOOL sInited
#define GET_TEMPLATE(enumValue, sel)

References OOShaderUniformTypeMethodSignatureTemplateClass::doubleMethod, OOShaderUniformTypeMethodSignatureTemplateClass::floatMethod, GET_TEMPLATE, OOShaderUniformTypeMethodSignatureTemplateClass::hpvectorMethod, OOShaderUniformTypeMethodSignatureTemplateClass::idMethod, kOOShaderUniformTypeChar, kOOShaderUniformTypeDouble, kOOShaderUniformTypeFloat, kOOShaderUniformTypeHPVector, kOOShaderUniformTypeInt, kOOShaderUniformTypeLong, kOOShaderUniformTypeMatrix, kOOShaderUniformTypeObject, kOOShaderUniformTypePoint, kOOShaderUniformTypeQuaternion, kOOShaderUniformTypeShort, kOOShaderUniformTypeUnsignedChar, kOOShaderUniformTypeUnsignedInt, kOOShaderUniformTypeUnsignedLong, kOOShaderUniformTypeUnsignedShort, kOOShaderUniformTypeVector, OOShaderUniformTypeMethodSignatureTemplateClass::matrixMethod, OOShaderUniformTypeMethodSignatureTemplateClass::pointMethod, OOShaderUniformTypeMethodSignatureTemplateClass::quaternionMethod, OOShaderUniformTypeMethodSignatureTemplateClass::signedCharMethod, OOShaderUniformTypeMethodSignatureTemplateClass::signedIntMethod, OOShaderUniformTypeMethodSignatureTemplateClass::signedLongMethod, OOShaderUniformTypeMethodSignatureTemplateClass::signedShortMethod, sInited, OOShaderUniformTypeMethodSignatureTemplateClass::unsignedCharMethod, OOShaderUniformTypeMethodSignatureTemplateClass::unsignedIntMethod, OOShaderUniformTypeMethodSignatureTemplateClass::unsignedLongMethod, OOShaderUniformTypeMethodSignatureTemplateClass::unsignedShortMethod, and OOShaderUniformTypeMethodSignatureTemplateClass::vectorMethod.

Referenced by OOShaderUniformTypeFromMethodSignature().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OOCallFloatMethod()

double OOCallFloatMethod ( id object,
SEL selector,
IMP method,
OOShaderUniformType type )

Definition at line 288 of file OOShaderUniformMethodType.m.

289{
290 switch (type)
291 {
293 return ((FloatReturnMsgSend)method)(object, selector);
294
296 return ((DoubleReturnMsgSend)method)(object, selector);
297
298 default:
299 return 0;
300 }
301}
double(* DoubleReturnMsgSend)(id, SEL)
float(* FloatReturnMsgSend)(id, SEL)

◆ OOCallIntegerMethod()

long long OOCallIntegerMethod ( id object,
SEL selector,
IMP method,
OOShaderUniformType type )

Definition at line 248 of file OOShaderUniformMethodType.m.

249{
250 switch (type)
251 {
253 return ((CharReturnMsgSend)method)(object, selector);
254
256 return ((UnsignedCharReturnMsgSend)method)(object, selector);
257
259 return ((ShortReturnMsgSend)method)(object, selector);
260
262 return ((UnsignedShortReturnMsgSend)method)(object, selector);
263
265 return ((IntReturnMsgSend)method)(object, selector);
266
268 return ((UnsignedIntReturnMsgSend)method)(object, selector);
269
271 return ((LongReturnMsgSend)method)(object, selector);
272
274 return ((UnsignedLongReturnMsgSend)method)(object, selector);
275
277 return ((LongLongReturnMsgSend)method)(object, selector);
278
280 return ((UnsignedLongLongReturnMsgSend)method)(object, selector);
281
282 default:
283 return 0;
284 }
285}
int(* IntReturnMsgSend)(id, SEL)
unsigned int(* UnsignedIntReturnMsgSend)(id, SEL)
char(* CharReturnMsgSend)(id, SEL)
long long(* LongLongReturnMsgSend)(id, SEL)
short(* ShortReturnMsgSend)(id, SEL)
unsigned char(* UnsignedCharReturnMsgSend)(id, SEL)
unsigned long(* UnsignedLongReturnMsgSend)(id, SEL)
unsigned short(* UnsignedShortReturnMsgSend)(id, SEL)
@ kOOShaderUniformTypeLongLong
@ kOOShaderUniformTypeUnsignedLongLong
unsigned long long(* UnsignedLongLongReturnMsgSend)(id, SEL)
long(* LongReturnMsgSend)(id, SEL)

References kOOShaderUniformTypeChar, kOOShaderUniformTypeInt, kOOShaderUniformTypeLong, kOOShaderUniformTypeLongLong, kOOShaderUniformTypeShort, kOOShaderUniformTypeUnsignedChar, kOOShaderUniformTypeUnsignedInt, kOOShaderUniformTypeUnsignedLong, kOOShaderUniformTypeUnsignedLongLong, and kOOShaderUniformTypeUnsignedShort.

◆ OOShaderUniformTypeFromMethodSignature()

OOShaderUniformType OOShaderUniformTypeFromMethodSignature ( NSMethodSignature * signature)

Definition at line 62 of file OOShaderUniformMethodType.m.

63{
64 unsigned i;
65 const char *typeCode = NULL;
66
67 if (EXPECT_NOT(sInited == NO)) InitTemplates();
68
69 typeCode = [signature methodReturnType];
70 if (EXPECT_NOT(typeCode == NULL)) return kOOShaderUniformTypeInvalid;
71
73 {
74 if (sTemplates[i] != NULL && strcmp(sTemplates[i], typeCode) == 0) return i;
75 }
76
78}
#define EXPECT_NOT(x)
@ kOOShaderUniformTypeCount
@ kOOShaderUniformTypeInvalid
static void InitTemplates(void)

References EXPECT_NOT, InitTemplates(), kOOShaderUniformTypeCount, kOOShaderUniformTypeInvalid, sInited, and sTemplates.

Referenced by OOJSCallMethodSignatureTemplateClass::objectObjectMethod:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ __pad0__

__pad0__

Definition at line 288 of file OOShaderUniformMethodType.m.

◆ sInited

BOOL sInited = NO
static

◆ sTemplates

const char* sTemplates[kOOShaderUniformTypeCount]
static

Definition at line 56 of file OOShaderUniformMethodType.m.

Referenced by OOShaderUniformTypeFromMethodSignature().