webengine/osswebengine/WebKit/win/Interfaces/IWebScriptObject.idl
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2  * Copyright (C) 2006, 2007 Apple 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 cpp_quote("/*")
       
    27 cpp_quote(" * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.")
       
    28 cpp_quote(" *")
       
    29 cpp_quote(" * Redistribution and use in source and binary forms, with or without")
       
    30 cpp_quote(" * modification, are permitted provided that the following conditions")
       
    31 cpp_quote(" * are met:")
       
    32 cpp_quote(" * 1. Redistributions of source code must retain the above copyright")
       
    33 cpp_quote(" *    notice, this list of conditions and the following disclaimer.")
       
    34 cpp_quote(" * 2. Redistributions in binary form must reproduce the above copyright")
       
    35 cpp_quote(" *    notice, this list of conditions and the following disclaimer in the")
       
    36 cpp_quote(" *    documentation and/or other materials provided with the distribution.")
       
    37 cpp_quote(" *")
       
    38 cpp_quote(" * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY")
       
    39 cpp_quote(" * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE")
       
    40 cpp_quote(" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR")
       
    41 cpp_quote(" * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR")
       
    42 cpp_quote(" * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,")
       
    43 cpp_quote(" * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,")
       
    44 cpp_quote(" * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR")
       
    45 cpp_quote(" * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY")
       
    46 cpp_quote(" * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT")
       
    47 cpp_quote(" * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE")
       
    48 cpp_quote(" * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ")
       
    49 cpp_quote(" */")
       
    50 
       
    51 import "oaidl.idl";
       
    52 import "ocidl.idl";
       
    53 
       
    54 /*!
       
    55     @class WebScriptObject
       
    56     @discussion WebScriptObjects are used to wrap script objects passed from
       
    57     script environments to Objective-C.  WebScriptObjects cannot be created
       
    58     directly.  In normal uses of WebKit, you gain access to the script
       
    59     environment using the "windowScriptObject" method on WebView.
       
    60     
       
    61     The following KVC methods are commonly used to access properties of the
       
    62     WebScriptObject:
       
    63     
       
    64     - (void)setValue:(id)value forKey:(NSString *)key
       
    65     - (id)valueForKey:(NSString *)key
       
    66     
       
    67     As it possible to remove attributes from web script objects the following
       
    68     additional method augments the basic KVC methods:
       
    69     
       
    70     - (void)removeWebScriptKey:(NSString *)name;
       
    71     
       
    72     Also the sparse array access allowed in web script objects doesn't map well to NSArray, so
       
    73     the following methods can be used to access index based properties:
       
    74     
       
    75     - (id)webScriptValueAtIndex:(unsigned int)index;
       
    76     - (void)setWebScriptValueAtIndex:(unsigned int)index value:(id)value;
       
    77 
       
    78     @interface WebScriptObject : NSObject
       
    79 */
       
    80 [
       
    81     object,
       
    82     oleautomation,
       
    83     uuid(7022340A-649C-43fc-9214-85CA7D3BE3C7),
       
    84     pointer_default(unique)
       
    85 ]
       
    86 interface IWebScriptObject : IUnknown
       
    87 {
       
    88     /*!
       
    89         @method throwException:
       
    90         @discussion Throws an exception in the current script execution context.
       
    91         @result Either NO if an exception could not be raised, YES otherwise.
       
    92         + (BOOL)throwException:(NSString *)exceptionMessage;
       
    93     */
       
    94     HRESULT throwException([in] BSTR exceptionMessage, [out, retval] BOOL* result);
       
    95 
       
    96     /*!
       
    97         @method callWebScriptMethod:withArguments:
       
    98         @param name The name of the method to call in the script environment.
       
    99         @param args The arguments to pass to the script environment.
       
   100         @discussion Calls the specified method in the script environment using the
       
   101         specified arguments.
       
   102         @result Returns the result of calling the script method.
       
   103         - (id)callWebScriptMethod:(NSString *)name withArguments:(NSArray *)args;
       
   104     */
       
   105     HRESULT callWebScriptMethod([in] BSTR name, [in, size_is(cArgs)] const VARIANT args[], [in] int cArgs, [out, retval] VARIANT* result);
       
   106 
       
   107     /*!
       
   108         @method evaluateWebScript:
       
   109         @param script The script to execute in the target script environment.
       
   110         @discussion The script will be executed in the target script environment.  The format
       
   111         of the script is dependent of the target script environment.
       
   112         @result Returns the result of evaluating the script in the script environment.
       
   113         - (id)evaluateWebScript:(NSString *)script;
       
   114     */
       
   115     HRESULT evaluateWebScript([in] BSTR script, [out, retval] VARIANT* result);
       
   116 
       
   117     /*!
       
   118         @method removeWebScriptKey:
       
   119         @param name The name of the property to remove.
       
   120         @discussion Removes the property from the object in the script environment.
       
   121         - (void)removeWebScriptKey:(NSString *)name;
       
   122     */
       
   123     HRESULT removeWebScriptKey([in] BSTR name);
       
   124 
       
   125     /*!
       
   126         @method toString
       
   127         @discussion Converts the target object to a string representation.  The coercion
       
   128         of non string objects type is dependent on the script environment.
       
   129         @result Returns the string representation of the object.
       
   130         - (NSString *)stringRepresentation;
       
   131     */
       
   132     HRESULT stringRepresentation([out, retval] BSTR* stringRepresentation);
       
   133 
       
   134     /*!
       
   135         @method propertyAtIndex:
       
   136         @param index The index of the property to return.  Index based access is dependent 
       
   137         @discussion Gets the value of the property at the specified index.
       
   138         @result The value of the property.
       
   139         - (id)webScriptValueAtIndex:(unsigned int)index;
       
   140     */
       
   141     HRESULT webScriptValueAtIndex([in] unsigned int index, [out, retval] VARIANT* result);
       
   142 
       
   143     /*!
       
   144         @method setPropertyAtIndex:value:
       
   145         @param index The index of the property to set.
       
   146         @param value The value of the property to set.
       
   147         @discussion Sets the property value at the specified index.
       
   148         - (void)setWebScriptValueAtIndex:(unsigned int)index value:(id)value;
       
   149     */
       
   150     HRESULT setWebScriptValueAtIndex([in] unsigned int index, [in] VARIANT val);
       
   151 
       
   152     /*!
       
   153         @method setException:
       
   154         @param description The description of the exception.
       
   155         @discussion Raises an exception in the script environment in the context of the
       
   156         current object.
       
   157         - (void)setException: (NSString *)description;
       
   158     */
       
   159     HRESULT setException([in] BSTR description);
       
   160 }