diff --git a/MANIFEST b/MANIFEST index 958ccaa7a7..72b76fe62d 100644 --- a/MANIFEST +++ b/MANIFEST @@ -901,6 +901,10 @@ ext/nqp-rx/t/p6regex/rx_modifiers [test] ext/nqp-rx/t/p6regex/rx_quantifiers [test] ext/nqp-rx/t/p6regex/rx_subrules [test] ext/nqp-rx/t/p6regex/rx_syntax [test] +frontend/parrot/main.c [] +frontend/parrot_debugger/main.c [] +frontend/pbc_dump/main.c [] +frontend/pbc_merge/main.c [] include/parrot/atomic.h [main]include include/parrot/atomic/fallback.h [main]include include/parrot/atomic/gcc_pcc.h [main]include @@ -1287,7 +1291,6 @@ src/libnci_test.def [] src/library.c [] src/list.c [] src/longopt.c [] -src/main.c [] src/misc.c [] src/multidispatch.c [] src/namespace.c [] @@ -1316,14 +1319,12 @@ 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/parrot_debugger.c [] src/pbc_disassemble.c [] -src/pbc_dump.c [] -src/pbc_merge.c [] src/pmc.c [] src/pmc/addrregistry.pmc [] src/pmc/arrayiterator.pmc [] @@ -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 [] @@ -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 [] diff --git a/config/gen/makefiles/docs.in b/config/gen/makefiles/docs.in index 8c4b9aa0ff..b1eb1bdf2f 100644 --- a/config/gen/makefiles/docs.in +++ b/config/gen/makefiles/docs.in @@ -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 diff --git a/config/gen/makefiles/root.in b/config/gen/makefiles/root.in index a1a52893d1..4708027574 100644 --- a/config/gen/makefiles/root.in +++ b/config/gen/makefiles/root.in @@ -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) \ @@ -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@ \ @@ -591,7 +591,7 @@ MAKE = @make_c@ .SUFFIXES : .c .S .s .pmc .dump $(O) .str .pir .pbc .c$(O) : # suffix rule (limited support) - $(CC) $(CFLAGS) @optimize@ $(CC_WARN) -I$(@D) @cc_o_out@$@ -c $< + $(CC) $(CFLAGS) @optimize@ $(CC_WARN) -I$(@D) -Isrc/ @cc_o_out@$@ -c $< #UNLESS(win32):.s$(O) : # suffix rule (limited support) #UNLESS(win32): $(CC) $(CFLAGS) @optimize@ $(CC_WARN) -I$(@D) @cc_o_out@$@ -c $< @@ -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 \ @@ -857,11 +857,11 @@ runtime/parrot/include/config.fpmc : myconfig config_lib.pir \ runtime/parrot/include/datatypes.pasm $(MINIPARROT) $(MINIPARROT) -Iruntime/parrot/include config_lib.pir > $@ -$(PARROT) : src/main$(O) $(GEN_HEADERS) $(LIBPARROT) \ +$(PARROT) : frontend/parrot/main$(O) $(GEN_HEADERS) $(LIBPARROT) \ src/parrot_config$(O) \ $(MINIPARROT) $(LINK) @ld_out@$@ \ - src/main$(O) src/parrot_config$(O) \ + frontend/parrot/main$(O) src/parrot_config$(O) \ @rpath_blib@ $(ALL_PARROT_LIBS) $(LINKFLAGS) $(LINK_DYNAMIC) #IF(win32): if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1 @@ -885,17 +885,17 @@ $(PARROT_CONFIG) : $(DEV_TOOLS_DIR)/parrot-config.pir $(PARROT) $(PBC_TO_EXE) $(PARROT) -o parrot_config.pbc $(DEV_TOOLS_DIR)/parrot-config.pir $(PARROT) pbc_to_exe.pbc parrot_config.pbc -$(MINIPARROT) : src/main$(O) $(GEN_HEADERS) $(LIBPARROT) \ +$(MINIPARROT) : frontend/parrot/main$(O) $(GEN_HEADERS) $(LIBPARROT) \ src/null_config$(O) - $(LINK) @ld_out@$@ src/main$(O) src/null_config$(O) \ + $(LINK) @ld_out@$@ frontend/parrot/main$(O) src/null_config$(O) \ @rpath_blib@ $(ALL_PARROT_LIBS) $(LINKFLAGS) #IF(win32): if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1 -$(INSTALLABLEPARROT) : src/main$(O) $(GEN_HEADERS) $(LIBPARROT) \ +$(INSTALLABLEPARROT) : frontend/parrot/main$(O) $(GEN_HEADERS) $(LIBPARROT) \ src/install_config$(O) \ $(PARROT) $(LINK) @ld_out@$@ \ - src/main$(O) src/install_config$(O) \ + frontend/parrot/main$(O) src/install_config$(O) \ @rpath_lib@ $(ALL_PARROT_LIBS) $(LINKFLAGS) #IF(win32): if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1 @@ -1023,20 +1023,20 @@ $(INSTALLABLEPROVE) : parrot-prove.pbc $(PBC_TO_EXE) src/install_config$(O) # Parrot Debugger # -src/parrot_debugger$(O) : $(PARROT_H_HEADERS) src/parrot_debugger.c \ +frontend/parrot_debugger/main$(O) : $(PARROT_H_HEADERS) frontend/parrot_debugger/main.c \ $(INC_DIR)/embed.h \ $(INC_DIR)/runcore_api.h -$(PDB) : src/parrot_debugger$(O) src/parrot_config$(O) $(LIBPARROT) +$(PDB) : frontend/parrot_debugger/main$(O) src/parrot_config$(O) $(LIBPARROT) $(LINK) @ld_out@$@ \ - src/parrot_debugger$(O) \ + frontend/parrot_debugger/main$(O) \ src/parrot_config$(O) \ @rpath_blib@ $(ALL_PARROT_LIBS) $(LINKFLAGS) #IF(win32): if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1 -$(INSTALLABLEPDB) : src/parrot_debugger$(O) $(LIBPARROT) src/parrot_config$(O) +$(INSTALLABLEPDB) : frontend/parrot_debugger/main$(O) $(LIBPARROT) src/parrot_config$(O) $(LINK) @ld_out@$@ \ - src/parrot_debugger$(O) \ + frontend/parrot_debugger/main$(O) \ src/parrot_config$(O) \ @rpath_lib@ $(ALL_PARROT_LIBS) $(LINKFLAGS) #IF(win32): if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1 @@ -1067,24 +1067,24 @@ $(INSTALLABLEDIS) : src/pbc_disassemble$(O) \ src/packdump$(O) : $(PARROT_H_HEADERS) include/pmc/pmc_sub.h \ include/pmc/pmc_key.h src/packdump.c -$(PDUMP) : src/pbc_dump$(O) src/packdump$(O) $(LIBPARROT) +$(PDUMP) : frontend/pbc_dump/main$(O) src/packdump$(O) $(LIBPARROT) $(LINK) @ld_out@$@ \ - src/pbc_dump$(O) \ + frontend/pbc_dump/main$(O) \ src/packdump$(O) @rpath_blib@ $(ALL_PARROT_LIBS) $(LINKFLAGS) #IF(win32): if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1 -src/pbc_dump$(O) : \ +frontend/pbc_dump/main$(O) : \ $(INC_DIR)/embed.h \ $(INC_DIR)/oplib/ops.h \ $(INC_DIR)/oplib/core_ops.h \ $(PARROT_H_HEADERS) \ $(INC_DIR)/runcore_api.h \ - src/pbc_dump.c + frontend/pbc_dump/main.c -$(INSTALLABLEPDUMP) : src/pbc_dump$(O) src/packdump$(O) \ +$(INSTALLABLEPDUMP) : frontend/pbc_dump/main$(O) src/packdump$(O) \ src/install_config$(O) $(LIBPARROT) $(LINK) @ld_out@$@ \ - src/pbc_dump$(O) \ + frontend/pbc_dump/main$(O) \ src/packdump$(O) \ @rpath_lib@ $(ALL_PARROT_LIBS) $(LINKFLAGS) #IF(win32): if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1 @@ -1095,16 +1095,16 @@ $(INSTALLABLEPDUMP) : src/pbc_dump$(O) src/packdump$(O) \ # Parrot Bytecode File Merger # -$(PBC_MERGE) : src/pbc_merge$(O) $(LIBPARROT) src/parrot_config$(O) +$(PBC_MERGE) : frontend/pbc_merge/main$(O) $(LIBPARROT) src/parrot_config$(O) $(LINK) @ld_out@$@ \ - src/pbc_merge$(O) \ + frontend/pbc_merge/main$(O) \ src/parrot_config$(O) \ @rpath_blib@ $(ALL_PARROT_LIBS) $(LINK_DYNAMIC) $(LINKFLAGS) #IF(win32): if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1 -$(INSTALLABLEPBC_MERGE) : src/pbc_merge$(O) $(LIBPARROT) $(INSTALLABLECONFIG) +$(INSTALLABLEPBC_MERGE) : frontend/pbc_merge/main$(O) $(LIBPARROT) $(INSTALLABLECONFIG) $(LINK) @ld_out@$@ \ - src/pbc_merge$(O) \ + frontend/pbc_merge/main$(O) \ src/install_config$(O) \ @rpath_lib@ $(ALL_PARROT_LIBS) $(LINKFLAGS) #IF(win32): if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1 @@ -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 @@ -1537,13 +1537,13 @@ src/io/win32$(O) : $(PARROT_H_HEADERS) src/io/io_private.h \ src/gc/alloc_memory$(O) : $(PARROT_H_HEADERS) src/gc/alloc_memory.c -src/main$(O) : \ +frontend/parrot/main$(O) : \ $(INC_DIR)/imcc.h \ $(PARROT_H_HEADERS) \ $(INC_DIR)/embed.h \ $(INC_DIR)/runcore_api.h \ src/gc/gc_private.h \ - src/main.c \ + frontend/parrot/main.c \ src/gc/variable_size_pool.h src/multidispatch$(O) : \ @@ -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 \ @@ -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 \ @@ -1707,9 +1707,9 @@ src/string/encoding/ucs4$(O) : $(PARROT_H_HEADERS) \ src/string/encoding/shared.h \ src/string/unicode.h -src/pbc_merge$(O) : \ +frontend/pbc_merge/main$(O) : \ $(INC_DIR)/embed.h \ - src/pbc_merge.c \ + frontend/pbc_merge/main.c \ include/pmc/pmc_sub.h \ $(INC_DIR)/oplib/ops.h \ $(INC_DIR)/oplib/core_ops.h \ @@ -2062,12 +2062,12 @@ prog-clean : parrot-prove.pbc parrot-prove.c parrot-prove$(O) parrot-prove$(EXE) \ parrot_config$(EXE) parrot_config.c parrot_config$(O) parrot_config.pbc \ compilers/imcc/main$(O) \ - $(PDUMP) src/pbc_dump$(O) src/packdump$(O) \ - $(PDB) src/parrot_debugger$(O) \ - $(PBC_MERGE) src/pbc_merge$(O) \ + $(PDUMP) frontend/pbc_dump/main$(O) src/packdump$(O) \ + $(PDB) frontend/parrot_debugger/main$(O) \ + $(PBC_MERGE) frontend/pbc_merge/main$(O) \ $(DIS) src/pbc_disassemble$(O) $(RM_F) \ - src/main$(O) \ + frontend/parrot/main$(O) \ src/null_config$(O) \ src/parrot_config$(O) \ src/install_config$(O) \ @@ -2100,9 +2100,9 @@ archclean: dynext-clean $(INSTALLABLECONFIG) \ $(INSTALLABLENQP) \ compilers/imcc/main$(O) \ - $(PDUMP) src/pbc_dump$(O) src/packdump$(O) \ - $(PDB) src/parrot_debugger$(O) \ - $(PBC_MERGE) src/pbc_merge$(O) \ + $(PDUMP) frontend/pbc_dump/main$(O) src/packdump$(O) \ + $(PDB) frontend/parrot_debugger/main$(O) \ + $(PBC_MERGE) frontend/pbc_merge/main$(O) \ $(DIS) src/pbc_disassemble$(O) \ $(PARROT_CONFIG) parrot_config$(O) parrot_config.c \ src/parrot_config$(O) parrot_config.pbc \ @@ -2216,7 +2216,7 @@ status : patch : git diff -LINTABLE_CFILES = `echo src/main$(O) $(O_FILES) src/parrot_config$(O) | $(PERL) -pe @PQ@s/\.o/\.c/g@PQ@` +LINTABLE_CFILES = `echo frontend/parrot/main$(O) $(O_FILES) src/parrot_config$(O) | $(PERL) -pe @PQ@s/\.o/\.c/g@PQ@` lint : sunlint @@ -2728,9 +2728,9 @@ cagecritic: HEADERIZER_O_FILES = \ $(O_FILES) \ - src/main$(O) \ + frontend/parrot/main$(O) \ src/packdump$(O) \ - src/pbc_merge$(O) \ + frontend/pbc_merge/main$(O) \ headerizer : src/core_pmcs.c $(HEADERIZER) $(HEADERIZER_O_FILES) compilers/imcc/imcc.y diff --git a/src/main.c b/frontend/parrot/main.c similarity index 100% rename from src/main.c rename to frontend/parrot/main.c diff --git a/src/parrot_debugger.c b/frontend/parrot_debugger/main.c similarity index 100% rename from src/parrot_debugger.c rename to frontend/parrot_debugger/main.c diff --git a/src/pbc_dump.c b/frontend/pbc_dump/main.c similarity index 100% rename from src/pbc_dump.c rename to frontend/pbc_dump/main.c diff --git a/src/pbc_merge.c b/frontend/pbc_merge/main.c similarity index 100% rename from src/pbc_merge.c rename to frontend/pbc_merge/main.c diff --git a/src/packfile.c b/src/packfile/api.c similarity index 99% rename from src/packfile.c rename to src/packfile/api.c index eb5ce784cb..485b0e2e6e 100644 --- a/src/packfile.c +++ b/src/packfile/api.c @@ -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" diff --git a/src/pmc_freeze.c b/src/packfile/object_serialization.c similarity index 99% rename from src/pmc_freeze.c rename to src/packfile/object_serialization.c index 0383065e74..29b5b4e457 100644 --- a/src/pmc_freeze.c +++ b/src/packfile/object_serialization.c @@ -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 */ diff --git a/src/packout.c b/src/packfile/output.c similarity index 100% rename from src/packout.c rename to src/packfile/output.c diff --git a/src/pmc/hash.pmc b/src/pmc/hash.pmc index d0a7fb715c..0f314f8369 100644 --- a/src/pmc/hash.pmc +++ b/src/pmc/hash.pmc @@ -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, @@ -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) \ @@ -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); @@ -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); @@ -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); } } @@ -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); } @@ -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); @@ -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); } } @@ -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); @@ -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); } } @@ -902,9 +903,7 @@ Sets C 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); } } @@ -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); } @@ -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); } @@ -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); } @@ -1221,6 +1214,40 @@ Used to unarchive the hash. =back +=head1 Auxiliar functions + +=over 4 + +=item C + +=item C + +*/ + +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. diff --git a/t/pmc/iterator.t b/t/pmc/iterator.t index fac02b1711..1a1eb544ba 100644 --- a/t/pmc/iterator.t +++ b/t/pmc/iterator.t @@ -6,7 +6,7 @@ use warnings; use lib qw( . lib ../lib ../../lib ); use Test::More; -use Parrot::Test tests => 21; +use Parrot::Test tests => 27; =head1 NAME @@ -33,6 +33,184 @@ CODE ok 1 OUTPUT +pasm_output_is( <<'CODE', <<'OUTPUT', "new iter fails (init)" ); + push_eh THROWN + new P0, ['ResizablePMCArray'] + new P1, ['Iterator'], P0 + print "not " +THROWN: + pop_eh + print "ok 1\n" + end +CODE +ok 1 +OUTPUT + +pasm_output_is( <<'CODE', <<'OUTPUT', "keyed access on String and Hash PMCs" ); + new P0, ['String'] + set P0, "I am a very long string." + new P2, ['Integer'] + set P2, 1 + iter P1, P0 + set I0, P1[P2] + eq I0, 32, OK1 + print "not " +OK1:print "ok 1\n" + + set P2, 0 + set I0, P1[P2] + eq I0, 73, OK2 + print "not " +OK2:print "ok 2\n" + + set P2, 5 + set S0, P1[P2] + eq S0, 'a', OK3 + print "not " +OK3:print "ok 3\n" + + new P0, ['Hash'] + set P0['derp'], 3.257 + set P0['herp'], 2 + iter P1, P0 + set P2, 'herp' + set N0, P1[P2] + eq N0, 2, OK4 + print "not " +OK4:print "ok 4\n" + + set P2, 'derp' + set N0, P1[P2] + eq N0, 3.257, OK5 + print "not " +OK5:print "ok 5\n" + end +CODE +ok 1 +ok 2 +ok 3 +ok 4 +ok 5 +OUTPUT + +pasm_output_is( <<'CODE', <<'OUTPUT', "keyed exist and defined on String and Hash PMCs" ); + new P0, ['String'] + set P0, 'somelongstring' + iter P1, P0 + + new P2, ['Integer'] + set P2, 2 + exists I0, P1[P2] + eq I0, 1, OK1 + print "not " +OK1:print "ok 1\n" + + set P2, 20 + exists I0, P1[P2] + eq I0, 0, OK2 + print "not " +OK2:print "ok 2\n" + + defined I0, P1 + eq I0, 1, OK3 + print "not " +OK3:print "ok 3\n" + + + new P0, ['Hash'] + set P0['something'], 'stringg' + set P0['nothing'], 'something' + iter P1, P0 + set P2, 'something' + defined I0, P1[P2] + eq I0, 1, OK4 + print "not " +OK4:print "ok 4\n" + + set P2, 'somenothing' + defined I0, P1[P2] + eq I0, 0, OK5 + print "not " +OK5:print "ok 5\n" + end +CODE +ok 1 +ok 2 +ok 3 +ok 4 +ok 5 +OUTPUT + +pasm_output_is( <<'CODE', <<'OUTPUT', "get_iter" ); + new P0, ['ResizableIntegerArray'] + push P0, 20 + iter P1, P0 + iter P2, P1 + + issame I0, P1, P2 + eq I0, 1, OK + print "not " +OK: print "ok\n" + end +CODE +ok +OUTPUT + +pir_output_is( <<'CODE', <<'OUTPUT', "next()" ); +.sub _main + .local pmc str, str2, iterate + str = new ['String'] + str = '0hey' + iterate = iter str + + str2 = iterate.'next'() + eq str2, '0', OK1 + print "not " +OK1:print "ok 1 - next returns first character\n" + + eq str, '0hey', OK2 + print "not " +OK2:print "ok 2 - does not touch input\n" + + str2 = iterate.'next'() + eq str2, 'h', OK3 + print "not " +OK3:print "ok 3 - next returns second character\n" +.end +CODE +ok 1 - next returns first character +ok 2 - does not touch input +ok 3 - next returns second character +OUTPUT + +TODO: { +pir_output_is( <<'CODE', <<'OUTPUT', "custom subclass, set_integer_native", todo => "subclassing init VTABLE method is not properly overridden." ); + +.sub _main :main + .local pmc myiter, inst + myiter = subclass 'Iterator', 'MyIter' + #myiter = newclass 'MyIter' + inst = new ['MyIter'] + + push_eh THROWN + inst = 1 + print "not " +THROWN: + pop_eh + print "ok\n" +.end + +.namespace ["MyIter"] +.sub init :vtable + print "init\n" + .return() +.end + +CODE +ok +OUTPUT +} + pasm_output_is( <<'CODE', <<'OUTPUT', "int test" ); .include "iterator.pasm" new P0, ['ResizablePMCArray'] # empty array diff --git a/t/pmc/string.t b/t/pmc/string.t index 996831a8d0..d6cffcdd14 100644 --- a/t/pmc/string.t +++ b/t/pmc/string.t @@ -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) @@ -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") @@ -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'" ) diff --git a/tools/dev/github_post_receive.pl b/tools/dev/github_post_receive.pl index ba1526977c..4badd0aef1 100644 --- a/tools/dev/github_post_receive.pl +++ b/tools/dev/github_post_receive.pl @@ -1,4 +1,6 @@ -#!/usr/bin/env perl +#! perl +# Copyright (C) 2010, Parrot Foundation. + use strict; use warnings; @@ -18,7 +20,7 @@ =head1 DESCRIPTION a post-receive script to send commit diffs to parrot developers -=cut +=cut my $q = CGI->new; print $q->header; @@ -31,24 +33,24 @@ =head1 DESCRIPTION #tie my %short, 'Tie::Function' => sub { substr( shift(), 0, 8 ) }; my $commits = - join '', - map { - my %c = %$_; - $c{timestamp} = eval { fmt_time($c{timestamp}) } || $c{timestamp}; - my @file_changes = - map ' '.join(' ', @$_), - sort { $a->[1] cmp $b->[1] } - ( ( map ['A',$_], @{$c{added} } ), - ( map ['D',$_], @{$c{removed} } ), - ( map ['M',$_], @{$c{modified}} ), - ); - my $file_change_count = @file_changes; - $file_change_count = "$file_change_count ".($file_change_count > 1 ? 'files changed' : 'file changed'); - my $file_changes = join "\n", @file_changes; - - $c{message} = indent($c{message}); - - <[1] cmp $b->[1] } + ( ( map ['A',$_], @{$c{added} } ), + ( map ['D',$_], @{$c{removed} } ), + ( map ['M',$_], @{$c{modified}} ), + ); + my $file_change_count = @file_changes; + $file_change_count = "$file_change_count ".($file_change_count > 1 ? 'files changed' : 'file changed'); + my $file_changes = join "\n", @file_changes; + + $c{message} = indent($c{message}); + + < @@ -69,8 +71,8 @@ =head1 DESCRIPTION $commit_cnt = "$commit_cnt ".( $commit_cnt > 1 ? 'commits' : 'commit' ); my %mail = ( From => 'github-commits@bugs.sgn.cornell.edu', - Subject => "[$p->{repository}{owner}{name}/$p->{repository}{name}($head)] $commit_cnt - GitHub", - Message => < "[$p->{repository}{owner}{name}/$p->{repository}{name}($head)] $commit_cnt - GitHub", + Message => <{after} Home: $p->{repository}->{url} Browse: $p->{repository}->{url}/tree/$head @@ -79,12 +81,12 @@ =head1 DESCRIPTION $commits EOF - ); + ); my @send_list = ( 'parrot-commits@lists.parrot.org' ); foreach my $to ( @send_list ) { - sendmail( %mail, To => $to ) - or warn "error sending to $to: $Mail::Sendmail::error"; + sendmail( %mail, To => $to ) + or warn "error sending to $to: $Mail::Sendmail::error"; } #print "OK. Log says:\n", $Mail::Sendmail::log; @@ -107,3 +109,10 @@ sub fmt_time { $d->set_time_zone(DateTime::TimeZone::Local->TimeZone() ); return $d->strftime(q|%a %m/%d/%y, %I:%m %p %Z|); } + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: