Loading...
Searching...
No Matches
countedref.h File Reference

This file defines reusable classes supporting reference counted interpreter objects and initiates the `blackbox` operations for high-level types 'reference' and 'shared'. More...

`#include "omalloc/omalloc.h"`
`#include "kernel/structs.h"`
`#include "Singular/subexpr.h"`
`#include "Singular/idrec.h"`
`#include "Singular/ipid.h"`

Go to the source code of this file.

## Data Structures

class | CountedRefPtr< PtrType, Nondestructive, NeverNull, CountType >
| This class implements a smart pointer which handles pointer-style access to a reference-counted structure and destructing the latter after use. More...
class | RefCounter
| This class implements implements a reference counter which we can use as a public base of objects managed by @CountedRefPtr. More...
class | CountedRefIndirectPtr< PtrType >
class | CountedRefWeakPtr< PtrType >
class | LeftvHelper
| This class implements some recurrent code sniplets to be used with `leftv` and `idhdl.implements` a reference counter which we can use. More...
class | LeftvShallow
| This class wraps `leftv` by taking into account memory allocation, destruction as well as shallowly copying of a given `leftv`, i.e. More...
class | LeftvDeep
| This class wraps `leftv` by taking into account memory allocation, destruction as well as deeply copying of a given `leftv`, i.e. More...
struct | LeftvDeep::copy_tag
| Construct even deeper copy: Skip identifier (if any) and take care of the data on our own. More...

## Functions

template<class PtrType>
void | CountedRefPtr_kill (CountedRefIndirectPtr< PtrType > *pval)
void | countedref_reference_load ()
| Initialize `blackbox` types 'reference' and 'shared', or both.
void | countedref_shared_load ()
void | countedref_init ()

## Detailed Description

This file defines reusable classes supporting reference counted interpreter objects and initiates the `blackbox` operations for high-level types 'reference' and 'shared'.

Note
  This works was supported by the "Industrial Algebra" project.

Author
  Alexander Dreyer

Date
  2012-08-15

Copyright:
  (c) 2012 by The Singular Team, see LICENSE file

Definition in file countedref.h.

## Data Structure Documentation

## LeftvDeep::copy_tag

struct LeftvDeep::copy_tag

Construct even deeper copy: Skip identifier (if any) and take care of the data on our own.

Definition at line 357 of file countedref.h.

## Function Documentation

## countedref_init()

void countedref_init | ( |  | ) |

inline

Definition at line 458 of file countedref.h.

{
countedref_reference_load();
countedref_shared_load();
}
countedref_reference_load
void countedref_reference_load()
Initialize blackbox types 'reference' and 'shared', or both.
Definition countedref.cc:700
countedref_shared_load
void countedref_shared_load()
Definition countedref.cc:724

## countedref_reference_load()

void countedref_reference_load | ( |  | ) |

Initialize `blackbox` types 'reference' and 'shared', or both.

Definition at line 700 of file countedref.cc.

