1 // Copyright 2007, Google Inc.
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are met:
6 // 1. Redistributions of source code must retain the above copyright notice,
7 // this list of conditions and the following disclaimer.
8 // 2. Redistributions in binary form must reproduce the above copyright notice,
9 // this list of conditions and the following disclaimer in the documentation
10 // and/or other materials provided with the distribution.
11 // 3. Neither the name of Google Inc. nor the names of its contributors may be
12 // used to endorse or promote products derived from this software without
13 // specific prior written permission.
15 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
18 // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 // Components that will be loaded by the Gears Factory will conform to the
27 // SafariGearsBaseClass protocol. There is also a base class
28 // SafariGearsBaseClass that can be subclassed to provide convenient
29 // interaction with the script environment.
31 #import <Cocoa/Cocoa.h>
33 @
class SafariGearsFactory
;
34 @
class WebScriptObject
;
35 class ModuleImplBaseClass
;
37 //------------------------------------------------------------------------------
38 @protocol SafariGearsBaseClass
39 // The dictionary of exposed selector strings and their web kit names
40 + (NSDictionary
*)webScriptSelectorStrings
;
42 // The dictionary of exposed key names and their web kit names
43 + (NSDictionary
*)webScriptKeys
;
46 @interface SafariGearsBaseClass
: NSObject
<SafariGearsBaseClass
> {
48 ModuleImplBaseClass
*base_
; // The base class for C++ objects (STRONG)
49 SafariGearsFactory
*factory_
; // The creator (STRONG)
50 BOOL isWorker_
; // YES, if this is a worker pool instance
53 //------------------------------------------------------------------------------
55 //------------------------------------------------------------------------------
56 // Convert 'array' into an NSArray. If 'array' is nil or WebUndefined, return
57 // nil. If 'array' is not a WebScriptObject (e.g., string or number), return
58 // [NSNull null] to indicate there was a conversion error.
59 + (NSArray
*)convertWebScriptArray
:(WebScriptObject
*)array
;
61 //------------------------------------------------------------------------------
62 // SafariGearsBaseClass
63 //------------------------------------------------------------------------------
64 // 'factory' is the SafariGearsFactory that created this component instance.
65 - (id
)initWithFactory
:(SafariGearsFactory
*)factory
;
67 - (SafariGearsFactory
*)factory
;
68 - (ModuleImplBaseClass
*)gearsBaseClass
;
70 //------------------------------------------------------------------------------
71 // NSObject (WebScripting)
72 //------------------------------------------------------------------------------
73 + (BOOL
)isSelectorExcludedFromWebScript
:(SEL
)sel
;
74 + (NSString
*)webScriptNameForSelector
:(SEL
)sel
;
76 + (BOOL
)isKeyExcludedFromWebScript
:(const char *)property
;
77 + (NSString
*)webScriptNameForKey
:(const char *)key
;