With the magic number I mean the number that defines the object's structure. It's one of the first 3 instance variables of every class, encoding how many instance variables there are; what kind of object it is supposed to be (normal, array, bytes, words...). Every "class" basically needs 3 instance variables. 1 defines the structure, 1 the superclass, 1 the behavior (method dictionary). I don't know the other; but just look at some class to know what the order is.

And yes, if you want to inspect the object, you'll need to support whatever protocol your inspector is using.

The format is formed as follows:

format
	| fieldSize sizeHiBits format |
	fieldSize := self fieldSize + 1.
	sizeHiBits := fieldSize // 64.
	format := sizeHiBits.
	format := (format bitShift: 5) + compactClassIndex.
	format := (format bitShift: 4) + self instanceSpecification.
	format := (format bitShift: 6) + (fieldSize \\ 64).
	format := (format bitShift: 1).
	^ format

If I read it correctly (just glancing), instance specification specifies if it's arrayed and if it has fields. 0 -> no fields, not arrayed, 1 -> fields, not arrayed, 2 -> arrayed no fields, 3 -> arrayed fields.

HTH,
Toon

On 11/25/2011 09:31 PM, Stéphane Ducasse wrote:
Apparently I can do a doit I was naively doing an inspect ;)

Don't you just need the basicNew primitive, and make sure that the "magic number" is set in the object that has the basicNew installed to something that makes sense?
I do not know what is the magic number. 
I guess that my problem was that I have first to define what is the minimal behavior. 

If you want to send messages to the object, probably also best install some dictionary as the method dict instvar.
But I guess that ProtoObject has some behavior since I can browse the class with a browser. 


Toon

On 11/25/2011 09:26 PM, Stéphane Ducasse wrote:
Hi
I would like to know the methods that I should define in a subclass of ProtoObject so that I can use basicNew.
Does any of you have an idea?

Stef