Forgot to commit this to TOT way back when; will be useful when actually porting...
[WebKit-https.git] / JavaScriptGlue / JSUtils.h
1 #ifndef __JSUtils_h
2 #define __JSUtils_h
3
4 /*
5         JSUtils.h
6 */
7
8 #ifndef __CORESERVICES__
9 #include <CoreServices/CoreServices.h>
10 #endif
11
12 #include <JavaScriptGlue/JavaScriptGlue.h>
13
14 #ifdef USE_JSHACK
15 #include <JSHack/value.h>
16 #include <JSHack/object.h>
17 #include <JSHack/types.h>
18 #include <JSHack/interpreter.h>
19 #include <JSHack/ustring.h>
20 #else
21 #include <JavaScriptCore/value.h>
22 #include <JavaScriptCore/object.h>
23 #include <JavaScriptCore/types.h>
24 #include <JavaScriptCore/interpreter.h>
25 #include <JavaScriptCore/protect.h>
26 #include <JavaScriptCore/collector.h>
27 #include <JavaScriptCore/ustring.h>
28 #endif
29
30 #define JAG_PINK_OR_LATER       1 /* %%% turn on for new JavaScriptCore */
31
32 using namespace KJS;
33
34 class JSBase;
35 class JSUserObject;
36 class JSRun;
37 class JSValueWrapper;
38 class JSUserObjectImp;
39
40 UString CFStringToUString(CFStringRef inCFString);
41 CFStringRef UStringToCFString(const UString& inUString);
42 #if JAG_PINK_OR_LATER
43 Identifier CFStringToIdentifier(CFStringRef inCFString);
44 CFStringRef IdentifierToCFString(const Identifier& inIdentifier);
45 #endif
46 JSUserObject* KJSValueToJSObject(const Value& inValue, ExecState *exec);
47 CFTypeRef KJSValueToCFType(const Value& inValue, ExecState *exec);
48 Value JSObjectKJSValue(JSUserObject* ptr);
49 CFTypeRef GetCFNull(void);
50
51 inline CFTypeRef RetainCFType(CFTypeRef x) { if (x) x = CFRetain(x); return x; }
52 inline void ReleaseCFType(CFTypeRef x) { if (x) CFRelease(x);  }
53
54 enum {
55         kJSInvalidTypeID = 0,
56         kJSObjectTypeID,
57         kJSRunTypeID
58 };
59
60 enum {
61     kJSUserObjectDataTypeUnknown,
62     kJSUserObjectDataTypeJSValueWrapper,
63     kJSUserObjectDataTypeCFType
64 };
65
66
67 #endif