D Programming Language 2.0

- Comments
- D
- Search
- Home

Last update Thu Feb 17 14:20:02 2011

# object

Forms the symbols available to all D programs. Includes Object, which is the root of the class object hierarchy. This module is implicitly imported.

License:
Boost License 1.0.

Authors:
Walter Bright, Sean Kelly

class Object;
  All D class objects inherit from Object.

  string toString();
    Convert Object to a human readable string.

  hash_t toHash();
    Compute hash function for Object.

  int opCmp(Object o);
    Compare with another Object obj.

    Returns:

    this < obj | < 0
    this == obj | 0
    this > obj | > 0
    this < obj | < 0
    this == obj | 0
    this > obj | > 0

  equals_t opEquals(Object o);
    Returns !=0 if this object does have the same contents as obj.

  static Object factory(string classname);
    Create instance of class specified by classname. The class must either have no constructors or have a default constructor.

    Returns:
    null if failed

bool opEquals(Object lhs, Object rhs);
  Returns true if lhs and rhs are equal.

struct Interface;
  Information about an interface. When an object is accessed via an interface, an Interface* appears as the first entry in its vtbl.

  TypeInfo_Class classinfo;
    .classinfo for this interface (not for containing class)

  ptrdiff_t offset;
    offset to Interface 'this' from Object 'this'

alias Classinfo;
  Runtime type information about a class. Can be retrieved for any class type or instance by using the .classinfo property. A pointer to this appears as the first entry in the class's vtbl[].

struct OffsetTypeInfo;
  Array of pairs giving the offset and type information for each member in an aggregate.

  size_t offset;
    Offset of member from start of object

  TypeInfo ti;
    TypeInfo for this member

class TypeInfo;
  Runtime type information about a type. Can be retrieved for any type using a TypeidExpression.

  hash_t getHash(in void* p);
    Returns a hash of the instance of a type.

  equals_t equals(in void* p1, in void* p2);
    Compares two instances for equality.

  int compare(in void* p1, in void* p2);
    Compares two instances for <, ==, or >.

  size_t tsize();
    Returns size of the type.

  void swap(void* p1, void* p2);
    Swaps two instances of the type.

  TypeInfo next();
    Get TypeInfo for 'next' type, as defined by what kind of type this is, null if none.

  void[] init();
    Return default initializer, null if default initialize to 0

  uint flags();
    Get flags for type: 1 means GC should scan for pointers

  OffsetTypeInfo[] offTi();
    Get type information on the contents of the type; null if not available

  void destroy(void* p);
    Run the destructor on the object and all its sub-objects

  void postblit(void* p);
    Run the postblit on the object and all its sub-objects

  size_t talign();
    Return alignment of type

class TypeInfo_Class: object.TypeInfo;
  Runtime type information about a class. Can be retrieved from an object instance by using the .classinfo property.

  byte[] init;
    class static initializer (init.length gives size in bytes of class)

  string name;
    class name

  void*[] vtbl;
    virtual function pointer table

  Interface[] interfaces;
    interfaces this class implements

  TypeInfo_Class base;
    base class

  static TypeInfo_Class find(in char[] classname);
    Search all modules for TypeInfo_Class corresponding to classname.

    Returns:
    null if not found

  Object create();
    Create instance of Object represented by 'this'.

  const(MemberInfo[]) getMembers(in char[] name);
    Search for all members with the name 'name'. If name[] is null, return all members.

class Throwable;

void rt_setTraceHandler(TraceHandler h);
  Overrides the default trace hander with a user-supplied version.

  Parameters:

  TraceHandler h | The new trace handler. Set to null to use the default handler.

TraceHandler rt_getTraceHandler();
  Return the current trace handler

Throwable.TraceInfo _d_traceContext(void* ptr = null);
  This function will be called when an exception is constructed. The user-supplied trace handler will be called if one has been supplied, otherwise no trace will be generated.

  Parameters:

  void* ptr | A pointer to the location from which to generate the trace, or null if the trace should be generated from within the trace handler itself.

  Returns:
  An object describing the current calling context or null if no handler is supplied.

void _moduleCtor();
  Initialize the modules.

void _checkModCtors();
  Check for cycles on module constructors, and establish an order for module constructors.

void _moduleTlsCtor();
  Run static constructors for thread local global data.

void _moduleDtor();
  Destruct the modules.

alias IMonitor;

size_t capacity(T)(T[] arr);
  (Property) Get the current capacity of an array. The capacity is the number of elements that the array can grow to before the array must be extended/reallocated.

size_t reserve(T)(ref T[] arr, size_t newcapacity);
  Try to reserve capacity for an array. The capacity is the number of elements that the array can grow to before the array must be extended/reallocated.

  The return value is the new capacity of the array (which may be larger than the requested capacity).

void assumeSafeAppend(T)(T[] arr);
  Assume that it is safe to append to this array. Appends made to this array after calling this function may append in place, even if the array was a slice of a larger array to begin with.

  Use this only when you are sure no elements are in use beyond the array in the memory block. If there are, those elements could be overwritten by appending to this array.

  Calling this function, and then using references to data located after the given array results in undefined behavior.

bool _ArrayEq(T1, T2)(T1[] a1, T2[] a2);
  Helper function used to see if two containers of different types have the same contents in the same sequence.

Copyright Digital Mars 2000 - 2011. | Page generated by Ddoc.