File: easyxs_structref.h

package info (click to toggle)
libpromise-xs-perl 0.20-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 908 kB
  • sloc: perl: 1,097; ansic: 355; makefile: 3
file content (21 lines) | stat: -rw-r--r-- 513 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef EASYXS_STRUCTREF_H
#define EASYXS_STRUCTREF_H 1

#include "init.h"

#define exs_new_structref(type, classname) _exs_new_structref_f(aTHX_ sizeof(type), classname)

#define exs_structref_ptr(svrv) ( (void *) SvPVX( SvRV(svrv) ) )

static inline SV* _exs_new_structref_f (pTHX_ unsigned size, const char* classname) {

    SV* referent = newSV(size);
    SvPOK_on(referent);

    SV* reference = newRV_noinc(referent);
    sv_bless(reference, gv_stashpv(classname, FALSE));

    return reference;
}

#endif