cvsuser 04/11/29 08:18:54
Modified: dynclasses pybuiltin.pmc
t/dynclass pybuiltin.t
Log:
Boolean constants
Revision Changes Path
1.5 +14 -1 parrot/dynclasses/pybuiltin.pmc
Index: pybuiltin.pmc
===================================================================
RCS file: /cvs/public/parrot/dynclasses/pybuiltin.pmc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- pybuiltin.pmc 29 Nov 2004 04:47:01 -0000 1.4
+++ pybuiltin.pmc 29 Nov 2004 16:18:51 -0000 1.5
@@ -1,6 +1,6 @@
/*
Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-$Id: pybuiltin.pmc,v 1.4 2004/11/29 04:47:01 rubys Exp $
+$Id: pybuiltin.pmc,v 1.5 2004/11/29 16:18:51 rubys Exp $
=head1 NAME
@@ -22,6 +22,7 @@
/* cache of classes referenced */
static INTVAL dynclass_PyObject;
+static INTVAL dynclass_PyBoolean;
static INTVAL dynclass_PyInt;
static INTVAL dynclass_PyFloat;
static INTVAL dynclass_PyList;
@@ -47,6 +48,7 @@
void class_init() {
if (pass) {
dynclass_PyObject = Parrot_PMC_typenum(INTERP, "PyObject");
+ dynclass_PyBoolean = Parrot_PMC_typenum(INTERP, "PyBoolean");
dynclass_PyInt = Parrot_PMC_typenum(INTERP, "PyInt");
dynclass_PyFloat = Parrot_PMC_typenum(INTERP, "PyFloat");
dynclass_PyList = Parrot_PMC_typenum(INTERP, "PyList");
@@ -104,6 +106,17 @@
scratchpad_store_by_name(INTERP, pad, 0, key, item);
}
+ /* Boolean constants */
+ key = const_string(INTERP, "False");
+ item = pmc_new(INTERP, dynclass_PyBoolean);
+ VTABLE_set_integer_native(INTERP, item, 0);
+ scratchpad_store_by_name(INTERP, pad, 0, key, item);
+
+ key = const_string(INTERP, "True");
+ item = pmc_new(INTERP, dynclass_PyBoolean);
+ VTABLE_set_integer_native(INTERP, item, 1);
+ scratchpad_store_by_name(INTERP, pad, 0, key, item);
+
/* Begin main! */
item = pmc_new(INTERP, dynclass_PyString);
VTABLE_set_string_native(INTERP, item,
1.3 +22 -2 parrot/t/dynclass/pybuiltin.t
Index: pybuiltin.t
===================================================================
RCS file: /cvs/public/parrot/t/dynclass/pybuiltin.t,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- pybuiltin.t 23 Nov 2004 19:34:26 -0000 1.2
+++ pybuiltin.t 29 Nov 2004 16:18:53 -0000 1.3
@@ -1,6 +1,6 @@
#! perl -w
# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-# $Id: pybuiltin.t,v 1.2 2004/11/23 19:34:26 rubys Exp $
+# $Id: pybuiltin.t,v 1.3 2004/11/29 16:18:53 rubys Exp $
=head1 NAME
@@ -16,7 +16,7 @@
=cut
-use Parrot::Test tests => 2;
+use Parrot::Test tests => 3;
output_is(<< 'CODE', << 'OUTPUT', "delegating");
##PIR##
@@ -126,3 +126,23 @@
[0, 1, 2]
[0, 1]
OUTPUT
+
+output_is(<< 'CODE', << 'OUTPUT', "boolean");
+##PIR##
+.sub main @MAIN
+ new_pad 0
+ loadlib $P0, "python_group"
+ find_global P0, "PyBuiltin", "__load__"
+ invoke
+
+ find_lex $P1, "False"
+ find_lex $P2, "True"
+
+ print $P1
+ print " "
+ print $P2
+ print "\n"
+.end
+CODE
+False True
+OUTPUT