Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.80 KB | None | 0 0
  1. diff --git a/include/v8.h b/include/v8.h
  2. index c3bccdc..8ecaf68 100644
  3. --- a/include/v8.h
  4. +++ b/include/v8.h
  5. @@ -1435,6 +1435,9 @@ class Object : public Value {
  6.  
  7.    V8EXPORT Local<Value> Get(uint32_t index);
  8.  
  9. +  V8EXPORT PropertyAttribute GetPropertyAttribute(Handle<Value> key);
  10. +  V8EXPORT void Tipli(v8::Handle<Value> key);
  11. +
  12.    // TODO(1245389): Replace the type-specific versions of these
  13.    // functions with generic ones that accept a Handle<Value> key.
  14.    V8EXPORT bool Has(Handle<String> key);
  15. diff --git a/src/api.cc b/src/api.cc
  16. index 3fe5621..f576112 100644
  17. --- a/src/api.cc
  18. +++ b/src/api.cc
  19. @@ -2698,6 +2698,33 @@ Local<Value> v8::Object::Get(uint32_t index) {
  20.  }
  21.  
  22.  
  23. +PropertyAttribute v8::Object::GetPropertyAttribute(v8::Handle<Value> key) {
  24. +  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
  25. +  ON_BAILOUT(isolate, "v8::Object::GetPropertyAttribute()",
  26. +             return static_cast<PropertyAttribute>(NONE));
  27. +  ENTER_V8(isolate);
  28. +  i::Handle<i::JSObject> self = Utils::OpenHandle(this);
  29. +  i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
  30. +  EXCEPTION_PREAMBLE(isolate);
  31. +  i::Handle<i::String> name = i::Handle<i::String>::cast(key_obj);
  32. +  PropertyAttributes result = self->GetPropertyAttribute(*name);
  33. +  has_pending_exception = (result == ABSENT);
  34. +  EXCEPTION_BAILOUT_CHECK(isolate, static_cast<PropertyAttribute>(NONE));
  35. +  return static_cast<PropertyAttribute>(result);
  36. +}
  37. +
  38. +void v8::Object::Tipli(v8::Handle<Value> key) {
  39. +  i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
  40. +  ON_BAILOUT(isolate, "v8::Object::Tipli()", return);
  41. +  ENTER_V8(isolate);
  42. +  i::Handle<i::JSObject> self = Utils::OpenHandle(this);
  43. +  i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
  44. +
  45. +  i::Handle<i::String> name = i::Handle<i::String>::cast(key_obj);
  46. +  self->getGet(*name);
  47. +}
  48. +
  49. +
  50.  Local<Value> v8::Object::GetPrototype() {
  51.    i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
  52.    ON_BAILOUT(isolate, "v8::Object::GetPrototype()",
  53. diff --git a/src/objects.cc b/src/objects.cc
  54. index 6c9f52b..b3835d8 100644
  55. --- a/src/objects.cc
  56. +++ b/src/objects.cc
  57. @@ -3348,6 +3348,35 @@ MaybeObject* JSObject::PreventExtensions() {
  58.  }
  59.  
  60.  
  61. +void JSObject::getGet(String* name) {
  62. +    Object* obj = this;
  63. +    LookupResult result;
  64. +    JSObject::cast(obj)->LocalLookup(name, &result);
  65. +    if (result.IsProperty()) {
  66. +        if (result.IsReadOnly()) {
  67. +            printf("read only\n");
  68. +        } else if (result.type() == CALLBACKS) {
  69. +            Object* obj = result.GetCallbackObject();
  70. +            if (obj->IsFixedArray()) {
  71. +                printf("HEJ!\n");
  72. +                Object* getter = FixedArray::cast(obj)->get(kGetterIndex);
  73. +
  74. +                Handle<JSFunction> fun(JSFunction::cast(getter));
  75. +                Handle<Object> self(obj);
  76. +                bool has_pending_exception;
  77. +                Handle<Object> result = Execution::Call(fun, self, 0, NULL, &has_pending_exception);
  78. +            } else {
  79. +                printf("obj isn't FixedArray\n");
  80. +            }
  81. +        } else {
  82. +            printf("result.type = %d\n", result.type());
  83. +        }
  84. +    } else {
  85. +        printf("result isn't property\n");
  86. +    }
  87. +}
  88. +
  89. +
  90.  // Tests for the fast common case for property enumeration:
  91.  // - This object and all prototypes has an enum cache (which means that it has
  92.  //   no interceptors and needs no access checks).
  93. diff --git a/src/objects.h b/src/objects.h
  94. index 4d1f68d..e7cdca4 100644
  95. --- a/src/objects.h
  96. +++ b/src/objects.h
  97. @@ -1894,6 +1894,7 @@ class JSObject: public JSReceiver {
  98.    // Disalow further properties to be added to the object.
  99.    MUST_USE_RESULT MaybeObject* PreventExtensions();
  100.  
  101. +  void getGet(String* name);
  102.  
  103.    // Dispatched behavior.
  104.    void JSObjectShortPrint(StringStream* accumulator);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement