My Project
Loading...
Searching...
No Matches
LibThread::Command Class Reference

Public Member Functions

 Command (const char *n, leftv r, leftv a)
 
 ~Command ()
 
void check_argc (int n)
 
void check_argc (int lo, int hi)
 
void check_argc_min (int n)
 
void check_arg (int i, int type, const char *err)
 
void check_init (int i, const char *err)
 
void check_arg (int i, int type, int type2, const char *err)
 
int argtype (int i)
 
int nargs ()
 
void * arg (int i)
 
template<typename T>
Tshared_arg (int i)
 
long int_arg (int i)
 
void report (const char *err)
 
int test_arg (int i, int type)
 
void set_result (long n)
 
void set_result (const char *s)
 
void set_result (int type, void *p)
 
void set_result (int type, long n)
 
void no_result ()
 
bool ok ()
 
BOOLEAN status ()
 
BOOLEAN abort (const char *err)
 

Private Attributes

const char * name
 
const char * error
 
leftv result
 
leftvargs
 
int argc
 

Detailed Description

Definition at line 36 of file shared.cc.

Constructor & Destructor Documentation

◆ Command()

LibThread::Command::Command ( const char * n,
leftv r,
leftv a )
inline

Definition at line 44 of file shared.cc.

45 {
46 name = n;
47 result = r;
48 error = NULL;
49 argc = 0;
50 for (leftv t = a; t != NULL; t = t->next) {
51 argc++;
52 }
53 args = (leftv *) omAlloc0(sizeof(leftv) * argc);
54 int i = 0;
55 for (leftv t = a; t != NULL; t = t->next) {
56 args[i++] = t;
57 }
58 result->rtyp = NONE;
59 result->data = NULL;
60 }
int i
Definition cfEzgcd.cc:132
const char * error
Definition shared.cc:39
const char * name
Definition shared.cc:38
leftv next
Definition subexpr.h:86
#define omAlloc0(size)
#define NULL
Definition omList.c:12
sleftv * leftv
Definition structs.h:53
#define NONE
Definition tok.h:223

◆ ~Command()

LibThread::Command::~Command ( )
inline

Definition at line 61 of file shared.cc.

61 {
62 omFree(args);
63 }
#define omFree(addr)

Member Function Documentation

◆ abort()

BOOLEAN LibThread::Command::abort ( const char * err)
inline

Definition at line 143 of file shared.cc.

143 {
144 report(err);
145 return status();
146 }
void report(const char *err)
Definition shared.cc:106
BOOLEAN status()
Definition shared.cc:137

◆ arg()

void * LibThread::Command::arg ( int i)
inline

Definition at line 96 of file shared.cc.

96 {
97 return args[i]->Data();
98 }

◆ argtype()

int LibThread::Command::argtype ( int i)
inline

Definition at line 90 of file shared.cc.

90 {
91 return args[i]->Typ();
92 }

◆ check_arg() [1/2]

void LibThread::Command::check_arg ( int i,
int type,
const char * err )
inline

Definition at line 76 of file shared.cc.

76 {
77 if (error) return;
78 if (args[i]->Typ() != type) error = err;
79 }

◆ check_arg() [2/2]

void LibThread::Command::check_arg ( int i,
int type,
int type2,
const char * err )
inline

Definition at line 86 of file shared.cc.

86 {
87 if (error) return;
88 if (args[i]->Typ() != type && args[i]->Typ() != type2) error = err;
89 }

◆ check_argc() [1/2]

void LibThread::Command::check_argc ( int lo,
int hi )
inline

Definition at line 68 of file shared.cc.

68 {
69 if (error) return;
70 if (argc < lo || argc > hi) error = "wrong number of arguments";
71 }

◆ check_argc() [2/2]

void LibThread::Command::check_argc ( int n)
inline

Definition at line 64 of file shared.cc.

64 {
65 if (error) return;
66 if (argc != n) error = "wrong number of arguments";
67 }

