Version 2.0.0-0

Runtime Reference

File
XSFoundation/include/XS/Functions/Runtime.h
Author
Jean-David Gadina - www.xs-labs.com
Copyright
© (c) 2020 - Jean-David Gadina - www.xs-labs.com
Date
Sunday, September 27, 2020

Overview

Runtime functions

Tasks

XSRuntimeCreateInstance Top

Initializes a new instance of a registered class

XS_EXPORT XSMutableObjectRef XSRuntimeCreateInstance( XSClassID classID );

Parameters
  • classID
    The class type ID
Return value

The allocated instance

XSRuntimeCreateInstanceOfClassNamed Top

Initializes a new instance of a class with a specific name

XS_EXPORT XSMutableObjectRef XSRuntimeCreateInstanceOfClassNamed( const char *name );

Parameters
  • name
    The name of the class
Return value

The allocated instance

XSRuntimeGetClassID Top

Gets the class type ID for an object

XS_EXPORT XSClassID XSRuntimeGetClassID( XSObjectRef object );

Parameters
  • object
    The object
Return value

The class type ID for the object

XSRuntimeGetClassIDOfClassNamed Top

Gets the class type ID for a class with a specific name

XS_EXPORT XSClassID XSRuntimeGetClassIDOfClassNamed( const char *className );

Parameters
  • className
    The name of the class
Return value

The class type ID

XSRuntimeGetClassName Top

Gets the class name for an class type ID

XS_EXPORT const char * XSRuntimeGetClassName( XSClassID classID );

Parameters
  • classID
    The class type ID
Return value

The name of the class

XSRuntimeGetClassType Top

Gets the class type for an class type ID

XS_EXPORT XSClassType XSRuntimeGetClassType( XSClassID classID );

Parameters
  • classID
    The class type ID
Return value

The type of the class

XSRuntimeGetDescription Top

Gets an object's description

XS_EXPORT const char * XSRuntimeGetDescription( XSObjectRef object );

Parameters
  • object
    The pointer to the object
Return value

The object's description

XSRuntimeGetSharedInstance Top

Gets the shared instance of a registered class

XS_EXPORT XSObjectRef XSRuntimeGetSharedInstance( XSClassID classID );

Parameters
  • classID
    The class type ID
Return value

The shared instance if it exists, otherwise NULL

XSRuntimeInitialize Top

Initializes the XSFoundation runtime

XS_EXPORT void XSRuntimeInitialize( void );

Discussion

This function must be called before using any XSFoundation function.

XSRuntimeIsInstance Top

Checks whether a pointer is an object instance

XS_EXPORT bool XSRuntimeIsInstance( const void *ptr );

Parameters
  • ptr
    The pointer to check
Return value

True if the pointer represents an instance, otherwise false

XSRuntimeIsRegisteredClass Top

Checks whether a class type ID corresponds to a registered class

XS_EXPORT bool XSRuntimeIsRegisteredClass( XSClassID classID );

Parameters
  • classID
    The class type ID
Return value

True if the class ID represents an valid class, otherwise false

XSRuntimeRegisterClass Top

Registers a class for the runtime

XS_EXPORT XSClassID XSRuntimeRegisterClass( const XSClassInfo *cls );

Discussion

All runtime classes needs to be registered before the runtime can use them and create instances. This function needs to be called once per class, ie using pthread_once().

Parameters
  • cls
    The class information structure to register
Return value

The runtime type ID for the class

XSRuntimeRegisterFinalizer Top

Registers a finalizer function, to be called when the program exits

void XSRuntimeRegisterFinalizer( void ( *func )( void ) );

Discussion

Based on its address, a finalizer function will only be registered once.

Parameters
  • func
    The finalizer function