September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -0,0 +1,36 @@
|
|||
//-*-c-*-
|
||||
// flf.c, Call a foreign-language function
|
||||
|
||||
// export zklRoot=/home/ZKL
|
||||
// clang -O -fPIC -I $zklRoot/VM -c -o flf.o flf.c
|
||||
// clang flf.o -L$zklRoot/Lib -lzkl -shared -Wl,-soname,flf.so -o flf.so
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "zklObject.h"
|
||||
#include "zklMethod.h"
|
||||
#include "zklString.h"
|
||||
#include "zklImports.h"
|
||||
|
||||
// strlen(str)
|
||||
static Instance *zkl_strlen(Instance *_,pArglist arglist,pVM vm)
|
||||
{
|
||||
Instance *s = arglistGetString(arglist,0,"strlen",vm);
|
||||
size_t sz = strlen(stringText(s));
|
||||
return intCreate(sz,vm);
|
||||
}
|
||||
|
||||
static int one;
|
||||
|
||||
DllExport void *construct(void *vm)
|
||||
{
|
||||
if (!vm) return (void *)ZKLX_PROTOCOL; // handshake
|
||||
// If this is reloaded, nothing happens except
|
||||
// construct() is called again so don't reinitialize
|
||||
if (!one) // static items are zero
|
||||
{
|
||||
// do some one time initialization
|
||||
one = 1;
|
||||
}
|
||||
return methodCreate(Void,0,zkl_strlen,vm);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue