Select Git revision
module_support.h
-
Marcus Comstedt authored
Rev: bin/precompile.pike:1.72 Rev: src/module_support.h:1.16 Rev: src/modules/CommonLog/clf.c:1.11 Rev: src/modules/DVB/dvb.c:1.13 Rev: src/modules/Gdbm/gdbmmod.c:1.22 Rev: src/modules/Gettext/gettext.c:1.13 Rev: src/modules/Gmp/mpf.cmod:1.13 Rev: src/modules/Gmp/mpq.cmod:1.14 Rev: src/modules/Gmp/mpz_glue.c:1.115 Rev: src/modules/Gmp/my_mpz_xor.c:1.6 Rev: src/modules/Gz/zlibmod.c:1.57 Rev: src/modules/HTTPLoop/accept_and_parse.c:1.30 Rev: src/modules/HTTPLoop/cache.c:1.20 Rev: src/modules/HTTPLoop/filesystem.c:1.8 Rev: src/modules/HTTPLoop/log.c:1.14 Rev: src/modules/HTTPLoop/requestobject.c:1.24 Rev: src/modules/HTTPLoop/timeout.c:1.10 Rev: src/modules/HTTPLoop/util.c:1.10 Rev: src/modules/Image/blit.c:1.54 Rev: src/modules/Image/colors.c:1.64 Rev: src/modules/Image/colortable.c:1.113 Rev: src/modules/Image/dct.c:1.23 Rev: src/modules/Image/encodings/_xpm.c:1.22 Rev: src/modules/Image/encodings/any.c:1.26 Rev: src/modules/Image/encodings/avs.c:1.15 Rev: src/modules/Image/encodings/bmp.c:1.38 Rev: src/modules/Image/encodings/dsi.c:1.7 Rev: src/modules/Image/encodings/hrz.c:1.9 Rev: src/modules/Image/encodings/iff.c:1.13 Rev: src/modules/Image/encodings/ilbm.c:1.27 Rev: src/modules/Image/encodings/pcx.c:1.20 Rev: src/modules/Image/encodings/png.c:1.47 Rev: src/modules/Image/encodings/pnm.c:1.29 Rev: src/modules/Image/encodings/psd.c:1.35 Rev: src/modules/Image/encodings/pvr.c:1.22 Rev: src/modules/Image/encodings/ras.c:1.19 Rev: src/modules/Image/encodings/tga.c:1.30 Rev: src/modules/Image/encodings/tim.c:1.15 Rev: src/modules/Image/encodings/wbf.c:1.14 Rev: src/modules/Image/encodings/x.c:1.40 Rev: src/modules/Image/encodings/xbm.c:1.18 Rev: src/modules/Image/encodings/xcf.c:1.43 Rev: src/modules/Image/encodings/xwd.c:1.24 Rev: src/modules/Image/font.c:1.75 Rev: src/modules/Image/image.c:1.200 Rev: src/modules/Image/image_module.c:1.17 Rev: src/modules/Image/layers.c:1.82 Rev: src/modules/Image/matrix.c:1.43 Rev: src/modules/Image/operator.c:1.43 Rev: src/modules/Image/orient.c:1.23 Rev: src/modules/Image/pattern.c:1.28 Rev: src/modules/Image/poly.c:1.17 Rev: src/modules/Image/polyfill.c:1.42 Rev: src/modules/Image/search.c:1.26 Rev: src/modules/Java/jvm.c:1.45 Rev: src/modules/MIME/mime.c:1.35 Rev: src/modules/Math/math_matrix.c:1.36 Rev: src/modules/Math/math_module.c:1.12 Rev: src/modules/Math/transforms.cmod:1.9 Rev: src/modules/Mird/mird_glue.c:1.20 Rev: src/modules/Msql/msqlmod.c:1.23 Rev: src/modules/Mysql/mysql.c:1.61 Rev: src/modules/Odbc/odbc.c:1.33 Rev: src/modules/Odbc/odbc_result.c:1.33 Rev: src/modules/Oracle/oracle.c:1.74 Rev: src/modules/PDF/pdf_module.c:1.14 Rev: src/modules/PDF/pdflib_glue.c:1.11 Rev: src/modules/Parser/html.c:1.156 Rev: src/modules/Parser/parser.c:1.17 Rev: src/modules/Perl/perlmod.c:1.29 Rev: src/modules/Pipe/pipe.c:1.52 Rev: src/modules/Postgres/pgresult.c:1.20 Rev: src/modules/Postgres/postgres.c:1.29 Rev: src/modules/Regexp/glue.c:1.32 Rev: src/modules/Regexp/pike_regexp.c:1.23 Rev: src/modules/SANE/sane.c:1.15 Rev: src/modules/Ssleay/ssleay.c:1.20 Rev: src/modules/Yp/yp.c:1.28 Rev: src/modules/_Charset/charsetmod.c:1.39 Rev: src/modules/_Charset/iso2022.c:1.26 Rev: src/modules/_Crypto/arcfour.c:1.20 Rev: src/modules/_Crypto/cast.c:1.14 Rev: src/modules/_Crypto/cbc.c:1.24 Rev: src/modules/_Crypto/crypto.c:1.52 Rev: src/modules/_Crypto/des.c:1.27 Rev: src/modules/_Crypto/idea.c:1.21 Rev: src/modules/_Crypto/invert.c:1.16 Rev: src/modules/_Crypto/md2.c:1.16 Rev: src/modules/_Crypto/md4.c:1.5 Rev: src/modules/_Crypto/md5.c:1.21 Rev: src/modules/_Crypto/nt.c:1.12 Rev: src/modules/_Crypto/pipe.c:1.25 Rev: src/modules/_Crypto/rijndael.c:1.10 Rev: src/modules/_Crypto/rsa.c:1.28 Rev: src/modules/_Crypto/sha.c:1.24 Rev: src/modules/_Ffmpeg/ffmpeg.c:1.12 Rev: src/modules/_Image_FreeType/freetype.c:1.10 Rev: src/modules/_Image_GIF/gif_lzw.c:1.6 Rev: src/modules/_Image_GIF/image_gif.c:1.14 Rev: src/modules/_Image_JPEG/image_jpeg.c:1.59 Rev: src/modules/_Image_TIFF/image_tiff.c:1.31 Rev: src/modules/_Image_TTF/image_ttf.c:1.47 Rev: src/modules/_Image_XFace/image_xface.c:1.18 Rev: src/modules/_Roxen/roxen.c:1.32 Rev: src/modules/_math/math.c:1.53 Rev: src/modules/files/file.c:1.247 Rev: src/modules/files/file.h:1.24 Rev: src/modules/spider/discdate.c:1.14 Rev: src/modules/spider/spider.c:1.120 Rev: src/modules/spider/stardate.c:1.16 Rev: src/modules/spider/xml.c:1.55 Rev: src/modules/sprintf/sprintf.c:1.99 Rev: src/modules/sybase/sybase.c:1.12 Rev: src/modules/system/memory.c:1.18 Rev: src/modules/system/nt.c:1.54 Rev: src/modules/system/system.c:1.129 Rev: src/post_modules/GL/auto.c.in:1.25 Rev: src/post_modules/GL/top.c:1.18 Rev: src/post_modules/GLUT/auto.c.in:1.7 Rev: src/post_modules/GLUT/top.c:1.8 Rev: src/post_modules/GTK/dummy.c:1.6 Rev: src/post_modules/GTK/output/split.pike:1.10 Rev: src/post_modules/GTK/pgtk.h:1.30 Rev: src/post_modules/SDL/SDL.cmod:1.7 Rev: src/post_modules/Shuffler/Shuffler.cmod:1.17 Rev: src/post_modules/Unicode/normalize.c:1.12 Rev: src/post_modules/Unicode/unicode_module.cmod:1.6 Rev: src/post_modules/_Image_SVG/svg.c:1.8
Marcus Comstedt authoredRev: bin/precompile.pike:1.72 Rev: src/module_support.h:1.16 Rev: src/modules/CommonLog/clf.c:1.11 Rev: src/modules/DVB/dvb.c:1.13 Rev: src/modules/Gdbm/gdbmmod.c:1.22 Rev: src/modules/Gettext/gettext.c:1.13 Rev: src/modules/Gmp/mpf.cmod:1.13 Rev: src/modules/Gmp/mpq.cmod:1.14 Rev: src/modules/Gmp/mpz_glue.c:1.115 Rev: src/modules/Gmp/my_mpz_xor.c:1.6 Rev: src/modules/Gz/zlibmod.c:1.57 Rev: src/modules/HTTPLoop/accept_and_parse.c:1.30 Rev: src/modules/HTTPLoop/cache.c:1.20 Rev: src/modules/HTTPLoop/filesystem.c:1.8 Rev: src/modules/HTTPLoop/log.c:1.14 Rev: src/modules/HTTPLoop/requestobject.c:1.24 Rev: src/modules/HTTPLoop/timeout.c:1.10 Rev: src/modules/HTTPLoop/util.c:1.10 Rev: src/modules/Image/blit.c:1.54 Rev: src/modules/Image/colors.c:1.64 Rev: src/modules/Image/colortable.c:1.113 Rev: src/modules/Image/dct.c:1.23 Rev: src/modules/Image/encodings/_xpm.c:1.22 Rev: src/modules/Image/encodings/any.c:1.26 Rev: src/modules/Image/encodings/avs.c:1.15 Rev: src/modules/Image/encodings/bmp.c:1.38 Rev: src/modules/Image/encodings/dsi.c:1.7 Rev: src/modules/Image/encodings/hrz.c:1.9 Rev: src/modules/Image/encodings/iff.c:1.13 Rev: src/modules/Image/encodings/ilbm.c:1.27 Rev: src/modules/Image/encodings/pcx.c:1.20 Rev: src/modules/Image/encodings/png.c:1.47 Rev: src/modules/Image/encodings/pnm.c:1.29 Rev: src/modules/Image/encodings/psd.c:1.35 Rev: src/modules/Image/encodings/pvr.c:1.22 Rev: src/modules/Image/encodings/ras.c:1.19 Rev: src/modules/Image/encodings/tga.c:1.30 Rev: src/modules/Image/encodings/tim.c:1.15 Rev: src/modules/Image/encodings/wbf.c:1.14 Rev: src/modules/Image/encodings/x.c:1.40 Rev: src/modules/Image/encodings/xbm.c:1.18 Rev: src/modules/Image/encodings/xcf.c:1.43 Rev: src/modules/Image/encodings/xwd.c:1.24 Rev: src/modules/Image/font.c:1.75 Rev: src/modules/Image/image.c:1.200 Rev: src/modules/Image/image_module.c:1.17 Rev: src/modules/Image/layers.c:1.82 Rev: src/modules/Image/matrix.c:1.43 Rev: src/modules/Image/operator.c:1.43 Rev: src/modules/Image/orient.c:1.23 Rev: src/modules/Image/pattern.c:1.28 Rev: src/modules/Image/poly.c:1.17 Rev: src/modules/Image/polyfill.c:1.42 Rev: src/modules/Image/search.c:1.26 Rev: src/modules/Java/jvm.c:1.45 Rev: src/modules/MIME/mime.c:1.35 Rev: src/modules/Math/math_matrix.c:1.36 Rev: src/modules/Math/math_module.c:1.12 Rev: src/modules/Math/transforms.cmod:1.9 Rev: src/modules/Mird/mird_glue.c:1.20 Rev: src/modules/Msql/msqlmod.c:1.23 Rev: src/modules/Mysql/mysql.c:1.61 Rev: src/modules/Odbc/odbc.c:1.33 Rev: src/modules/Odbc/odbc_result.c:1.33 Rev: src/modules/Oracle/oracle.c:1.74 Rev: src/modules/PDF/pdf_module.c:1.14 Rev: src/modules/PDF/pdflib_glue.c:1.11 Rev: src/modules/Parser/html.c:1.156 Rev: src/modules/Parser/parser.c:1.17 Rev: src/modules/Perl/perlmod.c:1.29 Rev: src/modules/Pipe/pipe.c:1.52 Rev: src/modules/Postgres/pgresult.c:1.20 Rev: src/modules/Postgres/postgres.c:1.29 Rev: src/modules/Regexp/glue.c:1.32 Rev: src/modules/Regexp/pike_regexp.c:1.23 Rev: src/modules/SANE/sane.c:1.15 Rev: src/modules/Ssleay/ssleay.c:1.20 Rev: src/modules/Yp/yp.c:1.28 Rev: src/modules/_Charset/charsetmod.c:1.39 Rev: src/modules/_Charset/iso2022.c:1.26 Rev: src/modules/_Crypto/arcfour.c:1.20 Rev: src/modules/_Crypto/cast.c:1.14 Rev: src/modules/_Crypto/cbc.c:1.24 Rev: src/modules/_Crypto/crypto.c:1.52 Rev: src/modules/_Crypto/des.c:1.27 Rev: src/modules/_Crypto/idea.c:1.21 Rev: src/modules/_Crypto/invert.c:1.16 Rev: src/modules/_Crypto/md2.c:1.16 Rev: src/modules/_Crypto/md4.c:1.5 Rev: src/modules/_Crypto/md5.c:1.21 Rev: src/modules/_Crypto/nt.c:1.12 Rev: src/modules/_Crypto/pipe.c:1.25 Rev: src/modules/_Crypto/rijndael.c:1.10 Rev: src/modules/_Crypto/rsa.c:1.28 Rev: src/modules/_Crypto/sha.c:1.24 Rev: src/modules/_Ffmpeg/ffmpeg.c:1.12 Rev: src/modules/_Image_FreeType/freetype.c:1.10 Rev: src/modules/_Image_GIF/gif_lzw.c:1.6 Rev: src/modules/_Image_GIF/image_gif.c:1.14 Rev: src/modules/_Image_JPEG/image_jpeg.c:1.59 Rev: src/modules/_Image_TIFF/image_tiff.c:1.31 Rev: src/modules/_Image_TTF/image_ttf.c:1.47 Rev: src/modules/_Image_XFace/image_xface.c:1.18 Rev: src/modules/_Roxen/roxen.c:1.32 Rev: src/modules/_math/math.c:1.53 Rev: src/modules/files/file.c:1.247 Rev: src/modules/files/file.h:1.24 Rev: src/modules/spider/discdate.c:1.14 Rev: src/modules/spider/spider.c:1.120 Rev: src/modules/spider/stardate.c:1.16 Rev: src/modules/spider/xml.c:1.55 Rev: src/modules/sprintf/sprintf.c:1.99 Rev: src/modules/sybase/sybase.c:1.12 Rev: src/modules/system/memory.c:1.18 Rev: src/modules/system/nt.c:1.54 Rev: src/modules/system/system.c:1.129 Rev: src/post_modules/GL/auto.c.in:1.25 Rev: src/post_modules/GL/top.c:1.18 Rev: src/post_modules/GLUT/auto.c.in:1.7 Rev: src/post_modules/GLUT/top.c:1.8 Rev: src/post_modules/GTK/dummy.c:1.6 Rev: src/post_modules/GTK/output/split.pike:1.10 Rev: src/post_modules/GTK/pgtk.h:1.30 Rev: src/post_modules/SDL/SDL.cmod:1.7 Rev: src/post_modules/Shuffler/Shuffler.cmod:1.17 Rev: src/post_modules/Unicode/normalize.c:1.12 Rev: src/post_modules/Unicode/unicode_module.cmod:1.6 Rev: src/post_modules/_Image_SVG/svg.c:1.8
Function.pmod 3.53 KiB
#pike __REAL_VERSION__
constant defined = __builtin.function_defined;
//! Calls the given function with the @[args] array plus the optional
//! extra arguments as its arguments and returns the result.
//!
//! Most useful in conjunction with @[map], and particularly in combination
//! with @[sscanf] with @expr{"...%{...%}..."@} scan strings (which indeed
//! was what it was invented for in the first place).
//!
//! @param args
//! The first arguments the function @[f] expects.
//! @param f
//! The function to apply the arguments on.
//! @param extra
//! Optional extra arguments to send to @[f].
//! @returns
//! Whatever the supplied function @[f] returns.
//!
//! @example
//! @code
//! class Product(string name, string version)
//! {
//! string _sprintf()
//! {
//! return sprintf("Product(%s/%s)", name, version);
//! }
//! }
//! map(({ ({ "pike", "7.1.11" }),
//! ({ "whitefish", "0.1" }) }),
//! Function.splice_call, Product);
//! ({ /* 2 elements */
//! Product(pike/7.1.11),
//! Product(whitefish/0.1)
//! })
//! @endcode
mixed splice_call(array args, function f, mixed|void ... extra)
{
return f(@args, @extra);
}
//! The dreaded fixpoint combinator "Y".
//!
//! The Y combinator is useful when writing recursive lambdas. It
//! converts a lambda that expects a self-reference as its first argument
//! into one which can be called without this argument.
//!
//! @example
//! This example creates a lambda that computes the faculty function.
//! @code
//! Function.Y(lambda(function f, int n) { return n>1? n*f(n-1) : 1; })
//! @endcode
function Y(function f)
{
return lambda(function p) {
return lambda(mixed ... args) {
return f(p(p), @args);
};
} (lambda(function p) {
return lambda(mixed ... args) {
return f(p(p), @args);
};
});
}
//! Partially evaluate a function call.
//!
//! This function allows N parameters to be given to a function taking
//! M parameters (N<=M), yielding a new function taking M-N parameters.
//!
//! What is actually returned from this function is a function taking N
//! parameters, and returning a function taking M-N parameters.
//!
//! @example
//! This example creates a function adding 7 to its argument.
//! @code
//! Function.curry(`+)(7)
//! @endcode
function(mixed...:function(mixed...:mixed|void)) curry(function f)
{
return lambda(mixed ... args1) {
return lambda(mixed ... args2) {
return f(@args1, @args2);
};
};
}
//! This function, given a function taking N parameters, returns a new
//! function taking N+1 parameters. The first argument will be
//! ignored.
//!
//! @example
//! @code
//! > Function.uncurry(`+)(7,2,3)
//! Result: 5
//! @endcode
function(mixed...:function(mixed...:mixed|void)) uncurry(function f)
{
return lambda(mixed ... args1) {
return f(@args1[1..]);
};
}
//! Call a callback function, but send throws from the callback
//! function (ie, errors) to master()->handle_error.
//! Also accepts if f is zero (0) without error.
//!
//! @example
//! @code
//! Functions.call_callback(the_callback,some,arguments);
//! @endcode
//! equals
//! @code
//! {
//! mixed err=catch { if (the_callback) the_callback(some,arguments); };
//! if (err) master()->handle_error(err);
//! }
//! @endcode
//! (Approximately, since call_callback also calls handle_error
//! if 0 were thrown.)
void call_callback(function f,mixed ... args)
{
if (!f) return;
mixed err=catch { f(@args); return; };
handle_error(err);
}
private function handle_error = master()->handle_error;