cvsuser 04/08/13 03:44:59
Modified: classes delegate.pmc
examples/japh japh10.pasm japh13.pasm japh4.pasm japh5.pasm
japh6.pasm japh9.pasm
Log:
#31050 and japh example fixes
delegate.pmc patch courtesy of Felix Gallo <[EMAIL PROTECTED]>
Revision Changes Path
1.28 +9 -4 parrot/classes/delegate.pmc
Index: delegate.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/delegate.pmc,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -w -r1.27 -r1.28
--- delegate.pmc 16 Jul 2004 12:15:27 -0000 1.27
+++ delegate.pmc 13 Aug 2004 10:44:55 -0000 1.28
@@ -1,6 +1,6 @@
/*
Copyright: 2003 The Perl Foundation. All Rights Reserved.
-$Id: delegate.pmc,v 1.27 2004/07/16 12:15:27 leo Exp $
+$Id: delegate.pmc,v 1.28 2004/08/13 10:44:55 leo Exp $
=head1 NAME
@@ -85,14 +85,19 @@
PMC *class = pmc;
if (PObj_is_object_TEST(pmc)) {
class = GET_CLASS((Buffer *)PMC_data(pmc), pmc);
- }
internal_exception(METH_NOT_FOUND,
- "Can't find method '%s' for object '%s'",
+ "Can't find method '%s' for object '%s'\n",
string_to_cstring(interpreter, meth),
string_to_cstring(interpreter, PMC_str_val(
get_attrib_num((SLOTTYPE *)PMC_data(class),
PCD_CLASS_NAME)))
);
+ } else {
+ internal_exception(METH_NOT_FOUND,
+ "Can't find method '%s' - erroneous PMC\n",
+ string_to_cstring(interpreter, meth)
+ );
+ }
}
return returnPMC;
}
1.3 +14 -8 parrot/examples/japh/japh10.pasm
Index: japh10.pasm
===================================================================
RCS file: /cvs/public/parrot/examples/japh/japh10.pasm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- japh10.pasm 30 Mar 2004 10:23:13 -0000 1.2
+++ japh10.pasm 13 Aug 2004 10:44:59 -0000 1.3
@@ -21,11 +21,15 @@
defined I1, P7 # check if queue entry is ...
unless I1, w1 # ... defined, yes: it's ours
set S5, P6 # get string param
- substr S0, S5, I0, 1 # extract next char
- print S0 # and print it
- inc I0 # increment char pointer
+ substr S9, S5, I10, 1 # extract next char
+ print S9 # and print it
+
+ getstdout P2 # flush output, its line-buffered
+ callmethod "flush"
+
+ inc I10 # increment char pointer
shift P8, P7 # pull item off from queue
- if S0, w1 # then wait again, if todo
+ if S9, w1 # then wait again, if todo
invoke P1 # done with string
.pcc_sub _th2: # 2nd thread function
@@ -33,11 +37,13 @@
defined I1, P7 # if queue entry is defined
if I1, w2 # then wait
set S5, P6
- substr S0, S5, I0, 1 # if not print next char
- print S0
- inc I0
+ substr S9, S5, I10, 1 # if not print next char
+ print S9
+ getstdout P2
+ callmethod "flush"
+ inc I10
new P8, .PerlInt # and put a defined entry
push P7, P8 # onto the queue so that
- if S0, w2 # the other thread will run
+ if S9, w2 # the other thread will run
invoke P1 # done with string
1.3 +6 -4 parrot/examples/japh/japh13.pasm
Index: japh13.pasm
===================================================================
RCS file: /cvs/public/parrot/examples/japh/japh13.pasm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- japh13.pasm 30 Mar 2004 10:23:13 -0000 1.2
+++ japh13.pasm 13 Aug 2004 10:44:59 -0000 1.3
@@ -13,9 +13,11 @@
.pcc_sub _th:
set S5, P6
l:
- substr S0, S5, I0, 1
- print S0
- inc I0
+ substr S9, S5, I10, 1
+ print S9
+ getstdout P2
+ callmethod "flush"
+ inc I10
sleep 0.1
- if S0, l
+ if S9, l
invoke P1
1.2 +5 -5 parrot/examples/japh/japh4.pasm
Index: japh4.pasm
===================================================================
RCS file: /cvs/public/parrot/examples/japh/japh4.pasm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -r1.1 -r1.2
--- japh4.pasm 19 Feb 2004 17:37:53 -0000 1.1
+++ japh4.pasm 13 Aug 2004 10:44:59 -0000 1.2
@@ -1,9 +1,9 @@
-# JaPH utilizing delegate
- new P0, .delegate
- typeof S0, P0
- print S0
+# JaPH utilizing a class
+ newclass P0, "Japh"
+ print P0
end
-.pcc_sub __name:
+.namespace ["Japh"]
+.pcc_sub __get_string:
set S5, "Just another Parrot Hacker\n"
invoke P1
1.2 +7 -3 parrot/examples/japh/japh5.pasm
Index: japh5.pasm
===================================================================
RCS file: /cvs/public/parrot/examples/japh/japh5.pasm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -r1.1 -r1.2
--- japh5.pasm 19 Feb 2004 17:37:53 -0000 1.1
+++ japh5.pasm 13 Aug 2004 10:44:59 -0000 1.2
@@ -1,12 +1,16 @@
-# JaPH utilizing delegate
- new P0, .delegate
+# JaPH utilizing an object
+ newclass P0, "Japh"
+ find_type I0, "Japh"
+ new P0, I0
set P0[1], "Just"
set P0[2], "another"
set P0[3], "Parrot"
set P0[0], "Hacker"
end
-.pcc_sub __set_string_keyed_int:
+.namespace ["Japh"]
+.pcc_sub __set_string_keyed:
print S5
+ set I5, P5
if I5, sp
print "\n"
invoke P1
1.2 +8 -3 parrot/examples/japh/japh6.pasm
Index: japh6.pasm
===================================================================
RCS file: /cvs/public/parrot/examples/japh/japh6.pasm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -r1.1 -r1.2
--- japh6.pasm 19 Feb 2004 17:37:53 -0000 1.1
+++ japh6.pasm 13 Aug 2004 10:44:59 -0000 1.2
@@ -1,12 +1,17 @@
-# JaPH utilizing delegate
- new P0, .delegate
+# JaPH utilizing object
+ newclass P1, "Japh"
+ find_type I1, "Japh"
+ new P0, I1
set S0, P0[I0]
print S0
inc I0
set S0, P0[I0]
print S0
end
-.pcc_sub __get_string_keyed_int:
+.namespace ["Japh"]
+.pcc_sub __get_string_keyed:
+ set I3, 0
+ set I5, P5
unless I5, x
set S5, "Parrot Hacker\n"
invoke P1
1.2 +5 -2 parrot/examples/japh/japh9.pasm
Index: japh9.pasm
===================================================================
RCS file: /cvs/public/parrot/examples/japh/japh9.pasm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -r1.1 -r1.2
--- japh9.pasm 19 Feb 2004 17:37:53 -0000 1.1
+++ japh9.pasm 13 Aug 2004 10:44:59 -0000 1.2
@@ -1,7 +1,10 @@
-# another one with delegate
- new P0, .delegate
+# another one with an object
+ newclass P0, "Japh"
+ find_type I0,"Japh"
+ new P0, I0
delete P0[S0;"another";S0;"Parrot";S0]
end
+.namespace ["Japh"]
.pcc_sub __delete_keyed:
set S0, " "
l: