why duplicated code in v8-master/include/v8.h ?

20 views
Skip to first unread message

Alvaro Barcellos

unread,
Oct 22, 2019, 11:10:51 AM10/22/19
to v8-dev
Hi,

I was looking for tips inside v8.h and got surprised that lines 6504 to 6511 are duplicated as 6512 to 6519, as void SetAccessor(...) block, why ? is a trick to compiler or just a forgot ctrl-c&ctr-v ?

6482    *
 6483    * \param name The name of the property for which an accessor is added.
 6484    * \param getter The callback to invoke when getting the property.
 6485    * \param setter The callback to invoke when setting the property.
 6486    * \param data A piece of data that will be passed to the getter and setter
 6487    *   callbacks whenever they are invoked.
 6488    * \param settings Access control settings for the accessor. This is a bit
 6489    *   field consisting of one of more of
 6490    *   DEFAULT = 0, ALL_CAN_READ = 1, or ALL_CAN_WRITE = 2.
 6491    *   The default is to not allow cross-context access.
 6492    *   ALL_CAN_READ means that all cross-context reads are allowed.
 6493    *   ALL_CAN_WRITE means that all cross-context writes are allowed.
 6494    *   The combination ALL_CAN_READ | ALL_CAN_WRITE can be used to allow all
 6495    *   cross-context access.
 6496    * \param attribute The attributes of the property for which an accessor
 6497    *   is added.
 6498    * \param signature The signature describes valid receivers for the accessor
 6499    *   and is used to perform implicit instance checks against them. If the
 6500    *   receiver is incompatible (i.e. is not an instance of the constructor as
 6501    *   defined by FunctionTemplate::HasInstance()), an implicit TypeError is
 6502    *   thrown and no callback is invoked.
 6503    */
 6504   void SetAccessor(
 6505       Local<String> name, AccessorGetterCallback getter,
 6506       AccessorSetterCallback setter = nullptr,
 6507       Local<Value> data = Local<Value>(), AccessControl settings = DEFAULT,
 6508       PropertyAttribute attribute = None,
 6509       Local<AccessorSignature> signature = Local<AccessorSignature>(),
 6510       SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
 6511       SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
 6512   void SetAccessor(
 6513       Local<Name> name, AccessorNameGetterCallback getter,
 6514       AccessorNameSetterCallback setter = nullptr,
 6515       Local<Value> data = Local<Value>(), AccessControl settings = DEFAULT,
 6516       PropertyAttribute attribute = None,
 6517       Local<AccessorSignature> signature = Local<AccessorSignature>(),
 6518       SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
 6519       SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
 6520
 6521   /**
 6522    * Sets a named property handler on the object template.
 6523    *

Jakob Kummerow

unread,
Oct 22, 2019, 11:27:20 AM10/22/19
to v8-...@googlegroups.com
Look closely, it's not the same.

The String version should probably be deprecated in favor of the Name version.

Matheus Marchini

unread,
Oct 22, 2019, 11:27:42 AM10/22/19
to v8-dev
The method on line 6512 is an overload of 6504. The first three arguments are different, so if embedders call SetAccessor with a String argument, 6504 will be called. If embedders call SetAccessor with a Name argument, 6512 will be called.

Alvaro Barcellos

unread,
Oct 22, 2019, 11:43:23 AM10/22/19
to v8-...@googlegroups.com
Now I got the light :)

thanks!

--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/3d4a3b8d-9527-418b-aee6-c896d406ea61%40googlegroups.com.


--


"Sling and move continents, a rock at a time.
"
Reply all
Reply to author
Forward
0 new messages