Skip to content

Commit

Permalink
Merge branch 'master' of github.com:parrot/parrot
Browse files Browse the repository at this point in the history
  • Loading branch information
Whiteknight committed Dec 11, 2010
2 parents 8a6314e + 352d610 commit d3b6bc7
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 81 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -238,6 +238,10 @@
/ext/Parrot-Embed/t/*.pbc
# generated from svn:ignore of 'ext/nqp-rx/src/stage0/'
/ext/nqp-rx/src/stage0/nqp-setting.pir
/frontend/parrot/main.o
/frontend/parrot_debugger/main.o
/frontend/pbc_dump/main.o
/frontend/pbc_merge/main.o
# generated from svn:ignore of 'include/parrot/'
/include/parrot/*.tmp
/include/parrot/config.h
Expand Down
7 changes: 4 additions & 3 deletions MANIFEST
Expand Up @@ -1319,10 +1319,11 @@ src/ops/string.ops []
src/ops/sys.ops []
src/ops/var.ops []
src/packdump.c []
src/packfile.c []
src/packfile/api.c []
src/packfile/byteorder.h []
src/packfile/object_serialization.c []
src/packfile/output.c []
src/packfile/pf_items.c []
src/packout.c []
src/pbc_disassemble.c []
src/pmc.c []
src/pmc/addrregistry.pmc []
Expand Down Expand Up @@ -1411,7 +1412,6 @@ src/pmc/threadinterpreter.pmc []
src/pmc/timer.pmc []
src/pmc/undef.pmc []
src/pmc/unmanagedstruct.pmc []
src/pmc_freeze.c []
src/pointer_array.c []
src/runcore/cores.c []
src/runcore/main.c []
Expand Down Expand Up @@ -2090,6 +2090,7 @@ tools/dev/gen_charset_tables.pl []
tools/dev/gen_class.pl []
tools/dev/gen_makefile.pl [devel]
tools/dev/gen_valgrind_suppressions.pl []
tools/dev/github_post_receive.pl []
tools/dev/headerizer.pl []
tools/dev/install_dev_files.pl []
tools/dev/install_doc_files.pl []
Expand Down
6 changes: 3 additions & 3 deletions config/gen/makefiles/docs.in
Expand Up @@ -39,9 +39,9 @@ doc-prep:
$(MKPATH) ops
$(TOUCH) doc-prep

packfile-c.pod: ../src/packfile.c
#IF(new_perldoc): $(PERLDOC_BIN) -ud packfile-c.pod ../src/packfile.c
#ELSE: $(PERLDOC_BIN) -u ../src/packfile.c > packfile-c.pod
packfile-c.pod: ../src/packfile/api.c
#IF(new_perldoc): $(PERLDOC_BIN) -ud packfile-c.pod ../src/packfile/api.c
#ELSE: $(PERLDOC_BIN) -u ../src/packfile/api.c > packfile-c.pod

clean:
$(RM_F) packfile-c.pod $(POD) doc-prep
Expand Down
22 changes: 11 additions & 11 deletions config/gen/makefiles/root.in
Expand Up @@ -495,10 +495,8 @@ INTERP_O_FILES = \
#IF(has_core_nci_thunks): src/nci/core_thunks$(O) \
#IF(has_extra_nci_thunks): src/nci/extra_thunks$(O) \
src/oo$(O) \
src/packfile$(O) \
src/packout$(O) \
src/platform$(O) \
src/pmc_freeze$(O) \
src/packfile/object_serialization$(O) \
src/pmc$(O) \
src/runcore/main$(O) \
src/runcore/cores$(O) \
Expand All @@ -513,6 +511,8 @@ INTERP_O_FILES = \
src/utils$(O) \
src/vtables$(O) \
src/warnings$(O) \
src/packfile/api$(O) \
src/packfile/output$(O) \
src/packfile/pf_items$(O) \
@TEMP_atomic_o@ \
@TEMP_gc_o@ \
Expand Down Expand Up @@ -700,10 +700,10 @@ STR_FILES = \
#IF(has_core_nci_thunks): src/nci/core_thunks.str \
#IF(has_extra_nci_thunks): src/nci/extra_thunks.str \
src/nci/signatures.str \
src/packfile.str \
src/packfile/api.str \
src/packfile/object_serialization.str \
src/packfile/pf_items.str \
src/pmc.str \
src/pmc_freeze.str \
src/oo.str \
src/runcore/cores.str \
src/runcore/main.str \
Expand Down Expand Up @@ -1295,7 +1295,7 @@ src/namespace$(O) : $(PARROT_H_HEADERS) src/namespace.str src/namespace.c \
src/pmc$(O) : include/pmc/pmc_class.h src/pmc.c \
src/pmc.str $(PARROT_H_HEADERS)

src/pmc_freeze$(O) : $(PARROT_H_HEADERS) src/pmc_freeze.str src/pmc_freeze.c
src/packfile/object_serialization$(O) : $(PARROT_H_HEADERS) src/packfile/object_serialization.str src/packfile/object_serialization.c

src/hash$(O) : $(PARROT_H_HEADERS) src/hash.c

Expand Down Expand Up @@ -1555,9 +1555,9 @@ src/multidispatch$(O) : \
include/pmc/pmc_nci.h \
include/pmc/pmc_sub.h

src/packfile$(O) : \
src/packfile.str \
src/packfile.c \
src/packfile/api$(O) : \
src/packfile/api.str \
src/packfile/api.c \
include/pmc/pmc_sub.h \
include/pmc/pmc_key.h \
include/pmc/pmc_parrotlibrary.h \
Expand All @@ -1577,14 +1577,14 @@ src/packfile$(O) : \
$(PARROT_H_HEADERS) \
$(INC_DIR)/runcore_api.h

src/packfile/output$(O) : $(PARROT_H_HEADERS) include/pmc/pmc_key.h src/packfile/output.c

src/packfile/pf_items$(O) : \
$(PARROT_H_HEADERS) \
src/packfile/byteorder.h \
src/packfile/pf_items.str \
src/packfile/pf_items.c

src/packout$(O) : $(PARROT_H_HEADERS) include/pmc/pmc_key.h src/packout.c

src/parrot$(O) : $(GENERAL_H_FILES)

src/runcore/cores$(O) : src/runcore/cores.str \
Expand Down
13 changes: 12 additions & 1 deletion src/dynpmc/os.pmc
Expand Up @@ -495,7 +495,18 @@ reads entries from a directory.
}

while ((dirent = readdir(dir)) != NULL) {
VTABLE_push_string(INTERP, array, Parrot_str_new(INTERP, dirent->d_name, 0));
/* We don't have yet a good way to know what encoding should be
* used. In the meantime, use binary when there is any non ascii
* character */
const char *const name = dirent->d_name;
STR_VTABLE *encoding;
size_t l = strlen(name);
size_t i;
for (i = 0; i < l; ++i)
if ((unsigned char)name[i] > 127)
break;
encoding = i == l ? Parrot_ascii_encoding_ptr : Parrot_binary_encoding_ptr;
VTABLE_push_string(INTERP, array, Parrot_str_new_init(INTERP, name, l, encoding, 0));
}

