IObject
IObject
is the parent interface of all interfaces and is the interface automatically implemented by all Class.
as
zig
pub fn as(self: I, comptime T: type) t: {
break :t if (isInterface(T)) ?T else ?*T;
}
Function: Dynamically convert object types
parameter:
self
: the interface instance you want to convertT
: the type you want to convert to, which can be Class or Interface
Return: If the conversion is possible, return the converted object or interface, otherwise return null
Note
This conversion requires an array search operation, which is expensive.
asptr
zig
pub fn asptr(self: I) *anyopaque
asraw
zig
pub fn asraw(self: I) IRaw
Function: Copy self.ptr
and self.vptr
to IRaw
parameter:
self
: sourceInterface
Returns: An IRaw with the values of self.ptr
and self.vptr
copied
asraw is equivalent to the following code
zig
pub fn asraw(self: I) IRaw {
return IRaw{.ptr = self.ptr, .vptr = @ptrCast(self.vptr)};
}
eql
zig
pub fn eql(self: I, other: I) bool
Function: Compare whether two interface instances are equal
parameter:
self
: one of the interfaces involved in the comparisonother
: another interface
Returns: true if equal, false otherwise
destroy
zig
pub fn destroy(self: I) void
Function: Same as Class.destroy()