1 #ifndef INTERNAL_NAMESPACE_H /*-*-C-*-vi:se ft=c:*/
2 #define INTERNAL_NAMESPACE_H
4 #include "ruby/ruby.h" /* for VALUE */
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.
20 long ns_id
; // namespace id to generate ext filenames
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
;
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 int rb_namespace_available(void);
55 void rb_namespace_enable_builtin(void);
56 void rb_namespace_disable_builtin(void);
57 void rb_namespace_push_loading_namespace(const rb_namespace_t
*);
58 void rb_namespace_pop_loading_namespace(const rb_namespace_t
*);
59 rb_namespace_t
* rb_root_namespace(void);
60 const rb_namespace_t
*rb_builtin_namespace(void);
61 rb_namespace_t
* rb_main_namespace(void);
62 const rb_namespace_t
* rb_definition_namespace(void);
63 const rb_namespace_t
* rb_loading_namespace(void);
64 const rb_namespace_t
* rb_current_namespace(void);
65 VALUE
rb_current_namespace_details(VALUE
);
67 void rb_namespace_entry_mark(void *);
69 rb_namespace_t
* rb_get_namespace_t(VALUE ns
);
70 VALUE
rb_get_namespace_object(rb_namespace_t
*ns
);
71 typedef VALUE
namespace_exec_func(VALUE arg
);
72 VALUE
rb_namespace_exec(const rb_namespace_t
*ns
, namespace_exec_func
*func
, VALUE arg
);
74 VALUE
rb_namespace_local_extension(VALUE
namespace, VALUE fname
, VALUE path
);
76 void rb_initialize_main_namespace(void);
78 #endif /* INTERNAL_NAMESPACE_H */