annotate modules/dl.tp @ 277:2b58eafa360b

Add SDL bindings for creating a renderer, clearing it, presenting it and destroying it
author Michael Pavone <pavone@retrodev.com>
date Sun, 20 Jul 2014 17:30:46 -0700
parents cba0cb39517a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
264
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #{
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
2 includeSystemHeader: "dlfcn.h"
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
3
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
4 llMessage: sym:from withVars: {
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
5 handle <- obj_uint64 ptr
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
6 name <- string ptr
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
7 intret <- obj_uint64 ptr
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
8 } andCode: :name :handle {
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
9 intret <- make_object: (addr_of: obj_int64_meta) NULL 0
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
10 intret num!: (dlsym: (handle num) (name data))
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
11 intret
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
12 }
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
13
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
14 llMessage: open:withFlags withVars: {
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
15 name <- string ptr
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
16 intret <- obj_uint64 ptr
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
17 flags <- obj_int32 ptr
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
18 } andCode: :name :flags {
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
19 intret <- make_object: (addr_of: obj_int64_meta) NULL 0
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
20 if: (name len) > 0 {
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
21 intret num!: (dlopen: (name data) (flags num))
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
22 } else: {
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
23 intret num!: (dlopen: NULL (flags num))
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
24 }
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
25 intret
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
26 }
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
27
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
28 llMessage: LAZY withVars: {
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
29 flagret <- obj_int32 ptr
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
30 } andCode: {
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
31 flagret <- make_object: (addr_of: obj_int64_meta) NULL 0
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
32 flagret num!: RTLD_LAZY
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
33 flagret
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
34 }
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
35
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
36 llMessage: NOW withVars: {
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
37 flagret <- obj_int32 ptr
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
38 } andCode: {
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
39 flagret <- make_object: (addr_of: obj_int64_meta) NULL 0
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
40 flagret num!: RTLD_NOW
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
41 flagret
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
42 }
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
43
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
44 main <- :args {
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
45 library <- ""
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
46 func <- "main"
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
47 if: (args length) > 2 {
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
48 library <- args get: 1
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
49 func <- args get: 2
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
50 } else: {
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
51 if: (args length) > 1 {
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
52 func <- args get: 1
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
53 }
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
54 }
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
55 handle <- open: library withFlags: NOW
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
56 print: "handle: " . handle . "\n"
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
57 address <- sym: func from: handle
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
58 if: (library length) > 0 {
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
59 print: library . " - " . func . ": " . address . "\n"
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
60 } else: {
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
61 print: func . ": " . address . "\n"
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
62 }
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
63 0
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
64 }
cba0cb39517a Add module for interfacing with libdl
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
65 }