My Project  UNKNOWN_GIT_VERSION
Static Public Member Functions
LeftvHelper Class Reference

#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)); }

◆ 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  }

◆ 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  }

◆ 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  }

◆ 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  }

◆ newid()

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

Definition at line 223 of file countedref.h.

223  {
224 
225  static 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  }

◆ 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  }

◆ 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  }

◆ 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  }

◆ 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:
FALSE
#define FALSE
Definition: auxiliary.h:94
omFree
#define omFree(addr)
Definition: omAllocDecl.h:261
result
return result
Definition: facAbsBiFact.cc:76
enterid
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:267
NONE
#define NONE
Definition: tok.h:219
IDDATA
#define IDDATA(a)
Definition: ipid.h:121
sleftv
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
LeftvHelper::shallowcpy
static Type * shallowcpy(Type *result, Type *data)
Definition: countedref.h:259
leftv
sleftv * leftv
Definition: structs.h:60
TRUE
#define TRUE
Definition: auxiliary.h:98
res
CanonicalForm res
Definition: facAbsFact.cc:64
killhdl2
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition: ipid.cc:417
IDTYP
#define IDTYP(a)
Definition: ipid.h:114
LeftvHelper::cpy
static Type * cpy(Type *result, Type *data)
Definition: countedref.h:244
idrec
Definition: idrec.h:35
name
char name(const Variable &v)
Definition: factory.h:180
IDHDL
#define IDHDL
Definition: tok.h:31
LeftvHelper::recursivecpy
static Type * recursivecpy(Type *data)
Definition: countedref.h:252
NULL
#define NULL
Definition: omList.c:10
LeftvHelper::recursivekill
static void recursivekill(Type *current)
Definition: countedref.h:268
head
CanonicalForm head(const CanonicalForm &f)
Definition: canonicalform.h:353
idrec::set
idhdl set(const char *s, int lev, int t, BOOLEAN init=TRUE)
Definition: ipid.cc:225
omAlloc0
#define omAlloc0(size)
Definition: omAllocDecl.h:211
LeftvHelper::newid
static idhdl newid(leftv head, idhdl *root)
Definition: countedref.h:223