7. LFUN

  Module lfun


Method __INIT

void lfun::__INIT()

Description

Global variable initialization.

This function is called just before lfun::create() when an object is instanciated.

Note

This function is generated automatically by the compiler, and can not be overloaded.

See also

lfun::create()


Method create

void lfun::(zero ... args)

Description

Object creation callback.

This function is called right after lfun::__INIT() .

args will be the arguments passed when the program was called.

Note

In Pike 7.2 and later this function can be created implicitly by the compiler using the new syntax:


       class Foo(int foo) {
         int bar;
       }
     
In the above case an implicit lfun::create() will be created, and it will be equvivalent to:

       class Foo {
         int foo;
         int bar;
         static void create(int foo)
         {
           local::foo = foo;
         }
       }
     

See also

lfun::__INIT() , lfun::destroy()


Method destroy

void lfun::destroy()

Description

Object destruction callback.

This function is called by destruct() right before it will zero all the object variables, and destroy the object.

Note

Note that it will also be called on implicit destruct, eg when there are no more references to the object, or when the garbage-collector decides to destruct the object.

See also

lfun::create() , destruct()


Method `+

mixed lfun::`+(zero ... args)

Description

Left associative addition operator callback.

See also

lfun::``+() , `+()


Method `-

mixed lfun::`-(zero ... args)

Description

Left associative subtraction operator callback.

See also

lfun::``-() , `-()


Method `&

mixed lfun::`&(zero ... args)

Description

Left associative and operator callback.

See also

lfun::``&() , `&()


Method `|

mixed lfun::`|(zero ... args)

Description

Left associative or operator callback.

See also

lfun::``|() , `|()


Method `^

mixed lfun::`^(zero ... args)

Description

Left associative exclusive or operator callback.

See also

lfun::``^() , `^()


Method `<<

mixed lfun::`<<(zero arg)

Description

Left associative left shift operator callback.

See also

lfun::``<<() , `<<()


Method `>>

mixed lfun::`>>(zero arg)

Description

Left associative right shift operator callback.

See also

lfun::``>>() , `>>()


Method `*

mixed lfun::`*(zero ... args)

Description

Left associative multiplication operator callback.

See also

lfun::``*() , `*()


Method `/

mixed lfun::`/(zero ... args)

Description

Left associative division operator callback.

See also

lfun::``/() , `/()


Method `%

mixed lfun::`%(zero ... args)

Description

Left associative modulo operator callback.

See also

lfun::``%() , `%()


Method `~

mixed lfun::`~()

Description

Inversion operator callback.

See also

`~()


Method `==

int(0..1) lfun::`==(mixed arg)

Description

Equality operator callback.

See also

`==()


Method `<

int(0..1) lfun::`<(mixed arg)

Description

Less than operator callback.

See also

`<()


Method `>

int(0..1) lfun::`>(mixed arg)

Description

Greater than operator callback.

See also

`>()


Method __hash

int lfun::__hash()

Description

Hashing callback.

This function gets called by various mapping operations when the object is used as index in a mapping.


Method cast

mixed lfun::cast(string requested_type)

Description

Cast operator callback.

Parameter requested_type

Type to cast to.

Returns

Expected to return the object value-casted (converted) to the type described by requested_type .

Note

The argument is currently a string with the name of the type, but might in the future be a value of the type type.

Note

Currently casting between object types is a noop.

Note

If the returned value is not deemed to be of the requested type a runtime error may be thrown.


Method `!

int lfun::`!()

Description

Not operator callback.

Returns

Returns non-zero if the object should be evaluated as false, and 0 (zero) otherwise.

See also

`!()


Method `[]

mixed lfun::`[](zero arg1, zero|void arg2)

Description

Index/range operator callback.

See also

`[]()


Method `[]=

mixed lfun::`[]=(zero arg1, zero arg2)

Description

Index assignment operator callback.

See also

`[]=() , lfun::`->=()


Method `->

mixed lfun::`->(string arg)

Description

Arrow index operator callback.

See also

`->()


Method `->=

mixed lfun::`->=(string arg1, zero arg2)

Description

Arrow index assign operator callback.

See also

`->=() , lfun::`[]=()


Method _sizeof

int lfun::_sizeof()

Description

Sizeof operator callback.

Called by sizeof() to determine the number of elements in an object. If this function is not present, the number of public symbols in the object will be returned.

Returns

Expected to return the number of valid indices in the object.

See also

sizeof()


Method _indices

array lfun::_indices()

Description

Indices operator callback.

Returns

Expected to return an array with the valid indices in the object.

See also

indices() , lfun::_values()


Method _values

array lfun::_values()

Description

Values operator callback.

Returns

Expected to return an array with the values corresponding to the indices returned by lfun::_indices() .

See also

values() , lfun::_indices()


Method `()

mixed lfun::`()(zero ... args)

Description

Function call operator callback.

See also

`()


Method ``+

