aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2019-12-03 15:11:09 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2019-12-26 20:45:12 +0900
commitf3a229fe2d8b1b5dcc4fc4577341256743421f10 (patch)
tree87068ea64f768b77e3bfb4e9324ad8c4bef1b6ef
parent989068cf7087bf48f30c7f7c3f9acfa0bfd263ef (diff)
downloadruby-f3a229fe2d8b1b5dcc4fc4577341256743421f10.tar.gz
internal/variable.h rework
Eliminated macros. Also marked MJIT_FUNC_EXPORTED functions as such. Some of them are declared in constant.h so edited that file also.
-rw-r--r--constant.h9
-rw-r--r--internal/variable.h63
2 files changed, 54 insertions, 18 deletions
diff --git a/constant.h b/constant.h
index 3f1418df17..610bdf1dfe 100644
--- a/constant.h
+++ b/constant.h
@@ -39,12 +39,15 @@ VALUE rb_mod_private_constant(int argc, const VALUE *argv, VALUE obj);
VALUE rb_mod_public_constant(int argc, const VALUE *argv, VALUE obj);
VALUE rb_mod_deprecate_constant(int argc, const VALUE *argv, VALUE obj);
void rb_free_const_table(struct rb_id_table *tbl);
+VALUE rb_const_source_location(VALUE, ID);
+
+MJIT_SYMBOL_EXPORT_BEGIN
+int rb_autoloading_value(VALUE mod, ID id, VALUE *value, rb_const_flag_t *flag);
+rb_const_entry_t *rb_const_lookup(VALUE klass, ID id);
VALUE rb_public_const_get_at(VALUE klass, ID id);
VALUE rb_public_const_get_from(VALUE klass, ID id);
int rb_public_const_defined_from(VALUE klass, ID id);
-rb_const_entry_t *rb_const_lookup(VALUE klass, ID id);
-int rb_autoloading_value(VALUE mod, ID id, VALUE *value, rb_const_flag_t *flag);
-VALUE rb_const_source_location(VALUE, ID);
VALUE rb_const_source_location_at(VALUE, ID);
+MJIT_SYMBOL_EXPORT_END
#endif /* CONSTANT_H */
diff --git a/internal/variable.h b/internal/variable.h
index 1de31f6b92..1cdc06e08d 100644
--- a/internal/variable.h
+++ b/internal/variable.h
@@ -10,29 +10,24 @@
* file COPYING are met. Consult the file for details.
*/
+#include "ruby/config.h"
+#include <stddef.h> /* for size_t */
+#include "constant.h" /* for rb_const_entry_t */
+#include "internal/stdbool.h" /* for bool */
+#include "ruby/ruby.h" /* for VALUE */
+
/* global variable */
+#define ROBJECT_TRANSIENT_FLAG FL_USER13
+
+struct rb_global_variable; /* defined in variable.c */
+
struct rb_global_entry {
struct rb_global_variable *var;
ID id;
};
-struct rb_global_entry *rb_global_entry(ID);
-VALUE rb_gvar_get(struct rb_global_entry *);
-VALUE rb_gvar_set(struct rb_global_entry *, VALUE);
-VALUE rb_gvar_defined(struct rb_global_entry *);
-
/* variable.c */
-#if USE_TRANSIENT_HEAP
-#define ROBJECT_TRANSIENT_FLAG FL_USER13
-#define ROBJ_TRANSIENT_P(obj) FL_TEST_RAW((obj), ROBJECT_TRANSIENT_FLAG)
-#define ROBJ_TRANSIENT_SET(obj) FL_SET_RAW((obj), ROBJECT_TRANSIENT_FLAG)
-#define ROBJ_TRANSIENT_UNSET(obj) FL_UNSET_RAW((obj), ROBJECT_TRANSIENT_FLAG)
-#else
-#define ROBJ_TRANSIENT_P(obj) 0
-#define ROBJ_TRANSIENT_SET(obj) ((void)0)
-#define ROBJ_TRANSIENT_UNSET(obj) ((void)0)
-#endif
void rb_gc_mark_global_tbl(void);
size_t rb_generic_ivar_memsize(VALUE);
VALUE rb_search_class_path(VALUE);
@@ -46,6 +41,9 @@ rb_gvar_getter_t *rb_gvar_getter_function_of(const struct rb_global_entry *);
rb_gvar_setter_t *rb_gvar_setter_function_of(const struct rb_global_entry *);
bool rb_gvar_is_traced(const struct rb_global_entry *);
void rb_gvar_readonly_setter(VALUE v, ID id, VALUE *_);
+static inline bool ROBJ_TRANSIENT_P(VALUE obj);
+static inline void ROBJ_TRANSIENT_SET(VALUE obj);
+static inline void ROBJ_TRANSIENT_UNSET(VALUE obj);
RUBY_SYMBOL_EXPORT_BEGIN
/* variable.c (export) */
@@ -56,4 +54,39 @@ int rb_class_ivar_set(VALUE klass, ID vid, VALUE value);
void rb_iv_tbl_copy(VALUE dst, VALUE src);
RUBY_SYMBOL_EXPORT_END
+MJIT_SYMBOL_EXPORT_BEGIN
+struct rb_global_entry *rb_global_entry(ID);
+VALUE rb_gvar_get(struct rb_global_entry *);
+VALUE rb_gvar_set(struct rb_global_entry *, VALUE);
+VALUE rb_gvar_defined(struct rb_global_entry *);
+struct st_table *rb_ivar_generic_ivtbl(void);
+void rb_const_warn_if_deprecated(const rb_const_entry_t *, VALUE, ID);
+MJIT_SYMBOL_EXPORT_END
+
+static inline bool
+ROBJ_TRANSIENT_P(VALUE obj)
+{
+#if USE_TRANSIENT_HEAP
+ return FL_TEST_RAW(obj, ROBJECT_TRANSIENT_FLAG);
+#else
+ return false;
+#endif
+}
+
+static inline void
+ROBJ_TRANSIENT_SET(VALUE obj)
+{
+#if USE_TRANSIENT_HEAP
+ FL_SET_RAW(obj, ROBJECT_TRANSIENT_FLAG);
+#endif
+}
+
+static inline void
+ROBJ_TRANSIENT_UNSET(VALUE obj)
+{
+#if USE_TRANSIENT_HEAP
+ FL_UNSET_RAW(obj, ROBJECT_TRANSIENT_FLAG);
+#endif
+}
+
#endif /* INTERNAL_VARIABLE_H */