public class Prelude extends Object
| Constructor and Description |
|---|
Prelude() |
| Modifier and Type | Method and Description |
|---|---|
static Object |
do_popen(String command,
String mode)
Fork a process and return a file handle for reading or writing from/to its
standard output/input.
|
static void |
exit(int exitCode)
Exit the the current program.
|
static void |
fflush(Object file)
Flush a file to disk.
|
static int |
fgetc(Object file)
Read one char from a file and return it or -1 on end of file or errors.
|
static void |
fileClose(Object file)
Close a file handle
|
static int |
fileEOF(Object file)
Test if a file has reached its end during
idris_readStr operations. |
static int |
fileError(Object file)
Tests for a file error.
|
static SeekableByteChannel |
fileOpen(String name,
String privs)
Open a file.
|
static int |
fpoll(Object file)
Wait for one second or until input becomes available for the given file.
|
static void |
fputStr(Object file,
String string)
Write a string to a file handle.
|
static void |
free(Object buf)
Release a memory buffer.
|
static int |
getchar()
Receive a char from
System.in |
static String |
getenv(String x)
Query the system environment for a value.
|
static String |
getEnvPair(int n)
Get the n-th "key=value" property from the environment.
|
static int |
idris_checkMessages(Object dest)
Check if a message has arrived.
|
static int |
idris_eqPtr(Object reference1,
Object reference2)
Compare two references for equality.
|
static void |
idris_forceGC(Object thread)
Force garbage collection to be triggered.
|
static String |
idris_getArg(int num)
Get the num-th commandline argument.
|
static void |
idris_initArgs(String[] args)
Initialize the command line arguments.
|
static void |
idris_memmove(Object dstBuf,
Object srcBuf,
int dstOffset,
int srcOffset,
int size)
Copy data in buffers.
|
static void |
idris_memset(Object buf,
int offset,
Object c,
int size)
Initialize a memory location.
|
static int |
idris_numArgs()
Get the number of command line arguments.
|
static byte |
idris_peek(Object buf,
int offset)
Read a byte from a buffer.
|
static void |
idris_poke(Object buf,
int offset,
Object data)
Write a byte to a buffer.
|
static String |
idris_readStr(Object file)
Read a line from a file.
|
static Object |
idris_recvMessage(Object dest)
Receive a message.
|
static void |
idris_sendMessage(Object from,
Object dest,
Object message)
Pass a message to another thread.
|
static int |
idris_time()
Get the time in seconds since 1970-01-01 00:00:00 UTC.
|
static int |
isNull(Object o)
Check if an object is
null |
static int |
isNullString(String s)
Check if a string is
null |
static Object |
malloc(int size)
Allocate raw memory.
|
static int |
pclose(Object file)
Wait for a forked process and close its file handle.
|
static void |
putchar(int c)
Output a character to
System.out |
static void |
putStr(String str)
Output a string to
System.out |
static int |
setenv(String key,
String value,
int overwrite)
Set a system environment value.
|
static int |
unsetenv(String key)
Unset a system environment value.
|
static void |
usleep(int microsecs)
Sleep for some time.
|
public static void idris_initArgs(String[] args)
args - arguments to initializepublic static int idris_numArgs()
public static String idris_getArg(int num)
num - argument positionidris_initArgspublic static String getenv(String x)
x - query keypublic static int setenv(String key, String value, int overwrite)
key - property name to setvalue - property value to setoverwrite - a value other than zero indicates, that existing values
should be overwrittenpublic static String getEnvPair(int n)
n - public static int unsetenv(String key)
key - the value to clearpublic static void exit(int exitCode)
exitCode - program resultpublic static void usleep(int microsecs)
microsecs - number of microseconds to sleeppublic static int idris_time()
public static void idris_sendMessage(Object from, Object dest, Object message) throws InterruptedException
from - source threaddest - target threadmessage - object containing the messageInterruptedException - if waiting for the message queue failedpublic static int idris_checkMessages(Object dest) throws InterruptedException
dest - thread to check messages forInterruptedException - if waiting for the message queue failedpublic static Object idris_recvMessage(Object dest) throws InterruptedException
dest - thread to receive messages forInterruptedException - if waiting for the message failedpublic static void putStr(String str)
System.outstr - message to write to stdoutpublic static void putchar(int c)
System.outc - char to write to stdoutpublic static int getchar()
System.inpublic static SeekableByteChannel fileOpen(String name, String privs)
name - filenameprivs - privileges as described in man fopen(3)public static Object do_popen(String command, String mode)
command - command to runmode - "r" for reading, "w" for writingpublic static int pclose(Object file)
file - the file handle to wait forpublic static void fileClose(Object file)
file - handle to closepublic static int fpoll(Object file)
file - the file to wait forpublic static void fputStr(Object file, String string)
file - handle to write to. Has to be a PrintStream or a SeekableByteChannel.string - outputpublic static int fgetc(Object file)
file - the file to read frompublic static String idris_readStr(Object file)
line.seperator System property as delimiter.file - handle to read frompublic static int fileEOF(Object file)
idris_readStr operations.file - handle to testpublic static int fileError(Object file)
file - the handle to checkpublic static void fflush(Object file)
file - handle to write topublic static int isNull(Object o)
nullo - object to checknull 0 otherwisepublic static int isNullString(String s)
nulls - string to checknull 0 otherwisepublic static Object malloc(int size)
size - number of bytes to allocateByteBuffer capable of storing the requested amount of bytespublic static void idris_memset(Object buf, int offset, Object c, int size)
buf - ByteBuffer to initializeoffset - bytes to skip at the beginning of the bufferc - byte value to use for initializationsize - number of bytes to initializepublic static void free(Object buf)
buf - buffer to releasepublic static byte idris_peek(Object buf, int offset)
buf - ByteBuffer to read fromoffset - address to readpublic static void idris_poke(Object buf, int offset, Object data)
buf - ByteBuffer to write tooffset - address to write atdata - byte to write outpublic static void idris_memmove(Object dstBuf, Object srcBuf, int dstOffset, int srcOffset, int size)
dstBuf - ByteBuffer to copy data tosrcBuf - ByteBuffer to copy data fromdstOffset - bytes to skip from the destination startsrcOffset - bytes to skip from the source startsize - number of bytes to movepublic static void idris_forceGC(Object thread)
thread - the thread to be forced (currently ignored, since
System.gc() is thread agnostic.Copyright © 2014. All Rights Reserved.