Commit a31965f5 authored by -urso-'s avatar -urso-

documentation and exmaples update

darcs-hash:9d6928a257aecdbbb8c9a6d57faee06965f79807
parent d381d88e
......@@ -17,10 +17,12 @@
<h3>Example Usage (Secondary Databases)</h3>
<p>WARNING: this 'native' kind of using secondary databases with Berkeley DB is very C-centric, thus for
every callback function you create, cffi will create one and those functions and associated data (when using closures for example)
will not being garbage collected, even if databases were closed. Thus if you use alot of secondary databases, there will be
a lot of garbage being produced over time...
will not being garbage collected, even if databases were closed. Thus if you use alot of secondary databases, there may be
a lot of garbage being produced over time...<br>
Using transactional databases, C-Style callbacks are not used anymore and you must not be "afraid" about anything...
</p>
<pre>
CL-USER&gt; (asdf:oos 'asdf:load-op :bdb-playground)
NIL
CL-USER&gt; (in-package :bdb-playground)
......@@ -30,10 +32,10 @@ BDB-PLAYGROUND&gt; (defun first-callback (sdb key data)
FIRST-CALLBACK
BDB-PLAYGROUND&gt; (setq *callback* (create-assoc-callback #'first-callback))
#.(SB-SYS:INT-SAP #X050006F8)
BDB-PLAYGROUND&gt; (setq *db* (db-open "test.db" :create t))
#.(SB-SYS:INT-SAP #X08197120)
BDB-PLAYGROUND&gt; (setq *sdb* (db-open "sec.db" :create t :dup-sort t))
#.(SB-SYS:INT-SAP #X081995A0)
BDB-PLAYGROUND&gt; (setq *db* (db-open "test.db" :create t :exclusive t))
#&lt;DB-STD {A866C31}&gt;
BDB-PLAYGROUND&gt; (setq *sdb* (db-open "sec.db" :create t :exclusive t :dup-sort t))
#&lt;DB-STD {A9DEB49}&gt;
BDB-PLAYGROUND&gt; (db-associate *db* *sdb* *callback*)
T
BDB-PLAYGROUND&gt; (db-put *db* 1 '(max mustermann))
......@@ -43,7 +45,7 @@ T
BDB-PLAYGROUND&gt; (db-put *db* 3 '(micky maus))
T
BDB-PLAYGROUND&gt; (setq *cursor* (db-cursor *db*))
#.(SB-SYS:INT-SAP #X0819CF28)
#&lt;BDB::CURSOR {B350ED1}&gt;
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
1
(MAX MUSTERMANN)
......@@ -57,9 +59,9 @@ BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
NIL
NIL
BDB-PLAYGROUND&gt; (db-cursor-close *cursor*)
T
NIL
BDB-PLAYGROUND&gt; (setq *cursor* (db-cursor *sdb*))
#.(SB-SYS:INT-SAP #X0819BB28)
#&lt;BDB::CURSOR {B4CF249}&gt;
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
KATER
(KATER KARLO)
......@@ -72,8 +74,15 @@ MAX
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
NIL
NIL
BDB-PLAYGROUND&gt; (db-cursor-close *cursor*)
NIL
BDB-PLAYGROUND&gt; (db-close *sdb*)
NIL
BDB-PLAYGROUND&gt; (db-close *db*)
NIL
BDB-PLAYGROUND&gt; ;;bye bye
</pre>
<p> </p>
<div class="footer">
<a href="mailto:-urso-@web.de">Email</a>
......
......@@ -20,85 +20,84 @@ CL-USER&gt; (asdf:oos 'asdf:load-op :bdb-playground)
NIL
CL-USER&gt; (in-package :bdb-playground)
#&lt;PACKAGE "BDB-PLAYGROUND"&gt;
BDB-PLAYGROUND&gt; (setq *db* (db-open "test-db.db" :create t :exclusive t))
#.(SB-SYS:INT-SAP #X08197120)
BDB-PLAYGROUND&gt; (db-put *db* "key1" "data1")
BDB-PLAYGROUND&gt; (setq *db* (db-open "test.db" :create t :exclusive t))
#&lt;DB-STD {AB8B471}&gt;
BDB-PLAYGROUND&gt; (db-put *db* 'key1 "data1")
T
BDB-PLAYGROUND&gt; (db-put *db* "key2" "data2")
BDB-PLAYGROUND&gt; (db-put *db* 'key2 "data2")
T
BDB-PLAYGROUND&gt; (db-put *db* "key3" "data3")
BDB-PLAYGROUND&gt; (db-put *db* 'key3 "data3")
T
BDB-PLAYGROUND&gt; (db-put *db* "key4" "data4")
BDB-PLAYGROUND&gt; (db-put *db* 'key4 "data4")
T
BDB-PLAYGROUND&gt; (db-get *db* "key2")
BDB-PLAYGROUND&gt; (db-get *db* 'key2)
"data2"
BDB-PLAYGROUND&gt; (db-get *db* "key4")
BDB-PLAYGROUND&gt; (db-get *db* 'key4)
"data4"
BDB-PLAYGROUND&gt; (db-get *db* "key1012")
BDB-PLAYGROUND&gt; (db-get *db* 'key1022)
NIL
BDB-PLAYGROUND&gt; (db-get *db* "key1012" :not-found t)
BDB-PLAYGROUND&gt; (db-get *db* 'key1022 :not-found t))
; Evaluation aborted | comment: used debugger to abort, cause of exception...
BDB-PLAYGROUND&gt; (db-get *db* "key1012" :not-found (lambda () "uhoh"))
"uhoh"
BDB-PLAYGROUND&gt; (db-get *db* 'key1022 :not-found (lambda () 'uhoh))
UHOH
BDB-PLAYGROUND&gt; (setq *cursor* (db-cursor *db*))
#.(SB-SYS:INT-SAP #X08198338)
#&lt;BDB::CURSOR {B97D641}&gt;
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
"key1"
KEY1
"data1"
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
"key2"
KEY2
"data2"
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
"key3"
KEY3
"data3"
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
"key4"
KEY4
"data4"
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
NIL
NIL
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :first t)
"key1"
KEY1
"data1"
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :key "key3" :set t)
"key3"
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :key 'key3 :set t)
KEY3
"data3"
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
"key4"
KEY4
"data4"
BDB-PLAYGROUND&gt; (db-cursor-count *cursor*) ;;number of duplicates
1
BDB-PLAYGROUND&gt; (db-cursor-close *cursor*)
T
NIL
BDB-PLAYGROUND&gt; (db-close *db*)
T
BDB-PLAYGROUND&gt; (setq *db* (db-open "test-db.db"))
#.(SB-SYS:INT-SAP #X08197120)
NIL
BDB-PLAYGROUND&gt; (setq *db* (db-open "test.db"))
#&lt;DB-STD {A7EB5E9}&gt;
BDB-PLAYGROUND&gt; (setq *cursor* (db-cursor *db*))
#.(SB-SYS:INT-SAP #X081982F0)
#&lt;BDB::CURSOR {A81DD71}&gt;
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
"key1"
KEY1
"data1"
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
"key2"
KEY2
"data2"
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
"key3"
KEY3
"data3"
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
"key4"
KEY4
"data4"
BDB-PLAYGROUND&gt; (db-cursor-get *cursor* :next t)
NIL
NIL
BDB-PLAYGROUND&gt; (db-cursor-close *cursor*)
T
NIL
BDB-PLAYGROUND&gt; (db-close *db*)
T
BDB-PLAYGROUND&gt; ;;thats it...
; No value
NIL
BDB-PLAYGROUND&gt;
</pre>
<p> </p>
<div class="footer">
<a href="mailto:-urso-@web.de">Email</a>
......@@ -109,4 +108,3 @@ BDB-PLAYGROUND&gt;
</div>
</body>
</html>
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>BDB</title>
<link rel="stylesheet" type="text/css" href="../style.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
</head>
<body>
<div class="header">
<h1>BDB</h1>
<h2>Berkeley DB CFFI bindings</h2>
</div>
<h3>Example Usage (Transactions)</h3>
<pre>
CL-USER&gt; (asdf:oos 'asdf:load-op :bdb-playground)
NIL
CL-USER&gt; (in-package :bdb-playground)
#&lt;PACKAGE "BDB-PLAYGROUND"&gt;
BDB-PLAYGROUND&gt; (setq *env* (db-env-open "/home/main/tdb" :init-txn t :init-log t :init-lock t :init-mpool t :create t))
#&lt;DB-ENV {B7A4221}&gt;
BDB-PLAYGROUND&gt; (setq *db* (db-open "test.db" :env *env* :auto-commit t :create t))
#&lt;DB-TXN {B8042D1}&gt;
BDB-PLAYGROUND&gt; (with-txn (txn *env*)
(db-put *db* 1 "data1" :txn txn)
(db-put *db* 2 "data2" :txn txn))
T
BDB-PLAYGROUND&gt; (db-get *db* 1)
"data1"
BDB-PLAYGROUND&gt; (db-get *db* 2)
"data2"
BDB-PLAYGROUND&gt; (db-get *db* 3)
NIL
BDB-PLAYGROUND&gt; (with-txn (txn *env*)
(db-put *db* 3 "data3" :txn txn)
(db-put *db* 4 "data4" :txn txn)
(error "ohoh, abort transaction"))
BDB-PLAYGROUND&gt; (db-get *db* 1)
"data1"
BDB-PLAYGROUND&gt; (db-get *db* 2)
"data2"
BDB-PLAYGROUND&gt; (db-get *db* 3)
NIL
BDB-PLAYGROUND&gt; (db-get *db* 4)
NIL
BDB-PLAYGROUND&gt; (db-del *db* 1)
; Evaluation aborted | comment: if you want to delete an entry, you must use a txn
BDB-PLAYGROUND&gt; (with-txn (txn *env*)
(db-del *db* 1 :txn txn))
T
BDB-PLAYGROUND&gt; (db-get *db* 1)
NIL
BDB-PLAYGROUND&gt; (db-get *db* 2)
"data2"
BDB-PLAYGROUND&gt; (db-get *db* 3)
NIL
BDB-PLAYGROUND&gt; (db-get *db* 4)
NIL
BDB-PLAYGROUND&gt; (db-close *db*)
T
BDB-PLAYGROUND&gt; (db-env-close *env*)
NIL
BDB-PLAYGROUND&gt; ;; bye bye
</pre>
<p> </p>
<div class="footer">
<a href="mailto:-urso-@web.de">Email</a>
</div>
<div class="check">
<a href="http://validator.w3.org/check/referer"> Valid XHTML 1.0 Strict</a>
</div>
</body>
</html>
......@@ -146,6 +146,7 @@
<ol>
<li><a href="examples/simple.html">Simple db Example</a></li>
<li><a href="examples/secondary.html">Secondary Databases</a></li>
<li><a href="examples/txn.html">Transactions</a></li>
</ol>
<h3>Mailing Lists</h3>
......
......@@ -24,8 +24,7 @@
> | <a href="index.html"
>toc</a
></div
><p> (to be used by this library only)
><p><p> (to be used by this library only) </p>
<pre class="code"
><span class="first-line"><span class="paren">(</span>defcfun &quot;strlen&quot; :int</span><span class"body">
<span class="paren">(</span>str :pointer<span class="paren">)</span><span class="paren">)</span></span></pre
......
<html
><head
><title
>Berkley DB CFFI-Bindings</title
><link href="style.css" rel="stylesheet"
/><link title="Print" href="print.css" rel="alternate stylesheet"
/></head
><body
><div class="qbook"
><h1 class="title"
>Berkley DB CFFI-Bindings</h1
><div class="contents"
><h2
><a name="Secondary_0020Databases"
>Secondary Databases</a
>&nbsp;</h2
><div class="nav-links"
><a class="nav-link" href="Logging.html"
>prev</a
> | <span class="dead-nav-link"
>up</span
> | <a href="Utilities.html"
>next</a
> | <a href="index.html"
>toc</a
></div
><p>
Notes:
the C library handles secondaries like this:
db_create: - will create environment, if none specified and
add to db pointer
db_put/__db_put: - create cursor with write-lock
- use __db_c_put on cursor to insert data
__db_c_put: - uses private flag DB_UPDATE_SECONDARY to do puts on
secondary databases
- use __db_s_first and __db_s_next for iterating over
secondaries, they will take care of thread-locking
- in first loop add new keys:
- call callback to get secondary key
- open cursor on secondary with transaction and
lock id of primary database
- use __db_c_put with DB_UPDATE_SECONDARY flag
to insert data into secondary
- close cursor
- in second loop remove old secondary indicies:
- get old secondary key
- if secondary key needs to be deleted than:
- get cursor
- use get to move cursor to position
- delete entry
- update primary database now
perl/tcl/python/ruby libs weren't much more helpfull :(
for the lisp library:
- when opening a database it depends on the environment,
wether we'll use the C-based (using db-associate-ll)
implementation or a transaction based if transactions
are supported by environment.
Todo so, db-open returns different kind of classes:
- db-std ;; standard db-class, if txn not allowed
- db-txn ;; if environment supports transactions
- db-associate needs different implementations for db-std
and db-txn:
- db-std:
- use the old low level method
- use defcallback and go on
- no changes to db-put
- db-txn:
- add callback function and secondary to table
in database
- when closing secondary, remove from table
- don't use defcallback, use lambda directly
- overwrite db-put:
- create an transaction
- add data to primary
- in a loop, add keys to secondaries
<pre class="code"
><span class="first-line"><span class="paren">(</span>defcstruct DBT ;;tried to avoid using DBT directly... :'<span class="paren">(</span></span><span class"body">
<span class="paren">(</span>data :pointer<span class="paren">)</span>
<span class="paren">(</span>size :uint32<span class="paren">)</span>
<span class="paren">(</span>ulen :uint32<span class="paren">)</span>
<span class="paren">(</span>dlen :uint32<span class="paren">)</span>
<span class="paren">(</span>doff :uint32<span class="paren">)</span>
<span class="paren">(</span>flags :uint32<span class="paren">)</span><span class="paren">)</span></span></pre
>
<div class="computational-element-link computational-element-link-function"
><p
><a href="api/function_005FBDB_003A_003ACREATE-DB-ASSOC-CALLBACK.html" name="function_005FBDB_003A_003ACREATE-DB-ASSOC-CALLBACK"
>Function CREATE-DB-ASSOC-CALLBACK</a
> </p
></div
>
<div class="computational-element-link computational-element-link-function"
><p
><a href="api/function_005FBDB_003A_003ACREATE-CBUFFERED-DB-ASSOC-CALLBACK.html" name="function_005FBDB_003A_003ACREATE-CBUFFERED-DB-ASSOC-CALLBACK"
>Function CREATE-CBUFFERED-DB-ASSOC-CALLBACK</a
> </p
></div
>
<div class="computational-element-link computational-element-link-function"
><p
><a href="api/function_005FBDB_003A_003ABUILD-ASSOC-CALLBACK-MAKER.html" name="function_005FBDB_003A_003ABUILD-ASSOC-CALLBACK-MAKER"
>Function BUILD-ASSOC-CALLBACK-MAKER</a
> </p
></div
>
<div class="computational-element-link computational-element-link-function"
><p
><a href="api/function_005FBDB_003A_003ABUILD-CBUFFERED-ASSOC-LAMBDA.html" name="function_005FBDB_003A_003ABUILD-CBUFFERED-ASSOC-LAMBDA"
>Function BUILD-CBUFFERED-ASSOC-LAMBDA</a
> </p
></div
>
<div class="computational-element-link computational-element-link-method"
><p
><a href="api/method_005FBDB_003A_003A_0028DB-ASSOCIATE_0020DB-STD_0020DB_0020T_0029.html" name="method_005FBDB_003A_003A_0028DB-ASSOCIATE_0020DB-STD_0020DB_0020T_0029"
>Method (DB-ASSOCIATE DB-STD DB T)</a
> </p
></div
>
<div class="computational-element-link computational-element-link-method"
><p
><a href="api/method_005FBDB_003A_003A_0028DB-ASSOCIATE_0020DB-TXN_0020DB-TXN_0020T_0029.html" name="method_005FBDB_003A_003A_0028DB-ASSOCIATE_0020DB-TXN_0020DB-TXN_0020T_0029"
>Method (DB-ASSOCIATE DB-TXN DB-TXN T)</a
> </p
></div
>
<div class="computational-element-link computational-element-link-method"
><p
><a href="api/method_005FBDB_003A_003A_0028DB-DISASSOCIATE_0020DB-TXN_0020DB-TXN_0029.html" name="method_005FBDB_003A_003A_0028DB-DISASSOCIATE_0020DB-TXN_0020DB-TXN_0029"
>Method (DB-DISASSOCIATE DB-TXN DB-TXN)</a
> </p
></div
>
<div class="computational-element-link computational-element-link-method"
><p
><a href="api/method_005FBDB_003A_003A_0028DB-JOIN_0020DB_0020T_0029.html" name="method_005FBDB_003A_003A_0028DB-JOIN_0020DB_0020T_0029"
>Method (DB-JOIN DB T)</a
> </p
></div
>
</div
></div
></body
></html
>
\ No newline at end of file
......@@ -14,13 +14,7 @@
><h2
>Documentation</h2
><blockquote
>creates and opens a new Database
params: env = Environment the database shall be opened in
txn = Transaction
db = Database in File (optional)
mode = file mode, use create-umask or 0 for default
type = :db-btree :db-hash :db-recno or :db-queue
flags... see BDB documentation or db.h</blockquote
><p>creates and opens a new Database <br>&nbsp;&nbsp;&nbsp;params: env = Environment the database shall be opened in txn = Transaction db = Database in File (optional) mode = file mode, use create-umask or 0 for default type = :db-btree :db-hash :db-recno or :db-queue flags... see BDB documentation or db.h </p></blockquote
><h2
>Source</h2
><pre class="code"
......
......@@ -14,7 +14,7 @@
><h2
>Documentation</h2
><blockquote
>callback returns a cbuffer, which will be freed by this put function</blockquote
><p>callback returns a cbuffer, which will be freed by this put function </p></blockquote
><h2
>Source</h2
><pre class="code"
......
......@@ -26,33 +26,15 @@
></div
>
<pre class="code"
><span class="first-line"><span class="paren">(</span>eval-when <span class="paren">(</span>:compile-toplevel :load-toplevel :execute<span class="paren">)</span></span><span class"body">
<span class="paren">(</span>unless <span class="paren">(</span>find-package :cffi-util-system<span class="paren">)</span>
<span class="paren">(</span>defpackage :cffi-util-system
<span class="paren">(</span>:use :common-lisp :asdf<span class="paren">)</span><span class="paren">)</span><span class="paren">)</span><span class="paren">)</span></span></pre
><span class="first-line"><p><span class="paren">(</span>eval-when <span class="paren">(</span>:compile-toplevel :load-toplevel :execute<span class="paren">)</span> <br>&nbsp;&nbsp;<span class="paren">(</span>unless <span class="paren">(</span>find-package :cffi-util-system<span class="paren">)</span> <span class="paren">(</span>defpackage :cffi-util-system <span class="paren">(</span>:use :common-lisp :asdf<span class="paren">)</span><span class="paren">)</span><span class="paren">)</span><span class="paren">)</span> </p></span><span class"body"></span></pre
>
<pre class="code"
><span class="first-line"><span class="paren">(</span>in-package :cffi-util-system<span class="paren">)</span></span><span class"body"></span></pre
><span class="first-line"><p><span class="paren">(</span>in-package :cffi-util-system<span class="paren">)</span> </p></span><span class"body"></span></pre
>
<pre class="code"
><span class="first-line"><span class="paren">(</span>defsystem :cffi-util</span><span class"body">
:description &quot;some utilities&quot;
:author &quot;&quot;
:version &quot;0.0,0&quot;
:components
<span class="paren">(</span><span class="paren">(</span>:module :src
:components <span class="paren">(</span><span class="paren">(</span>:file &quot;packages&quot;<span class="paren">)</span>
<span class="paren">(</span>:file &quot;flags&quot;
:depends-on <span class="paren">(</span>&quot;packages&quot;<span class="paren">)</span><span class="paren">)</span>
<span class="paren">(</span>:file &quot;defcfun&quot;
:depends-on <span class="paren">(</span>&quot;packages&quot; &quot;flags&quot;<span class="paren">)</span><span class="paren">)</span>
<span class="paren">(</span>:file &quot;cbuffer&quot;
:depends-on <span class="paren">(</span>&quot;packages&quot;<span class="paren">)</span><span class="paren">)</span>
<span class="paren">(</span>:file &quot;cbuffer-streams&quot;
:depends-on <span class="paren">(</span>&quot;cbuffer&quot;<span class="paren">)</span><span class="paren">)</span><span class="paren">)</span><span class="paren">)</span><span class="paren">)</span>
:depends-on <span class="paren">(</span>:cffi :mycl-util :trivial-gray-streams :flexi-streams<span class="paren">)</span><span class="paren">)</span></span></pre
><span class="first-line"><p><span class="paren">(</span>defsystem :cffi-util <br>&nbsp;&nbsp;:description "some utilities" <br>&nbsp;&nbsp;:author "" <br>&nbsp;&nbsp;:version "0.0,0" <br>&nbsp;&nbsp;:components <br>&nbsp;&nbsp;<span class="paren">(</span><span class="paren">(</span>:module :src :components <span class="paren">(</span><span class="paren">(</span>:file "packages"<span class="paren">)</span> <span class="paren">(</span>:file "flags" :depends-on <span class="paren">(</span>"packages"<span class="paren">)</span><span class="paren">)</span> <span class="paren">(</span>:file "defcfun" :depends-on <span class="paren">(</span>"packages" "flags"<span class="paren">)</span><span class="paren">)</span> <span class="paren">(</span>:file "cbuffer" :depends-on <span class="paren">(</span>"packages"<span class="paren">)</span><span class="paren">)</span> <span class="paren">(</span>:file "cbuffer-streams" :depends-on <span class="paren">(</span>"cbuffer"<span class="paren">)</span><span class="paren">)</span><span class="paren">)</span><span class="paren">)</span><span class="paren">)</span> <br>&nbsp;&nbsp;:depends-on <span class="paren">(</span>:cffi :mycl-util :trivial-gray-streams :flexi-streams<span class="paren">)</span><span class="paren">)</span> </p></span><span class"body"></span></pre
>
</div
......
......@@ -26,10 +26,7 @@
></div
>
<pre class="code"
><span class="first-line"><span class="paren">(</span>defstruct cbuffer</span><span class"body">
<span class="paren">(</span>data <span class="paren">(</span>foreign-alloc :uchar :count 16<span class="paren">)</span><span class="paren">)</span>
<span class="paren">(</span>size 0<span class="paren">)</span>
<span class="paren">(</span>length 16<span class="paren">)</span><span class="paren">)</span></span></pre
><span class="first-line"><p><span class="paren">(</span>defstruct cbuffer <br>&nbsp;&nbsp;<span class="paren">(</span>data <span class="paren">(</span>foreign-alloc :uchar :count 16<span class="paren">)</span><span class="paren">)</span> <br>&nbsp;&nbsp;<span class="paren">(</span>size 0<span class="paren">)</span> <br>&nbsp;&nbsp;<span class="paren">(</span>length 16<span class="paren">)</span><span class="paren">)</span> </p></span><span class"body"></span></pre
>
......@@ -90,11 +87,7 @@
>
<pre class="code"
><span class="first-line"><span class="paren">(</span>defcfun &quot;memcpy&quot;</span><span class"body">
:pointer
<span class="paren">(</span>dest :pointer<span class="paren">)</span>
<span class="paren">(</span>src :pointer<span class="paren">)</span>
<span class="paren">(</span>length :int<span class="paren">)</span><span class="paren">)</span></span></pre
><span class="first-line"><p><span class="paren">(</span>defcfun "memcpy" :pointer <br>&nbsp;&nbsp;<span class="paren">(</span>dest :pointer<span class="paren">)</span> <br>&nbsp;&nbsp;<span class="paren">(</span>src :pointer<span class="paren">)</span> <br>&nbsp;&nbsp;<span class="paren">(</span>length :int<span class="paren">)</span><span class="paren">)</span> </p></span><span class"body"></span></pre
>
<div class="computational-element-link computational-element-link-function"
......
......@@ -42,9 +42,7 @@
>
<pre class="code"
><span class="first-line"><span class="paren">(</span>def-construct flag-system</span><span class"body">
parent
<span class="paren">(</span>flags <span class="paren">(</span>make-hash-table<span class="paren">)</span><span class="paren">)</span><span class="paren">)</span></span></pre
><span class="first-line"><p><span class="paren">(</span>def-construct flag-system parent <br>&nbsp;&nbsp;<span class="paren">(</span>flags <span class="paren">(</span>make-hash-table<span class="paren">)</span><span class="paren">)</span><span class="paren">)</span> </p></span><span class"body"></span></pre
>
<div class="computational-element-link computational-element-link-function"
......
......@@ -26,66 +26,7 @@
></div
>
<pre class="code"
><span class="first-line"><span class="paren">(</span>defpackage :cffi-util</span><span class"body">
<span class="paren">(</span>:use :cl :cffi :mycl-util
:trivial-gray-streams
:flexi-streams<span class="paren">)</span>
<span class="paren">(</span>:export
;;flag-system
#:*current-flag-system*
#:make-flag-system #:flag-system-parent
#:find-flag-system
#:delete-flag-system
#:clear-flag-systems
#:use-flagsystem
#:def-flag-system
#:with-flag-system
#:direct-flag-value
#:flag-value
#:clear-flags
#:concat-flags
#:flags
#:def-flag
#:def-flag*
#:has-flag
#:flag-list
;;helpers
#:defcfun*
#:defmethod*
;;cbuffer
#:make-cbuffer
#:make-cbuffer-from-pointer
#:cbuffer-p
#:cbuffer-data
#:cbuffer-size
#:cbuffer-length
#:*use-cbuffer-pool*
#:*cbuffer-pool-max-size*
#:*cbuffer-pool-min-buffer-size*
#:*cbuffer-pool-max-buffer-size*
#:make-cbuffer-pool
#:*cbuffer-pool*
#:clear-cbuffer-pool
#:alloc-cbuffer
#:free-cbuffer
#:cbuffer-resize
#:cbuffer-eob-p
#:cbuffer-ensure-size
#:cbuffer-adjust-min-size
#:with-cbuffer
#:cbuffer-checkbounds
#:cbuffer-byte
#:make-cbuffer-input-stream
#:make-cbuffer-output-stream
#:stream-position
#:stream-cbuffer
<span class="paren">)</span><span class="paren">)</span></span></pre
><span class="first-line"><p><span class="paren">(</span>defpackage :cffi-util <br>&nbsp;&nbsp;<span class="paren">(</span>:use :cl :cffi :mycl-util :trivial-gray-streams :flexi-streams<span class="paren">)</span> <br>&nbsp;&nbsp;<span class="paren">(</span>:export <br>&nbsp;&nbsp;&nbsp;;;flag-system <br>&nbsp;&nbsp;&nbsp;#:<em>current-flag-system</em> <br>&nbsp;&nbsp;&nbsp;#:make-flag-system #:flag-system-parent <br>&nbsp;&nbsp;&nbsp;#:find-flag-system <br>&nbsp;&nbsp;&nbsp;#:delete-flag-system <br>&nbsp;&nbsp;&nbsp;#:clear-flag-systems <br>&nbsp;&nbsp;&nbsp;#:use-flagsystem <br>&nbsp;&nbsp;&nbsp;#:def-flag-system <br>&nbsp;&nbsp;&nbsp;#:with-flag-system <br>&nbsp;&nbsp;&nbsp;#:direct-flag-value <br>&nbsp;&nbsp;&nbsp;#:flag-value <br>&nbsp;&nbsp;&nbsp;#:clear-flags <br>&nbsp;&nbsp;&nbsp;#:concat-flags <br>&nbsp;&nbsp;&nbsp;#:flags <br>&nbsp;&nbsp;&nbsp;#:def-flag <br>&nbsp;&nbsp;&nbsp;#:def-flag* <br>&nbsp;&nbsp;&nbsp;#:has-flag <br>&nbsp;&nbsp;&nbsp;#:flag-list </p><p> ;;helpers <br>&nbsp;&nbsp;&nbsp;#:defcfun* <br>&nbsp;&nbsp;&nbsp;#:defmethod* </p><p> ;;cbuffer <br>&nbsp;&nbsp;&nbsp;#:make-cbuffer <br>&nbsp;&nbsp;&nbsp;#:make-cbuffer-from-pointer <br>&nbsp;&nbsp;&nbsp;#:cbuffer-p <br>&nbsp;&nbsp;&nbsp;#:cbuffer-data <br>&nbsp;&nbsp;&nbsp;#:cbuffer-size <br>&nbsp;&nbsp;&nbsp;#:cbuffer-length </p><p> #:<em>use-cbuffer-pool</em> <br>&nbsp;&nbsp;&nbsp;#:<em>cbuffer-pool-max-size</em> <br>&nbsp;&nbsp;&nbsp;#:<em>cbuffer-pool-min-buffer-size</em> <br>&nbsp;&nbsp;&nbsp;#:<em>cbuffer-pool-max-buffer-size</em> <br>&nbsp;&nbsp;&nbsp;#:make-cbuffer-pool <br>&nbsp;&nbsp;&nbsp;#:<em>cbuffer-pool</em> <br>&nbsp;&nbsp;&nbsp;#:clear-cbuffer-pool <br>&nbsp;&nbsp;&nbsp;#:alloc-cbuffer <br>&nbsp;&nbsp;&nbsp;#:free-cbuffer </p><p> #:cbuffer-resize <br>&nbsp;&nbsp;&nbsp;#:cbuffer-eob-p <br>&nbsp;&nbsp;&nbsp;#:cbuffer-ensure-size <br>&nbsp;&nbsp;&nbsp;#:cbuffer-adjust-min-size <br>&nbsp;&nbsp;&nbsp;#:with-cbuffer </p><p> #:cbuffer-checkbounds <br>&nbsp;&nbsp;&nbsp;#:cbuffer-byte <br>&nbsp;&nbsp;&nbsp;#:make-cbuffer-input-stream <br>&nbsp;&nbsp;&nbsp;#:make-cbuffer-output-stream <br>&nbsp;&nbsp;&nbsp;#:stream-position <br>&nbsp;&nbsp;&nbsp;#:stream-cbuffer </p><p> <span class="paren">)</span><span class="paren">)</span> </p></span><span class"body"></span></pre
>
</div
......
......@@ -14,9 +14,7 @@
><h2
>Documentation</h2
><blockquote
>WARNING: size must be smaller then length!!!
use cbuffer-ensure-size before using cbuffer-adjust-min-size
for example</blockquote
><p>WARNING: size must be smaller then length!!! use cbuffer-ensure-size before using cbuffer-adjust-min-size for example </p></blockquote
><h2
>Source</h2
><pre class="code"
......
......@@ -14,8 +14,7 @@
><h2
>Documentation</h2
><blockquote
>resizes cbuffer by creating a new one and copying the data along.
if new-size &lt; size then buffer may be truncated</blockquote
><p>resizes cbuffer by creating a new one and copying the data along. <br>&nbsp;&nbsp;&nbsp;if new-size < size then buffer may be truncated </p></blockquote
><h2
>Source</h2
><pre class="code"
......
......@@ -14,8 +14,7 @@
><h2
>Documentation</h2
><blockquote
>creates an integer using logior using a list of flags:
e.g. (concat-flags '(:append :create &lt;more-symbols&gt;))</blockquote
><p>creates an integer using logior using a list of flags: <br>&nbsp;&nbsp;&nbsp;e.g. (concat-flags '(:append :create <more-symbols>)) </p></blockquote
><h2
>Source</h2
><pre class="code"
......
......@@ -21,10 +21,16 @@
((member :flag arg) (create-flag-call arg))
((member :const arg) (fourth arg))
((member :class arg)
(let ((class-desc (second (member :class arg))))
`(slot-value ,name ',(if (listp class-desc)
(let* ((class-desc (second (member :class arg)))
(slot-val `(slot-value ,name
',(if (listp class-desc)
(second class-desc)
class-desc))))
(if (or (member :pointer arg)
(member :string arg))
`(if (or (not ,name) (not ,slot-val))
(null-pointer) ,slot-val)
slot-val)))
(t (if (or (member :pointer arg)
(member :string arg))
`(if (not ,name) (null-pointer) ,name)
......
......@@ -14,7 +14,7 @@
><h2
>Documentation</h2
><blockquote
>flag systems may be children of other flag systems</blockquote
><p>flag systems may be children of other flag systems </p></blockquote
><h2
>Source</h2
><pre class="code"
......
......@@ -14,7 +14,7 @@
><h2
>Documentation</h2
><blockquote
>returns a list of flags, which byte pattern is found in value</blockquote
><p>returns a list of flags, which byte pattern is found in value </p></blockquote
><h2
>Source</h2
><pre class="code"
......
......@@ -14,8 +14,7 @@
><h2
>Documentation</h2
><blockquote
>make-cbuffer-pool creates a priority-pool using the length
of buffers as priority... Largest Buffers have highest priority</blockquote
><p>make-cbuffer-pool creates a priority-pool using the length <br>&nbsp;&nbsp;&nbsp;of buffers as priority... Largest Buffers have highest priority </p></blockquote
><h2
>Source</h2
><pre class="code"
......
......@@ -14,7 +14,7 @@
><h2
>Documentation</h2
><blockquote
>same as def-flag, but creates a constant</blockquote
><p>same as def-flag, but creates a constant </p></blockquote
><h2
>Source</h2
><pre class="code"
......
......@@ -14,32 +14,7 @@
><h2
>Documentation</h2
><blockquote
>if ret-type is keyword :error-int the cfunction will return
an int indicating an error if ret!=0 and error-fun is called with using
the returned value
syntax: (defcfun* (name fun-name &lt;:error-fun symbol&gt; &lt;:method t|nil&gt;)
ret-type