mixed lfun::``+(zero ... args)

Description

Right associative addition operator callback.

See also

lfun::`+() , `+()


Method ``-

mixed lfun::``-(zero ... args)

Description

Right associative subtraction operator callback.

See also

lfun::`-() , `-()


Method ``&

mixed lfun::``&(zero ... args)

Description

Right associative and operator callback.

See also

lfun::`&() , `&()


Method ``|

mixed lfun::``|(zero ... args)

Description

Right associative or operator callback.

See also

lfun::`|() , `|()


Method ``^

mixed lfun::``^(zero ... args)

Description

Right associative exclusive or operator callback.

See also

lfun::`^() , `^()


Method ``<<

mixed lfun::``<<(zero arg)

Description

Right associative left shift operator callback.

See also

lfun::`<<() , `<<()


Method ``>>

mixed lfun::``>>(zero arg)

Description

Right associative right shift operator callback.

See also

lfun::`>>() , `>>()


Method ``*

mixed lfun::``*(zero ... args)

Description

Right associative multiplication operator callback.

See also

lfun::`*() , `*()


Method ``/

mixed lfun::``/(zero ... args)

Description

Right associative division operator callback.

See also

lfun::`/() , `/()


Method ``%

mixed lfun::``%(zero ... args)

Description

Right associative modulo operator callback.

See also

lfun::`%() , `%()


Method `+=

mixed lfun::`+=(zero arg)

Description

Self increment operator callback.

See also

`+() , lfun::`+()


Method _is_type

int(0..1) lfun::_is_type(string basic_type)

Description

Type comparison callback.

Called by the cast operator to determine if an object simulates a basic type.

Parameter basic_type

One of:

"array"
"float"
"function"
"int"
"mapping"
"multiset"
"object"
"program"
"string"
"type"
"void"
"zero"

The following five shouldn't occurr, but are here for completeness:

"lvalue"
"mapping_data"
"object storage"
"pike_frame"
"unknown"

Returns

Expected to return 1 if the object is to be regarded as a simulation of the type specified by basic_type .

Note

The argument is currently a string with the name of the type, but might in the future be a value of the type type.


Method _sprintf

string lfun::_sprintf(int conversion_type, mapping(string:int)|void params)

Description

Sprintf callback.

This method is called by sprintf() to print objects. If it is not present, printing of the object will not be supported for any conversion-type except for the %O-conversion-type, which will output "object".

Parameter conversion_type

One of:

'b'

Signed binary integer.

'd'

Signed decimal integer.

'u'

Unsigned decimal integer.

'o'

Signed octal integer.

'x'

Lowercase signed hexadecimal integer.

'X'

Uppercase signed hexadecimal integer.

'c'

Character. If a fieldsize has been specified this will output the low-order bytes of the integer in network byte order.

'f'

Float.

'g'

Heuristically chosen representation of float.

'G'

Like %g, but uses uppercase E for exponent.

'e'

Exponential notation float.

'E'

Like %e, but uses uppercase E for exponent.

's'

String.

'O'

Any value (debug style).

't'

Type of the argument.


Parameter params

Conversion parameters. The following parameters may be supplied:

"precision" : int

Precision.

"width" : int

Field width.

"flag_left" : int(1..1)

Indicates that the output should be left-aligned.

"indent" : int

Indentation level in %O-mode.


Returns

Is expected to return a string describing the object formatted according to conversion_type .

Note

_sprintf() is currently not called for the following conversion-types:

'F'

Binary IEEE representation of float (%4F gives single precision, %8F gives double precision.)


See also

sprintf()


Method _equal

int lfun::_equal(mixed arg)

Description

Equal callback.

See also

equal() , lfun::`==()


Method _m_delete

mixed lfun::_m_delete(mixed arg)

Description

Mapping delete callback.

See also

m_delete()


Method _get_iterator

object lfun::_get_iterator()

Description

Iterator creation callback.

Returns

Should return an object that implements the iterator API:

lfun::`!() should return 0 (zero) when not at end of stream, and 1 at end of stream.

lfun::`+=() should advance the specified number of steps.

index() should return the current index.

value() should return the current value.

See also

Iterator , foreach()

  Module


Method `->

mixed ::`->(string index)

Description

Builtin arrow operator.

This function indexes the current object with the string index . This is useful when the arrow operator has been overloaded.

See also

::`->=()


Method `->=

void ::`->=(string index, mixed value)

Description

Builtin arrow set operator.

This function indexes the current object with the string index , and sets it to value . This is useful when the arrow set operator has been overloaded.

See also

::`->()


Method _indices

mixed ::_indices()

Description

Builtin function to list the identifiers of an object. This is useful when lfun::_indices has been overloaded.

See also

::_values, ::`->


Method _values

mixed ::_values()

Description

Builtin function to list the values of the identifiers of an object. This is useful when lfun::_values has been overloaded.

See also

::_indices, ::`->