Glenn Tarcea | 30 Aug 08:00
Favicon

BerkeleyDB Port Update/Question

Hi,

Is there a way to override the >>xxx xxx>> accessors?

The reason I ask is I have code in the BerkeleyDB interface I'm working on that looks as follows:

: <DB-ENV> ( -- DB-ENV/f )
    [let | err [ 0 <int> ] |
       0 err db_env_creat err *int [ \ DB-ENV new swap alien-address >>dbenv ] db-item-create ] ;

The db_env_creat routine is returning a pointer to a DB_ENV. This gets treated as a ALIEN: by factor, and I can't assign that to the >>dbenv write accessor (hence the call to alien-address, which ends up necessitating a later call like 'dbenv>> <alien>' when I need the value in dbenv). What I would like to do is to override >>dbenv to accept a ALIEN: . Or alternatively to have the >>dbenv and dbenv>> automatically do the translation.

Status:

I have basic operations working for BerkeleyDB. I also have interfaces for DB_ENV, DB, Cursors, Sequences, and Transactions. Some of the interfaces are touchy and are going through some refactoring. Currently you can open a DB and a DB_ENV, write to it, and close it. I'm not real happy with my read interface so its going through some changes. The approached I took with the interface was to create a separate set of C routines that hide the DB_ENV->xxx() calls. It also allows me to place the out parameters at the end of the function which allowed me to eliminate a lot of the stack shuffling. I took the C interface code from Elephant which is a persistent object store for Lisp and modified it for my needs.

Thanks,

Glenn

V. Glenn Tarcea
Hey brother, can you paradigm?





-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
Factor-talk@...
https://lists.sourceforge.net/lists/listinfo/factor-talk
Slava Pestov | 30 Aug 09:15

Re: BerkeleyDB Port Update/Question

Hi,

I don't understand the problem you're having with aliens. Aliens can be assigned to slots and there is never any reason to call alien-address and <alien> unless you need to do address arithmetic.

Slava

On Sat, Aug 30, 2008 at 1:02 AM, Glenn Tarcea <gtarcea-63aXycvo3TyHXe+LvDLADg@public.gmane.org> wrote:
Hi,

Is there a way to override the >>xxx xxx>> accessors?

The reason I ask is I have code in the BerkeleyDB interface I'm working on that looks as follows:

: <DB-ENV> ( -- DB-ENV/f )
    [let | err [ 0 <int> ] |
       0 err db_env_creat err *int [ \ DB-ENV new swap alien-address >>dbenv ] db-item-create ] ;

The db_env_creat routine is returning a pointer to a DB_ENV. This gets treated as a ALIEN: by factor, and I can't assign that to the >>dbenv write accessor (hence the call to alien-address, which ends up necessitating a later call like 'dbenv>> <alien>' when I need the value in dbenv). What I would like to do is to override >>dbenv to accept a ALIEN: . Or alternatively to have the >>dbenv and dbenv>> automatically do the translation.

Status:

I have basic operations working for BerkeleyDB. I also have interfaces for DB_ENV, DB, Cursors, Sequences, and Transactions. Some of the interfaces are touchy and are going through some refactoring. Currently you can open a DB and a DB_ENV, write to it, and close it. I'm not real happy with my read interface so its going through some changes. The approached I took with the interface was to create a separate set of C routines that hide the DB_ENV->xxx() calls. It also allows me to place the out parameters at the end of the function which allowed me to eliminate a lot of the stack shuffling. I took the C interface code from Elephant which is a persistent object store for Lisp and modified it for my needs.

Thanks,

Glenn

V. Glenn Tarcea
Hey brother, can you paradigm?






-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
Factor-talk-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/factor-talk


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
Factor-talk@...
https://lists.sourceforge.net/lists/listinfo/factor-talk
Glenn Tarcea | 31 Aug 00:33
Favicon

Re: BerkeleyDB Port Update/Question

Ok, nevermind... I'm not sure what I was doing but once I restarted factor I stopped getting an error on the generic word >>dbenv when trying to assign an alien.... I thought it was strange that the other FFI interfaces weren't doing the alien-address and <alien> rigamarole.

Glenn

On Aug 30, 2008, at 3:15 AM, Slava Pestov wrote:

Hi,

I don't understand the problem you're having with aliens. Aliens can be assigned to slots and there is never any reason to call alien-address and <alien> unless you need to do address arithmetic.

Slava

On Sat, Aug 30, 2008 at 1:02 AM, Glenn Tarcea <gtarcea-63aXycvo3TyHXe+LvDLADg@public.gmane.org> wrote:
Hi,

Is there a way to override the >>xxx xxx>> accessors?

The reason I ask is I have code in the BerkeleyDB interface I'm working on that looks as follows:

: <DB-ENV> ( -- DB-ENV/f )
    [let | err [ 0 <int> ] |
       0 err db_env_creat err *int [ \ DB-ENV new swap alien-address >>dbenv ] db-item-create ] ;

The db_env_creat routine is returning a pointer to a DB_ENV. This gets treated as a ALIEN: by factor, and I can't assign that to the >>dbenv write accessor (hence the call to alien-address, which ends up necessitating a later call like 'dbenv>> <alien>' when I need the value in dbenv). What I would like to do is to override >>dbenv to accept a ALIEN: . Or alternatively to have the >>dbenv and dbenv>> automatically do the translation.

Status:

