summaryrefslogtreecommitdiff
path: root/ipl/packs/loadfuncpp/doc/isexternal.cpp
blob: ef5d21918315d9a00fa854a92b6cf1161f5ad23c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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;
}