summaryrefslogtreecommitdiffstats
path: root/sysif.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-12-16 07:11:28 -0800
committerKaz Kylheku <kaz@kylheku.com>2015-12-16 07:11:28 -0800
commit954d698350e41df2bca00c4cba09dfe55f3a8e40 (patch)
tree4cfe48c1fd17644541ae82a4de3f125ed7aec714 /sysif.c
parentb860fe2ea8450109c4bcc0de755bccac40f377ef (diff)
downloadtxr-954d698350e41df2bca00c4cba09dfe55f3a8e40.tar.gz
txr-954d698350e41df2bca00c4cba09dfe55f3a8e40.tar.bz2
txr-954d698350e41df2bca00c4cba09dfe55f3a8e40.zip
Useful feature: object post-initialization.
Structs can now have code which executes after an object is initialized, which is useful for doing work like registering objects in global lists and whatever, when those actions need access to the initialized slots of the object. * share/txr/stdlib/struct.tl (defstruct): Handle :posinit syntax, by generating lambda as eighth argument of sys:make-struct call. * struct.c (struct struct_type): New member, postinitfun. (struct_init): Adjust registrations of make_struct_type to account for new parameter. The user visible make-struct-type is registered as having one optional argument, for backward compat. (make_struct_type): New argument, postinitfun. Store this in the structure. For backward compatibility, the argument is defaulted. (struct_type_mark): Mark the new postinitfun member. (call_postinitfun_chain): New static function. (make_struct, lazy_struct_init): Call call_postinitfun_chain after slots are initialized, and after the boa function is called. * struct.h (make_struct_type): Declaration updated. * lib.c (time_init): Pass eighth argument to make_struct type. * sysif.c (sysif_init): Likewise. * unwind.c (uw_late_init): Likewise. * tests/012/struct.tl: Update defstruct expansion test case. * txr.1: Document new argument of make-struct-type, and clarify ordering of initfun with regard to other actions. Likewise, document :postinit, and clarify ordering of :init actions with regard to other actions.
Diffstat (limited to 'sysif.c')
-rw-r--r--sysif.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sysif.c b/sysif.c
index 95a65c5d..eba00a27 100644
--- a/sysif.c
+++ b/sysif.c
@@ -1173,15 +1173,16 @@ void sysif_init(void)
make_struct_type(stat_s, nil, nil,
list(dev_s, ino_s, mode_s, nlink_s, uid_s, gid_s,
rdev_s, size_s, blksize_s, blocks_s, atime_s,
- mtime_s, ctime_s, nao), nil, nil, nil);
+ mtime_s, ctime_s, nao), nil, nil, nil, nil);
#if HAVE_PWUID
make_struct_type(passwd_s, nil, nil,
list(name_s, passwd_s, uid_s, gid_s,
- gecos_s, dir_s, shell_s, nao), nil, nil, nil);
+ gecos_s, dir_s, shell_s, nao), nil, nil, nil, nil);
#endif
#if HAVE_GRGID
make_struct_type(group_s, nil, nil,
- list(name_s, passwd_s, gid_s, mem_s, nao), nil, nil, nil);
+ list(name_s, passwd_s, gid_s, mem_s, nao),
+ nil, nil, nil, nil);
#endif
reg_fun(intern(lit("errno"), user_package), func_n1o(errno_wrap, 0));