summaryrefslogtreecommitdiff
path: root/ipl/packs/loadfuncpp/doc/isexternal.cpp
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2013-01-28 19:02:21 +0000
committerIgor Pashev <pashev.igor@gmail.com>2013-01-28 19:02:21 +0000
commitd78e6c19ff93964183950f846868ade625e6b537 (patch)
treef2d588a9646c8496db23d3fe868d7dce4f7dfa83 /ipl/packs/loadfuncpp/doc/isexternal.cpp
parentf944578414d5adc0c6c3fb22ad5808077444a410 (diff)
parentf627f77f23d1497c9e1f4269b5c8812d12b42f18 (diff)
downloadicon-d78e6c19ff93964183950f846868ade625e6b537.tar.gz
Merge tag 'upstream/9.5.0'
Upstream version 9.5.0
Diffstat (limited to 'ipl/packs/loadfuncpp/doc/isexternal.cpp')
-rw-r--r--ipl/packs/loadfuncpp/doc/isexternal.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/ipl/packs/loadfuncpp/doc/isexternal.cpp b/ipl/packs/loadfuncpp/doc/isexternal.cpp
new file mode 100644
index 0000000..ef5d219
--- /dev/null
+++ b/ipl/packs/loadfuncpp/doc/isexternal.cpp
@@ -0,0 +1,31 @@
+
+
+/* Example of a C++ extension to icon via loadfunc,
+ * without garbage collection difficulties.
+ * Type 'make iexample' to build.
+ * Carl Sturtivant, 2008/3/16
+ */
+
+
+#include "loadfuncpp.h"
+using namespace Icon;
+
+class myval: public external {
+ public:
+ virtual value name() { return "my external"; }
+};
+
+extern "C" int myext(value argv[]) {
+ argv[0] = new myval();
+ return SUCCEEDED;
+}
+
+extern "C" int ismine(value argv[]) {
+ if( argv[1].isExternal("my external") )
+ argv[0] = "Yes!";
+ else
+ argv[0] = "No!";
+ return SUCCEEDED;
+}
+
+