Ruby  3.4.0dev (2024-11-05 revision 348a53415339076afc4a02fcd09f3ae36e9c4c61)
constant.h (348a53415339076afc4a02fcd09f3ae36e9c4c61)
1 #ifndef CONSTANT_H
2 #define CONSTANT_H
3 /**********************************************************************
4 
5  constant.h -
6 
7  $Author$
8  created at: Sun Nov 15 00:09:33 2009
9 
10  Copyright (C) 2009 Yusuke Endoh
11 
12 **********************************************************************/
13 #include "ruby/ruby.h"
14 #include "id_table.h"
15 
16 typedef enum {
17  CONST_DEPRECATED = 0x100,
18 
19  CONST_VISIBILITY_MASK = 0xff,
20  CONST_PUBLIC = 0x00,
21  CONST_PRIVATE,
22  CONST_VISIBILITY_MAX
23 } rb_const_flag_t;
24 
25 #define RB_CONST_PRIVATE_P(ce) \
26  (((ce)->flag & CONST_VISIBILITY_MASK) == CONST_PRIVATE)
27 #define RB_CONST_PUBLIC_P(ce) \
28  (((ce)->flag & CONST_VISIBILITY_MASK) == CONST_PUBLIC)
29 
30 #define RB_CONST_DEPRECATED_P(ce) \
31  ((ce)->flag & CONST_DEPRECATED)
32 
33 typedef struct rb_const_entry_struct {
34  rb_const_flag_t flag;
35  int line;
36  VALUE value; /* should be mark */
37  VALUE file; /* should be mark */
39 
40 VALUE rb_mod_private_constant(int argc, const VALUE *argv, VALUE obj);
41 VALUE rb_mod_public_constant(int argc, const VALUE *argv, VALUE obj);
42 VALUE rb_mod_deprecate_constant(int argc, const VALUE *argv, VALUE obj);
43 void rb_free_const_table(struct rb_id_table *tbl);
44 VALUE rb_const_source_location(VALUE, ID);
45 
46 int rb_autoloading_value(VALUE mod, ID id, VALUE *value, rb_const_flag_t *flag);
47 rb_const_entry_t *rb_const_lookup(VALUE klass, ID id);
48 VALUE rb_public_const_get_at(VALUE klass, ID id);
49 VALUE rb_public_const_get_from(VALUE klass, ID id);
50 int rb_public_const_defined_from(VALUE klass, ID id);
51 VALUE rb_const_source_location_at(VALUE, ID);
52 
53 #endif /* CONSTANT_H */
Definition: constant.h:33
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
Definition: value.h:52
uintptr_t VALUE
Type that represents a Ruby object.
Definition: value.h:40