Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

start of actual extension routines and docs

git-svn-id: https://svn.parrot.org/parrot/trunk@4282 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
commit 99b337c09a40a3f20d4e37b7def2850c10912696 1 parent 7299d30
Dan Sugalski authored
View
2  MANIFEST
@@ -174,6 +174,7 @@ docs/dev/jit_i386.dev [main]doc
docs/dev/longopt.dev [main]doc
docs/dev/rx.dev [main]doc
docs/embed.pod [main]doc
+docs/extend.pod [main]doc
docs/faq.pod [main]doc
docs/glossary.pod [main]doc
docs/intro.pod [main]doc
@@ -232,6 +233,7 @@ encodings/singlebyte.c []
encodings/utf16.c []
encodings/utf32.c []
encodings/utf8.c []
+extend.c []
events.c []
examples/assembly/99beer.pasm [main]doc
examples/assembly/Makefile [main]doc
View
4 config/gen/makefiles/root.in
@@ -167,7 +167,7 @@ INTERP_O_FILES = exceptions$(O) global_setup$(O) interpreter$(O) \
headers$(O) dod$(O) method_util$(O) exit$(O) \
misc$(O) spf_render$(O) spf_vtable$(O) datatypes$(O) fingerprint$(O) \
nci$(O) cpu_dep$(O) ${asmfun_o} tsq$(O) longopt$(O) events$(O) \
- dynext$(O) utils$(O) vtables$(O) mmd$(O)
+ dynext$(O) utils$(O) vtables$(O) mmd$(O) extend$(O)
O_FILES = $(INTERP_O_FILES) $(IO_O_FILES) $(CLASS_O_FILES) \
$(ENCODING_O_FILES) $(CHARTYPE_O_FILES) \
@@ -490,6 +490,8 @@ encoding/utf32$(O) : $(GENERAL_H_FILES)
events$(O) : $(GENERAL_H_FILES)
+extend$(O) : $(GENERAL_H_FILES) $(INC)/extend.h
+
interpreter$(O) : interpreter.c $(GENERAL_H_FILES) ${jit_h}
io/io$(O) : $(GENERAL_H_FILES) io/io_private.h
View
11 docs/extend.pod
@@ -0,0 +1,11 @@
+=head1 TITLE
+
+extend.pod - Parrot extension system
+
+=head1 SYNOPSIS
+
+This is a rough version of the extension documentation for Parrot. It
+should be cleaned up and made into a PDD before final release.
+
+=head1 DESCRIPTION
+
View
63 extend.c
@@ -0,0 +1,63 @@
+/* embed.c
+ * Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
+ * CVS Info
+ * $Id$
+ * Overview:
+ * The Parrot extension interface. These are the functions that
+ * parrot extensions (i.e. parrot subroutines written in C, or
+ * some other compiled language, rather than in parrot bytecode)
+ * may access.
+ *
+ * There is a deliberate distancing from the internals here. Don't
+ * go peeking inside -- you've as much access as bytecode does,
+ * but no more, so we can provide backwards compatibility for as
+ * long as we possibly can.
+ * Data Structure and Algorithms:
+ * See include/parrot/extend.h and docs/extend.pod.
+ * History:
+ * Initial version by Dan Sugalski
+ * Notes:
+ * References:
+ */
+
+
+#include "parrot/parrot.h"
+#include "parrot/extend.h"
+
+/*=for api extend Parrot_PMC_get_string
+ *
+ * Return an opaque string that represents the string contained in the
+ * PMC.
+ */
+
+Parrot_STRING Parrot_PMC_get_string(Parrot_INTERP interp, Parrot_PMC pmc) {
+ return VTABLE_get_string(interp, pmc);
+}
+
+/*=for api extend Parrot_PMC_get_intval
+ *
+ * Return the signed integer value of the value in the PMC
+ */
+
+Parrot_Int Parrot_PMC_get_intval(Parrot_INTERP interp, Parrot_PMC pmc) {
+ return VTABLE_get_integer(interp, pmc);
+}
+
+/*=for api extend Parrot_PMC_get_numval
+ *
+ * Return the floating-point value of the PMC
+ */
+
+Parrot_Float Parrot_PMC_get_numval(Parrot_INTERP interp, Parrot_PMC pmc) {
+ return VTABLE_get_number(interp, pmc);
+}
+
+/*
+ * Local variables:
+ * c-indentation-style: bsd
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vim: expandtab shiftwidth=4:
+ */
View
31 include/parrot/extend.h
@@ -19,23 +19,38 @@
#include "parrot/interpreter.h" /* give us the interpreter flags */
#include "parrot/warnings.h" /* give us the warnings flags */
+/* Two versions of each routine, one for when we're building the core
+ and one for when people are writing extensions. If this gets abused
+ we'll split this into two pieces and not install the core version,
+ but that would be really annoying */
+#if defined(PARROT_IN_CORE)
+
+#define Parrot_INTERP struct Parrot_Interp *
+#define Parrot_STRING STRING *
+#define Parrot_PMC PMC *
+
+#else
+
typedef void * Parrot_INTERP;
typedef void * Parrot_STRING;
typedef void * Parrot_PMC;
-typedef INTVAL Parrot_INTVAL;
-typedef NUMVAL Parrot_NUMVAL;
+
+#endif
Parrot_STRING Parrot_PMC_get_string(Parrot_INTERP, Parrot_PMC);
-Parrot_INTVAL Parrot_PMC_get_intval(Parrot_INTERP, Parrot_PMC);
-Parrot_NUMVAL Parrot_PMC_get_numval(Parrot_INTERP, Parrot_PMC);
+Parrot_Int Parrot_PMC_get_intval(Parrot_INTERP, Parrot_PMC);
+Parrot_Float Parrot_PMC_get_numval(Parrot_INTERP, Parrot_PMC);
char *Parrot_PMC_get_cstring(Parrot_INTERP, Parrot_PMC);
-char *Parrot_PMC_get_cstringn(Parrot_INTERP, Parrot_PMC, Parrot_INTVAL *);
+char *Parrot_PMC_get_cstringn(Parrot_INTERP, Parrot_PMC, Parrot_Int *);
void Parrot_PMC_set_string(Parrot_INTERP, Parrot_PMC, Parrot_STRING);
void Parrot_PMC_set_cstring(Parrot_INTERP, Parrot_PMC, char *);
-void Parrot_PMC_set_cstringn(Parrot_INTERP, Parrot_PMC, char *, Parrot_INTVAL);
-void Parrot_PMC_set_intval(Parrot_INTERP, Parrot_PMC, Parrot_INTVAL);
-void Parrot_PMC_set_numval(Parrot_INTERP, Parrot_PMC, Parrot_NUMVAL);
+void Parrot_PMC_set_cstringn(Parrot_INTERP, Parrot_PMC, char *, Parrot_Int);
+void Parrot_PMC_set_intval(Parrot_INTERP, Parrot_PMC, Parrot_Int);
+void Parrot_PMC_set_numval(Parrot_INTERP, Parrot_PMC, Parrot_Float);
+
+Parrot_PMC Parrot_PMC_new(Parrot_INTERP, Parrot_Int);
+
#endif
View
63 src/extend.c
@@ -0,0 +1,63 @@
+/* embed.c
+ * Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
+ * CVS Info
+ * $Id$
+ * Overview:
+ * The Parrot extension interface. These are the functions that
+ * parrot extensions (i.e. parrot subroutines written in C, or
+ * some other compiled language, rather than in parrot bytecode)
+ * may access.
+ *
+ * There is a deliberate distancing from the internals here. Don't
+ * go peeking inside -- you've as much access as bytecode does,
+ * but no more, so we can provide backwards compatibility for as
+ * long as we possibly can.
+ * Data Structure and Algorithms:
+ * See include/parrot/extend.h and docs/extend.pod.
+ * History:
+ * Initial version by Dan Sugalski
+ * Notes:
+ * References:
+ */
+
+
+#include "parrot/parrot.h"
+#include "parrot/extend.h"
+
+/*=for api extend Parrot_PMC_get_string
+ *
+ * Return an opaque string that represents the string contained in the
+ * PMC.
+ */
+
+Parrot_STRING Parrot_PMC_get_string(Parrot_INTERP interp, Parrot_PMC pmc) {
+ return VTABLE_get_string(interp, pmc);
+}
+
+/*=for api extend Parrot_PMC_get_intval
+ *
+ * Return the signed integer value of the value in the PMC
+ */
+
+Parrot_Int Parrot_PMC_get_intval(Parrot_INTERP interp, Parrot_PMC pmc) {
+ return VTABLE_get_integer(interp, pmc);
+}
+
+/*=for api extend Parrot_PMC_get_numval
+ *
+ * Return the floating-point value of the PMC
+ */
+
+Parrot_Float Parrot_PMC_get_numval(Parrot_INTERP interp, Parrot_PMC pmc) {
+ return VTABLE_get_number(interp, pmc);
+}
+
+/*
+ * Local variables:
+ * c-indentation-style: bsd
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vim: expandtab shiftwidth=4:
+ */
Please sign in to comment.
Something went wrong with that request. Please try again.