Attachment #653265: Part 9 - Implement ScriptedDirectProxyHandler stub for bug #703537

View | Details | Raw Unified | Return to bug 703537
Collapse All | Expand All

(-)a/js/src/jsproxy.cpp (+139 lines)
Line     Link Here 
 Lines 1018-1033   ScriptedIndirectProxyHandler::defaultVal Link Here 
1018
     * This function is only here to prevent bug 757063. It will be removed when
1018
     * This function is only here to prevent bug 757063. It will be removed when
1019
     * the direct proxy refactor is complete.
1019
     * the direct proxy refactor is complete.
1020
     */
1020
     */
1021
    return BaseProxyHandler::defaultValue(cx, proxy, hint, vp);
1021
    return BaseProxyHandler::defaultValue(cx, proxy, hint, vp);
1022
}
1022
}
1023
1023
1024
ScriptedIndirectProxyHandler ScriptedIndirectProxyHandler::singleton;
1024
ScriptedIndirectProxyHandler ScriptedIndirectProxyHandler::singleton;
1025
1025
1026
static JSObject *
1027
GetDirectProxyHandlerObject(JSObject *proxy)
1028
{
1029
    return GetProxyExtra(proxy, 0).toObjectOrNull();
1030
}
1031
1032
/* Derived class for all scripted direct proxy handlers. */
1033
class ScriptedDirectProxyHandler : public DirectProxyHandler {
1034
  public:
1035
    ScriptedDirectProxyHandler();
1036
    virtual ~ScriptedDirectProxyHandler();
1037
1038
    /* ES5 Harmony fundamental proxy traps. */
1039
    virtual bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
1040
                                       PropertyDescriptor *desc) MOZ_OVERRIDE;
1041
    virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
1042
                                          PropertyDescriptor *desc) MOZ_OVERRIDE;
1043
    virtual bool defineProperty(JSContext *cx, JSObject *proxy, jsid id,
1044
                                PropertyDescriptor *desc) MOZ_OVERRIDE;
1045
    virtual bool getOwnPropertyNames(JSContext *cx, JSObject *proxy, AutoIdVector &props);
1046
    virtual bool delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp) MOZ_OVERRIDE;
1047
    virtual bool enumerate(JSContext *cx, JSObject *proxy, AutoIdVector &props) MOZ_OVERRIDE;
1048
1049
    /* ES5 Harmony derived proxy traps. */
1050
    virtual bool has(JSContext *cx, JSObject *proxy, jsid id, bool *bp) MOZ_OVERRIDE;
1051
    virtual bool hasOwn(JSContext *cx, JSObject *proxy, jsid id, bool *bp) MOZ_OVERRIDE;
1052
    virtual bool get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id,
1053
                     Value *vp) MOZ_OVERRIDE;
1054
    virtual bool set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, bool strict,
1055
                     Value *vp) MOZ_OVERRIDE;
1056
    virtual bool keys(JSContext *cx, JSObject *proxy, AutoIdVector &props) MOZ_OVERRIDE;
1057
    virtual bool iterate(JSContext *cx, JSObject *proxy, unsigned flags, Value *vp) MOZ_OVERRIDE;
1058
1059
    static ScriptedDirectProxyHandler singleton;
1060
};
1061
1062
static int sScriptedDirectProxyHandlerFamily = 0;
1063
1064
ScriptedDirectProxyHandler::ScriptedDirectProxyHandler()
1065
        : DirectProxyHandler(&sScriptedDirectProxyHandlerFamily)
1066
{
1067
}
1068
1069
ScriptedDirectProxyHandler::~ScriptedDirectProxyHandler()
1070
{
1071
}
1072
1073
bool
1074
ScriptedDirectProxyHandler::getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id,
1075
                                                  bool set, PropertyDescriptor *desc)
1076
{
1077
    JS_NOT_REACHED("not yet implemented");
1078
    return false;
1079
}
1080
1081
bool
1082
ScriptedDirectProxyHandler::getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id,
1083
                                                     bool set, PropertyDescriptor *desc)
1084
{
1085
    JS_NOT_REACHED("not yet implemented");
1086
    return false;
1087
}
1088
1089
bool
1090
ScriptedDirectProxyHandler::defineProperty(JSContext *cx, JSObject *proxy, jsid id,
1091
                                           PropertyDescriptor *desc)
1092
{
1093
    JS_NOT_REACHED("not yet implemented");
1094
    return false;
1095
}
1096
1097
bool
1098
ScriptedDirectProxyHandler::getOwnPropertyNames(JSContext *cx, JSObject *proxy,
1099
                                                AutoIdVector &props)
1100
{
1101
    JS_NOT_REACHED("not yet implemented");
1102
    return false;
1103
}
1104
1105
bool
1106
ScriptedDirectProxyHandler::delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp)
1107
{
1108
    JS_NOT_REACHED("not yet implemented");
1109
    return false;
1110
}
1111
1112
bool
1113
ScriptedDirectProxyHandler::enumerate(JSContext *cx, JSObject *proxy, AutoIdVector &props)
1114
{
1115
    JS_NOT_REACHED("not yet implemented");
1116
    return false;
1117
}
1118
1119
bool
1120
ScriptedDirectProxyHandler::has(JSContext *cx, JSObject *proxy, jsid id, bool *bp)
1121
{
1122
    JS_NOT_REACHED("not yet implemented");
1123
    return false;
1124
}
1125
1126
bool
1127
ScriptedDirectProxyHandler::hasOwn(JSContext *cx, JSObject *proxy, jsid id, bool *bp)
1128
{
1129
    JS_NOT_REACHED("not yet implemented");
1130
    return false;
1131
}
1132
1133
bool
1134
ScriptedDirectProxyHandler::get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id,
1135
                                Value *vp)
1136
{
1137
    JS_NOT_REACHED("not yet implemented");
1138
    return false;
1139
}
1140
1141
bool
1142
ScriptedDirectProxyHandler::set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id,
1143
                                bool strict, Value *vp)
1144
{
1145
    JS_NOT_REACHED("not yet implemented");
1146
    return false;
1147
}
1148
1149
bool
1150
ScriptedDirectProxyHandler::keys(JSContext *cx, JSObject *proxy, AutoIdVector &props)
1151
{
1152
    JS_NOT_REACHED("not yet implemented");
1153
    return false;
1154
}
1155
1156
bool
1157
ScriptedDirectProxyHandler::iterate(JSContext *cx, JSObject *proxy, unsigned flags, Value *vp)
1158
{
1159
    JS_NOT_REACHED("not yet implemented");
1160
    return false;
1161
}
1162
1163
ScriptedDirectProxyHandler ScriptedDirectProxyHandler::singleton;
1164
1026
#define INVOKE_ON_PROTOTYPE(cx, handler, proxy, protoCall)                   \
1165
#define INVOKE_ON_PROTOTYPE(cx, handler, proxy, protoCall)                   \
1027
    JS_BEGIN_MACRO                                                           \
1166
    JS_BEGIN_MACRO                                                           \
1028
        JSObject *proto;                                                     \
1167
        JSObject *proto;                                                     \
1029
        if (!handler->getPrototypeOf(cx, proxy, &proto))                     \
1168
        if (!handler->getPrototypeOf(cx, proxy, &proto))                     \
1030
            return false;                                                    \
1169
            return false;                                                    \
1031
        if (!proto)                                                          \
1170
        if (!proto)                                                          \
1032
            return true;                                                     \
1171
            return true;                                                     \
1033
        assertSameCompartment(cx, proxy, proto);                             \
1172
        assertSameCompartment(cx, proxy, proto);                             \

Return to bug 703537