Skip to content

Commit

Permalink
Update redis library to also support Ciao Prolog (work-in-progress)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmoura committed May 27, 2020
1 parent 88901f5 commit d67d7e6
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/_sources/index.rst.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/_sources/redis_0.rst.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/redis_0.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion library/redis/loader.lgt
Expand Up @@ -18,7 +18,15 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


:- if(current_logtalk_flag(prolog_dialect, eclipse)).
:- if(current_logtalk_flag(prolog_dialect, ciao)).

:- use_module(library(sockets), []).
:- initialization((
logtalk_load(basic_types(loader)),
logtalk_load(redis, [optimize(on)])
)).

:- elif(current_logtalk_flag(prolog_dialect, eclipse)).

:- initialization((
logtalk_load(basic_types(loader)),
Expand Down
14 changes: 11 additions & 3 deletions library/redis/redis.lgt
Expand Up @@ -21,9 +21,9 @@
:- object(redis).

:- info([
version is 0:3:0,
version is 0:4:0,
author is 'Paulo Moura',
date is 2017-06-29,
date is 2020-05-27,
comment is 'Redis client. Inspired by Sean Charles GNU Prolog Redis client.',
remarks is [
'Command representation' - 'Use the Redis command name as the functor of a compound term where the arguments are the command arguments.',
Expand Down Expand Up @@ -114,7 +114,15 @@
% backend Prolog compiler dependent auxiliary predicates
% (there is not standard sockets Prolog library)

:- if(current_logtalk_flag(prolog_dialect, eclipse)).
:- if(current_logtalk_flag(prolog_dialect, ciao)).

connect_to_server(Host, Port, redis(Stream, Stream, _)) :-
sockets:connect_to_socket(Host, Port, Stream).

disconnect_from_server(redis(Stream, _, _)) :-
sockets:socket_shutdown(Stream, read_write).

:- elif(current_logtalk_flag(prolog_dialect, eclipse)).

connect_to_server(Host, Port, redis(Stream, Stream, _)) :-
socket(internet, stream, Stream),
Expand Down
6 changes: 4 additions & 2 deletions library/redis/tester.lgt
Expand Up @@ -20,7 +20,7 @@

:- if((
current_logtalk_flag(prolog_dialect, Dialect),
Dialect \== eclipse, Dialect \== gnu, Dialect \== qp, Dialect \== sicstus, Dialect \== swi, Dialect \== xsb
Dialect \== ciao, Dialect \== eclipse, Dialect \== gnu, Dialect \== qp, Dialect \== sicstus, Dialect \== swi, Dialect \== xsb
)).

:- initialization((
Expand All @@ -29,7 +29,9 @@

:- else.

:- if(current_logtalk_flag(prolog_dialect, sicstus)).
:- if(current_logtalk_flag(prolog_dialect, ciao)).
:- use_module(library(system), []).
:- elif(current_logtalk_flag(prolog_dialect, sicstus)).
:- use_module(library(system), []).
:- elif(current_logtalk_flag(prolog_dialect, xsb)).
:- import(from(/(sleep,1), shell)).
Expand Down
8 changes: 5 additions & 3 deletions library/redis/tests.lgt
Expand Up @@ -22,9 +22,9 @@
extends(lgtunit)).

:- info([
version is 0:2:0,
version is 0:3:0,
author is 'Sean Charles. Adapted to Logtalk by Paulo Moura',
date is 2020-01-25,
date is 2020-05-27,
comment is 'Unit tests for the "redis" library.'
]).

Expand All @@ -38,7 +38,9 @@
length/2
]).

:- if(current_logtalk_flag(prolog_dialect, sicstus)).
:- if(current_logtalk_flag(prolog_dialect, ciao)).
:- use_module(system, [pause/1 as sleep/1]).
:- elif(current_logtalk_flag(prolog_dialect, sicstus)).
:- use_module(system, [sleep/1]).
:- elif(current_logtalk_flag(prolog_dialect, qp)).
:- uses(user, [thread_sleep/1 as sleep/1]).
Expand Down

0 comments on commit d67d7e6

Please sign in to comment.