X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=src%2Fbuiltin.c;h=5d9d7e42f00dd9574fd9548bd8b65a696cfaa889;hp=057e6f2fa7f9407d16deb16af6843934d05ba396;hb=f9a22bf3b60ca02611f7040cd5dcde433849a09b;hpb=077b151b807ea0704eb79761278bb4ca615a5344 diff --git a/src/builtin.c b/src/builtin.c index 057e6f2..5d9d7e4 100644 --- a/src/builtin.c +++ b/src/builtin.c @@ -45,7 +45,9 @@ static bool has_feature(struct psi_cpp *cpp, struct psi_token *target, struct ps static bool builtin_constant_p(struct psi_cpp *cpp, struct psi_token *target, struct psi_plist **args, struct psi_plist **res); static bool BASE_FILE__(struct psi_cpp *cpp, struct psi_token *target, struct psi_plist **args, struct psi_plist **res); static bool COUNTER__(struct psi_cpp *cpp, struct psi_token *target, struct psi_plist **args, struct psi_plist **res); +static bool FILE__(struct psi_cpp *cpp, struct psi_token *target, struct psi_plist **args, struct psi_plist **res); static bool INCLUDE_LEVEL__(struct psi_cpp *cpp, struct psi_token *target, struct psi_plist **args, struct psi_plist **res); +static bool LINE__(struct psi_cpp *cpp, struct psi_token *target, struct psi_plist **args, struct psi_plist **res); static bool TIMESTAMP__(struct psi_cpp *cpp, struct psi_token *target, struct psi_plist **args, struct psi_plist **res); static inline struct psi_plist *builtin_sig(token_t typ, ...) @@ -107,7 +109,9 @@ PHP_MINIT_FUNCTION(psi_builtin) PSI_BUILTIN(BASE_FILE__, -1); PSI_BUILTIN(COUNTER__, -1); + PSI_BUILTIN(FILE__, -1); PSI_BUILTIN(INCLUDE_LEVEL__, -1); + PSI_BUILTIN(LINE__, -1); PSI_BUILTIN(TIMESTAMP__, -1); return SUCCESS; @@ -230,6 +234,13 @@ static bool COUNTER__(struct psi_cpp *cpp, struct psi_token *target, return true; } +static bool FILE__(struct psi_cpp *cpp, struct psi_token *target, + struct psi_plist **args, struct psi_plist **res) +{ + ADD_QUOTED_ZSTRING(target->file); + return true; +} + static bool INCLUDE_LEVEL__(struct psi_cpp *cpp, struct psi_token *target, struct psi_plist **args, struct psi_plist **res) { @@ -237,6 +248,13 @@ static bool INCLUDE_LEVEL__(struct psi_cpp *cpp, struct psi_token *target, return true; } +static bool LINE__(struct psi_cpp *cpp, struct psi_token *target, + struct psi_plist **args, struct psi_plist **res) +{ + ADD_UNSIGNED_NUMBER(target->line); + return true; +} + static bool TIMESTAMP__(struct psi_cpp *cpp, struct psi_token *target, struct psi_plist **args, struct psi_plist **res) {