ZJIT: Enable a couple more btests (#13748)
[ruby.git] / internal / namespace.h
blob4cdfbc305fe1da123faac9ee210ba33b85506834
1 #ifndef INTERNAL_NAMESPACE_H /*-*-C-*-vi:se ft=c:*/
2 #define INTERNAL_NAMESPACE_H
4 #include "ruby/ruby.h" /* for VALUE */
6 /**
7 * @author Ruby developers <ruby-core@ruby-lang.org>
8 * @copyright This file is a part of the programming language Ruby.
9 * Permission is hereby granted, to either redistribute and/or
10 * modify this file, provided that the conditions mentioned in the
11 * file COPYING are met. Consult the file for details.
12 * @brief Internal header for Namespace.
14 struct rb_namespace_struct {
16 * To retrieve Namespace object that provides #require and so on.
17 * That is used from load.c, etc., that uses rb_namespace_t internally.
19 VALUE ns_object;
20 long ns_id; // namespace id to generate ext filenames
22 VALUE top_self;
24 VALUE load_path;
25 VALUE load_path_snapshot;
26 VALUE load_path_check_cache;
27 VALUE expanded_load_path;
28 VALUE loaded_features;
29 VALUE loaded_features_snapshot;
30 VALUE loaded_features_realpaths;
31 VALUE loaded_features_realpath_map;
32 struct st_table *loaded_features_index;
33 struct st_table *loading_table;
34 VALUE ruby_dln_libmap;
36 VALUE gvar_tbl;
38 bool is_builtin;
39 bool is_user;
40 bool is_optional;
42 typedef struct rb_namespace_struct rb_namespace_t;
44 #define NAMESPACE_BUILTIN_P(ns) (ns && ns->is_builtin)
45 #define NAMESPACE_USER_P(ns) (ns && ns->is_user)
46 #define NAMESPACE_OPTIONAL_P(ns) (ns && ns->is_optional)
47 #define NAMESPACE_MAIN_P(ns) (ns && ns->is_user && !ns->is_optional)
49 #define NAMESPACE_METHOD_DEFINITION(mdef) (mdef ? mdef->ns : NULL)
50 #define NAMESPACE_METHOD_ENTRY(me) (me ? NAMESPACE_METHOD_DEFINITION(me->def) : NULL)
51 #define NAMESPACE_CC(cc) (cc ? NAMESPACE_METHOD_ENTRY(cc->cme_) : NULL)
52 #define NAMESPACE_CC_ENTRIES(ccs) (ccs ? NAMESPACE_METHOD_ENTRY(ccs->cme) : NULL)
54 RUBY_EXTERN bool ruby_namespace_enabled;
55 RUBY_EXTERN bool ruby_namespace_init_done;
57 static inline bool
58 rb_namespace_available(void)
60 return ruby_namespace_enabled;
63 void rb_namespace_enable_builtin(void);
64 void rb_namespace_disable_builtin(void);
65 void rb_namespace_push_loading_namespace(const rb_namespace_t *);
66 void rb_namespace_pop_loading_namespace(const rb_namespace_t *);
67 rb_namespace_t * rb_root_namespace(void);
68 const rb_namespace_t *rb_builtin_namespace(void);
69 rb_namespace_t * rb_main_namespace(void);
70 const rb_namespace_t * rb_definition_namespace(void);
71 const rb_namespace_t * rb_loading_namespace(void);
72 const rb_namespace_t * rb_current_namespace(void);
73 VALUE rb_current_namespace_details(VALUE);
75 void rb_namespace_entry_mark(void *);
77 rb_namespace_t * rb_get_namespace_t(VALUE ns);
78 VALUE rb_get_namespace_object(rb_namespace_t *ns);
79 typedef VALUE namespace_exec_func(VALUE arg);
80 VALUE rb_namespace_exec(const rb_namespace_t *ns, namespace_exec_func *func, VALUE arg);
82 VALUE rb_namespace_local_extension(VALUE namespace, VALUE fname, VALUE path);
84 void rb_initialize_main_namespace(void);
85 void rb_namespace_init_done(void);
86 #endif /* INTERNAL_NAMESPACE_H */