File: closures.c

package info (click to toggle)
barnowl 1.10-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 5,472 kB
  • sloc: ansic: 36,670; perl: 20,938; sh: 1,598; makefile: 181
file content (28 lines) | stat: -rw-r--r-- 768 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
22
23
24
25
26
27
28
#define OWL_PERL
#include "owl.h"
#include <dlfcn.h>
#include <gperl.h>
#include <gperl_marshal.h>

gboolean (*gvalue_from_sv) (GValue * value, SV * sv) = NULL;
SV * (*sv_from_gvalue) (const GValue * value) = NULL;
GClosure * (*perl_closure_new) (SV * callback, SV * data, gboolean swap) = NULL;

/* Caller does not own return value */
const char *owl_closure_init(void)
{
  void *handle = NULL;
  const char *res = "Unable to dlopen self - huh?";

  handle = dlopen(NULL, RTLD_LAZY | RTLD_NOLOAD);
  if(handle) {
    gvalue_from_sv = dlsym(handle, "gperl_value_from_sv");
    sv_from_gvalue = dlsym(handle, "gperl_sv_from_value");
    perl_closure_new = dlsym(handle, "gperl_closure_new");
    /* ... */
    res = dlerror();
    dlclose(handle);
  }
  return res;
}