[svn:parrot] r36962 - in trunk: . examples/embed
NotFound at svn.parrot.org
NotFound at svn.parrot.org
Tue Feb 24 11:58:44 UTC 2009
Author: NotFound
Date: Tue Feb 24 11:58:44 2009
New Revision: 36962
URL: https://trac.parrot.org/parrot/changeset/36962
Log:
[examples] add embed example
Added:
trunk/examples/embed/
trunk/examples/embed/Makefile (contents, props changed)
trunk/examples/embed/lorito.c (contents, props changed)
Modified:
trunk/MANIFEST
trunk/MANIFEST.SKIP
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST Tue Feb 24 11:15:37 2009 (r36961)
+++ trunk/MANIFEST Tue Feb 24 11:58:44 2009 (r36962)
@@ -1,7 +1,7 @@
# ex: set ro:
# $Id$
#
-# generated by tools/dev/mk_manifest_and_skip.pl Sun Feb 22 10:02:18 2009 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Tue Feb 24 11:53:22 2009 UT
#
# See tools/dev/install_files.pl for documentation on the
# format of this file.
@@ -635,6 +635,8 @@
examples/c/test_main.c [examples]
examples/compilers/Makefile [examples]
examples/compilers/japhc.c [examples]
+examples/embed/Makefile [examples]
+examples/embed/lorito.c [examples]
examples/io/async_select.pir [examples]
examples/io/echo_client.pir [examples]
examples/io/http.pir [examples]
Modified: trunk/MANIFEST.SKIP
==============================================================================
--- trunk/MANIFEST.SKIP Tue Feb 24 11:15:37 2009 (r36961)
+++ trunk/MANIFEST.SKIP Tue Feb 24 11:58:44 2009 (r36962)
@@ -1,6 +1,6 @@
# ex: set ro:
# $Id$
-# generated by tools/dev/mk_manifest_and_skip.pl Wed Feb 18 20:41:36 2009 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Tue Feb 24 11:53:22 2009 UT
#
# This file should contain a transcript of the svn:ignore properties
# of the directories in the Parrot subversion repository. (Needed for
@@ -934,6 +934,8 @@
^languages/squaak/.*\.pbc/
^languages/squaak/Makefile$
^languages/squaak/Makefile/
+^languages/squaak/man$
+^languages/squaak/man/
# generated from svn:ignore of 'languages/squaak/src/'
^languages/squaak/src/gen_.*\.pir$
^languages/squaak/src/gen_.*\.pir/
Added: trunk/examples/embed/Makefile
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/examples/embed/Makefile Tue Feb 24 11:58:44 2009 (r36962)
@@ -0,0 +1,25 @@
+# Copyright (C) 2009, Parrot Foundation.
+## $Id$
+
+# To build this example in a parrot development environment:
+
+# PATH=$PATH:/parrot_directory
+# export LD_RUN_PATH=/parrot_directory/blib/lib
+# make
+
+CC = `parrot_config cc`
+CCFLAGS = `parrot_config ccflags`
+LD = `parrot_config ld`
+LDFLAGS = `parrot_config libparrot_ldflags`
+
+all: lorito
+
+#-----------------------------------------------------------------------
+
+lorito.o: lorito.c
+ $(CC) $(CCFLAGS) -c -I ~/parrot/include lorito.c
+
+lorito: lorito.o
+ $(LD) -o lorito lorito.o $(LDFLAGS)
+
+#-----------------------------------------------------------------------
Added: trunk/examples/embed/lorito.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/examples/embed/lorito.c Tue Feb 24 11:58:44 2009 (r36962)
@@ -0,0 +1,72 @@
+/*
+Copyright (C) 2009, Parrot Foundation.
+$Id$
+
+A parrot embedding test
+'lorito' is 'little parrot' in spanish
+*/
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "parrot/embed.h"
+#include "parrot/extend.h"
+
+/**********************************************************************/
+
+void fail(const char *msg);
+int lorito_main(Parrot_Interp interp, int argc, char **argv);
+
+/**********************************************************************/
+
+void fail(const char *msg)
+{
+ fprintf(stderr, "lorito failed: %s\n", msg);
+ exit(EXIT_FAILURE);
+}
+
+/**********************************************************************/
+
+int lorito_main(Parrot_Interp interp, int argc, char **argv)
+{
+ char *source;
+ Parrot_PackFile pf;
+ if (argc < 2)
+ fail("no args");
+ source = argv[1];
+
+ pf = Parrot_pbc_read(interp, source, 0);
+ if (! pf)
+ fail("Cannot load file");
+ Parrot_pbc_load(interp, pf);
+
+ Parrot_runcode(interp, argc - 1, argv + 1);
+
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ Parrot_Interp interp;
+ int r;
+
+ interp = Parrot_new(NULL);
+ if (! interp)
+ fail("Cannot create parrot interpreter");
+
+ Parrot_setwarnings(interp, PARROT_WARNINGS_ALL_FLAG);
+
+ r = lorito_main(interp, argc, argv);
+
+ Parrot_destroy(interp);
+ return r;
+}
+
+/*
+ * Local variables:
+ * c-file-style: "parrot"
+ * End:
+ * vim: expandtab shiftwidth=4:
+ */
More information about the parrot-commits
mailing list