MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | SYNOPSIS |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 2 | #include <functionlist.h> |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 3 | |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 4 | mixed function_exists(string str) |
| 5 | mixed function_exists(string str, int flags) |
Zesstra | 5481d49 | 2021-04-08 20:07:06 +0200 | [diff] [blame] | 6 | mixed function_exists(string str, object|lwobject ob) |
| 7 | mixed function_exists(string str, object|lwobject ob, int flags) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 8 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 9 | DESCRIPTION |
| 10 | Look up a function <str> in the current object, respectively |
| 11 | in the object <ob>. Depending on the value of <flags>, one |
| 12 | of the following informations is returned: |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 13 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 14 | <flags> == FEXISTS_PROGNAME (0, default): |
| 15 | Return the name of the program the function is defined in. |
| 16 | This can be either object_name(ob), or the name of an inherited |
| 17 | program. If !compat mode, the returned name always begins |
| 18 | with a '/'. |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 19 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 20 | <flags> == FEXISTS_FILENAME (1): |
| 21 | Return the name of the file the function is defined in (this |
| 22 | may be an include file). If !compat mode, the returned name |
| 23 | always begins with a '/'. |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 24 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 25 | <flags> == FEXISTS_LINENO (2): |
| 26 | Return the line number within the source file. |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 27 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 28 | <flags> == FEXISTS_ALL (3): |
| 29 | Return an array with all the above information, plus information |
| 30 | about the function type/flags/number of arguments. |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 31 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 32 | The returned array contains this information: |
| 33 | string [FEXISTS_PROGNAME]: the program name |
| 34 | string [FEXISTS_FILENAME]: the filename |
| 35 | int [FEXISTS_LINENO]: the linenumber |
| 36 | int [FEXISTS_NUMARG]: the number of arguments to the function |
| 37 | int [FEXISTS_TYPE]: the return type of the function |
| 38 | int [FEXISTS_FLAGS]: the function flags |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 39 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 40 | The <flags> value can be or-ed to NAME_HIDDEN to return |
| 41 | information about static and protected functions in other objects. |
| 42 | It is not possible to return information about private functions. |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 43 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 44 | If the function cannot be found (because it doesn't exist or |
| 45 | it is not visible to the caller), the result is 0. |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 46 | |
| 47 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 48 | EXAMPLES |
| 49 | function_exists("create") |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 50 | function_exists("create", that_object, NAME_HIDDEN|FEXISTS_ALL); |
| 51 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 52 | HISTORY |
| 53 | LDMud 3.2.10 broadened the range of returned values and introduced |
| 54 | the <flags> argument. |
| 55 | LDMud 3.2.12/3.3.713 added the function type/flags/number of arguments |
| 56 | to the result of FEXISTS_ALL. |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 57 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame] | 58 | SEE ALSO |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 59 | call_other(E), call_resolved(E), functionlist(E), variable_exists(E) |