closedir(dir);
Expand Down
2 changes: 1 addition & 1 deletion src/packfile.c → src/packfile/api.c
Expand Up @@ -30,7 +30,7 @@ about the structure of the frozen bytecode.
#include "parrot/dynext.h"
#include "parrot/runcore_api.h"
#include "../compilers/imcc/imc.h"
#include "packfile.str"
#include "api.str"
#include "pmc/pmc_sub.h"
#include "pmc/pmc_key.h"
#include "pmc/pmc_callcontext.h"
Expand Down
2 changes: 1 addition & 1 deletion src/pmc_freeze.c → src/packfile/object_serialization.c
Expand Up @@ -23,7 +23,7 @@ individual action vtable (freeze/thaw) is then called for all todo-PMCs.

#include "parrot/parrot.h"
#include "pmc/pmc_callcontext.h"
#include "pmc_freeze.str"
#include "object_serialization.str"

/* when thawing a string longer then this size, we first do a GC run and then
* block GC - the system can't give us more headers */
Expand Down
File renamed without changes.
89 changes: 58 additions & 31 deletions src/pmc/hash.pmc
Expand Up @@ -51,6 +51,14 @@ These are the vtable functions for the Hash PMC.
/* HEADERIZER BEGIN: static */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */

PARROT_DOES_NOT_RETURN
static void cannot_autovivify_nested(PARROT_INTERP)
__attribute__nonnull__(1);

PARROT_DOES_NOT_RETURN
static void entry_type_must_be_pmc(PARROT_INTERP)
__attribute__nonnull__(1);

