| Did you know ... | Search Documentation: |
| Packs (add-ons) for SWI-Prolog |
| Title: | SWI-Prolog interface to C/C++/.NET/Mono/Objective-C |
|---|---|
| Rating: | Not rated. Create the first rating! |
| Latest version: | 2.0.0 |
| SHA1 sum: | 575d4db97338db9f1cfc9413c8a878e7a01a48d9 |
| Author: | Douglas Miles http://www.linkedin.com/in/logicmoo |
| Maintainer: | Douglas Miles http://www.linkedin.com/in/logicmoo |
| Packager: | Douglas Miles http://www.linkedin.com/in/logicmoo |
| Home page: | https://github.com/swi-to-yap/swicli |
| Download URL: | https://github.com/swi-to-yap/swicli/release/*.zip |
| Provides: | swicffi |
No reviews. Create the first review!.
| Version | SHA1 | #Downloads | URL |
|---|---|---|---|
| 2.0.0 | 356b70bbe95b18b6ebe809a15cc50fd8f952935a | 27 | https://github.com/logicmoo/swicli.git |
| 575d4db97338db9f1cfc9413c8a878e7a01a48d9 | 8 | https://github.com/logicmoo/swicli.git | |
| 444b5ca36896fe1840657923474d367cdded8c6c | 20 | https://github.com/logicmoo/swicli.git | |
| 1.1.3 | e565a6eb7998b56cba0aa6697ca9a5addc9a0f5d | 1 | https://github.com/logicmoo/swicli.git |
| https://github.com/swi-to-yap/swicli.git | |||
| 1.1.2 | bf79d7208f85c91b39632b243c7d69d4a35d600c | 1 | https://github.com/logicmoo/swicli.git |
| 1.1.1 | 2b93da7fce90fd8a163ef4b7ecdf13979e4baad8 | 9 | https://github.com/logicmoo/swicli/archive/1.1.1.zip |
| de4ac385c68656862a7cb12d0426d20af94aeba2 | 1 | https://github.com/logicmoo/swicli.git | |
| 95d3b40c6e4f8f635e21a678a0081b98d90de49b | 2 | https://github.com/logicmoo/swicli.git | |
| e60360cb71b46646038c2f6fb29faf0ee05cd144 | 2 | https://github.com/logicmoo/swicli.git | |
| 2d080fd15dba573c5ae981841248035577917a30 | 2 | https://github.com/logicmoo/swicli.git | |
| 1.0.2 | 006dd61d6eea5987fe13dfef0971027f3fd76932 | 17 | http://logicmoo.org/downloads/packs/swicli-1.0.2.zip |
| 1.0.1 | 5ad26122630974d5d0c9d17840b780077353b05a | 2 | http://logicmoo.org/downloads/packs/swicli-1.0.1.zip |
| 1.0.0 | cac8d1de69ef5d4dde6b2abe3882ed536fd16d25 | 1 | http://www.logicmoo.org/devel/swicli-1.0.0.zip |
YAP/SWI-Prolog 2-Way interface to Common Language Infrastructure (.NET)
====
== [http://code.google.com/p/opensim4opencog/downloads/list Download] == The File named (SWICLI-xxx-DIST-xxxx.zip) == [https://github.com/swi-to-yap/swicli Sourcecode] ==
== [http://swi-to-yap.github.io/swicli/api.html Documentation] ==
== [http://swi-to-yap.github.io/swicli/documentation.html Old Docs] ==
Example of Prject that uses it:
=== MS windows requires .NET 4.0 or above === Copy these two directories onto your Prolog Install Dir. {{{
Copy pl\bin to your c:\program files[x86]\swipl\bin Folder Copy pl\library to your c:\program files[x86]\swipl\library Folder
Install .NET 4.0
And thats it!
pl//bin/ pl/library/ }}}
=== Linux OS/X requires Mono (2.10.8+) === Ubuntu: apt-get install mono-devel libmono-system-Data-Linq4.0-cil libmono-system-xml-Linq4.0-cil libmono-microsoft-visualbasic10.0-cil Copy these two directories onto your Prolog Install Dir {{{ pl/lib/ pl/library/ }}}
== Running / Examples == {{{
root@titan:~# swipl Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.1.26) Copyright (c) 1990-2014 University of Amsterdam, VU Amsterdam SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
?- use_module(library(swicffi)).
SetupProlog
Cannot install hook ThreadExit to Mono Swicli.Library.Embedded.install suceeded true.
?- cli_get_dll('libc.so.6',DLL),cli_call(DLL,printf,["I have been clicked %d times\n", 2],O).
I have been clicked 2 times
DLL = @'C#666',
O = @void.
?-
}}} {{{ [root@titan bin]# . mono_sysvars.sh [root@titan bin]# swipl Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 6.0.2) Copyright (c) 1990-2011 University of Amsterdam, VU Amsterdam SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
?- use_module(library(swicli)).
SetupProlog
RegisterPLCSForeigns
done RegisterPLCSForeigns
Swicli.Library.Embedded.install suceeded
% library(swicli) compiled into swicli 2.00 sec, 1,411 clauses
true.
?- cli_call('System.Threading.ThreadPool','GetAvailableThreads'(X,Y),_).
X = 200,
Y = 8.
}}}
{{{
?- cli_new('System.Collections.Generic.List'('System.String'),[int],[10],Obj).
Obj = @'C#516939544'.
}}}
{{{
?- cli_get($Obj,'Count',Out).
Out = 0.
}}}
{{{
?- cli_call($Obj,'Add'("foo"),Out).
Out = @void.
}}}
{{{
?- cli_call($Obj,'Add'("bar"),Out).
Out = @void.
}}}
{{{
?- cli_get($Out,'Count',Out).
Out = 2.
}}}
{{{
?- cli_col($Obj,E).
E = "foo" ;
E = "bar" ;
false.
}}}
{{{
?- cli_get_type($Obj,Type),cli_get_typename(Type,Name).
Type = @'C#516939520',
Name = 'System.Collections.Generic.List`1[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'.
}}}
{{{
?- cli_get_type($Obj,Type), cli_to_typespec(Type,Name).
Type = @'C#516939520',
Name = 'System.Collections.Generic.List'('String').
?- cli_get_typespec($Obj,Type).
Type = 'System.Collections.Generic.List'('String').
}}}
{{{
?- cli_shorttype(stringl,'System.Collections.Generic.List'('String')).
true.
}}}
{{{
?- cli_new(stringl,[],O).
O = @'C#516939472'.
}}}
{{{
?- cli_get_type($O,Type),cli_typespec(Type,Name).
Type = @'C#516939520',
Name = 'System.Collections.Generic.List'('String').
}}}
cli_add_event_handler( +Class_or_Object, +EventName, +PredicateIndicator) :-
==ADDING A NEW EVENT HOOK==
We already at least know that the object we want to hook is found via our call to
{{{
?- botget(['Self'],AM).
}}}
So we ask for the e/7 (event handlers of the members)
{{{
?- botget(['Self'],AM),cli_memb(AM,e(A,B,C,D,E,F,G)).
}}}
Press ;;;; a few times until you find the event Name you need (in the B var)
{{{
A = 6, % index number
B = 'IM', % event name
C = 'System.EventHandler'('InstantMessageEventArgs'), % the delegation type
D = ['Object', 'InstantMessageEventArgs'], % the parameter types (2)
E = [], % the generic paramters
F = decl(static(false), 'AgentManager'), % the static/non static-ness.. the declaring class
G = access_pafv(true, false, false, false) % the PAFV bits
}}}
So reading the parameter types "['Object', 'InstantMessageEventArgs']" lets you know the predicate needs at least two arguments
And "F = decl(static(false), 'AgentManager')" says add on extra argument at start for Origin
handle_im(Origin,Obj,IM)*
So registering the event is done:
{{{
?- botget(['Self'],AM), cli_add_event_handler(AM,'IM',handle_im(_Origin,_Object,_InstantMessageEventArgs))
}}}
To target a predicate such as:
{{{
handle_im(Origin,Obj,IM):-writeq(handle_im(Origin,Obj,IM)),nl.
}}}
= Release notes =
== TODO == # Publish the autoload examples (to website - outside of this package)
== 0.7 == # Started making release notes # The PL_agc_hook (Atom GC) tracker for deciding when to GC foriegn objects # Added the dynamic registrations for exit and abort hooks
Pack contains 1,032 files holding a total of 86.4M bytes.