LCOV - code coverage report
Current view: directory - js/xpconnect/wrappers - XrayWrapper.h (source / functions) Found Hit Coverage
Test: app.info Lines: 19 2 10.5 %
Date: 2012-06-02 Functions: 20 2 10.0 %

       1                 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2                 :  * vim: set ts=4 sw=4 et tw=99 ft=cpp:
       3                 :  *
       4                 :  * ***** BEGIN LICENSE BLOCK *****
       5                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       6                 :  *
       7                 :  * The contents of this file are subject to the Mozilla Public License Version
       8                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       9                 :  * the License. You may obtain a copy of the License at
      10                 :  * http://www.mozilla.org/MPL/
      11                 :  *
      12                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      13                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      14                 :  * for the specific language governing rights and limitations under the
      15                 :  * License.
      16                 :  *
      17                 :  * The Original Code is mozilla.org code, released
      18                 :  * June 24, 2010.
      19                 :  *
      20                 :  * The Initial Developer of the Original Code is
      21                 :  *    The Mozilla Foundation
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  *    Andreas Gal <gal@mozilla.com>
      25                 :  *
      26                 :  * Alternatively, the contents of this file may be used under the terms of
      27                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      28                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      29                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      30                 :  * of those above. If you wish to allow use of your version of this file only
      31                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      32                 :  * use your version of this file under the terms of the MPL, indicate your
      33                 :  * decision by deleting the provisions above and replace them with the notice
      34                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      35                 :  * the provisions above, a recipient may use your version of this file under
      36                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      37                 :  *
      38                 :  * ***** END LICENSE BLOCK ***** */
      39                 : 
      40                 : #include "jsapi.h"
      41                 : #include "jswrapper.h"
      42                 : 
      43                 : // Xray wrappers re-resolve the original native properties on the native
      44                 : // object and always directly access to those properties.
      45                 : // Because they work so differently from the rest of the wrapper hierarchy,
      46                 : // we pull them out of the Wrapper inheritance hierarchy and create a
      47                 : // little world around them.
      48                 : 
      49                 : namespace xpc {
      50                 : 
      51                 : namespace XrayUtils {
      52                 : 
      53                 : extern JSClass HolderClass;
      54                 : 
      55                 : bool
      56                 : IsTransparent(JSContext *cx, JSObject *wrapper);
      57                 : 
      58                 : JSObject *
      59                 : GetNativePropertiesObject(JSContext *cx, JSObject *wrapper);
      60                 : 
      61                 : }
      62                 : 
      63                 : // NB: Base *must* derive from JSProxyHandler
      64                 : template <typename Base>
      65                 : class XrayWrapper : public Base {
      66                 :   public:
      67            4392 :     XrayWrapper(unsigned flags);
      68            4461 :     virtual ~XrayWrapper();
      69                 : 
      70                 :     /* Fundamental proxy traps. */
      71               0 :     virtual bool getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
      72                 :                                        bool set, js::PropertyDescriptor *desc);
      73               0 :     virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
      74                 :                                           bool set, js::PropertyDescriptor *desc);
      75               0 :     virtual bool defineProperty(JSContext *cx, JSObject *wrapper, jsid id,
      76                 :                                 js::PropertyDescriptor *desc);
      77               0 :     virtual bool getOwnPropertyNames(JSContext *cx, JSObject *wrapper,
      78                 :                                      js::AutoIdVector &props);
      79               0 :     virtual bool delete_(JSContext *cx, JSObject *wrapper, jsid id, bool *bp);
      80               0 :     virtual bool enumerate(JSContext *cx, JSObject *wrapper, js::AutoIdVector &props);
      81               0 :     virtual bool fix(JSContext *cx, JSObject *proxy, js::Value *vp);
      82                 : 
      83                 :     /* Derived proxy traps. */
      84               0 :     virtual bool get(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id,
      85                 :                      js::Value *vp);
      86               0 :     virtual bool set(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id,
      87                 :                      bool strict, js::Value *vp);
      88               0 :     virtual bool has(JSContext *cx, JSObject *wrapper, jsid id, bool *bp);
      89               0 :     virtual bool hasOwn(JSContext *cx, JSObject *wrapper, jsid id, bool *bp);
      90               0 :     virtual bool keys(JSContext *cx, JSObject *wrapper, js::AutoIdVector &props);
      91               0 :     virtual bool iterate(JSContext *cx, JSObject *wrapper, unsigned flags, js::Value *vp);
      92                 : 
      93               0 :     virtual bool call(JSContext *cx, JSObject *wrapper, unsigned argc, js::Value *vp);
      94               0 :     virtual bool construct(JSContext *cx, JSObject *wrapper,
      95                 :                            unsigned argc, js::Value *argv, js::Value *rval);
      96                 : 
      97               0 :     static JSObject *createHolder(JSContext *cx, JSObject *wrappedNative, JSObject *parent);
      98                 : 
      99                 :     static XrayWrapper singleton;
     100                 : 
     101                 :   private:
     102               0 :     bool resolveOwnProperty(JSContext *cx, JSObject *wrapper, jsid id, bool set,
     103                 :                             js::PropertyDescriptor *desc);
     104                 : };
     105                 : 
     106                 : class XrayProxy : public XrayWrapper<js::CrossCompartmentWrapper> {
     107                 :   public:
     108                 :     XrayProxy(unsigned flags);
     109                 :     virtual ~XrayProxy();
     110                 : 
     111                 :     virtual bool getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
     112                 :                                        bool set, js::PropertyDescriptor *desc);
     113                 :     virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
     114                 :                                           bool set, js::PropertyDescriptor *desc);
     115                 :     virtual bool defineProperty(JSContext *cx, JSObject *wrapper, jsid id,
     116                 :                                 js::PropertyDescriptor *desc);
     117                 :     virtual bool getOwnPropertyNames(JSContext *cx, JSObject *wrapper,
     118                 :                                      js::AutoIdVector &props);
     119                 :     virtual bool delete_(JSContext *cx, JSObject *wrapper, jsid id, bool *bp);
     120                 :     virtual bool enumerate(JSContext *cx, JSObject *wrapper, js::AutoIdVector &props);
     121                 :     // XrayWrapper's fix implementation works for us.
     122                 : 
     123                 :     static XrayProxy singleton;
     124                 : };
     125                 : 
     126                 : }

Generated by: LCOV version 1.7