Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate names under Struct #9

Merged
merged 1 commit into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ext/etc/etc.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ char *getlogin();

#define RUBY_ETC_VERSION "1.1.0"

#ifdef HAVE_RB_DEPRECATE_CONSTANT
void rb_deprecate_constant(VALUE mod, const char *name);
#else
# define rb_deprecate_constant(mod,name) ((void)(mod),(void)(name))
#endif

#include "constdefs.h"

/* call-seq:
Expand Down Expand Up @@ -1165,6 +1171,7 @@ Init_etc(void)
rb_define_const(mEtc, "Passwd", sPasswd);
#endif
rb_define_const(rb_cStruct, "Passwd", sPasswd); /* deprecated name */
rb_deprecate_constant(rb_cStruct, "Passwd");
rb_extend_object(sPasswd, rb_mEnumerable);
rb_define_singleton_method(sPasswd, "each", etc_each_passwd, 0);

Expand Down Expand Up @@ -1200,6 +1207,7 @@ Init_etc(void)
rb_define_const(mEtc, "Group", sGroup);
#endif
rb_define_const(rb_cStruct, "Group", sGroup); /* deprecated name */
rb_deprecate_constant(rb_cStruct, "Group");
rb_extend_object(sGroup, rb_mEnumerable);
rb_define_singleton_method(sGroup, "each", etc_each_group, 0);
#endif
Expand Down
5 changes: 5 additions & 0 deletions ext/etc/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
%x[#{RbConfig.ruby} #{srcdir}/mkconstants.rb -o #{srcdir}/constdefs.h]
end

decl = [
"void rb_deprecate_constant(VALUE, const char *);",
]
have_func('rb_deprecate_constant(Qnil, "None")', [decl])

$distcleanfiles << "constdefs.h"

create_makefile("etc")