◆ check_argc_min()

void LibThread::Command::check_argc_min ( int n)
inline

Definition at line 72 of file shared.cc.

72 {
73 if (error) return;
74 if (argc < n) error = "wrong number of arguments";
75 }

◆ check_init()

void LibThread::Command::check_init ( int i,
const char * err )
inline

Definition at line 80 of file shared.cc.

80 {
81 if (error) return;
82 leftv arg = args[i];
83 if (arg->Data() == NULL || *(void **)(arg->Data()) == NULL)
84 error = err;
85 }
void * arg(int i)
Definition shared.cc:96

◆ int_arg()

long LibThread::Command::int_arg ( int i)
inline

Definition at line 103 of file shared.cc.

103 {
104 return (long)(args[i]->Data());
105 }

◆ nargs()

int LibThread::Command::nargs ( )
inline

Definition at line 93 of file shared.cc.

93 {
94 return argc;
95 }

◆ no_result()

void LibThread::Command::no_result ( )
inline

Definition at line 131 of file shared.cc.

131 {
132 result->rtyp = NONE;
133 }

◆ ok()

bool LibThread::Command::ok ( )
inline

Definition at line 134 of file shared.cc.

134 {
135 return error == NULL;
136 }

◆ report()

void LibThread::Command::report ( const char * err)
inline

Definition at line 106 of file shared.cc.

106 {
107 error = err;
108 }

◆ set_result() [1/4]

void LibThread::Command::set_result ( const char * s)
inline

Definition at line 119 of file shared.cc.

119 {
120 result->rtyp = STRING_CMD;
121 result->data = omStrDup(s);
122 }
const CanonicalForm int s
Definition facAbsFact.cc:51
#define omStrDup(s)
@ STRING_CMD
Definition tok.h:187

◆ set_result() [2/4]

void LibThread::Command::set_result ( int type,
long n )
inline

Definition at line 127 of file shared.cc.

127 {
128 result->rtyp = type;
129 result->data = (char *) n;
130 }

◆ set_result() [3/4]

void LibThread::Command::set_result ( int type,
void * p )
inline

Definition at line 123 of file shared.cc.

123 {
124 result->rtyp = type;
125 result->data = (char *) p;
126 }
int p
Definition cfModGcd.cc:4086

◆ set_result() [4/4]

void LibThread::Command::set_result ( long n)
inline

Definition at line 115 of file shared.cc.

115 {
116 result->rtyp = INT_CMD;
117 result->data = (char *)n;
118 }
@ INT_CMD
Definition tok.h:96

◆ shared_arg()

template<typename T>
T * LibThread::Command::shared_arg ( int i)
inline

Definition at line 100 of file shared.cc.

100 {
101 return *(T **)(arg(i));
102 }
STATIC_VAR jList * T
Definition janet.cc:30

◆ status()

BOOLEAN LibThread::Command::status ( )
inline

Definition at line 137 of file shared.cc.

137 {
138 if (error) {
139 Werror("%s: %s", name, error);
140 }
141 return error != NULL;
142 }
void Werror(const char *fmt,...)
Definition reporter.cc:189

◆ test_arg()

int LibThread::Command::test_arg ( int i,
int type )
inline

Definition at line 111 of file shared.cc.

111 {
112 if (i >= argc) return 0;
113 return args[i]->Typ() == type;
114 }

Field Documentation

◆ argc

int LibThread::Command::argc
private

Definition at line 42 of file shared.cc.

◆ args

leftv* LibThread::Command::args
private

Definition at line 41 of file shared.cc.

◆ error

const char* LibThread::Command::error
private

Definition at line 39 of file shared.cc.

◆ name

const char* LibThread::Command::name
private

Definition at line 38 of file shared.cc.

◆ result

leftv LibThread::Command::result
private

Definition at line 40 of file shared.cc.


The documentation for this class was generated from the following file: