use Perl Daily Newsletter In this issue: * Ctypes for Perl: Intro and API spec * News: Rakudo Perl 6 development release #29 * New CPAN Distributions for May 23, 2010
+--------------------------------------------------------------------+ | Ctypes for Perl: Intro and API spec | | posted by brian_d_foy on Sunday May 23, @07:50 (User Journal) | | http://use.perl.org/article.pl?sid=10/05/23/1130259 | +--------------------------------------------------------------------+ Hello, good evening and welcome. For the next few months I will be using this blog to help document and publicise my "[0]Ctypes for Perl" project. The project is being carried out for TPF under the auspices of the [1]Google Summer of Code programme, and mentored by [2]Reini Urban. What's a ctypes? '[3]ctypes' is the [4]Foreign Function Interface (FFI) library distributed with the Python core. It basically allows native C libraries to be called easily from Python; for module authors, it allows the wrapping of C libraries in pure Python. This is obviously a powerful concept. Imagine a world where Perl module authors didn't need to use XS, and module consumers don't need to have a correctly configured compiler set up on their system. This is the purpose of the project: to create an easy, cross-platform, pure-Perl interface to native C libraries. Implementations ctypes is based on [5]libffi. It's small, supports a wide range of systems, and has a very [6]liberal license. It's been distributed with GCC for a number of years, used by gcj for interfacing between interpreted and compiled code. >From what I can gather, Python set the trend in dynamic languages using libffi. Looking at the success of the Python module, developers at Mozilla chose libffi to develop [7]ctypes.jsm. [8]Ruby-FFI uses it too, so there's plenty of prior art which will hopefully help me out. The FFI problem hasn't been ignored in the Perl world. There's [9]FFI.pm, the biggest disadvantage of which in my view is being built on libffcall, a library analogous to libffi but under the GPL (I don't think libffi was around at the time FFI.pm was written). It also sets out to provide a 'low-level' interface. [10]P5NCI, on the other hand, is all about the lovely interfaces, but only allows up to four arguments passed to C functions, and doesn't yet support passing in pointers. [11]C::Dynalib provides similar functionality to the other two modules; [12]click here for the latest updates on its development. It's worth pointing out that none of these modules worked out of the box on Strawberry 5.10.1. My proposed API rolls in features of several of the above implementations, particularly P5NCI and FFI.pm. I have indeed copied and pasted swathes from their POD pages (So what? Wanna fight about it?). I plan to also mimic C::DynaLib's acceptance of both positional & named parameters; examples are omitted below for succinctness. 1. Functional use Ptypes; # FFI.pm's interface of Absolute Freedom... my $addr = (address of a C function) my $signature = (function signature) my $ret = Ptypes::call($addr, $signature, ...); # Keeping things where you can see them... my $library_path = Ptypes::find_lib( 'mathtastic' ); my $library = Ptypes::load_lib( $library_path ); my $double_func = Ptypes::load_func( $library, 'double_double', 'dd' ); my $ret = $double_func->( 1.0 ); # Supplying a Perl callback... $ret = Ptypes::call($addr, $signature, $subref, ...) 2. Objectionable use Ptypes; my $lib = Ptypes->new( library => 'mathtastic' [, package => 'MyPackage' ] ); my $double_func = $lib->load_function( 'double_double', 'dd' ); my $ret = $double_func->( 1.0 ); # Exposing funcs directly in Perl namespaces... $lib->install_function( 'double_int', 'ii' [, 'perl_sub_name', 'AnotherPackage' ] ); my $ret = AnotherPackage::double_int( 1 ); # or simply... package AnotherPackage; my $ret = double_int( 3 ); All fairly self-explanatory, perhaps apart from arguments like 'ii' or 'dd' - these strings describe return values and arguments for C functions in the same notation used by [13]pack. In addition to the above, the module may provide mechanisms for manipulating C data types directly from Perl ($c = new Ptypes::char). To start off with though there'll be a fairly straight-forward / 'stupid' translation based on seeing what kind of data's in your SV*, for initial experimentation. There's also some exciting stuff to do with [14]GCC::TranslationUnit to tell you about, but details of that will wait till later. For now, I have some questions for you, the community: * How d'you like the API proposal above? Anything you'd add? Take out? * How does 'Ptypes' take you as a name for this malarky? Y'know, like ctypes, but for Perl. 'FFI' is already taken after all... Don't want to gush here, but I'm so chuffed* to be working on this. I'm already learning loads, and I think it will save a lot of blood, sweat & tears for module authors and users in the future. I want to thank rurban for his guidance & help so far, and dukeleto and others for organising the The Perl Foundation's participation in GSoC and letting me participate! I like to work log, so follow @doubious_code on Twitter to get far more information than you want about this project. I hope to be blogging pretty regularly too. * For American-speakers, 'chuffed' is kinda equivalent to 'stoked' Discuss this story at: http://use.perl.org/comments.pl?sid=10/05/23/1130259 Links: 0. http://socghop.appspot.com/gsoc/student_project/show/google/gsoc2010/tpf/t127230763807 1. http://code.google.com/soc/ 2. http://blogs.perl.org/users/rurban 3. http://starship.python.net/crew/theller/ctypes/ 4. http://en.wikipedia.org/wiki/Foreign_function_interface 5. http://sourceware.org/libffi/ 6. http://github.com/atgreen/libffi/blob/master/LICENSE 7. https://developer.mozilla.org/en/JavaScript_code_modules/ctypes.jsm 8. http://wiki.github.com/ffi/ffi/ 9. http://search.cpan.org/~gaal/FFI-1.04/FFI.pm 10. http://search.cpan.org/~chromatic/P5NCI-0.31/lib/P5NCI.pm 11. http://search.cpan.org/~rurban/C-DynaLib-0.60/lib/C/DynaLib.pm 12. http://blogs.perl.org/users/rurban/2010/05/cdynalib-progress.html 13. http://perldoc.perl.org/functions/pack.html 14. http://search.cpan.org/~awin/GCC-TranslationUnit-1.00/TranslationUnit.pm +--------------------------------------------------------------------+ | News: Rakudo Perl 6 development release #29 | | posted by brian_d_foy on Sunday May 23, @07:50 (Perl 6) | | http://use.perl.org/article.pl?sid=10/05/23/1130246 | +--------------------------------------------------------------------+ [0]colomon writes "On behalf of the Rakudo development team, I'm pleased to announce theMay 2010 development release of Rakudo Perl #29 "Erlangen". Rakudo is an implementation of Perl 6 on the Parrot Virtual Machine (see [1]http://www.parrot.org./ The tarball for the May 2010 release is available from [2]http://github.com/rakudo/rakudo/downloads . Rakudo Perl follows a monthly release cycle, with each release named after a Perl Mongers group. The May 2010 release is code named "Erlangen" in recognition of Erlangen.pm and the Perl 6 talk that Moritz Lenz, one of our core developers, gave this month. Some of the specific changes and improvements occurring with this release include: * Lexical classes and roles were implemented. Additionally, anonymous classes which were never quite right in alpha are now implemented more correctly, and anonymous roles are also supported. * Basic support for named enumerations of the form 'enum Weekday ' has been restored. * First cut of use Foo:from and eval('foo', :lang); needs Blizkost[1] to be installed to work. * Numeric / Real roles much closer to the spec now. * As always, many additional small features and bug fixes make working with Rakudo more pleasant. * Rakudo now passes 32,347 spectests. We estimate that there are about 39,500 tests in the test suite, so Rakudo passes about 82% of all tests. For a more detailed list of changes see "docs/ChangeLog". The development team thanks all of our contributors and sponsors for making Rakudo Perl possible, as well as those people who worked on parrot, the Perl 6 test suite and the specification. The following people contributed to this release: Solomon Foster, Moritz Lenz, Jonathan Worthington, Martin Berends, chromatic, Carl Masak, snarkyboojum, Stefan O'Rear, Reini Urban, Jonathan Scott Duff, takadonet, Christoph Otto, isBEKaml, ash_, bubaflub, Jimmy Zhuo, Peter Lobsinger and Patrick Abi Salloum If you would like to contribute, see [3]http://rakudo.org/how-to-help , ask on the perl6-compi...@perl.org mailing list, or ask on IRC #perl6 on freenode. The next release of Rakudo (#30) is scheduled for June 17, 2010. A list of the other planned release dates and code names for 2010 is available in the "docs/release_guide.pod" file. In general, Rakudo development releases are scheduled to occur two days after each Parrot monthly release. Parrot releases the third Tuesday of each month. Have fun! [1] [4]http://github.com/jnthn/blizkost" Discuss this story at: http://use.perl.org/comments.pl?sid=10/05/23/1130246 Links: 0. mailto:colo...@gmail.com 1. http://www.parrot.org./ 2. http://github.com/rakudo/rakudo/downloads 3. http://rakudo.org/how-to-help 4. http://github.com/jnthn/blizkost +--------------------------------------------------------------------+ | New CPAN Distributions for May 23, 2010 | | posted by pudge on Sunday May 23, @11:30 (Module Listings) | | http://use.perl.org/article.pl?sid=10/05/23/1530207 | +--------------------------------------------------------------------+ * [0]Algorithm-Networksort-1.09 -- Create Sorting Networks. * [1]Apache2-WebApp-Extra-Admin-0.10 -- Web based admin control panel * [2]App-TinyMVC-0.01_1 -- A lightweight MVC framework for dynamic content * [3]App-TinyMVC-0.01_2 -- A lightweight MVC framework for dynamic content * [4]App-perlbrew-0.07 -- Manage perl installations in your $HOME * [5]App-perlzonji-1.101420 -- A more knowledgeable perldoc * [6]Attribute-SubName-1.101420 -- Naming anonymous subroutines via attributes * [7]CHI-Driver-DBI-1.23 -- Use DBI for cache * [8]Carp-Source-1.101420 -- Warn of errors with stack backtrace and source context * [9]Catalyst-View-Email-0.30 -- Send Email from Catalyst * [10]Cindy-0.11 -- use unmodified XML or HTML documents as templates. * [11]Cindy-Apache2-0.04 -- use unmodified XML or HTML documents as templates. * [12]Class-Action-0.4 -- Basic command pattern obj undo/rollback actions * [13]Class-Factory-Enhanced-1.101420 -- More functionality for Class::Factory * [14]Class-Null-2.101420 -- Implements the Null Class design pattern * [15]DBIx-Class-Schema-Loader-0.07000 -- Dynamic definition of a DBIx::Class::Schema * [16]Devel-REPL-1.003010 -- a modern perl interactive shell * [17]Dist-Zilla-3.101421 -- distribution builder; installer not included! * [18]Dist-Zilla-Plugin-AutoVersion-Relative-0.01027903 -- Time-Relative versioning * [19]Dist-Zilla-Plugin-DistManifestTests-1.101420 -- Release tests for the manifest * [20]Dist-Zilla-Plugin-HasVersionTests-1.101420 -- Release tests for version numbers * [21]Dist-Zilla-Plugin-Homepage-1.101420 -- Automatically sets the homepage URL * [22]Dist-Zilla-Plugin-InstallGuide-1.101420 -- Build an INSTALL file * [23]Dist-Zilla-Plugin-KwaliteeTests-1.101420 -- Release tests for kwalitee * [24]Dist-Zilla-Plugin-MetaProvides-1.10027802 -- Generating and Populating 'provides' in your META.yml * [25]Dist-Zilla-Plugin-MinimumVersionTests-1.101420 -- Release tests for minimum required versions * [26]Dist-Zilla-Plugin-MinimumVersionTests-1.101421 -- Release tests for minimum required versions * [27]Dist-Zilla-Plugin-PodLoom-3.00 -- Dist::Zilla plugin for Pod::Loom * [28]Dist-Zilla-Plugin-PodSpellingTests-1.101420 -- Release tests for POD spelling * [29]Dist-Zilla-Plugin-PortabilityTests-1.101420 -- Release tests for portability * [30]Dist-Zilla-Plugin-ReportVersions-1.101420 -- Write a test that reports used module versions * [31]Dist-Zilla-Plugin-ReportVersions-1.101421 -- Write a test that reports used module versions * [32]Dist-Zilla-Plugin-SynopsisTests-1.101420 -- Release tests for synopses * [33]Dist-Zilla-Plugins-CJM-3.00 -- CJM's plugins for Dist::Zilla * [34]Dist-Zilla-Role-Tempdir-0.01021401 -- Shell Out and collect the result in a DZ plug-in. * [35]File-Namaste-0.24 -- routines to manage NAMe-AS-TExt tags * [36]FusqlFS-0.001 -- fusqlfs - FUSE file system to mount DB and provide tools to control and admin it * [37]Graph-Easy-0.65 -- Convert or render graphs (as ASCII, HTML, SVG or via Graphviz) * [38]IPC-SysV-2.03 -- System V IPC constants and system calls * [39]Judy-0.27 -- Library for creating and accessing dynamic arrays * [40]KappaCUDA-1.1.0 -- Module to give easy access to NVIDIA CUDA from Perl using the Kappa Library. * [41]Language-Befunge-4.13 -- a generic funge interpreter * [42]Language-Befunge-Vector-XS-1.1.1 -- Language::Befunge::Vector rewritten for speed * [43]Log-Contextual-0.00202 -- Simple logging interface with a contextual log * [44]Log-Syslog-Fast-0.30 -- Perl extension for sending syslog messages over TCP, UDP, * [45]Markup-Unified-0.02 -- A simple, unified interface for Textile, Markdown and BBCode. * [46]Markup-Unified-0.03 -- A simple, unified interface for Textile, Markdown and BBCode. * [47]Marpa-0.101_000 -- Generate Parsers from any BNF grammar * [48]Math-Evol-1.11 -- Evolution search optimisation * [49]Monotone-AutomateStdio-0.08 -- Perl interface to Monotone via automate stdio * [50]MooseX-MarkAsMethods-0.07 -- Mark overload code symbols as methods * [51]PDL-2.4.6_007 -- Perl Data Language * [52]Perl-Critic-Bangs-1.06 -- Perl::Critic::Bangs - A collection of policies for Perl::Critic * [53]Pod-Weaver-Section-Installation-1.101420 -- Add an INSTALLATION pod section * [54]RDF-Query-2.202 -- A pure-perl impelmentation of the RDF query languages SPARQL and RDQL. * [55]RDF-RDFa-Linter-0.03 -- find common mistakes in RDFa files * [56]Rose-DB-0.761 -- A DBI wrapper and abstraction layer. * [57]Rose-DB-Object-0.788 -- Extensible, high performance object-relational mapper (ORM). * [58]SVG-Rasterize-0.001005 -- rasterize SVG content to pixel graphics * [59]Test-Module-Used-0.2.0 -- Test required module is really used and vice versa bitween lib/t and META.yml * [60]Text-Template-Library-0.03 -- a derived class of Text::Template * [61]Tk-ForDummies-Graph-1.12 -- Extension of Canvas widget to create a graph like GDGraph. * [62]once-1.101420 -- Execute code only once throughout the program's lifetime Discuss this story at: http://use.perl.org/comments.pl?sid=10/05/23/1530207 Links: 0. http://search.cpan.org/~jgamble/Algorithm-Networksort-1.09 1. http://search.cpan.org/~mbrooks/Apache2-WebApp-Extra-Admin-0.10 2. http://search.cpan.org/~smash/App-TinyMVC-0.01_1 3. http://search.cpan.org/~smash/App-TinyMVC-0.01_2 4. http://search.cpan.org/~gugod/App-perlbrew-0.07 5. http://search.cpan.org/~marcel/App-perlzonji-1.101420 6. http://search.cpan.org/~marcel/Attribute-SubName-1.101420 7. http://search.cpan.org/~jswartz/CHI-Driver-DBI-1.23 8. http://search.cpan.org/~marcel/Carp-Source-1.101420 9. http://search.cpan.org/~dhoss/Catalyst-View-Email-0.30 10. http://search.cpan.org/~jzobel/Cindy-0.11 11. http://search.cpan.org/~jzobel/Cindy-Apache2-0.04 12. http://search.cpan.org/~dmuey/Class-Action-0.4 13. http://search.cpan.org/~marcel/Class-Factory-Enhanced-1.101420 14. http://search.cpan.org/~marcel/Class-Null-2.101420 15. http://search.cpan.org/~rkitover/DBIx-Class-Schema-Loader-0.07000 16. http://search.cpan.org/~frew/Devel-REPL-1.003010 17. http://search.cpan.org/~rjbs/Dist-Zilla-3.101421 18. http://search.cpan.org/~kentnl/Dist-Zilla-Plugin-AutoVersion-Relative-0.01027903 19. http://search.cpan.org/~marcel/Dist-Zilla-Plugin-DistManifestTests-1.101420 20. http://search.cpan.org/~marcel/Dist-Zilla-Plugin-HasVersionTests-1.101420 21. http://search.cpan.org/~marcel/Dist-Zilla-Plugin-Homepage-1.101420 22. http://search.cpan.org/~marcel/Dist-Zilla-Plugin-InstallGuide-1.101420 23. http://search.cpan.org/~marcel/Dist-Zilla-Plugin-KwaliteeTests-1.101420 24. http://search.cpan.org/~kentnl/Dist-Zilla-Plugin-MetaProvides-1.10027802 25. http://search.cpan.org/~marcel/Dist-Zilla-Plugin-MinimumVersionTests-1.101420 26. http://search.cpan.org/~marcel/Dist-Zilla-Plugin-MinimumVersionTests-1.101421 27. http://search.cpan.org/~cjm/Dist-Zilla-Plugin-PodLoom-3.00 28. http://search.cpan.org/~marcel/Dist-Zilla-Plugin-PodSpellingTests-1.101420 29. http://search.cpan.org/~marcel/Dist-Zilla-Plugin-PortabilityTests-1.101420 30. http://search.cpan.org/~marcel/Dist-Zilla-Plugin-ReportVersions-1.101420 31. http://search.cpan.org/~marcel/Dist-Zilla-Plugin-ReportVersions-1.101421 32. http://search.cpan.org/~marcel/Dist-Zilla-Plugin-SynopsisTests-1.101420 33. http://search.cpan.org/~cjm/Dist-Zilla-Plugins-CJM-3.00 34. http://search.cpan.org/~kentnl/Dist-Zilla-Role-Tempdir-0.01021401 35. http://search.cpan.org/~jak/File-Namaste-0.24 36. http://search.cpan.org/~kstepme/FusqlFS-0.001 37. http://search.cpan.org/~shlomif/Graph-Easy-0.65 38. http://search.cpan.org/~mhx/IPC-SysV-2.03 39. http://search.cpan.org/~jjore/Judy-0.27 40. http://search.cpan.org/~brian/KappaCUDA-1.1.0 41. http://search.cpan.org/~jquelin/Language-Befunge-4.13 42. http://search.cpan.org/~jquelin/Language-Befunge-Vector-XS-1.1.1 43. http://search.cpan.org/~frew/Log-Contextual-0.00202 44. http://search.cpan.org/~athomason/Log-Syslog-Fast-0.30 45. http://search.cpan.org/~idoperel/Markup-Unified-0.02 46. http://search.cpan.org/~idoperel/Markup-Unified-0.03 47. http://search.cpan.org/~jkegl/Marpa-0.101_000 48. http://search.cpan.org/~pjb/Math-Evol-1.11 49. http://search.cpan.org/~aecooper/Monotone-AutomateStdio-0.08 50. http://search.cpan.org/~rsrchboy/MooseX-MarkAsMethods-0.07 51. http://search.cpan.org/~chm/PDL-2.4.6_007 52. http://search.cpan.org/~petdance/Perl-Critic-Bangs-1.06 53. http://search.cpan.org/~marcel/Pod-Weaver-Section-Installation-1.101420 54. http://search.cpan.org/~gwilliams/RDF-Query-2.202 55. http://search.cpan.org/~tobyink/RDF-RDFa-Linter-0.03 56. http://search.cpan.org/~jsiracusa/Rose-DB-0.761 57. http://search.cpan.org/~jsiracusa/Rose-DB-Object-0.788 58. http://search.cpan.org/~lgehlen/SVG-Rasterize-0.001005 59. http://search.cpan.org/~tsucchi/Test-Module-Used-0.2.0 60. http://search.cpan.org/~opi/Text-Template-Library-0.03 61. http://search.cpan.org/~djibel/Tk-ForDummies-Graph-1.12 62. http://search.cpan.org/~marcel/once-1.101420 Copyright 1997-2008 pudge. All rights reserved. ====================================================================== # Unsubscribe mailto:daily-news-unsubscr...@perl.org # News, archives, discussion http://use.perl.org/ # Perl News in The Perl Journal http://www.tpj.com/ # Feedback and news ideas mailto:n...@perl.org # http://use.perl.org/submit.pl