My Project
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes
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 41 of file shared.cc.

Constructor & Destructor Documentation

◆ Command()

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

Definition at line 49 of file shared.cc.

50 {
51 name = n;
52 result = r;
53 error = NULL;
54 argc = 0;
55 for (leftv t = a; t != NULL; t = t->next) {
56 argc++;
57 }
58 args = (leftv *) omAlloc0(sizeof(leftv) * argc);
59 int i = 0;
60 for (leftv t = a; t != NULL; t = t->next) {
61 args[i++] = t;
62 }
63 result->rtyp = NONE;
64 result->data = NULL;
65 }
int i
Definition: cfEzgcd.cc:132
leftv * args
Definition: shared.cc:46
const char * error
Definition: shared.cc:44
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
int rtyp
Definition: subexpr.h:91
void * data
Definition: subexpr.h:88
#define omAlloc0(size)
Definition: omAllocDecl.h:211
#define NULL
Definition: omList.c:12
int name
New type name for int.
Definition: templateForC.h:21
#define NONE
Definition: tok.h:221

◆ ~Command()

LibThread::Command::~Command ( )
inline

Definition at line 66 of file shared.cc.

66 {
67 omFree(args);
68 }
#define omFree(addr)
Definition: omAllocDecl.h:261

Member Function Documentation

◆ abort()

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

Definition at line 148 of file shared.cc.

148 {
149 report(err);
150 return status();
151 }
void report(const char *err)
Definition: shared.cc:111
BOOLEAN status()
Definition: shared.cc:142

◆ arg()

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

Definition at line 101 of file shared.cc.

101 {
102 return args[i]->Data();
103 }
void * Data()
Definition: subexpr.cc:1162

◆ argtype()

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

Definition at line 95 of file shared.cc.

95 {
96 return args[i]->Typ();
97 }
int Typ()
Definition: subexpr.cc:1019

◆ check_arg() [1/2]

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

Definition at line 81 of file shared.cc.

81 {
82 if (error) return;
83 if (args[i]->Typ() != type) error = err;
84 }

◆ check_arg() [2/2]

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

Definition at line 91 of file shared.cc.

91 {
92 if (error) return;
93 if (args[i]->Typ() != type && args[i]->Typ() != type2) error = err;
94 }

◆ check_argc() [1/2]

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

Definition at line 73 of file shared.cc.

73 {
74 if (error) return;
75 if (argc < lo || argc > hi) error = "wrong number of arguments";
76 }

◆ check_argc() [2/2]

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

Definition at line 69 of file shared.cc.

69 {
70 if (error) return;
71 if (argc != n) error = "wrong number of arguments";
72 }

◆ check_argc_min()

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

Definition at line 77 of file shared.cc.

77 {
78 if (error) return;
79 if (argc < n) error = "wrong number of arguments";
80 }

◆ check_init()

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

Definition at line 85 of file shared.cc.

85 {
86 if (error) return;
87 leftv arg = args[i];
88 if (arg->Data() == NULL || *(void **)(arg->Data()) == NULL)
89 error = err;
90 }
void * arg(int i)
Definition: shared.cc:101

◆ int_arg()

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

Definition at line 108 of file shared.cc.

108 {
109 return (long)(args[i]->Data());
110 }

◆ nargs()

int LibThread::Command::nargs ( )
inline

Definition at line 98 of file shared.cc.

98 {
99 return argc;
100 }

◆ no_result()

void LibThread::Command::no_result ( )
inline

Definition at line 136 of file shared.cc.

136 {
137 result->rtyp = NONE;
138 }

◆ ok()

bool LibThread::Command::ok ( )
inline

Definition at line 139 of file shared.cc.

139 {
140 return error == NULL;
141 }

◆ report()

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

Definition at line 111 of file shared.cc.

111 {
112 error = err;
113 }

◆ set_result() [1/4]

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

Definition at line 124 of file shared.cc.

124 {
126 result->data = omStrDup(s);
127 }
const CanonicalForm int s
Definition: facAbsFact.cc:51
#define omStrDup(s)
Definition: omAllocDecl.h:263
@ STRING_CMD
Definition: tok.h:185

◆ set_result() [2/4]

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

Definition at line 132 of file shared.cc.

132 {
133 result->rtyp = type;
134 result->data = (char *) n;
135 }

◆ set_result() [3/4]

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

Definition at line 128 of file shared.cc.

128 {
129 result->rtyp = type;
130 result->data = (char *) p;
131 }
int p
Definition: cfModGcd.cc:4078

◆ set_result() [4/4]

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

Definition at line 120 of file shared.cc.

120 {
122 result->data = (char *)n;
123 }
@ INT_CMD
Definition: tok.h:96

◆ shared_arg()

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

Definition at line 105 of file shared.cc.

105 {
106 return *(T **)(arg(i));
107 }
STATIC_VAR jList * T
Definition: janet.cc:30

◆ status()

BOOLEAN LibThread::Command::status ( )
inline

Definition at line 142 of file shared.cc.

142 {
143 if (error) {
144 Werror("%s: %s", name, error);
145 }
146 return error != NULL;
147 }
void Werror(const char *fmt,...)
Definition: reporter.cc:189

◆ test_arg()

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

Definition at line 116 of file shared.cc.

116 {
117 if (i >= argc) return 0;
118 return args[i]->Typ() == type;
119 }

Field Documentation

◆ argc

int LibThread::Command::argc
private

Definition at line 47 of file shared.cc.

◆ args

leftv* LibThread::Command::args
private

Definition at line 46 of file shared.cc.

◆ error

const char* LibThread::Command::error
private

Definition at line 44 of file shared.cc.

◆ name

const char* LibThread::Command::name
private

Definition at line 43 of file shared.cc.

◆ result

leftv LibThread::Command::result
private

Definition at line 45 of file shared.cc.


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