cvsuser 03/07/17 13:51:10
Modified: . object.ops
classes parrotclass.pmc
config/gen/platform darwin.c
Log:
Make classes actually not fail horribly.
Also add in timer support for Darwin
Revision Changes Path
1.5 +7 -3 parrot/object.ops
Index: object.ops
===================================================================
RCS file: /cvs/public/parrot/object.ops,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -w -r1.4 -r1.5
--- object.ops 16 Jul 2003 14:21:21 -0000 1.4
+++ object.ops 17 Jul 2003 20:51:03 -0000 1.5
@@ -126,7 +126,7 @@
=cut
inline op findclass(out INT, in STR) {
- if (VTABLE_get_pmc_keyed(interpreter, interpreter->class_hash,
key_new_string(interpreter, $2))) {
+ if (VTABLE_exists_keyed(interpreter, interpreter->class_hash,
key_new_string(interpreter, $2))) {
$1 = 1;
} else {
$1 = 0;
@@ -144,8 +144,12 @@
=cut
-inline op findclass(out PMC, in STR) {
+inline op getclass(out PMC, in STR) {
+ if (VTABLE_exists_keyed(interpreter, interpreter->class_hash,
key_new_string(interpreter, $2))) {
$1 = VTABLE_get_pmc_keyed(interpreter, interpreter->class_hash,
key_new_string(interpreter, $2));
+ } else {
+ internal_exception(NO_CLASS, "Class doesn't exist");
+ }
goto NEXT();
}
1.3 +7 -5 parrot/classes/parrotclass.pmc
Index: parrotclass.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/parrotclass.pmc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- parrotclass.pmc 16 Jul 2003 12:53:04 -0000 1.2
+++ parrotclass.pmc 17 Jul 2003 20:51:08 -0000 1.3
@@ -1,7 +1,7 @@
/* parrotclass.pmc
* Copyright: 2003 Yet Another Society
* CVS Info
- * $Id: parrotclass.pmc,v 1.2 2003/07/16 12:53:04 dan Exp $
+ * $Id: parrotclass.pmc,v 1.3 2003/07/17 20:51:08 dan Exp $
* Overview:
* These are the vtable functions for the ParrotClass base class
* Data Structure and Algorithms:
@@ -31,13 +31,15 @@
void init () {
/* Hang an array off the data pointer, empty of course */
- PMC_data(SELF) = pmc_new(interpreter, enum_class_Array);
+ PMC_data(SELF) = pmc_new(interpreter, enum_class_SArray);
+ /* We will have five entries in this array */
+ VTABLE_set_integer_native(interpreter, (PMC*)PMC_data(SELF), (INTVAL)5);
/* No attributes to start with */
- SELF->obj.u.int_val = 0;
+ SELF->cache.int_val = 0;
/* But we are a class, really */
PObj_is_class_SET(SELF);
- /* And, coincidentally, a buffer of PMCs. Fancy that... */
- PObj_get_FLAGS(SELF) |= PObj_is_buffer_of_PMCs_ptr_FLAG;
+ /* And, coincidentally, data points to a PMC. Fancy that... */
+ PObj_get_FLAGS(SELF) |= PObj_is_PMC_ptr_FLAG;
}
INTVAL type () {
1.9 +58 -0 parrot/config/gen/platform/darwin.c
Index: darwin.c
===================================================================
RCS file: /cvs/public/parrot/config/gen/platform/darwin.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -r1.8 -r1.9
--- darwin.c 14 Jul 2003 07:58:20 -0000 1.8
+++ darwin.c 17 Jul 2003 20:51:10 -0000 1.9
@@ -187,6 +187,64 @@
}
/*
+ * itimer stuff
+ */
+
+#ifdef HAS_SETITIMER
+
+/*
+ * Start a system timer with the passed value in milli seconds.
+ *
+ * The handle is that, what new_sys_timer_ms() returned.
+ * We could pass ITIMER_REAL in handle, but for now we ignore it
+ * as we are just having one timer.
+ */
+
+void
+start_sys_timer_ms(void *handle, int ms)
+{
+ struct itimerval its;
+ memset(&its, 0, sizeof(its));
+ if (ms) {
+ its.it_interval.tv_sec = its.it_value.tv_sec = ms/1000;
+ its.it_interval.tv_usec = its.it_value.tv_usec = 1000 *(ms%1000);
+ }
+ setitimer(ITIMER_REAL, &its, NULL);
+}
+
+/* Stop the given timer. */
+void
+stop_sys_timer_ms(void *handle)
+{
+ start_sys_timer_ms(handle, 0);
+}
+
+/*
+ * Return the programmed timer interval or 0 if none for the
+ * given timer handle.
+ */
+
+int
+get_sys_timer_ms(void *handle)
+{
+ struct itimerval ots;
+ getitimer(ITIMER_REAL, &ots);
+ return ots.it_interval.tv_sec * 1000 + ots.it_interval.tv_usec/1000;
+}
+
+/*
+ * Create a new system timer with ~ms resolution.
+ * The returned handle is passed to the other timer functions.
+ */
+void *
+new_sys_timer_ms()
+{
+ return 0;
+}
+
+#else
+#endif
+/*
* Local variables:
* c-indentation-style: bsd
* c-basic-offset: 4