Author: coke
Date: Fri Mar 28 14:06:08 2008
New Revision: 26607
Modified:
trunk/runtime/parrot/library/Getopt/Obj.pir
trunk/runtime/parrot/library/Stream/Base.pir
trunk/t/library/getopt_obj.t
Log:
use of type ids (e.g. ".Integer") is [DEPRECATED]
Avoid using them in some PIR modules.
Modified: trunk/runtime/parrot/library/Getopt/Obj.pir
==============================================================================
--- trunk/runtime/parrot/library/Getopt/Obj.pir (original)
+++ trunk/runtime/parrot/library/Getopt/Obj.pir Fri Mar 28 14:06:08 2008
@@ -22,7 +22,7 @@
$P0."long"("foo")
$P0."short"("f")
$P0."optarg"(1)
- $P0."type"(.String)
+ $P0."type"('String')
# these two are identical
@@ -31,7 +31,7 @@
$P0 = getopts."add"()
$P0."long"("bar")
$P0."short"("b")
- $P0."type"(.String)
+ $P0."type"('String')
.local pmc opts
opts = getopts."get_options"(argv)
@@ -172,8 +172,9 @@
$I0 = length $S0
unless long == key goto beginstore_1
$I0 = spec."optarg"()
- $I1 = spec."type"()
- unless $I1 == .Boolean goto endif_4
+ .local string type
+ type = spec."type"()
+ unless type == 'Boolean' goto endif_4
val = 1
goto beginstore_1
endif_4:
@@ -197,10 +198,11 @@
key = name
- $I1 = spec."type"()
+ .local string type
+ type = spec."type"()
$I2 = length val
- unless $I1 == .Boolean goto else_6
+ unless type == 'Boolean' goto else_6
if $I2 == 0 goto beginstore
# ok, boolean and bundled
.local string keys
@@ -214,8 +216,9 @@
(name, spec) = self."getNameForKey"(key)
if null name goto redofor
- $I0 = spec."type"()
- unless $I0 == .Boolean goto error_2
+ .local string type
+ type = spec."type"()
+ unless type == 'Boolean' goto error_2
$P0 = new 'Boolean'
$P0 = 1
@@ -256,15 +259,16 @@
beginstore_1:
# Store the value...
- $I0 = spec."type"()
+ .local string type
+ type = spec."type"()
$S0 = typeof $I0
if_null val, undef
- if $I0 == .String goto str
- if $I0 == .Array goto array
- if $I0 == .Hash goto hash
- if $I0 == .Integer goto integer
- if $I0 == .Float goto flt
- if $I0 == .Boolean goto bool
+ if type == 'String' goto str
+ if type == 'Array' goto array
+ if type == 'Hash' goto hash
+ if type == 'Integer' goto integer
+ if type == 'Float' goto flt
+ if type == 'Boolean' goto bool
# XXX default to boolean?
# And are pmc's necessary?
goto bool
@@ -279,8 +283,9 @@
array:
$P0 = return[name]
if null $P0 goto not_set
- $I0 = typeof $P0
- unless $I0 != .ResizableStringArray goto endif_5
+ .local string type
+ type = typeof $P0
+ unless type != 'ResizableStringArray' goto endif_5
not_set:
$P0 = new 'ResizableStringArray'
endif_5:
@@ -289,8 +294,9 @@
hash:
$P0 = return[name]
if null $P0 goto not_set_hash
- $I0 = typeof $P0
- unless $I0 != .Hash goto endif_7
+ .local string type
+ type = typeof $P0
+ unless type != 'Hash' goto endif_7
not_set_hash:
$P0 = new 'Hash'
endif_7:
@@ -351,25 +357,24 @@
=item "foo|f"
-A long option of "foo" and a short option of "f" is set to C<.Boolean>.
+A long option of "foo" and a short option of "f" is set to C<Boolean>.
=item "foo"
-A long option of "foo" is set to C<.Boolean>.
+A long option of "foo" is set to C<Boolean>.
=item "f"
-A short option of "f" is set to C<.Boolean>.
+A short option of "f" is set to C<Boolean>.
=item "f=s"
-A short option of "f" is set to C<.String>. Use C<i> for C<.Integer>, C<f> for
-C<.Float>, C<@> for an C<.Array>, and C<%> for a C<.Hash>.
-
+A short option of "f" is set to C<String>. Use C<i> for C<Integer>, C<f> for
+C<Float>, C<@> for an C<Array>, and C<%> for a C<Hash>.
=item "foo:s"
-A long option of "foo" is set to C<.String>, with "optarg" set to a true value.
+A long option of "foo" is set to C<String>, with "optarg" set to a true value.
=back
@@ -387,7 +392,7 @@
else_0:
key = format
$I0 = index format, '='
- # .Boolean is the default
+ # Boolean is the default
if $I0 == -1 goto endcase
check:
key = substr format, 0, $I0
@@ -408,19 +413,19 @@
throw $P0
str:
- $P0."type"(.String)
+ $P0."type"('String')
goto endcase
array:
- $P0."type"(.Array)
+ $P0."type"('Array')
goto endcase
hash:
- $P0."type"(.Hash)
+ $P0."type"('Hash')
goto endcase
integer:
- $P0."type"(.Integer)
+ $P0."type"('Integer')
goto endcase
flt:
- $P0."type"(.Float)
+ $P0."type"('Float')
endcase:
$I0 = index key, '|'
unless $I0 == -1 goto endif_2
@@ -566,7 +571,7 @@
=item C<init()>
Set the defaults to all our attributes, more internal stuff. Sets the default
-"type" to C<.Boolean>.
+"type" to C<Boolean>.
=cut
@@ -585,8 +590,8 @@
$P0 = new 'Boolean'
$P0 = 0
setattribute self, "optarg", $P0
- $P0 = new 'Integer'
- $P0 = .Boolean
+ $P0 = new 'String'
+ $P0 = 'Boolean'
setattribute self, "type", $P0
.end
@@ -682,42 +687,40 @@
NOTE: It doesn't verify it's a corrent type.
-Use the constants:
-
=over 4
-=item C<.Boolean>
+=item C<Boolean>
A true/false value, the default.
-For a short argument, it's simply C<-f>. Groups of C<.Boolean>'s tied
+For a short argument, it's simply C<-f>. Groups of C<Boolean>'s tied
together, such as C<-foobar>, if C<-f>, C<-o>, C<-b>, C<-a>, and C<-r> are all
-C<.Boolean> values, then each will be set. If C<-f> is a C<.Boolean> but one
+C<Boolean> values, then each will be set. If C<-f> is a C<Boolean> but one
of the others is not, an exception is thrown.
For a long argument, it takes the form C<--foo>. Usage such as C<--foo=this>
or C<--foo=> are allowed, but it just sets it to true, so no difference.
-=item C<.String>
+=item C<String>
A string. This can take the form of C<--foo=bar>, C<-f bar>, or C<-fbar>.
-=item C<.Integer>
+=item C<Integer>
An integer, --foo=3.14 is stored as 3. Type conversions are done by Parrot.
-Same forms as for C<.String>.
+Same forms as for C<String>.
-=item C<.Float>
+=item C<Float>
A float. Same forms apply here as well.
-=item C<.Array>
+=item C<Array>
An array, done via multiple arguments. For something such as
C<-I./include -I./src/include> for example, C<I> will be an array of
C<./include> and C<./src/include>. If only used once, it's a one sized array.
-=item C<.Hash>
+=item C<Hash>
A hash, such as defines. For a short argument, the form is C<-Dfoo=bar>,
C<-Dfoo>, and C<--define=foo=bar>(both equal signs required).
@@ -730,7 +733,7 @@
=cut
.sub "type" :method
- .param int val :optional
+ .param string val :optional
.param int opt :opt_flag
$P0 = getattribute self, "type"
unless opt goto else_0
@@ -795,7 +798,7 @@
=item *
For an arg to a short arg, e.g. -C -d, will put -d as the value for -C so long
-as -C is not a C<.Boolean>. Should it be an error?
+as -C is not a C<Boolean>. Should it be an error?
=back
@@ -818,7 +821,7 @@
=item *
-Bundling of options will only work for C<.Boolean> options. So my little "perl
+Bundling of options will only work for C<Boolean> options. So my little "perl
pie" annoyance isn't handled, C<perl -pie "code">, although perl doesn't handle
it in a DWIM manner...
Modified: trunk/runtime/parrot/library/Stream/Base.pir
==============================================================================
--- trunk/runtime/parrot/library/Stream/Base.pir (original)
+++ trunk/runtime/parrot/library/Stream/Base.pir Fri Mar 28 14:06:08 2008
@@ -153,8 +153,8 @@
.local pmc stream
getattribute $P0, self, 'source'
- typeof $I0, $P0
- if $I0 == .Undef goto NOT
+ typeof $S0, $P0
+ if $S0 == 'Undef' goto NOT
can $I0, $P0, "connected"
unless $I0 goto SKIP
Modified: trunk/t/library/getopt_obj.t
==============================================================================
--- trunk/t/library/getopt_obj.t (original)
+++ trunk/t/library/getopt_obj.t Fri Mar 28 14:06:08 2008
@@ -40,15 +40,15 @@
$P0 = getopts."add"()
$P0."long"("foo")
- $P0."type"(.String)
+ $P0."type"('String')
$P0 = getopts."add"()
$P0."long"("bar")
- $P0."type"(.Float)
+ $P0."type"('Float')
$P0 = getopts."add"()
$P0."long"("bax")
- $P0."type"(.Integer)
+ $P0."type"('Integer')
$P0 = getopts."add"()
$P0."long"("baz")
@@ -99,11 +99,11 @@
$P0 = getopts."add"()
$P0."short"("f")
- $P0."type"(.String)
+ $P0."type"('String')
$P0 = getopts."add"()
$P0."short"("A")
- $P0."type"(.String)
+ $P0."type"('String')
$P0 = getopts."add"()
$P0."short"("c")
@@ -145,7 +145,7 @@
$P0 = getopts."add"()
$P0."short"("I")
- $P0."type"(.Array)
+ $P0."type"('Array')
$P1 = getopts."get_options"(argv)
@@ -180,7 +180,7 @@
$P0 = getopts."add"()
$P0."long"("include")
$P0."short"("I")
- $P0."type"(.Array)
+ $P0."type"('Array')
$P1 = getopts."get_options"(argv)
@@ -216,7 +216,7 @@
$P0 = getopts."add"()
$P0."long"("define")
$P0."short"("D")
- $P0."type"(.Hash)
+ $P0."type"('Hash')
$P1 = getopts."get_options"(argv)
@@ -427,17 +427,17 @@
$P0 = getopts."add"()
$P0."long"("foo")
$P0."optarg"(1)
- $P0."type"(.String)
+ $P0."type"('String')
$P0 = getopts."add"()
$P0."short"("f")
$P0."optarg"(1)
- $P0."type"(.String)
+ $P0."type"('String')
$P0 = getopts."add"()
$P0."short"("b")
$P0."optarg"(1)
- $P0."type"(.String)
+ $P0."type"('String')
$P1 = getopts."get_options"(argv)