本文整理汇总了C++中shape::Range::front方法的典型用法代码示例。如果您正苦于以下问题:C++ Range::front方法的具体用法?C++ Range::front怎么用?C++ Range::front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shape::Range
的用法示例。
在下文中一共展示了Range::front方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assertSameCompartment
JS_GetPropertyDesc(JSContext *cx, JSObject *obj, JSScopeProperty *sprop,
JSPropertyDesc *pd)
{
assertSameCompartment(cx, obj);
Shape *shape = (Shape *) sprop;
pd->id = IdToJsval(shape->propid());
JSBool wasThrowing = cx->isExceptionPending();
Value lastException = UndefinedValue();
if (wasThrowing)
lastException = cx->getPendingException();
cx->clearPendingException();
if (!js_GetProperty(cx, obj, shape->propid(), &pd->value)) {
if (!cx->isExceptionPending()) {
pd->flags = JSPD_ERROR;
pd->value = JSVAL_VOID;
} else {
pd->flags = JSPD_EXCEPTION;
pd->value = cx->getPendingException();
}
} else {
pd->flags = 0;
}
if (wasThrowing)
cx->setPendingException(lastException);
pd->flags |= (shape->enumerable() ? JSPD_ENUMERATE : 0)
| (!shape->writable() ? JSPD_READONLY : 0)
| (!shape->configurable() ? JSPD_PERMANENT : 0);
pd->spare = 0;
if (shape->getter() == GetCallArg) {
pd->slot = shape->shortid();
pd->flags |= JSPD_ARGUMENT;
} else if (shape->getter() == GetCallVar) {
pd->slot = shape->shortid();
pd->flags |= JSPD_VARIABLE;
} else {
pd->slot = 0;
}
pd->alias = JSVAL_VOID;
if (obj->containsSlot(shape->slot())) {
for (Shape::Range r = obj->lastProperty()->all(); !r.empty(); r.popFront()) {
const Shape &aprop = r.front();
if (&aprop != shape && aprop.slot() == shape->slot()) {
pd->alias = IdToJsval(aprop.propid());
break;
}
}
}
return JS_TRUE;
}
示例2:
static bool
EnumerateNativeProperties(JSContext *cx, JSObject *obj, JSObject *pobj, uintN flags, IdSet &ht,
AutoIdVector *props)
{
size_t initialLength = props->length();
/* Collect all unique properties from this object's scope. */
for (Shape::Range r = pobj->lastProperty()->all(); !r.empty(); r.popFront()) {
const Shape &shape = r.front();
if (!JSID_IS_DEFAULT_XML_NAMESPACE(shape.propid) &&
!Enumerate(cx, obj, pobj, shape.propid, shape.enumerable(), flags, ht, props))
{
return false;
}
}
::Reverse(props->begin() + initialLength, props->end());
return true;
}
示例3: obj
JS_GetPropertyDescArray(JSContext *cx, JSObject *obj_, JSPropertyDescArray *pda)
{
RootedObject obj(cx, obj_);
assertSameCompartment(cx, obj);
uint32_t i = 0;
JSPropertyDesc *pd = NULL;
if (obj->isDebugScope()) {
AutoIdVector props(cx);
if (!Proxy::enumerate(cx, obj, props))
return false;
pd = cx->pod_calloc<JSPropertyDesc>(props.length());
if (!pd)
return false;
for (i = 0; i < props.length(); ++i) {
pd[i].id = JSVAL_NULL;
pd[i].value = JSVAL_NULL;
if (!js_AddRoot(cx, &pd[i].id, NULL))
goto bad;
pd[i].id = IdToValue(props[i]);
if (!js_AddRoot(cx, &pd[i].value, NULL))
goto bad;
if (!Proxy::get(cx, obj, obj, props.handleAt(i), MutableHandleValue::fromMarkedLocation(&pd[i].value)))
goto bad;
}
pda->length = props.length();
pda->array = pd;
return true;
}
Class *clasp;
clasp = obj->getClass();
if (!obj->isNative() || (clasp->flags & JSCLASS_NEW_ENUMERATE)) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
JSMSG_CANT_DESCRIBE_PROPS, clasp->name);
return false;
}
if (!clasp->enumerate(cx, obj))
return false;
/* Return an empty pda early if obj has no own properties. */
if (obj->nativeEmpty()) {
pda->length = 0;
pda->array = NULL;
return true;
}
pd = cx->pod_malloc<JSPropertyDesc>(obj->propertyCount());
if (!pd)
return false;
for (Shape::Range r = obj->lastProperty()->all(); !r.empty(); r.popFront()) {
pd[i].id = JSVAL_NULL;
pd[i].value = JSVAL_NULL;
pd[i].alias = JSVAL_NULL;
if (!js_AddRoot(cx, &pd[i].id, NULL))
goto bad;
if (!js_AddRoot(cx, &pd[i].value, NULL))
goto bad;
RootedShape shape(cx, const_cast<Shape *>(&r.front()));
if (!GetPropertyDesc(cx, obj, shape, &pd[i]))
goto bad;
if ((pd[i].flags & JSPD_ALIAS) && !js_AddRoot(cx, &pd[i].alias, NULL))
goto bad;
if (++i == obj->propertyCount())
break;
}
pda->length = i;
pda->array = pd;
return true;
bad:
pda->length = i + 1;
pda->array = pd;
JS_PutPropertyDescArray(cx, pda);
return false;
}
示例4: shape
/*
* Construct a call object for the given bindings. If this is a call object
* for a function invocation, callee should be the function being called.
* Otherwise it must be a call object for eval of strict mode code, and callee
* must be null.
*/
CallObject *
CallObject::create(JSContext *cx, JSScript *script, JSObject &enclosing, JSObject *callee)
{
RootedVarShape shape(cx);
shape = script->bindings.callObjectShape(cx);
if (shape == NULL)
return NULL;
gc::AllocKind kind = gc::GetGCObjectKind(shape->numFixedSlots() + 1);
RootedVarTypeObject type(cx);
type = cx->compartment->getEmptyType(cx);
if (!type)
return NULL;
HeapSlot *slots;
if (!PreallocateObjectDynamicSlots(cx, shape, &slots))
return NULL;
JSObject *obj = JSObject::create(cx, kind, shape, type, slots);
if (!obj)
return NULL;
/*
* Update the parent for bindings associated with non-compileAndGo scripts,
* whose call objects do not have a consistent global variable and need
* to be updated dynamically.
*/
JSObject &global = enclosing.global();
if (&global != obj->getParent()) {
JS_ASSERT(obj->getParent() == NULL);
if (!obj->setParent(cx, &global))
return NULL;
}
#ifdef DEBUG
JS_ASSERT(!obj->inDictionaryMode());
for (Shape::Range r = obj->lastProperty(); !r.empty(); r.popFront()) {
const Shape &s = r.front();
if (s.hasSlot()) {
JS_ASSERT(s.slot() + 1 == obj->slotSpan());
break;
}
}
#endif
if (!obj->asScope().setEnclosingScope(cx, enclosing))
return NULL;
JS_ASSERT_IF(callee, callee->isFunction());
obj->initFixedSlot(CALLEE_SLOT, ObjectOrNullValue(callee));
obj->initFixedSlot(ARGUMENTS_SLOT, MagicValue(JS_UNASSIGNED_ARGUMENTS));
/*
* If |bindings| is for a function that has extensible parents, that means
* its Call should have its own shape; see BaseShape::extensibleParents.
*/
if (obj->lastProperty()->extensibleParents() && !obj->generateOwnShape(cx))
return NULL;
return &obj->asCall();
}