mint.type - Palamecia/mint GitHub Wiki
Module
load mint.type
This module provides functions to manage types.
Enums
MemberInfo.Flag
This enum describes the modifiers of the member.
Constant | Value | Description |
---|---|---|
ConstAddress | 0x02 |
The member has const address. |
ConstValue | 0x01 |
The member has const value. |
Global | 0x20 |
The member is global. |
None | 0x00 |
Empty flag for default created member. |
Package | 0x10 |
The member is public only inside his owner class's package. |
Private | 0x04 |
The member is private. |
Protected | 0x08 |
The member is protected. |
Classes
MemberInfo
This class provides informations about a member of a class.
Members
Modifiers | Member | Description |
---|---|---|
+ enum |
Flag | This enum describes the modifiers of the member. |
- final |
flags | Internal member flags. |
+ const |
getFlags | Returns the modifiers flags of the member as a mask of values described by Fl... |
+ const |
getName | Returns the name of the member. |
+ const |
getOwner | Returns the owner class of the member. |
+ const |
isConst | Returns true if the member is const (declared using a const modifier); ot... |
+ const |
isConstAddress | Returns true if the member has const address (declared using a $ modifier... |
+ const |
isConstValue | Returns true if the member has const value (declared using a % modifier);... |
+ const |
isGlobal | Returns true if the member is global (declared using a @ modifier); other... |
+ const |
isPackage | Returns true if the member is public inside his owner class package (declar... |
+ const |
isPrivate | Returns true if the member is private (declared using a - modifier); othe... |
+ const |
isProtected | Returns true if the member is protected (declared using a # modifier); ot... |
+ const |
isPublic | Returns true if the member is public (declared using a + modifier); other... |
- final |
name | Internal member name. |
+ const |
new | Creates a new member information with the name given by name and the modifi... |
- final |
owner | Internal member owner. |
Constants
Functions
- array
- boolean
- copy
- createGlobalMember
- getMemberInfo
- getMemberOwner
- hash
- isBaseOf
- isBaseOrSame
- isClass
- isCopyable
- isInstanceOf
- isMemberPrivate
- isMemberProtected
- isObject
- new
- number
- private
- protected
- regex
- string
- super
- type
Descriptions
MemberInfo.Flag.ConstAddress
0x02
The member has const address.
MemberInfo.Flag.ConstValue
0x01
The member has const value.
MemberInfo.Flag.Global
0x20
The member is global.
MemberInfo.Flag.None
0x00
Empty flag for default created member.
MemberInfo.Flag.Package
0x10
The member is public only inside his owner class's package.
MemberInfo.Flag.Private
0x04
The member is private.
MemberInfo.Flag.Protected
0x08
The member is protected.
MemberInfo.flags
none
Internal member flags.
MemberInfo.getFlags
def (const self)
Returns the modifiers flags of the member as a mask of values described by Flag.
MemberInfo.getName
def (const self)
Returns the name of the member.
MemberInfo.getOwner
def (const self)
Returns the owner class of the member.
MemberInfo.isConst
def (const self)
Returns true
if the member is const (declared using a const
modifier);
otherwise returns false
.
MemberInfo.isConstAddress
def (const self)
Returns true
if the member has const address (declared using a $
modifier); otherwise returns false
.
MemberInfo.isConstValue
def (const self)
Returns true
if the member has const value (declared using a %
modifier);
otherwise returns false
.
MemberInfo.isGlobal
def (const self)
Returns true
if the member is global (declared using a @
modifier);
otherwise returns false
.
MemberInfo.isPackage
def (const self)
Returns true
if the member is public inside his owner class package
(declared using a ~
modifier); otherwise returns false
.
MemberInfo.isPrivate
def (const self)
Returns true
if the member is private (declared using a -
modifier);
otherwise returns false
.
MemberInfo.isProtected
def (const self)
Returns true
if the member is protected (declared using a #
modifier);
otherwise returns false
.
MemberInfo.isPublic
def (const self)
Returns true
if the member is public (declared using a +
modifier);
otherwise returns false
.
MemberInfo.name
none
Internal member name.
MemberInfo.new
def (self, name, flags = None, owner = none)
Creates a new member information with the name given by name
and the
modifiers described by flags
. The flags
parameter must be a mask of
values givent by Flag. Optionally, the owner class of the member
can be provided using the owner
parameter.
MemberInfo.owner
none
Internal member owner.
array
def (value = [])
Converts value
to array
. If value
is already a array
, it is
returned; otherwise, if it provides a toArray
method, the result of the
method call is returned; otherwise, a built-in cast is performed.
boolean
def (value = false)
Converts value
to boolean
. If value
is already a boolean
, it is
returned; otherwise, if it provides a toBoolean
method, the result of the
method call is returned; otherwise, a built-in cast is performed.
copy
def (value)
Copy the value of value
. If value
provides a clone
method, the result
of the method call is returned; otherwise a built-in copy operation is
performed.
createGlobalMember
def (type, memberName, value = none)
Creates a new global member named memberName
for the type given by type
if no
global member with the same name already exists.
If value
is given, the member is initialized with the given value; otherwise
the member is initialized to none
.
Returns type
if the members was successfully created; otherwise returns
none
.
getMemberInfo
def (type, memberName)
Returns the informations about the memberName
member of the type
class
as an instance of MemberInfo. If the type
parameter is not a class, an
object or has no member memberName
, none
is returned.
getMemberOwner
def (type, memberName)
Returns the owner class of the member named memberName
in the class type
.
If no owner class can be found, none
is returned.
hash
def (value = {})
Converts value
to hash
. If value
is already a hash
, it is
returned; otherwise, if it provides a toHash
method, the result of the
method call is returned; otherwise, a built-in cast is performed.
isBaseOf
def (base, type)
Returns true
if base
is a base class of type
; otherwise returns false
.
isBaseOrSame
def (base, type)
Returns true
if base
is a base class of type
or the same class; otherwise
returns false
.
isClass
def (object)
Returns true
if object
is a non instanciated class; otherwise returns false
.
isCopyable
def (type)
Returns true
if the built-in copy operation can be applied to type
; otherwise
returns false
. The type
parameter can either be a class or an object.
isInstanceOf
def (object, type)
Returns true
if object
use the class of type
; otherwise returns false
.
isMemberPrivate
def (type, memberName)
Returns true
if the member named memberName
is private in the class
type
; otherwise returns false
.
If no member can be found, none
is returned.
isMemberProtected
def (type, memberName)
Returns true
if the member named memberName
is protected in the class
type
; otherwise returns false
.
If no member can be found, none
is returned.
isObject
def (object)
Returns true
if object
is an instanciated object; otherwise returns false
.
new
def (type, ...)
Creates a new instance of type
. The type
parameter can either be a cast
function of this module, a class or a type name. Extra arguments are passed
to the cast function or constructor called.
Example:
other = new(typeof value)
[!NOTE] If
type
is an object, the type oftype
is used instead.
number
def (value = 0)
Converts value
to number
. If value
is already a number
, it is
returned; otherwise, if it provides a toNumber
method, the result of the
method call is returned; otherwise, a built-in cast is performed.
private
def (member)
Returns the value of member
has a private member.
protected
def (member)
Returns the value of member
has a private member.
regex
def (value = /.*/)
Converts value
to regex
. If value
is already a regex
, it is
returned; otherwise, if it provides a toRegex
method, the result of the
method call is returned; otherwise, a built-in cast is performed.
string
def (value = '')
Converts value
to string
. If value
is already a string
, it is
returned; otherwise, if it provides a toString
method, the result of the
method call is returned; otherwise, a built-in cast is performed.
super
def (type)
Returns an array containing the base classes of type
.
toArray
array
Fallback to array function when calling toArray
on an object without
the method.
toBoolean
boolean
Fallback to boolean function when calling toBoolean
on an object without
the method.
toHash
hash
Fallback to hash function when calling toHash
on an object without
the method.
toNumber
number
Fallback to number function when calling toNumber
on an object without
the method.
toRegex
regex
Fallback to regex function when calling toRegex
on an object without
the method.
toString
string
Fallback to string function when calling toString
on an object without
the method.
type
def (object)
Returns the class of the object
parameter or none
if the object is not a
class instance.
def (type, members)
Creates a new local class named type
with the members described by members
.
The members
parameter must be an hash containing the members names mapped to
the default value. The key can also be an instance of MemberInfo to add
modifiers to the created member.
The created type is returned by the function. The returned value is the only way to access the described type. The type name is not registered as a class name and no standard instanciation is applicable.
By default, each created member is public and local. Members visibility can be
changed using the private
and protected
function. Global members can be
created using the createGlobalMember
function.
def (type, bases, members)
Creates a new local class named type
with the members described by members
.
The members
parameter must be an hash containing the members names mapped to
the default value. The key can also be an instance of MemberInfo to add
modifiers to the created member.
The bases
parameter must be an array containing the base classes or base
classes name for the created type.
The created type is returned by the function. The returned value is the only way to access the described type. The type name is not registered as a class name and no standard instanciation is applicable.
By default, each created member is public and local. Members visibility can be
changed using the private
and protected
function. Global members can be
created using the createGlobalMember
function.