I have basic operations working for BerkeleyDB. I also have interfaces for DB_ENV, DB, Cursors, Sequences, and Transactions. Some of the interfaces are touchy and are going through some refactoring. Currently you can open a DB and a DB_ENV, write to it, and close it. I'm not real happy with my read interface so its going through some changes. The approached I took with the interface was to create a separate set of C routines that hide the DB_ENV->xxx() calls. It also allows me to place the out parameters at the end of the function which allowed me to eliminate a lot of the stack shuffling. I took the C interface code from Elephant which is a persistent object store for Lisp and modified it for my needs.

Thanks,

Glenn

V. Glenn Tarcea
Hey brother, can you paradigm?






-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
Factor-talk-5NWGOfrQmncRDUWM+popnw@public.gmane.orgforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
Factor-talk mailing list

V. Glenn Tarcea
Hey brother, can you paradigm?





-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
Factor-talk@...
https://lists.sourceforge.net/lists/listinfo/factor-talk
Slava Pestov | 30 Aug 09:19

Re: BerkeleyDB Port Update/Question

Another tip: you can write this word without using locals.

: <DV-ENV> ( -- DB-ENV/f )
    0 0 <int> [ db_env_creat ] keep *int [ \ DB-ENV new swap alien-address >>dbenv ] db-item-create ;

Finally, in Factor we throw errors instead of returning null on error, so it is better to have your word check for an error condition and throw an error instead of returning f (assuming that's really what it does).

Slava

On Sat, Aug 30, 2008 at 1:02 AM, Glenn Tarcea <gtarcea-63aXycvo3TyHXe+LvDLADg@public.gmane.org> wrote:
Hi,

Is there a way to override the >>xxx xxx>> accessors?

The reason I ask is I have code in the BerkeleyDB interface I'm working on that looks as follows:

: <DB-ENV> ( -- DB-ENV/f )
    [let | err [ 0 <int> ] |
       0 err db_env_creat err *int [ \ DB-ENV new swap alien-address >>dbenv ] db-item-create ] ;

The db_env_creat routine is returning a pointer to a DB_ENV. This gets treated as a ALIEN: by factor, and I can't assign that to the >>dbenv write accessor (hence the call to alien-address, which ends up necessitating a later call like 'dbenv>> <alien>' when I need the value in dbenv). What I would like to do is to override >>dbenv to accept a ALIEN: . Or alternatively to have the >>dbenv and dbenv>> automatically do the translation.

Status:

I have basic operations working for BerkeleyDB. I also have interfaces for DB_ENV, DB, Cursors, Sequences, and Transactions. Some of the interfaces are touchy and are going through some refactoring. Currently you can open a DB and a DB_ENV, write to it, and close it. I'm not real happy with my read interface so its going through some changes. The approached I took with the interface was to create a separate set of C routines that hide the DB_ENV->xxx() calls. It also allows me to place the out parameters at the end of the function which allowed me to eliminate a lot of the stack shuffling. I took the C interface code from Elephant which is a persistent object store for Lisp and modified it for my needs.

Thanks,

Glenn

V. Glenn Tarcea
Hey brother, can you paradigm?






-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
Factor-talk-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/factor-talk


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
Factor-talk@...
https://lists.sourceforge.net/lists/listinfo/factor-talk
Glenn Tarcea | 31 Aug 00:35
Favicon

Re: BerkeleyDB Port Update/Question

Ahhh... that is much cleaner. I've also changed over to throwing an error. Thanks for the pointers.

Glenn

On Aug 30, 2008, at 3:19 AM, Slava Pestov wrote:

Another tip: you can write this word without using locals.

: <DV-ENV> ( -- DB-ENV/f )
    0 0 <int> [ db_env_creat ] keep *int [ \ DB-ENV new swap alien-address >>dbenv ] db-item-create ;

Finally, in Factor we throw errors instead of returning null on error, so it is better to have your word check for an error condition and throw an error instead of returning f (assuming that's really what it does).

Slava

On Sat, Aug 30, 2008 at 1:02 AM, Glenn Tarcea <gtarcea-63aXycvo3TyHXe+LvDLADg@public.gmane.org> wrote:
Hi,

Is there a way to override the >>xxx xxx>> accessors?

The reason I ask is I have code in the BerkeleyDB interface I'm working on that looks as follows:

: <DB-ENV> ( -- DB-ENV/f )
    [let | err [ 0 <int> ] |
       0 err db_env_creat err *int [ \ DB-ENV new swap alien-address >>dbenv ] db-item-create ] ;

The db_env_creat routine is returning a pointer to a DB_ENV. This gets treated as a ALIEN: by factor, and I can't assign that to the >>dbenv write accessor (hence the call to alien-address, which ends up necessitating a later call like 'dbenv>> <alien>' when I need the value in dbenv). What I would like to do is to override >>dbenv to accept a ALIEN: . Or alternatively to have the >>dbenv and dbenv>> automatically do the translation.

Status:

I have basic operations working for BerkeleyDB. I also have interfaces for DB_ENV, DB, Cursors, Sequences, and Transactions. Some of the interfaces are touchy and are going through some refactoring. Currently you can open a DB and a DB_ENV, write to it, and close it. I'm not real happy with my read interface so its going through some changes. The approached I took with the interface was to create a separate set of C routines that hide the DB_ENV->xxx() calls. It also allows me to place the out parameters at the end of the function which allowed me to eliminate a lot of the stack shuffling. I took the C interface code from Elephant which is a persistent object store for Lisp and modified it for my needs.

Thanks,

Glenn

V. Glenn Tarcea
Hey brother, can you paradigm?






-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
Factor-talk-5NWGOfrQmncRDUWM+popnw@public.gmane.orgforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
Factor-talk mailing list

V. Glenn Tarcea
Hey brother, can you paradigm?





-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
Factor-talk@...
https://lists.sourceforge.net/lists/listinfo/factor-talk

Gmane