Permalink
Browse files

move os.pmc from dynpmc back to static pmc

Manually cleaned up pull request 778 by bdw.

Rationale whiteknight:
It's my belief that making OS PMC a dynpmc in the
first place was a mistake.  It is the only real way to access some pretty
fundamental filesystem and other functionality from the user level.
Further, all the real logic is implemented inside libparrot already, but
without OS PMC it isn't exposed to the user at all.

dynpmcs should be used for cases when we want to add new logic to the VM,
not when we already have that logic but want to be stingy about when we
expose it.

All our major users rely on OS pmc also. Winxed, Rakudo, NQP and Rosella all
make some use of it.  It's important and necessary, and it should be in
core.
  • Loading branch information...
1 parent 1a0a31c commit 97aa16a4d827cfe4fd48b23d4556dce601fc8304 Reini Urban committed Sep 3, 2012
View
@@ -1207,7 +1207,6 @@ src/dynpmc/foo.pmc []
src/dynpmc/foo2.pmc []
src/dynpmc/gziphandle.pmc []
src/dynpmc/main.pasm []
-src/dynpmc/os.pmc []
src/dynpmc/pccmethod_test.pmc []
src/dynpmc/rational.pmc []
src/dynpmc/rotest.pmc []
@@ -1388,6 +1387,7 @@ src/pmc/opcode.pmc []
src/pmc/oplib.pmc []
src/pmc/orderedhash.pmc []
src/pmc/orderedhashiterator.pmc []
+src/pmc/os.pmc []
src/pmc/packfile.pmc []
src/pmc/packfileannotation.pmc []
src/pmc/packfileannotations.pmc []
@@ -1669,8 +1669,6 @@ t/dynpmc/foo-09.t [test]
t/dynpmc/foo-10.t [test]
t/dynpmc/foo2.t [test]
t/dynpmc/gziphandle.t [test]
-t/dynpmc/os.t [test]
-t/dynpmc/os_unicode.t [test]
t/dynpmc/pccmethod_test.t [test]
t/dynpmc/rational.t [test]
t/dynpmc/rotest.t [test]
@@ -1919,6 +1917,8 @@ t/pmc/opcode.t [test]
t/pmc/oplib.t [test]
t/pmc/orderedhash.t [test]
t/pmc/orderedhashiterator.t [test]
+t/pmc/os.t [test]
+t/pmc/os_unicode.t [test]
t/pmc/packfile.t [test]
t/pmc/packfileannotation.t [test]
t/pmc/packfileannotations.t [test]
View
@@ -91,6 +91,7 @@ include/pmc/pmc_opcode.h [devel]include
include/pmc/pmc_oplib.h [devel]include
include/pmc/pmc_orderedhash.h [devel]include
include/pmc/pmc_orderedhashiterator.h [devel]include
+include/pmc/pmc_os.h [devel]include
include/pmc/pmc_packfile.h [devel]include
include/pmc/pmc_packfileannotation.h [devel]include
include/pmc/pmc_packfileannotations.h [devel]include
@@ -202,10 +203,6 @@ runtime/parrot/dynext/obscure_ops.bundle [library]
runtime/parrot/dynext/obscure_ops.dll [library]
runtime/parrot/dynext/obscure_ops.dylib [library]
runtime/parrot/dynext/obscure_ops.so [library]
-runtime/parrot/dynext/os.bundle [library]
-runtime/parrot/dynext/os.dll [library]
-runtime/parrot/dynext/os.dylib [library]
-runtime/parrot/dynext/os.so [library]
runtime/parrot/dynext/rational.bundle [library]
runtime/parrot/dynext/rational.dll [library]
runtime/parrot/dynext/rational.dylib [library]
@@ -407,6 +404,7 @@ src/pmc/opcode.dump [devel]src
src/pmc/oplib.dump [devel]src
src/pmc/orderedhash.dump [devel]src
src/pmc/orderedhashiterator.dump [devel]src
+src/pmc/os.dump [devel]src
src/pmc/packfile.dump [devel]src
src/pmc/packfileannotation.dump [devel]src
src/pmc/packfileannotations.dump [devel]src
@@ -48,10 +48,7 @@ undefined values) is undefined, and may be rather funky.
$S0 = concat prefix, "/runtime"
push_eh L1
- # 'os' is dynop and can be absent at this point.
- # Treat it as developers mode.
- $P0 = loadlib 'os'
- $P0 = new ['OS']
+ $P0 = new 'OS'
pop_eh
push_eh file_not_found
@@ -912,7 +912,7 @@ $(PARROT) : $(FRPTWO_DIR)/main$(O) $(GEN_HEADERS) $(LIBPARROT) \
$(DEV_TOOLS_DIR)/pbc_to_exe.pir: $(DEV_TOOLS_DIR)/pbc_to_exe.winxed $(PARROT) $(WINXED_LANG) winxed.pbc
$(PARROT) winxed.pbc -c --noan $(DEV_TOOLS_DIR)/pbc_to_exe.winxed
-$(PBC_TO_EXE) : $(DEV_TOOLS_DIR)/pbc_to_exe.pir $(LIBRARY_DIR)/config.pir $(PARROT) $(DYNEXT_DIR)/os$(LOAD_EXT) $(DYNEXT_DIR)/file$(LOAD_EXT)
+$(PBC_TO_EXE) : $(DEV_TOOLS_DIR)/pbc_to_exe.pir $(LIBRARY_DIR)/config.pir $(PARROT) $(DYNEXT_DIR)/file$(LOAD_EXT)
$(PARROT) -o pbc_to_exe.pbc $(DEV_TOOLS_DIR)/pbc_to_exe.pir
$(PARROT) pbc_to_exe.pbc pbc_to_exe.pbc
@@ -23,7 +23,6 @@ Leopold Toetsch - <lt@toetsch.at>
=cut
-.loadlib 'os' # OS object
.sub _main :main
.param pmc args
View
@@ -38,7 +38,6 @@ You should check where the file is going to be before you run this.
print $S0
# now clean up after ourselves.
- $P0 = loadlib 'os'
$P1 = new "OS"
$P1."rm"(test_fn)
@@ -15,20 +15,19 @@ This example demonstrates basic file operations.
.sub main :main
.local pmc fileout, filein
- fileout = new ['FileHandle']
+ fileout = new 'FileHandle'
fileout.'open'('40_file_ops_data.txt', 'w')
fileout.'print'("The quick brown fox jumps over the lazy dog.\n")
fileout.'close'()
- filein = new ['FileHandle']
+ filein = new 'FileHandle'
filein.'open'('40_file_ops_data.txt', 'r')
$S0 = filein.'readline'()
say $S0
filein.'close'()
# Be nice and remove the temporary file we created.
- $P0 = loadlib 'os'
- $P1 = new ['OS']
+ $P1 = new 'OS'
$P1.'rm'('40_file_ops_data.txt')
.end
@@ -33,7 +33,6 @@ utilities. Think of it as a watered down version of GNU coreutils for Parrot.
.loadlib 'math_ops'
.sub '' :init :load :anon
- $P0 = loadlib 'os'
.end
=item B<system(string cmd, int :verbose(), int :ignore_error())>
@@ -130,8 +130,7 @@ Returns the location of a dynamic extension.
.local pmc os
.local string name
- $P0 = loadlib 'os'
- os = new ['OS']
+ os = new 'OS'
name = request
push_eh FILE_NOT_FOUND_1
@@ -200,8 +199,7 @@ END:
path = $P0
$S0 = concat path, name
- $P0 = loadlib 'os'
- $P0 = new ['OS']
+ $P0 = new 'OS'
push_eh FILE_NOT_FOUND
# OS.stat throws on file not found
$P0.'stat'($S0)
View
@@ -7,7 +7,6 @@ DYNPMC_TARGETS = \
$(DYNEXT_DIR)/dynlexpad$(LOAD_EXT) \
$(DYNEXT_DIR)/file$(LOAD_EXT) \
$(DYNEXT_DIR)/foo_group$(LOAD_EXT) \
- $(DYNEXT_DIR)/os$(LOAD_EXT) \
$(DYNEXT_DIR)/pccmethod_test$(LOAD_EXT) \
$(DYNEXT_DIR)/rotest$(LOAD_EXT) \
$(DYNEXT_DIR)/rational$(LOAD_EXT) \
View
@@ -1,4 +1,4 @@
-# Copyright (C) 2010, Parrot Foundation.
+# Copyright (C) 2010-2012, Parrot Foundation.
$(DYNEXT_DIR)/dynlexpad$(LOAD_EXT): src/dynpmc/dynlexpad$(O)
$(LD) @ld_out@$(DYNEXT_DIR)/dynlexpad$(LOAD_EXT) \
@@ -120,29 +120,6 @@ src/dynpmc/gziphandle.dump: src/dynpmc/gziphandle.pmc vtable.dump $(CLASS_O_FILE
-$(DYNEXT_DIR)/os$(LOAD_EXT): src/dynpmc/os$(O)
- $(LD) @ld_out@$(DYNEXT_DIR)/os$(LOAD_EXT) \
-#IF(cygwin and optimize): -s \
- src/dynpmc/os$(O) $(LINKARGS)
-#IF(win32): if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;2
-#IF(cygwin or hpux): $(CHMOD) 0775 $@
-
-src/dynpmc/pmc_os.h : src/dynpmc/os.c
-
-src/dynpmc/os$(O): \
- src/dynpmc/os.c \
- $(DYNPMC_H_FILES) \
- src/dynpmc/pmc_os.h \
- include/pmc/pmc_fixedintegerarray.h
-
-src/dynpmc/os.c: src/dynpmc/os.dump
- $(PMC2CC) src/dynpmc/os.pmc
-
-src/dynpmc/os.dump: src/dynpmc/os.pmc vtable.dump $(CLASS_O_FILES)
- $(PMC2CD) src/dynpmc/os.pmc
-
-
-
$(DYNEXT_DIR)/pccmethod_test$(LOAD_EXT): src/dynpmc/pccmethod_test$(O)
$(LD) @ld_out@$(DYNEXT_DIR)/pccmethod_test$(LOAD_EXT) \
#IF(cygwin and optimize): -s \
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2001-2011, Parrot Foundation.
+Copyright (C) 2001-2012, Parrot Foundation.
=head1 NAME
@@ -14,17 +14,14 @@ files and directories.
From PIR code:
- loadlib "os"
$P0 = new 'OS'
From NQP:
- pir::loadlib__s("os");
my $os := pir::new__ps("OS");
From Winxed:
- loadlib("os");
var os = new 'OS';
=head2 Methods
@@ -88,7 +85,7 @@ stat_buf_to_array(PARROT_INTERP, ARGIN(const Parrot_Stat_Buf *buf))
return array;
}
-pmclass OS dynpmc {
+pmclass OS pmc {
/*
@@ -32,7 +32,6 @@
.param string dir
.local pmc files, filtered_files, os, it
- $P0 = loadlib 'os'
os = new ['OS']
files = os.'readdir'(dir)
filtered_files = new ['ResizablePMCArray']
View
@@ -561,10 +561,8 @@ CODE
.end
.sub stdout_tests
- .local pmc oslib
.local pmc os
- oslib = loadlib 'os'
- os = new ['OS']
+ os = new 'OS'
$P0 = getstdout
$P1 = open 'test_file', 'w'
setstdout $P1
View
@@ -229,7 +229,6 @@ pir_output_is( <<"CODE", <<"OUT", "Test copy for files" );
\$S2 = '$otpxcopy'
\$P0 = loadlib 'file'
- \$P0 = loadlib 'os'
\$P1 = new ['File']
\$P2 = new ['OS']
@@ -264,7 +263,6 @@ SKIP: {
\$S2 = '$otpxcopy'
\$P0 = loadlib 'file'
- \$P0 = loadlib 'os'
\$P1 = new ['File']
\$P2 = new ['OS']
View
@@ -106,7 +106,6 @@ Tests the C<GzipHandle> PMC, a zlib wrapper.
# Clean up after ourselves
file.'close'()
- $P0 = loadlib 'os'
$P0 = new 'OS'
$P0.'rm'(filename)
.end
View
@@ -1,5 +1,5 @@
#!./parrot
-# Copyright (C) 2007-2010, Parrot Foundation.
+# Copyright (C) 2007-2012, Parrot Foundation.
=head1 NAME
@@ -54,16 +54,9 @@ END
.sub try_delete_library
.local pmc os
- $P0 = loadlib 'os'
- unless $P0 goto no_os
os = new 'OS'
os.'rm'(library_file)
.return ()
-
- no_os:
- $S1 = concat "WARNING: could not delete test file `", library_file
- $S1 = concat $S1, "' because the OS PMC is unavailable"
- diag($S1)
.end
.sub loading_methods_from_file
Oops, something went wrong.

0 comments on commit 97aa16a

Please sign in to comment.