TEMU
4.4
The Terma Emulator
|
#include "temu-c/Support/Attributes.h"
#include "temu-c/Support/Objsys.h"
#include <stddef.h>
#include <stdint.h>
Go to the source code of this file.
Data Structures | |
struct | temu_CmdArg |
Typedefs | |
typedef int(* | temu_CommandFunc) (void *) |
typedef enum temu_CmdOptionKind | temu_CmdOptionKind |
typedef int(* | temu_ObjectCommandFunc) (temu_Object *Obj, void *I, int argc, const temu_CmdArg args[]) |
Enumerations | |
enum | temu_CmdOptionKind { teCOK_String = 0, teCOK_Path, teCOK_Object, teCOK_Int, teCOK_Double, teCOK_Prop, teCOK_Iface, teCOK_Reg, teCOK_Field, teCOK_Class } |
Functions | |
TEMU_API int | temu_parseCommandLineOptions (int argc, const char *argv[]) |
TEMU_API void | temu_printCommandLineHelp (void) |
TEMU_API int | temu_execCommandFile (const char *File) |
TEMU_API int | temu_execCommand (const char *Cmd) |
TEMU_API void * | temu_createClassCmd (temu_Class *Cls, const char *Name, const char *Doc, temu_ObjectCommandFunc F) |
TEMU_API void * | temu_classGetCmd (temu_Class *Cls, const char *Name) |
TEMU_API int | temu_classCmdAddParam (void *Cmd, const char *Name, temu_CmdOptionKind Type, int Required, const char *Doc) |
const TEMU_API temu_CmdArg * | temu_classCmdGetOption (int argc, const temu_CmdArg args[], const char *OptName) |
TEMU_API int64_t | temu_classCmdGetOptionAsInteger (int argc, const temu_CmdArg args[], const char *OptName) |
TEMU_API uint64_t | temu_classCmdGetOptionAsUnsigned (int argc, const temu_CmdArg args[], const char *OptName) |
TEMU_API int | temu_objectInvokeCmd (temu_Object *Obj, void *I, const char *Name, int Argc, temu_CmdArg Argv[]) |
TEMU_API int | temu_raiseCmdError (void *I, const char *S,...) |
TEMU_API void * | temu_createCmd (const char *Name, temu_CommandFunc F, const char *Doc, void *Data) |
TEMU_API void | temu_cmdAddOption (void *Cmd, const char *OptName, temu_CmdOptionKind Type, int Required, const char *Doc, const char *Default) |
TEMU_API void * | temu_cmdGetData (void *Ctxt) |
TEMU_API void * | temu_cmdGetInterpreter (void *Ctxt) |
TEMU_API int64_t | temu_cmdGetOptionAsInteger (void *Ctxt, const char *OptName) |
TEMU_API void * | temu_cmdGetOptionAsObject (void *Ctxt, const char *OptName) |
const TEMU_API char * | temu_cmdGetOptionAsString (void *Ctxt, const char *OptName) |
TEMU_API double | temu_cmdGetOptionAsReal (void *Ctxt, const char *OptName) |
TEMU_API size_t | temu_cmdGetPosOptSize (void *Ctxt) |
const TEMU_API char * | temu_cmdGetPosOpt (void *Ctxt, size_t Idx) |
TEMU_API int | temu_cmdOptionIsValid (void *Ctxt, const char *OptName) |
TEMU_API int | temu_cmdSetVariable (const char *Key, const char *Value) |
const TEMU_API char * | temu_cmdGetVariable (const char *Key) |
typedef enum temu_CmdOptionKind temu_CmdOptionKind |
typedef int(* temu_CommandFunc) (void *) |
User command handlers implement this interface. The pointer argument is a pointer to an opaque context. Use the functions below to access properties from the context.
typedef int(* temu_ObjectCommandFunc) (temu_Object *Obj, void *I, int argc, const temu_CmdArg args[]) |
enum temu_CmdOptionKind |
TEMU_API int temu_classCmdAddParam | ( | void * | Cmd, |
const char * | Name, | ||
temu_CmdOptionKind | Type, | ||
int | Required, | ||
const char * | Doc | ||
) |
Add parameter to command
Cmd | Command handle |
Name | Name of parameter to add |
Type | Type of the parameter |
Required | Set to 1 if the parameter must be set for the command |
Doc | Documentation string for the parameter |
const TEMU_API temu_CmdArg* temu_classCmdGetOption | ( | int | argc, |
const temu_CmdArg | args[], | ||
const char * | OptName | ||
) |
Get named command option
argc | Number of arguments |
args | Argument vector |
OptName | Name of parameter / option to get |
TEMU_API int64_t temu_classCmdGetOptionAsInteger | ( | int | argc, |
const temu_CmdArg | args[], | ||
const char * | OptName | ||
) |
Get named command option as signed integer
Can only get valid numeric parameters. The function will never fail if the type is numeric and the option is required. For optional arguments, use the generic access function temu_classCmdGetOption()
argc | Number of arguments |
args | Argument vector |
OptName | Name of parameter / option to get |
TEMU_API uint64_t temu_classCmdGetOptionAsUnsigned | ( | int | argc, |
const temu_CmdArg | args[], | ||
const char * | OptName | ||
) |
Get named command option as unsigned integer
Can only get valid numeric parameters. The function will never fail if the type is numeric and the option is required. For optional arguments, use the generic access function temu_classCmdGetOption()
argc | Number of arguments |
args | Argument vector |
OptName | Name of parameter / option to get |
TEMU_API void* temu_classGetCmd | ( | temu_Class * | Cls, |
const char * | Name | ||
) |
Get an already registered command handle from class
This function can be used to for example get commands registered in the metaclass, such as the new command. The command can then have arguments added.
Cls | Class pointer |
Name | Name of command to get |
TEMU_API void temu_cmdAddOption | ( | void * | Cmd, |
const char * | OptName, | ||
temu_CmdOptionKind | Type, | ||
int | Required, | ||
const char * | Doc, | ||
const char * | Default | ||
) |
Add named argument to command
Cmd | Pointer to the command object |
OptName | Option name |
Type | Option type |
Required | Pass 0 if the option is not required, otherwise required |
Doc | Option documentation |
Default | Default value of the option |
TEMU_API void* temu_cmdGetData | ( | void * | Ctxt | ) |
Get data pointer from command context This function shall be called in a command handler on the passed context.
Ctxt | Pointer to the context of the command |
TEMU_API void* temu_cmdGetInterpreter | ( | void * | Ctxt | ) |
Get pointer to the command interpreter This function shall be called in a command handler on the passed context.
Ctxt | Pointer to the context of the command |
TEMU_API int64_t temu_cmdGetOptionAsInteger | ( | void * | Ctxt, |
const char * | OptName | ||
) |
Get named option as integer from command context This function shall be called in a command handler on the passed context.
Ctxt | Command context |
OptName | Option name |
TEMU_API void* temu_cmdGetOptionAsObject | ( | void * | Ctxt, |
const char * | OptName | ||
) |
Get named option as object pointer from command context This function shall be called in a command handler on the passed context.
Ctxt | Command context |
OptName | Option name |
TEMU_API double temu_cmdGetOptionAsReal | ( | void * | Ctxt, |
const char * | OptName | ||
) |
Get named option as double from command context This function shall be called in a command handler on the passed context.
Ctxt | Command context |
OptName | Option name |
const TEMU_API char* temu_cmdGetOptionAsString | ( | void * | Ctxt, |
const char * | OptName | ||
) |
Get named option as string from command context This function shall be called in a command handler on the passed context.
Ctxt | Command context |
OptName | Option name |
const TEMU_API char* temu_cmdGetPosOpt | ( | void * | Ctxt, |
size_t | Idx | ||
) |
Get positional option at index This function shall be called in a command handler on the passed context.
Ctxt | Command context |
Idx | Index of the option |
TEMU_API size_t temu_cmdGetPosOptSize | ( | void * | Ctxt | ) |
Get number of positional options given This function shall be called in a command handler on the passed context.
Ctxt | Command context |
const TEMU_API char* temu_cmdGetVariable | ( | const char * | Key | ) |
Get a variable in the command line
Key | Variable name |
TEMU_API int temu_cmdOptionIsValid | ( | void * | Ctxt, |
const char * | OptName | ||
) |
Return 1 if the option is valid, 0 if invalid / not set This function shall be called in a command handler on the passed context.
Ctxt | Command context |
OptName | Option name |
TEMU_API int temu_cmdSetVariable | ( | const char * | Key, |
const char * | Value | ||
) |
Set a variable in the command line
Key | Variable name (must match [A-Za-z_][A-Za-z0-9_]*) |
Value | Value to assign to variable |
TEMU_API void* temu_createClassCmd | ( | temu_Class * | Cls, |
const char * | Name, | ||
const char * | Doc, | ||
temu_ObjectCommandFunc | F | ||
) |
Register a class command
Cls | Class pointer |
Name | Name of command |
Doc | Documentation string for command |
F | Command handler function |
TEMU_API void* temu_createCmd | ( | const char * | Name, |
temu_CommandFunc | F, | ||
const char * | Doc, | ||
void * | Data | ||
) |
Create and register global command
Name | Name of command |
F | Command function to invoke |
Doc | Documentation string |
Data | Data pointer. Some commands e.g. disassemble will increase the address between invocations. This must be saved in some data object which can be provided when the command is created. |
TEMU_API int temu_execCommand | ( | const char * | Cmd | ) |
Executes a single command
Cmd | The command to be executed |
TEMU_API int temu_execCommandFile | ( | const char * | File | ) |
Executes the commands in the file "File"
File | Path to the file with the commands to be executed |
TEMU_API int temu_objectInvokeCmd | ( | temu_Object * | Obj, |
void * | I, | ||
const char * | Name, | ||
int | Argc, | ||
temu_CmdArg | Argv[] | ||
) |
Invoke command on object
Obj | Object |
I | Interpreter context |
Name | Name of command |
Argc | Number of arguments |
Argv | Argument vector |
TEMU_API int temu_parseCommandLineOptions | ( | int | argc, |
const char * | argv[] | ||
) |
Parses command line options The TEMU command supports a number of built in command line options. A simulator embedding TEMU may want initialise these options in the same way that the TEMU CLI does. Note that not all options are supported this way as some options will only be registered by the temu CLI application itself.
In general interactive options will not work (options that can be interpreted as a command). It is possible to use temu_printCommandLineHelp() to list currently registered options from an application that embedds temu.
argc | Number of arguments |
argv | Command line arguments |
TEMU_API void temu_printCommandLineHelp | ( | void | ) |
Print command line help to temu stderr stream.
TEMU_API int temu_raiseCmdError | ( | void * | I, |
const char * | S, | ||
... | |||
) |