| Age | Commit message (Collapse) | Author |
|
|
|
|
|
There are many APIs that expects application codes overwrite global methods.
For example, warn() expects Warning.warn() is overwritten to hook warning
messages.
If we enable namespace, Warning.warn defined in the app code is visible
only in the namespace, and invisible from warn() defined in the root namespace.
So we have to enable users to overwrite Warning.warn in the root namespace.
This is ugly and temporal workaround. We need to define better APIs to enable
users to hook such behaviors in the different way from defining global methods.
|
|
|
|
|
|
|
|
The two types of TypedData objects should be treated the same except for
the free function. Since Namespace::Root did not inherit from Namespace::Entry,
all the TypedData_Get_Struct calls for Namespace::Root would raise
"wrong argument type Namespace::Root (expected Namespace::Entry)".
|
|
|
|
|
|
|
|
|
|
|
|
It just shows "main" just like the main object without namespace.
All main objects in namespaces will show "main" and it is impossible
to determine a main from main objects if it returns "main".
But it's not a problem because we don't define anything on main
objects usually.
|
|
|
|
|
|
To avoid crashes during displaying crash reports.
|
|
|
|
* For having the common set of loaded libraries between root and main namespaces
* To have the consistent $LOADED_FEATURES in the main namespace
|
|
|
|
These methods are debug methods and no RDoc is provided.
Mark these methods as "nodoc" to fix "Miscellaneous checks"
CI job.
Failed CI job: https://github.com/ruby/ruby/actions/runs/18081591948/job/51445635741
|
|
|
|
|
|
|
|
|
|
|
|
With this change, the argument code of Namespace#eval cannot refer local
variables around the calling line, but it should not be able to refer
these values. The code is evaluated in the receiver namespace, independently
from the local context.
|
|
* The current namespace should be based on the Ruby-level location (file, line no in .rb)
and we can get it by LEP(ep) basically (VM_ENV_FLAG_LOCAL flag is set)
* But the control frame with VM_FRAME_MAGIC_CFUNC is also a LOCAL frame because
it's a visible Ruby-level frame without block handlers
* So, for the namespace detection, LEP(ep) is not enough and we need to skip CFUNC
frames to fetch the caller of such frames
|
|
|
|
|
|
|
|
See 8b5ac5abf258270b32ef63a6acb4eb0d191f79d9
|
|
Calling rb_current_namespace() in rb_namespace_current() means to show
the definition namespace of Namespace.current itself (it's the root always)
but the users' expectation is to show the namespace of the place where
the Namespace.current is called.
|
|
to fix inconsistent and wrong current namespace detections.
This includes:
* Moving load_path and related things from rb_vm_t to rb_namespace_t to simplify
accessing those values via namespace (instead of accessing either vm or ns)
* Initializing root_namespace earlier and consolidate builtin_namespace into root_namespace
* Adding VM_FRAME_FLAG_NS_REQUIRE for checkpoints to detect a namespace to load/require files
* Removing implicit refinements in the root namespace which was used to determine
the namespace to be loaded (replaced by VM_FRAME_FLAG_NS_REQUIRE)
* Removing namespaces from rb_proc_t because its namespace can be identified by lexical context
* Starting to use ep[VM_ENV_DATA_INDEX_SPECVAL] to store the current namespace when
the frame type is MAGIC_TOP or MAGIC_CLASS (block handlers don't exist in this case)
|
|
|
|
On OpenBSD:
```
ld: warning: namespace.c:731(namespace.o:(rb_namespace_local_extension)): warning: strcpy() is almost always misused, please use strlcpy()
```
|
|
|
|
|
|
This commit adds an `eval` method to `Namespace` that takes a string and
evaluates the string as Ruby code within the context of that namespace.
For example:
```ruby
n = Namespace.new
n.eval("class TestClass; def hello; 'from namespace'; end; end")
instance = n::TestClass.new
instance.hello # => "from namespace"
```
[Feature #21365]
|
|
|
|
Rather than to lazily check the env using a trinary
value, we can more straightforwardly check for the
env during the VM boot.
This allow `rb_namespace_available` to just be a pointer
dereference.
|
|
Now that classes fields are delegated to an object with its own
shape_id, we no longer need to mark all classes as TOO_COMPLEX.
Notes:
Merged: https://github.com/ruby/ruby/pull/13595
|
|
The implementation of Namespace#current_details shows warning about
use of snprintf directive arguments (only in gcc environments?).
This method will be useless when the current namespace management
will be updated.
Notes:
Merged: https://github.com/ruby/ruby/pull/13554
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13439
|
|
|
|
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13307
|
|
../namespace.c: In function ‘current_namespace’:
../namespace.c:221:48: warning: ‘proc_ns’ may be used uninitialized [-Wmaybe-uninitialized]
221 | if (permit_calling_builtin || (proc_ns && NAMESPACE_USER_P(proc_ns)))
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../namespace.c:204:31: note: ‘proc_ns’ was declared here
204 | const rb_namespace_t *proc_ns;
| ^~~~~~~
In function ‘copy_ext_file’,
inlined from ‘rb_namespace_local_extension’ at ../namespace.c:855:18:
../namespace.c:768:21: warning: ‘written’ may be used uninitialized [-Wmaybe-uninitialized]
768 | wrote = fwrite(buffer+written, 1, read-written, dst);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../namespace.c: In function ‘rb_namespace_local_extension’:
../namespace.c:748:25: note: ‘written’ was declared here
748 | size_t read, wrote, written;
| ^~~~~~~
In function ‘copy_ext_file’,
inlined from ‘rb_namespace_local_extension’ at ../namespace.c:855:18:
../namespace.c:768:21: warning: ‘read’ may be used uninitialized [-Wmaybe-uninitialized]
768 | wrote = fwrite(buffer+written, 1, read-written, dst);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../namespace.c: In function ‘rb_namespace_local_extension’:
../namespace.c:748:12: note: ‘read’ was declared here
748 | size_t read, wrote, written;
| ^~~~
|
|
|
|
this object.
https://github.com/tagomoris/ruby/pull/7
RUBY_TYPED_FREE_IMMEDIATELY can be added because namespace_entry_free does no IO nor
things to block.
|
|
```
/opt/rubies/head-namespaces/bin/ruby(sigsegv+0x84) [0x104e897e8]
/usr/lib/system/libsystem_platform.dylib(_sigtramp+0x38) [0x18de56de4]
/opt/rubies/head-namespaces/bin/ruby(object_id+0x80) [0x104d7d420]
/opt/rubies/head-namespaces/bin/ruby(object_id+0x80) [0x104d7d420]
/opt/rubies/head-namespaces/bin/ruby(rb_initialize_main_namespace+0xe4) [0x104ddaa20]
/opt/rubies/head-namespaces/bin/ruby(ruby_opt_init+0x120) [0x104e7f524]
/opt/rubies/head-namespaces/bin/ruby(ruby_process_options+0x1370) [0x104e7e31c]
/opt/rubies/head-namespaces/bin/ruby(ruby_options+0xb0) [0x104d69844]
/opt/rubies/head-namespaces/bin/ruby(main+0x64) [0x104ca8d54]
```
I'm not too sure why `rb_obj_id` crashes, but I suspect it's called too
early. Either way I don't think generating an object_id for namespaces
is a good idea. If all we need is a unique number we can do that
for much cheaper.
|