PARROT_CANNOT_RETURN_NULL
PARROT_WARN_UNUSED_RESULT
static PMC* get_next_hash(PARROT_INTERP,
Expand All @@ -61,6 +69,10 @@ static PMC* get_next_hash(PARROT_INTERP,
__attribute__nonnull__(3)
FUNC_MODIFIES(*hash);

#define ASSERT_ARGS_cannot_autovivify_nested __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_entry_type_must_be_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_get_next_hash __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(hash) \
Expand Down Expand Up @@ -88,8 +100,7 @@ get_next_hash(PARROT_INTERP, ARGMOD(Hash *hash), ARGIN(void *key))
HashBucket *bucket;

if (hash->entry_type != enum_type_PMC)
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Hash entry type must be PMC for multipart keys.");
entry_type_must_be_pmc(interp);

bucket = parrot_hash_get_bucket(interp, hash, key);

Expand Down Expand Up @@ -468,8 +479,7 @@ Returns the integer value for the element at C<*key>.
return hash_value_to_int(INTERP, hash, b->value);

if (hash->entry_type != enum_type_PMC)
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Hash entry type must be PMC for multipart keys.");
entry_type_must_be_pmc(INTERP);

/* Recursively call to enclosed aggregate */
return VTABLE_get_integer_keyed(INTERP, (PMC *)b->value, key);
Expand Down Expand Up @@ -502,9 +512,7 @@ Returns the integer value for the element at C<*key>.
else {
PMC * const next_hash = get_next_hash(INTERP, hash, hash_key);
if (PMC_IS_NULL(next_hash))
Parrot_ex_throw_from_c_args(INTERP, NULL,
EXCEPTION_INVALID_OPERATION,
"Cannot autovivify nested hashes");
cannot_autovivify_nested(INTERP);
VTABLE_set_integer_keyed(INTERP, next_hash, key, value);
}
}
Expand Down Expand Up @@ -593,8 +601,7 @@ Returns the floating-point value for the element at C<*key>.
return hash_value_to_number(INTERP, hash, b->value);

if (hash->entry_type != enum_type_PMC)
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Hash entry type must be PMC for multipart keys.");
entry_type_must_be_pmc(INTERP);

return VTABLE_get_number_keyed(INTERP, (PMC *)b->value, key);
}
Expand Down Expand Up @@ -658,8 +665,7 @@ Returns the string value for the element at C<*key>.
return hash_value_to_string(INTERP, hash, b->value);

if (hash->entry_type != enum_type_PMC)
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Hash entry type must be PMC for multipart keys.");
entry_type_must_be_pmc(INTERP);

/* Recursively call to enclosed aggregate */
return VTABLE_get_string_keyed(INTERP, (PMC *)b->value, key);
Expand Down Expand Up @@ -697,9 +703,7 @@ Returns the string value for the element at C<*key>.
else {
PMC * const next_hash = get_next_hash(INTERP, hash, hash_key);
if (PMC_IS_NULL(next_hash))
Parrot_ex_throw_from_c_args(INTERP, NULL,
EXCEPTION_INVALID_OPERATION,
"Cannot autovivify nested hashes");
cannot_autovivify_nested(INTERP);
VTABLE_set_string_keyed(INTERP, next_hash, key, value);
}
}
Expand Down Expand Up @@ -806,8 +810,7 @@ Returns the PMC value for the element at C<*key>.
return hash_value_to_pmc(INTERP, hash, b->value);

if (hash->entry_type != enum_type_PMC)
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Hash entry type must be PMC for multipart keys.");
entry_type_must_be_pmc(INTERP);

/* Recursively call to enclosed aggregate */
return VTABLE_get_pmc_keyed(INTERP, (PMC *)b->value, key);
Expand Down Expand Up @@ -840,9 +843,7 @@ Returns the PMC value for the element at C<*key>.
else {
PMC * const next_hash = get_next_hash(INTERP, hash, hash_key);
if (PMC_IS_NULL(next_hash))
Parrot_ex_throw_from_c_args(INTERP, NULL,
EXCEPTION_INVALID_OPERATION,
"Cannot autovivify nested hashes");
cannot_autovivify_nested(INTERP);
VTABLE_set_number_keyed(INTERP, next_hash, key, value);
}
}
Expand Down Expand Up @@ -902,9 +903,7 @@ Sets C<value> as the value for C<*key>.
else {
PMC * const next_hash = get_next_hash(INTERP, hash, hash_key);
if (PMC_IS_NULL(next_hash))
Parrot_ex_throw_from_c_args(INTERP, NULL,
EXCEPTION_INVALID_OPERATION,
"Cannot autovivify nested hashes");
cannot_autovivify_nested(INTERP);
VTABLE_set_pmc_keyed(INTERP, next_hash, key, value);
}
}
Expand Down Expand Up @@ -979,9 +978,7 @@ Returns whether a key C<*key> exists in the hash.
return 1;

