Skip to content

Commit

Permalink
Don't return the NULL namespace root as part of Namespace.name()
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.parrot.org/parrot/trunk@12816 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
mdiep committed May 28, 2006
1 parent 2915dc7 commit 442c8fc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
7 changes: 4 additions & 3 deletions src/pmc/namespace.pmc
Expand Up @@ -349,9 +349,6 @@ Return the name of this namespace part.

Returns the name of the namespace as an array of strings.

XXX Should the NULL String of namespace root be included?
See also t/pmc/namespace_20.pir.

$P2 = $P3.'name'()
$S0 = join '::', $P2 # '::Foo::Bar'

Expand All @@ -368,6 +365,10 @@ XXX Should the NULL String of namespace root be included?
VTABLE_unshift_string(INTERP, ar, PMC_data(ns));
ns = PMC_pmc_val(ns);
}

/* remove the NULL string of the namespace root */
VTABLE_shift_string(INTERP, ar);

return ar;
}

Expand Down
2 changes: 0 additions & 2 deletions src/sub.c
Expand Up @@ -290,8 +290,6 @@ Parrot_full_sub_name(Interp* interpreter, PMC* sub)
VTABLE_push_string(interpreter, ns_array, s->name);
}
j = const_string(interpreter, ";");
/* shift toplevel - it doesn't have a name */
(void)VTABLE_shift_string(interpreter, ns_array);

res = string_join(interpreter, j, ns_array);
Parrot_unblock_DOD(interpreter);
Expand Down
20 changes: 8 additions & 12 deletions t/pmc/namespace.t
Expand Up @@ -324,7 +324,7 @@ pir_output_is(<<'CODE', <<'OUTPUT', "get namespace in Foo::Bar::baz");
CODE
ok
baz
::parrot::Foo::Bar
parrot::Foo::Bar
OUTPUT

pir_output_is(<<'CODE', <<'OUTPUT', "segv in get_name");
Expand Down Expand Up @@ -415,11 +415,9 @@ pir_output_is(<<'CODE', <<'OUTPUT', "ns.name()");
print $S0
print "\n"
.end
# namespace root doesnt have a name
# XXX should the root namespace be included?
CODE
3
::parrot::Foo
2
parrot::Foo
OUTPUT

pir_output_is(<<'CODE', <<'OUTPUT', "get_namespace_p_p, getnamespace_p_kc");
Expand Down Expand Up @@ -452,13 +450,11 @@ pir_output_is(<<'CODE', <<'OUTPUT', "get_namespace_p_p, getnamespace_p_kc");
print $S0
print "\n"
.end
# namespace root doesnt have a name
# XXX should the root namespace be included?
CODE
3
::parrot::Foo
3
::parrot::Foo
2
parrot::Foo
2
parrot::Foo
OUTPUT

pir_output_is(<<'CODE', <<'OUTPUT', "Sub.get_namespace, get_namespace");
Expand All @@ -481,7 +477,7 @@ pir_output_is(<<'CODE', <<'OUTPUT', "Sub.get_namespace, get_namespace");
.end
CODE
ok
::parrot::Foo
parrot::Foo
Foo
OUTPUT

Expand Down

0 comments on commit 442c8fc

Please sign in to comment.