Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
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:
Authors:
Walter Bright, Sean Kelly
-
- Convert Object to a human readable string.
- Compute hash function for Object.
- Compare with another Object obj.Returns:
this < obj < 0 this == obj 0 this > obj > 0 this < obj < 0 this == obj 0 this > obj > 0 - Returns !=0 if this object does have the same contents as obj.
- Create instance of class specified by the fully qualified name classname. The class must either have no constructors or have a default constructor.Returns:null if failed
Example:
module foo.bar; class C { this() { x = 10; } int x; } void main() { auto c = cast(C)Object.factory("foo.bar.C"); assert(c !is null && c.x == 10); }
- Returns true if lhs and rhs are equal.
- Information about an interface. When an object is accessed via an interface, an Interface* appears as the first entry in its vtbl.
- Array of pairs giving the offset and type information for each member in an aggregate.
- Offset of member from start of object
- TypeInfo for this member
- Runtime type information about a type. Can be retrieved for any type using a TypeidExpression.
- Returns a hash of the instance of a type.
- Compares two instances for equality.
- Compares two instances for <, ==, or >.
- Returns size of the type.
- Swaps two instances of the type.
-
null if none.
-
an array with a null ptr and a length equal to the type size will be returned.
- Scheduled for deprecation. Please use initializer instead.
-
2 means arg of this type is passed in XMM register
- Get type information on the contents of the type; null if not available
- Run the destructor on the object and all its sub-objects
- Return alignment of type
- Return internal info on arguments fitting into 8byte. See X86-64 ABI 3.2.3
- Return info used by the garbage collector to do precise collection.
- Runtime type information about a class. Can be retrieved from an object instance by using the .classinfo property.
- class static initializer (init.length gives size in bytes of class)
- virtual function pointer table
- Search all modules for TypeInfo_Class corresponding to classname.Returns:null if not found
- Create instance of Object represented by 'this'.
- The base class of all thrown objects.All thrown objects must inherit from Throwable. Class Exception, which derives from this class, represents the category of thrown objects that are safe to catch and handle. In principle, one should not catch Throwable objects that are not derived from Exception, as they represent unrecoverable runtime errors. Certain runtime guarantees may fail to hold when these errors are thrown, making it unsafe to continue execution after catching them.
- A message describing the error.
- The stack trace of where the error happened. This is an opaque object that can either be converted to string, or iterated over with foreach to extract the items in the stack trace (as strings).
- A reference to the next error in the list. This is used when a new Throwable is thrown from inside a catch block. The originally caught Exception will be chained to the new Throwable via this field.
- The base class of all errors that are safe to catch and handle.In principle, only thrown objects derived from this class are safe to catch inside a catch block. Thrown objects not derived from Exception represent runtime errors that should not be caught, as certain runtime guarantees may not hold, making it unsafe to continue program execution.
- Creates a new instance of Exception. The next parameter is used internally and should always be null when passed by user code. This constructor does not automatically throw the newly-created Exception; the throw statement should be used for that purpose.
- The base class of all unrecoverable runtime errors.This represents the category of Throwable objects that are not safe to catch and handle. In principle, one should not catch Error objects, as they represent unrecoverable runtime errors. Certain runtime guarantees may fail to hold when these errors are thrown, making it unsafe to continue execution after catching them.
- Creates a new instance of Error. The next parameter is used internally and should always be null when passed by user code. This constructor does not automatically throw the newly-created Error; the throw statement should be used for that purpose.
- The first Exception which was bypassed when this Error was thrown,or null if no Exceptions were pending.
- (Property) Get the current capacity of a slice. The capacity is the size that the slice can grow to before the underlying array must be reallocated or extended.If an append must reallocate a slice with no possibility of extension, then 0 is returned. This happens when the slice references a static array, or if another slice references elements past the end of the current slice.Examples:
//Static array slice: no capacity int[4] sarray = [1, 2, 3, 4]; int[] slice = sarray[]; assert(sarray.capacity == 0); //Appending to slice will reallocate to a new array slice ~= 5; assert(slice.capacity >= 5); //Dynamic array slices int[] a = [1, 2, 3, 4]; int[] b = a[1 .. $]; int[] c = a[1 .. $ - 1]; debug(SENTINEL) {} else // non-zero capacity very much depends on the array and GC implementation { assert(a.capacity != 0); assert(a.capacity == b.capacity + 1); //both a and b share the same tail } assert(c.capacity == 0); //an append to c must relocate c.
- Reserves capacity for a slice. The capacity is the size that the slice can grow to before the underlying array must be reallocated or extended.The return value is the new capacity of the array (which may be larger than the requested capacity).Examples:
//Static array slice: no capacity. Reserve relocates. int[4] sarray = [1, 2, 3, 4]; int[] slice = sarray[]; auto u = slice.reserve(8); assert(u >= 8); assert(sarray.ptr !is slice.ptr); assert(slice.capacity == u); //Dynamic array slices int[] a = [1, 2, 3, 4]; a.reserve(8); //prepare a for appending 4 more items auto p = a.ptr; u = a.capacity; a ~= [5, 6, 7, 8]; assert(p == a.ptr); //a should not have been reallocated assert(u == a.capacity); //a should not have been extended
- 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 it is certain there are no elements in use beyond the array in the memory block. If there are, those elements will 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.Returns:The input is returned.Examples:
int[] a = [1, 2, 3, 4]; // Without assumeSafeAppend. Appending relocates. int[] b = a [0 .. 3]; b ~= 5; assert(a.ptr != b.ptr); debug(SENTINEL) {} else { // With assumeSafeAppend. Appending overwrites. int[] c = a [0 .. 3]; c.assumeSafeAppend() ~= 5; assert(a.ptr == c.ptr); }
- Helper function used to see if two containers of different types have the same contents in the same sequence.
- Calculates the hash value of arg with seed initial value. Result may be non-equals with typeid(T).getHash(&arg) The seed value may be used for hash chaining:
struct Test { int a; string b; MyObject c; size_t toHash() const @safe pure nothrow { size_t hash = a.hashOf(); hash = b.hashOf(hash); size_t h1 = c.myMegaHash(); hash = h1.hashOf(hash); //Mix two hash values return hash; } }
Copyright Digital Mars 2000 - 2011.
| Page generated by
Ddoc on (no date time)