From b92af62a230f04c2bec2afab77345df950888f5a Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Mon, 27 Apr 2020 18:14:39 +0300 Subject: [PATCH] updated docs... Signed-off-by: Alex A. Naanou --- object.js | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/object.js b/object.js index 1d600fe..8b3cc1c 100755 --- a/object.js +++ b/object.js @@ -339,16 +339,26 @@ function(context, constructor, ...args){ // // // Init protocol: -// 1) the base instance object is created -// 2) if .__new__(..) is defined it is passed to it along with the -// constructor arguments and the return value is used as base instance. -// NOTE: .__new__(..) is called in the context of the constructor -// .prototype... -// 2) the base instance object is prepared (.__proto__ is set) -// 3) if is present, then it is called with instance as -// context and passed the constructor arguments -// 4) if .__init__(..) is present, it is called with the instance -// as context and passed the constructor arguments. +// 1) raw instance is created: +// a) constructor.__rawinstance__(..) / makeRawInstance(..) called: +// - call .__new__(..) if defined and get return value as instance, or +// - if .__call__(..) defined or prototype is a function, wrap it and +// use the wrapper function as instance, or +// - create an empty object +// b) instance linked to prototype chain +// set .__proto__ to constructor.prototype +// 2) instance is initialized: +// call .__init__(..) if defined +// +// +// Special methods (constructor): +// .__rawinstance__(context, ...) +// +// +// Special methods (.prototype): +// .__new__(context, ..) +// .__call__(context, ..) +// .__init__(..) // // //