{
int tok;
if (blackboxIsCmd("reference", tok) == ROOT_DECL)
return;
blackbox *bbx = (blackbox*)omAlloc0(sizeof(blackbox));
bbx->blackbox_CheckAssign = countedref_CheckAssign;
bbx->blackbox_destroy = countedref_destroy;
bbx->blackbox_String = countedref_String;
bbx->blackbox_Print = countedref_Print;
bbx->blackbox_Init = countedref_Init;
bbx->blackbox_Copy = countedref_Copy;
bbx->blackbox_Assign = countedref_Assign;
bbx->blackbox_Op1 = countedref_Op1;
bbx->blackbox_Op2 = countedref_Op2;
bbx->blackbox_Op3 = countedref_Op3;
bbx->blackbox_OpM = countedref_OpM;
bbx->blackbox_serialize = countedref_serialize;
bbx->blackbox_deserialize = countedref_deserialize;
bbx->data = omAlloc0(newstruct_desc_size());
setBlackboxStuff(bbx, "reference");
}
setBlackboxStuff
int setBlackboxStuff(blackbox *bb, const char *n)
define a new type
Definition blackbox.cc:143
blackboxIsCmd
int blackboxIsCmd(const char *n, int &tok)
used by scanner: returns ROOT_DECL for known types (and the type number in tok)
Definition blackbox.cc:219
countedref_String
char * countedref_String(blackbox *, void *ptr)
blackbox support - convert to string representation
Definition countedref.cc:363
countedref_serialize
BOOLEAN countedref_serialize(blackbox *, void *d, si_link f)
Definition countedref.cc:679
countedref_Print
void countedref_Print(blackbox *, void *ptr)
blackbox support - convert to string representation
Definition countedref.cc:356
countedref_deserialize
BOOLEAN countedref_deserialize(blackbox **, void **d, si_link f)
Definition countedref.cc:691
countedref_OpM
BOOLEAN countedref_OpM(int op, leftv res, leftv args)
blackbox support - n-ary operations
Definition countedref.cc:592
countedref_Op3
BOOLEAN countedref_Op3(int op, leftv res, leftv head, leftv arg1, leftv arg2)
blackbox support - ternary operations
Definition countedref.cc:471
countedref_Assign
BOOLEAN countedref_Assign(leftv result, leftv arg)
blackbox support - assign element
Definition countedref.cc:377
countedref_Op2
BOOLEAN countedref_Op2(int op, leftv res, leftv head, leftv arg)
Definition countedref.cc:437
countedref_Init
void * countedref_Init(blackbox *)
blackbox support - initialization
Definition countedref.cc:186
countedref_destroy
void countedref_destroy(blackbox *, void *ptr)
blackbox support - destruction
Definition countedref.cc:484
countedref_Op1
BOOLEAN countedref_Op1(int op, leftv res, leftv head)
blackbox support - unary operations
Definition countedref.cc:406
countedref_CheckAssign
BOOLEAN countedref_CheckAssign(blackbox *, leftv, leftv)
We use the function pointer as a marker of reference types for CountedRef::is_ref(leftv),...
Definition countedref.cc:193
countedref_Copy
void * countedref_Copy(blackbox *, void *ptr)
blackbox support - copy element
Definition countedref.cc:370
ROOT_DECL
@ ROOT_DECL
Definition grammar.cc:320
newstruct_desc_size
int newstruct_desc_size()
Definition newstruct.cc:42
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211

## countedref_shared_load()

void countedref_shared_load | ( |  | ) |

Definition at line 724 of file countedref.cc.

{
int tok;
if (blackboxIsCmd("shared", tok) == ROOT_DECL)
return;
blackbox *bbxshared = (blackbox*)omAlloc0(sizeof(blackbox));
bbxshared->blackbox_String = countedref_String;
bbxshared->blackbox_Print = countedref_Print;
bbxshared->blackbox_Copy = countedref_Copy;
bbxshared->blackbox_Op3 = countedref_Op3;
bbxshared->blackbox_OpM = countedref_OpM;
bbxshared->blackbox_serialize = countedref_serialize;
bbxshared->blackbox_deserialize = countedref_deserialize;
bbxshared->blackbox_CheckAssign = countedref_CheckAssign;
bbxshared->blackbox_Assign = countedref_AssignShared;
bbxshared->blackbox_destroy = countedref_destroyShared;
bbxshared->blackbox_Op1 = countedref_Op1Shared;
bbxshared->blackbox_Op2 = countedref_Op2Shared;
bbxshared->blackbox_Init = countedref_InitShared;
bbxshared->data = omAlloc0(newstruct_desc_size());
setBlackboxStuff(bbxshared, "shared");
}
countedref_Op2Shared
BOOLEAN countedref_Op2Shared(int op, leftv res, leftv head, leftv arg)
blackbox support - binary operations
Definition countedref.cc:576
countedref_destroyShared
void countedref_destroyShared(blackbox *, void *ptr)
blackbox support - destruction
Definition countedref.cc:673
countedref_InitShared
void * countedref_InitShared(blackbox *)
Blackbox support - generate initialized, but all-zero - shared data.
Definition countedref.cc:540
countedref_AssignShared
BOOLEAN countedref_AssignShared(leftv result, leftv arg)
blackbox support - assign element
Definition countedref.cc:648
countedref_Op1Shared
BOOLEAN countedref_Op1Shared(int op, leftv res, leftv head)
Blackbox support - unary operation for shared data.
Definition countedref.cc:546

## CountedRefPtr_kill()

template<class PtrType>

void CountedRefPtr_kill | ( | CountedRefIndirectPtr< PtrType > * | pval | ) |

inline

Definition at line 151 of file countedref.h.

{ delete pval; }