forked from itod/parsekit
/
PKJSUtils_macros.h
33 lines (29 loc) · 1.09 KB
/
PKJSUtils_macros.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
* PKJSUtils_macros.h
* ParseKit
*
* Created by Todd Ditchendorf on 1/11/09.
* Copyright 2009 Todd Ditchendorf. All rights reserved.
*
*/
#undef PKPreconditionInstaceOf
#define PKPreconditionInstaceOf(cls, meth) \
if (!JSValueIsObjectOfClass(ctx, this, (cls)(ctx))) { \
NSString *s = [NSString stringWithFormat:@"calling method '%s' on an object that is not an instance of '%s'", (meth), #cls]; \
(*ex) = PKNSStringToJSValue(ctx, s, ex); \
return JSValueMakeUndefined(ctx); \
}
#undef PKPreconditionMethodArgc
#define PKPreconditionMethodArgc(n, meth) \
if (argc < (n)) { \
NSString *s = [NSString stringWithFormat:@"%s() requires %d arguments", (meth), (n)]; \
(*ex) = PKNSStringToJSValue(ctx, s, ex); \
return JSValueMakeUndefined(ctx); \
}
#undef PKPreconditionConstructorArgc
#define PKPreconditionConstructorArgc(n, meth) \
if (argc < (n)) { \
NSString *s = [NSString stringWithFormat:@"%s constructor requires %d arguments", (meth), (n)]; \
(*ex) = PKNSStringToJSValue(ctx, s, ex); \
return NULL; \
}