AC_DEFINE_UNQUOTED([PSI_MACROS], [$PSI_MACROS], [Redirected Macros])
AC_DEFINE_UNQUOTED([PSI_REDIRS], [$PSI_REDIRS], [Redirected functions])
AC_DEFINE_UNQUOTED([PSI_DECLS], [$PSI_DECLS], [Predefined functions])
+ AC_DEFINE_UNQUOTED([PSI_VA_DECLS], [$PSI_VA_DECLS], [Predefined vararg functions])
+
PHP_ADD_INCLUDE($PHP_PSI_SRCDIR/src)
PHP_ADD_BUILD_DIR($PHP_PSI_BUILDDIR/src)
PSI_REDIRS=
PSI_MACROS=
PSI_DECLS=
+PSI_VA_DECLS=
psi_includes() {
local have_
psi_decl_args="[$psi_decl_args{]PSI_TYPE_PAIR(member_type)[, \"]member_name[\",] $pl, $as[}]"
])
-dnl PSI_DECL(type func, args)
+dnl PSI_DECL(type func, args, flags)
AC_DEFUN(PSI_DECL, [
psi_decl_args=
PSI_DECL_ARG($1)
[()], [],
[m4_map_args_sep([PSI_DECL_ARG(m4_normalize(], [))], [], m4_bregexp([$2], [(\(.*\))], [\1]))])
PSI_FUNC(PSI_VAR_NAME($1), [
- PSI_DECLS="$psi_decl_args, {0}, $PSI_DECLS"
+ ifelse([$3], vararg, [
+ PSI_VA_DECLS="$psi_decl_args, {0}, $PSI_VA_DECLS"
+ ], [
+ PSI_DECLS="$psi_decl_args, {0}, $PSI_DECLS"
+ ])
], [
PSI_MACRO($1, $2, [
+ ifelse([$3], vararg, AC_MSG_ERROR(varargs macro support is not implemented),[])
PSI_DECLS="$psi_decl_args, {0}, $PSI_DECLS"
])
])
PSI_DECL(FILE *tmpfile, [(void)])
PSI_DECL(char *tmpnam, [(char *s)])
PSI_DECL(int ungetc, [(int c, FILE *stream)])
-
+
+ PSI_DECL(int dprintf, [(int fd, char *fmt)], vararg)
+ PSI_DECL(int fprintf, [(FILE *stream, char *fmt)], vararg)
+ PSI_DECL(int fscanf, [(FILE *stream, char *fmt)], vararg)
+ PSI_DECL(int printf, [(char *fmt)], vararg)
+ PSI_DECL(int scanf, [(char *fmt)], vararg)
+ PSI_DECL(int snprintf, [(char *str, size_t size, char *fmt)], vararg)
+ PSI_DECL(int sprintf, [(char *str, char *fmt)], vararg)
+ PSI_DECL(int sscanf, [(char *str, char *fmt)], vararg)
])
return void(rewind);
}
-extern int printf(const char *fmt, ...);
+//extern int printf(const char *fmt, ...);
function psi\printf(string $fmt, mixed ...$args) : int {
let fmt = strval($fmt);
return to_int(printf);
PSI_DECLS
{0}
};
+static struct psi_predef_decl psi_predef_vararg_decls[] = {
+ PSI_VA_DECLS
+ {0}
+};
static struct psi_predef_struct {
token_t type_tag;
decl_args *args = init_decl_args(NULL);
decl *decl = init_decl(init_decl_abi("default"), func, args);
+ for (farg = &predef_decl[1]; farg->type_tag; ++farg) {
+ decl_type *arg_type = init_decl_type(farg->type_tag, farg->type_name);
+ decl_var *arg_var = init_decl_var(farg->var_name, farg->pointer_level, farg->array_size);
+ decl_arg *darg = init_decl_arg(arg_type, arg_var);
+ args = add_decl_arg(args, darg);
+ }
+
+ T.decls = add_decl(T.decls, decl);
+ predef_decl = farg;
+ }
+
+ for (predef_decl = &psi_predef_vararg_decls[0]; predef_decl->type_tag; ++predef_decl) {
+ struct psi_predef_decl *farg;
+ decl_type *ftype = init_decl_type(predef_decl->type_tag, predef_decl->type_name);
+ decl_var *fname = init_decl_var(predef_decl->var_name, predef_decl->pointer_level, predef_decl->array_size);
+ decl_arg *func = init_decl_arg(ftype, fname);
+ decl_args *args = init_decl_args(NULL);
+ decl *decl = init_decl(init_decl_abi("default"), func, args);
for (farg = &predef_decl[1]; farg->type_tag; ++farg) {
decl_type *arg_type = init_decl_type(farg->type_tag, farg->type_name);
decl_arg *darg = init_decl_arg(arg_type, arg_var);
args = add_decl_arg(args, darg);
}
+ args->varargs = 1;
T.decls = add_decl(T.decls, decl);
predef_decl = farg;