prs-de / ffidl Goto Github PK
View Code? Open in Web Editor NEWFfidl for Tcl8.6
Home Page: https://prs-de.github.io/ffidl/
License: Other
Ffidl for Tcl8.6
Home Page: https://prs-de.github.io/ffidl/
License: Other
------------------------------------------------------------------------ Ffidl Version 0.7 Copyright (c) 1999 by Roger E Critchlow Jr, Santa Fe, NM, USA [email protected] Changes since ffidl 0.5 are under BSD License and are Copyright (c) 2005, Daniel A. Steffen <[email protected]> Changes since ffidl 0.6 are under BSD License and are Copyright (c) 2015-2021, Patzschke + Rasp Software GmbH, Wiesbaden ------------------------------------------------------------------------ Ffidl allows you to define Tcl/Tk extensions with pure Tcl wrappers calling any shared library installed on your system, including the Tcl and Tk core libraries. Documentation can be found at doc/ffidl.html. license.terms specifies the license under which Ffidl is distributed, and that there is NO WARRANTY. lib-src/libffi/LICENSE specifies the license under which libffi is distributed, and that there is NO WARRANTY. lib-src/ffcall/COPYING specifies the license under which ffcal is distributed, and that there is NO WARRANTY. ------------------------------------------------------------------------
Hello @ecky-l (writing the ticket here as there's no "Issues" in your fork). I've seen you've made many improvements to Ffidl in your fork. I'm keen on including them here. Would you like helping in doing that?
Apply the following changes to make Ffidl work with Tcl/Tk 8.7.a5:
See http://www.androwish.org/index.html/timeline?chng=jni/ffidl/*.
Must open a ticket.
I think that Code1 at the end of ffidlrt.tcl can be replaced by Code2, but is there no problem?
Because I would like to statically link Ffidl with Tcl using Tcl_StaticPackage C-function.
Code1: (original)
::ffidl::callout ::ffidl::pointer-into-string {pointer} pointer-utf8 [::ffidl::symbol [::ffidl::find-lib ffidl] ffidl_pointer_pun]
::ffidl::callout ::ffidl::pointer-into-unicode {pointer} pointer-utf16 [::ffidl::symbol [::ffidl::find-lib ffidl] ffidl_pointer_pun]
Code2: (new)
::ffidl::callout ::ffidl::_pointer-into-string {pointer pointer int} pointer-utf8 [::ffidl::symbol [::ffidl::find-lib c] memcpy]
proc ::ffidl::pointer-into-string {pointer} {
::ffidl::_pointer-into-string $pointer 0 0
}
::ffidl::callout ::ffidl::_pointer-into-unicode {pointer pointer int} pointer-utf16 [::ffidl::symbol [::ffidl::find-lib c] memcpy]
proc ::ffidl::pointer-into-unicode {pointer} {
::ffidl::_pointer-into-unicode $pointer 0 0
}
On Windows, you can use ffidl even if you pack ffidl into tclkit (built by KitCreator) by removing the directory name from the return string of find-pkg-lib function in ffidlrt.tcl.
Because Microsoft describes about LoadLibrary function that "if lpFileName does not include a path and there is more than one loaded module with the same base name and extension, the function returns a handle to the module that was loaded first".
(cf. https://msdn.microsoft.com/ja-jp/library/ms684175(v=vs.85).aspx )
Original (failed when "package require Ffidlrt"):
proc ::ffidl::find-pkg-lib {pkg} {
package require $pkg
foreach i [::info loaded {}] {
foreach {l p} $i {}
if {$p eq "$pkg"} {
return $l
}
}
# ignore errors when running under pkg_mkIndex:
if {![llength [info commands __package_orig]] } {
return -code error "Library for package $pkg not found"
}
}
Revised:
proc ::ffidl::find-pkg-lib {pkg} {
package require $pkg
foreach i [::info loaded {}] {
foreach {l p} $i {}
if {$p eq "$pkg"} {
return [file tail $l]
}
}
# ignore errors when running under pkg_mkIndex:
if {![llength [info commands __package_orig]] } {
return -code error "Library for package $pkg not found"
}
}
@recri, @ecky-l, @yanako: could you help testing the new beta https://github.com/prs-de/ffidl/releases/tag/0.8b0?
Hello,
If trying to [package require Ffidlrt 0.2] from a starkit and Tclkit, you get the error
couldn't load file "libFfidl0.7.so" : libFfidl0.7.so: cannot open shared object file: No such file or directory
while executing
"::ffidl::symbol [::ffidl::find-lib ffidl] ffidl_pointer_pun"
...
Reason are the calls to ::ffidl::symbol [::ffidl::find-lib ffidl]
in lines 307 and 308.
ffidl::find-lib
searches for the library in a directory, which is not possible within the VFS of a starkit. A solution would be to create a stubs table for ffidl itself, which exposes ffidl_pointer_pun
as stub function (see here on how to do this). Then use ffidl::stubsymbol
to resolve that function, rather than trying to resolve the symbol within the library itself with ffidl::symbol
.
After running ./configure
, my attempt to build ffidl
on MSYS2 (64-bit) failed during linking, as follows:
$ make
gcc -DHAVE_CONFIG_H -DHAVE_FFIDL_CONFIG_H -DFFI_BUILDING=static -I. -I"/mingw64/include/tcl8.6/tcl-private/generic" -I"/mingw64/include/tcl8.6/tcl-private/win" -pipe -O2 -fomit-frame-pointer -DNDEBUG -Wall -c
echo ./generic/ffidl.c -o ffidl.o
gcc -DHAVE_CONFIG_H -DHAVE_FFIDL_CONFIG_H -DFFI_BUILDING=static -I. -I"/mingw64/include/tcl8.6/tcl-private/generic" -I"/mingw64/include/tcl8.6/tcl-private/win" -pipe -O2 -fomit-frame-pointer -DNDEBUG -Wall -c
echo ./generic/ffidl_test.c -o ffidl_test.o
rm -f Ffidl09.dll
gcc -shared -o Ffidl09.dll ffidl.o ffidl_test.o -lC:/msys64/mingw64/lib/libffi "/mingw64/lib/libtclstub86.a" -static-libgcc
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lC:/msys64/mingw64/lib/libffi: Invalid argument
collect2.exe: error: ld returned 1 exit status
make: *** [GNUmakefile:258: Ffidl09.dll] Error 1
Linking worked once I changed the link command to:
gcc -shared -o Ffidl09.dll ffidl.o ffidl_test.o -lffi "/mingw64/lib/libtclstub86.a" -static-libgcc
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.