if (h->entry_type != enum_type_PMC)
Parrot_ex_throw_from_c_args(INTERP, NULL,
EXCEPTION_INVALID_OPERATION,
"Hash entry type must be PMC for multipart keys.");
entry_type_must_be_pmc(INTERP);

return VTABLE_exists_keyed(INTERP, (PMC *)b->value, key);
}
Expand Down Expand Up @@ -1031,9 +1028,7 @@ Returns whether the value for C<*key> is defined.
return VTABLE_defined(INTERP, hash_value_to_pmc(INTERP, h, b->value));

if (h->entry_type != enum_type_PMC)
Parrot_ex_throw_from_c_args(INTERP, NULL,
EXCEPTION_INVALID_OPERATION,
"Hash entry type must be PMC for multipart keys.");
entry_type_must_be_pmc(INTERP);

return VTABLE_defined_keyed(INTERP, (PMC *)b->value, key);
}
Expand Down Expand Up @@ -1078,9 +1073,7 @@ Deletes the element associated with C<*key>.
}

if (h->entry_type != enum_type_PMC)
Parrot_ex_throw_from_c_args(INTERP, NULL,
EXCEPTION_INVALID_OPERATION,
"Hash entry type must be PMC for multipart keys.");
entry_type_must_be_pmc(INTERP);

VTABLE_delete_keyed(INTERP, (PMC *)b->value, key);
}
Expand Down Expand Up @@ -1221,6 +1214,40 @@ Used to unarchive the hash.

=back

=head1 Auxiliar functions

=over 4

=item C<static void entry_type_must_be_pmc(PARROT_INTERP)>

=item C<static void cannot_autovivify_nested(PARROT_INTERP)>

*/

PARROT_DOES_NOT_RETURN
static void
entry_type_must_be_pmc(PARROT_INTERP)
{
ASSERT_ARGS(entry_type_must_be_pmc)
Parrot_ex_throw_from_c_args(interp, NULL,
EXCEPTION_INVALID_OPERATION,
"Hash entry type must be PMC for multipart keys.");
}

PARROT_DOES_NOT_RETURN
static void
cannot_autovivify_nested(PARROT_INTERP)
{
ASSERT_ARGS(cannot_autovivify_nested)
Parrot_ex_throw_from_c_args(interp, NULL,
EXCEPTION_INVALID_OPERATION,
"Cannot autovivify nested hashes");
}

/*

=back

=head1 SEE ALSO

F<docs/pdds/pdd08_keys.pod>.
Expand Down
10 changes: 5 additions & 5 deletions t/pmc/string.t
Expand Up @@ -620,7 +620,7 @@ OK4: ok( $I0, 'ne_str "0(Integer), "ABC" -> true' )

is( t, 'TAACGSTAACGS', 'trans' )
is( s, 'atugcsATUGCS', "trans doesn't touch source string")

push_eh THROWN
$I0 = 1
$P0.'trans'(unicode:"abc", tr_00)
Expand Down Expand Up @@ -692,7 +692,7 @@ loop:
$S1 = substr $S0, 3, 3
$I0 = $P0.'is_integer'($S1)
ok( $I0, '... substr' )

push_eh THROWN
$I0 = 1
$P0.'is_integer'(unicode:"123")
Expand Down Expand Up @@ -929,16 +929,16 @@ check:

.sub test_unescape
.local pmc s1, s2

s1 = new['String']
s1 = '\n'
s2 = s1.'unescape'('ascii')
is( s2, "\n", "unescape('\\n') == \"\\n\"" )

s1 = '\x41\x42'
s2 = s1.'unescape'('ascii')
is( s2, 'AB', "unescape('\\x41\\x42') == 'AB'" )

s1 = '\u0043\u0044'
s2 = s1.'unescape'('ascii')
is( s2, 'CD', "unescape('\\u0043\\u0044') == 'CD'" )
Expand Down

0 comments on commit d3b6bc7

Please sign in to comment.