]> git.saurik.com Git - apple/javascriptcore.git/blob - bindings/objc/objc_utility.h
JavaScriptCore-466.1.6.tar.gz
[apple/javascriptcore.git] / bindings / objc / objc_utility.h
1 /*
2 * Copyright (C) 2004 Apple Computer, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #ifndef KJS_BINDINGS_OBJC_UTILITY_H
27 #define KJS_BINDINGS_OBJC_UTILITY_H
28
29 #include <CoreFoundation/CoreFoundation.h>
30
31 #include <JavaScriptCore/object.h>
32 #include <JavaScriptCore/objc_header.h>
33
34 #ifdef __OBJC__
35 @class NSString;
36 #else
37 class NSString;
38 #endif
39
40 namespace KJS {
41 namespace Bindings {
42
43 typedef union {
44 ObjectStructPtr objectValue;
45 bool booleanValue;
46 char charValue;
47 short shortValue;
48 int intValue;
49 long longValue;
50 long long longLongValue;
51 float floatValue;
52 double doubleValue;
53 } ObjcValue;
54
55 typedef enum {
56 ObjcVoidType,
57 ObjcObjectType,
58 ObjcCharType,
59 ObjcUnsignedCharType,
60 ObjcShortType,
61 ObjcUnsignedShortType,
62 ObjcIntType,
63 ObjcUnsignedIntType,
64 ObjcLongType,
65 ObjcUnsignedLongType,
66 ObjcLongLongType,
67 ObjcUnsignedLongLongType,
68 ObjcFloatType,
69 ObjcDoubleType,
70 ObjcInvalidType
71 } ObjcValueType;
72
73 class RootObject;
74
75 ObjcValue convertValueToObjcValue(ExecState *exec, JSValue *value, ObjcValueType type);
76 JSValue *convertNSStringToString(NSString *nsstring);
77 JSValue *convertObjcValueToValue(ExecState *exec, void *buffer, ObjcValueType type, RootObject*);
78 ObjcValueType objcValueTypeForType(const char *type);
79
80 bool convertJSMethodNameToObjc(const char *JSName, char *buffer, size_t bufferSize);
81
82 JSObject *throwError(ExecState *, ErrorType, NSString *message);
83
84 } // namespace Bindings
85 } // namespace KJS
86
87 #endif