Jump to content

somGetInstancePartSize

From EDM2
Revision as of 03:52, 13 October 2017 by Martini (talk | contribs) (Created page with "{{DISPLAYTITLE:somGetInstancePartSize }} This method returns the total size of the instance data structure introduced by a class. Not generally overridden. For backward compa...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This method returns the total size of the instance data structure introduced by a class. Not generally overridden.

For backward compatibility, this method does not take an Environment parameter.

Original Class
SOMClass

Syntax

long somGetInstancePartSize (SOMClass receiver)

Parameters

receiver (SOMClass)
A pointer to the class object whose instance data size is desired.

Return Code

rc (long)
  • bytes Returns the size, in bytes, of the instance variables introduced by this class. This does not include the size of instance variables introduced by this class's ancestor or descendent classes.
  • 0 Returns 0 if a class introduces no instance variables.

Remarks

This method returns the amount of space needed in an object of the specified class or any of its subclasses to contain the instance variables introduced by the class.

Example Code

#include <animal.h>
main()
{
  Animal myAnimal;
  SOMClass animalClass;
  int instanceSize;
  int instanceOffset;
  int instancePartSize;

  myAnimal = AnimalNew ();
  animalClass = _somGetClass (myAnimal);
  instanceSize = _somGetInstanceSize (animalClass);
  instanceOffset = _somGetInstanceOffset (animalClass);
  instancePartSize = _somGetInstancePartSize (animalClass);
  somPrintf ("Instance Size: %d\n", instanceSize);
  somPrintf ("Instance Offset: %d\n", instanceOffset);
  somPrintf ("Instance Part Size: %d\n", instancePartSize);
  _somFree (myAnimal);
}
/*
Output from this program:
Instance Size: 8
Instance Offset: 0
Instance Part Size: 4
*/

Related

Methods