My Project
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
vspace::VRef< T > Struct Template Reference

#include <vspace.h>

Public Member Functions

 VRef ()
 
size_t offset () const
 
bool operator== (VRef< T > other)
 
bool operator!= (VRef< T > other)
 
 operator bool () const
 
bool is_null ()
 
 VRef (void *ptr)
 
void * to_ptr () const
 
Tas_ptr () const
 
Tas_ref () const
 
Toperator* () const
 
Toperator-> ()
 
VRef< T > & operator= (VRef< T > other)
 
Toperator[] (size_t index)
 
template<typename U >
VRef< U > cast ()
 
void free ()
 

Static Public Member Functions

static VRef< Tfrom_vaddr (internals::vaddr_t vaddr)
 
static VRef< Talloc (size_t n=1)
 

Private Member Functions

 VRef (internals::vaddr_t vaddr)
 

Private Attributes

internals::vaddr_t vaddr
 

Detailed Description

template<typename T>
struct vspace::VRef< T >

Definition at line 412 of file vspace.h.

Constructor & Destructor Documentation

◆ VRef() [1/3]

template<typename T >
vspace::VRef< T >::VRef ( internals::vaddr_t  vaddr)
inlineprivate

Definition at line 415 of file vspace.h.

415  : vaddr(vaddr) {
416  }
internals::vaddr_t vaddr
Definition: vspace.h:414

◆ VRef() [2/3]

template<typename T >
vspace::VRef< T >::VRef ( )
inline

Definition at line 418 of file vspace.h.

419  }
const vaddr_t VADDR_NULL
Definition: vspace.h:84

◆ VRef() [3/3]

template<typename T >
vspace::VRef< T >::VRef ( void *  ptr)
inline

Definition at line 438 of file vspace.h.

438  {
440  }
static vaddr_t allocated_ptr_to_vaddr(void *ptr)
Definition: vspace.h:362

Member Function Documentation

◆ alloc()

template<typename T >
static VRef<T> vspace::VRef< T >::alloc ( size_t  n = 1)
inlinestatic

Definition at line 467 of file vspace.h.

467  {
468  return VRef<T>(internals::vmem_alloc(n * sizeof(T)));
469  }
STATIC_VAR jList * T
Definition: janet.cc:30
vaddr_t vmem_alloc(size_t size)
Definition: vspace.cc:243

◆ as_ptr()

template<typename T >
T* vspace::VRef< T >::as_ptr ( ) const
inline

Definition at line 444 of file vspace.h.

444  {
445  return (T *) to_ptr();
446  }
void * to_ptr() const
Definition: vspace.h:441

◆ as_ref()

template<typename T >
T& vspace::VRef< T >::as_ref ( ) const
inline

Definition at line 447 of file vspace.h.

447  {
448  return *(T *) to_ptr();
449  }

◆ cast()

template<typename T >
template<typename U >
VRef<U> vspace::VRef< T >::cast ( )
inline

Definition at line 464 of file vspace.h.

464  {
465  return VRef<U>::from_vaddr(vaddr);
466  }
static VRef< T > from_vaddr(internals::vaddr_t vaddr)
Definition: vspace.h:420

◆ free()

template<typename T >
void vspace::VRef< T >::free ( )
inline

Definition at line 470 of file vspace.h.

470  {
471  as_ptr()->~T(); // explicitly call destructor
474  }
void vmem_free(vaddr_t vaddr)
Definition: vspace.cc:195
T * as_ptr() const
Definition: vspace.h:444

◆ from_vaddr()

template<typename T >
static VRef<T> vspace::VRef< T >::from_vaddr ( internals::vaddr_t  vaddr)
inlinestatic

Definition at line 420 of file vspace.h.

420  {
421  return VRef(vaddr);
422  }

◆ is_null()

template<typename T >
bool vspace::VRef< T >::is_null ( )
inline

Definition at line 435 of file vspace.h.

435  {
436  return vaddr == internals::VADDR_NULL;
437  }

◆ offset()

template<typename T >
size_t vspace::VRef< T >::offset ( ) const
inline

Definition at line 423 of file vspace.h.

423  {
424  return vaddr;
425  }

◆ operator bool()

template<typename T >
vspace::VRef< T >::operator bool ( ) const
inline

Definition at line 432 of file vspace.h.

432  {
433  return vaddr != internals::VADDR_NULL;
434  }

◆ operator!=()

template<typename T >
bool vspace::VRef< T >::operator!= ( VRef< T other)
inline

Definition at line 429 of file vspace.h.

429  {
430  return vaddr != other.vaddr;
431  }

◆ operator*()

template<typename T >
T& vspace::VRef< T >::operator* ( ) const
inline

Definition at line 450 of file vspace.h.

450  {
451  return *(T *) to_ptr();
452  }

◆ operator->()

template<typename T >
T* vspace::VRef< T >::operator-> ( )
inline

Definition at line 453 of file vspace.h.

453  {
454  return (T *) to_ptr();
455  }

◆ operator=()

template<typename T >
VRef<T>& vspace::VRef< T >::operator= ( VRef< T other)
inline

Definition at line 456 of file vspace.h.

456  {
457  vaddr = other.vaddr;
458  return *this;
459  }

◆ operator==()

template<typename T >
bool vspace::VRef< T >::operator== ( VRef< T other)
inline

Definition at line 426 of file vspace.h.

426  {
427  return vaddr == other.vaddr;
428  }

◆ operator[]()

template<typename T >
T& vspace::VRef< T >::operator[] ( size_t  index)
inline

Definition at line 460 of file vspace.h.

460  {
461  return as_ptr()[index];
462  }
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592

◆ to_ptr()

template<typename T >
void* vspace::VRef< T >::to_ptr ( ) const
inline

Definition at line 441 of file vspace.h.

441  {
442  return internals::vmem.to_ptr(vaddr);
443  }
static VMem & vmem
Definition: vspace.h:300
void * to_ptr(vaddr_t vaddr)
Definition: vspace.h:285

Field Documentation

◆ vaddr

template<typename T >
internals::vaddr_t vspace::VRef< T >::vaddr
private

Definition at line 414 of file vspace.h.


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