Jump to content

SomGetInstanceSize: Difference between revisions

From EDM2
Created page with "{{DISPLAYTITLE:somGetInstanceSize}} This method returns the size of an instance of a class. Not generally overridden. For backward compatibility, this method does not take an..."
 
Ak120 (talk | contribs)
mNo edit summary
 
Line 4: Line 4:
For backward compatibility, this method does not take an Environment parameter.
For backward compatibility, this method does not take an Environment parameter.


; Original Class : [[SOMClass]]
;Original Class : [[SOMClass]]
 
==Syntax==
==Syntax==
  long somGetInstanceSize (SOMClass receiver)
  long somGetInstanceSize (SOMClass receiver)
==Parameters==
==Parameters==
; receiver (SOMClass) : A pointer to the class object whose instance size is desired.
;receiver (SOMClass): A pointer to the class object whose instance size is desired.


==Return Code==
==Return Code==
; rc (long) : bytes. Returns the size, in bytes, of each instance of this class. This includes the space required for instance variables introduced by this class and all of its ancestor classes.
;rc (long): bytes. Returns the size, in bytes, of each instance of this class. This includes the space required for instance variables introduced by this class and all of its ancestor classes.


==Remarks==
==Remarks==
Line 27: Line 29:
   int instancePartSize;
   int instancePartSize;


      myAnimal = AnimalNew ();
  myAnimal = AnimalNew ();
   animalClass = _somGetClass (myAnimal);
   animalClass = _somGetClass (myAnimal);
   instanceSize = _somGetInstanceSize (animalClass);
   instanceSize = _somGetInstanceSize (animalClass);
Line 46: Line 48:


==Related==
==Related==
===Methods===
;Methods
* [[somGetInstancePartSize]]
*[[somGetInstancePartSize]]


[[Category:SOMClass]]
[[Category:SOM method]]

Latest revision as of 04:41, 6 May 2020

This method returns the size of an instance of a class. Not generally overridden.

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

Original Class
SOMClass

Syntax

long somGetInstanceSize (SOMClass receiver)

Parameters

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

Return Code

rc (long)
bytes. Returns the size, in bytes, of each instance of this class. This includes the space required for instance variables introduced by this class and all of its ancestor classes.

Remarks

This method returns the total amount of space needed in an instance of the specified 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