My Project
Loading...
Searching...
No Matches
Static Public Member Functions
LeftvHelper Class Reference

This class implements some recurrent code sniplets to be used with leftv and idhdl.implements a refernce counter which we can use. More...

#include <countedref.h>

Static Public Member Functions

static leftv idify (leftv head, idhdl *root)
 
static idhdl newid (leftv head, idhdl *root)
 
static void clearid (idhdl handle, idhdl *root)
 
template<class Type >
static Type * cpy (Type *result, Type *data)
 
template<class Type >
static Type * cpy (Type *data)
 
template<class Type >
static Type * recursivecpy (Type *data)
 
template<class Type >
static Type * shallowcpy (Type *result, Type *data)
 
template<class Type >
static Type * shallowcpy (Type *data)
 
template<class Type >
static void recursivekill (Type *current)
 
static leftv allocate ()
 

Detailed Description

This class implements some recurrent code sniplets to be used with leftv and idhdl.implements a refernce counter which we can use.

Definition at line 213 of file countedref.h.

Member Function Documentation

◆ allocate()

static leftv LeftvHelper::allocate ( )
inlinestatic

Definition at line 273 of file countedref.h.

273{ return (leftv)omAlloc0(sizeof(sleftv)); }
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ clearid()

static void LeftvHelper::clearid ( idhdl  handle,
idhdl root 
)
inlinestatic

Definition at line 237 of file countedref.h.

237 {
238 IDDATA(handle)=NULL;
239 IDTYP(handle)=NONE;
240 killhdl2(handle, root, NULL);
241 }
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition: ipid.cc:445
#define IDDATA(a)
Definition: ipid.h:126
#define IDTYP(a)
Definition: ipid.h:119
#define NULL
Definition: omList.c:12
#define NONE
Definition: tok.h:221

◆ cpy() [1/2]

template<class Type >
static Type * LeftvHelper::cpy ( Type *  data)
inlinestatic

Definition at line 248 of file countedref.h.

248 {
249 return cpy((Type*)omAlloc0(sizeof(Type)), data);
250 }
static Type * cpy(Type *result, Type *data)
Definition: countedref.h:244

◆ cpy() [2/2]

template<class Type >
static Type * LeftvHelper::cpy ( Type *  result,
Type *  data 
)
inlinestatic

Definition at line 244 of file countedref.h.

244 {
245 return (Type*)memcpy(result, data, sizeof(Type));
246 }
return result
Definition: facAbsBiFact.cc:75

◆ idify()

static leftv LeftvHelper::idify ( leftv  head,
idhdl root 
)
inlinestatic

Definition at line 215 of file countedref.h.

215 {
216 idhdl handle = newid(head, root);
217 leftv res = (leftv)omAlloc0(sizeof(*res));
218 res->data =(void*) handle;
219 res->rtyp = IDHDL;
220 return res;
221 }
CanonicalForm head(const CanonicalForm &f)
static idhdl newid(leftv head, idhdl *root)
Definition: countedref.h:223
Definition: idrec.h:35
CanonicalForm res
Definition: facAbsFact.cc:60
sleftv * leftv
Definition: structs.h:57
#define IDHDL
Definition: tok.h:31

◆ newid()

static idhdl LeftvHelper::newid ( leftv  head,
idhdl root 
)
inlinestatic

Definition at line 223 of file countedref.h.

223 {
224
225 STATIC_VAR unsigned int counter = 0;
226 char* name = (char*) omAlloc0(512);
227 sprintf(name, " :%u:%p:_shared_: ", ++counter, head->data);
228 if ((*root) == NULL )
229 enterid(name, 0, head->rtyp, root, TRUE, FALSE);
230 else
231 *root = (*root)->set(name, 0, head->rtyp, TRUE);
232
233 IDDATA(*root) = (char*) head->data;
234 return *root;
235 }
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
idhdl set(const char *s, int lev, int t, BOOLEAN init=TRUE)
Definition: ipid.cc:237
#define STATIC_VAR
Definition: globaldefs.h:7
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:279
int name
New type name for int.
Definition: templateForC.h:21

◆ recursivecpy()

template<class Type >
static Type * LeftvHelper::recursivecpy ( Type *  data)
inlinestatic

Definition at line 252 of file countedref.h.

252 {
253 if (data == NULL) return data;
254 Type* result = cpy(data);
255 result->next = recursivecpy(data->next);
256 return result;
257 }
static Type * recursivecpy(Type *data)
Definition: countedref.h:252

◆ recursivekill()

template<class Type >
static void LeftvHelper::recursivekill ( Type *  current)
inlinestatic

Definition at line 268 of file countedref.h.

268 {
269 if(current == NULL) return;
270 recursivekill(current->next);
271 omFree(current);
272 }
static void recursivekill(Type *current)
Definition: countedref.h:268
#define omFree(addr)
Definition: omAllocDecl.h:261

◆ shallowcpy() [1/2]

template<class Type >
static Type * LeftvHelper::shallowcpy ( Type *  data)
inlinestatic

Definition at line 264 of file countedref.h.

264 {
265 return shallowcpy((Type*) omAlloc0(sizeof(Type)), data);
266 }
static Type * shallowcpy(Type *result, Type *data)
Definition: countedref.h:259

◆ shallowcpy() [2/2]

template<class Type >
static Type * LeftvHelper::shallowcpy ( Type *  result,
Type *  data 
)
inlinestatic

Definition at line 259 of file countedref.h.

259 {
260 cpy(result, data)->e = recursivecpy(data->e);
261 return result;
262 }

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