Download Shareware and Freeware Software for Windows, Linux, Macintosh, PDA

line Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

Serving Software Downloads in 976 Categories, Downloaded 31.332.024 Times

Code::Splice 0.01

  Date Added: September 18, 2010  |  Visits: 880


Report Broken Link
Printer Friendly Version

Product Homepage
Download (76 downloads)

Code::Splice injects the contents of one subroutine at a specified point elsewhere. SYNOPSIS use Code::Splice; Code::Splice::inject( code => sub { print "fredn"; }, package => main, method => foo, precondition => sub { my $op = shift; my $line = shift; $line =~ m/print/ and $line =~ m/four/; }, postcondition => sub { my $op = shift; my $line = shift; $line =~ m/print/ and $line =~ m/five/; }, ); sub foo { print "onen"; print "twon"; print "threen"; print "fourn"; print "fiven"; } This module removes the contents of a subroutine (usually an anonymous subroutine created just for the purpose) and splices in into the program elsewhere. Why, you ask? Write stronger unit tests than the granularity of the API would otherwise allow Write unit tests for nasty, interdependant speghetti code (my motivation -- hey, you gotta have tests before you can start refactoring, and if you cant write tests for the code, youre screwed) Fix stupid bugs and remove stupid restrictions in other peoples code in a way thats more resiliant across upgrades than editing files you dont own Be what "aspects" should be Screw with your cow-orkers by introducing monster heisenbugs Play with self-modifying code Write self-replicating code (but be nice, were all friends here, right?) The specifics: The body of the code { } block are extracted from the subroutine and inserted in a place in the code specified by the call to the splice() function. Where the new code is spliced in, the old code is spliced out. The package and method arguments are required and tell the thing how to find the code to be modified. The code argument is required as it specifies the code to be spliced in. That same code block should not be used for anything else under penalty of coredump. The rest of the argumets specify where the code is to be inserted. Any number of precondition and postcondition arguments provide callbacks to help locate the exact area to splice the code in at. Before the code can e spliced in, all of the precondition blocks must have returned true, and none of the postcondition blocks may have yet returned true. If a postcondition returns true before all of the precondition blocks have, an error is raised. Both blocks get called numerous times per line and get passed a reference to the B OP object currently under consideration and the text of the current line: precondition => sub { my $op = shift; my $line = shift; $line =~ m/print/ and $line =~ m/four/; }, ... or... precondition => sub { my $op = shift; $op->name eq padsv and $op->sv->sv =~ m/fred/; }, Its possible to insert code in the middle of an expression when testing ops, but when testing the text of the line of code, the spliced in code will always replace the whole line. Ill probably drop sending in the opcode in a future version, at least for the precondition/postcondition blocks, or maybe Ill swap them to the 2nd arg so theyre more optional. Do not attempt to match text in comments as it wont be there. The code in $line is re-generated from the bytecode using B::Deparse and will vary from the original source code in a few ways, including changes to formatting, changes to some idioms and details of the expressions, and formatting of the code with regards to whitespace. The splicing code will die if it fails for any reason. This will likely change in possible future versions. There are also label and line arguments that create preconditions for you, for simple cases. Of course, you shouldnt use line for anything other than simple experimentation. References to lexical variables in the code to be injected are replaced with references to the lexical variables of the same name in the location the code is inserted into. If a variable of the same name doesnt exist there, its an error. ... but it probably shouldnt be an error, at least in the cases where the code being spliced in declares that lexical with my, or when the variable was initiailized entirely outside of the sub block being spliced in and was merely closed over by it. See the comments in the source code (at the top, in a nice block) for my todo/desired features. Let me know if there are any features in there or yet unsuggested that you want. I wont promise them, but I would like to hear about them..

Requirements: No special requirements
Platforms: Linux
Keyword: Code Codesplice Contents Of Libraries Line Programming Shift Spliced Sub Subroutine
Users rating: 0/10

License: Freeware Size: 10.24 KB
Libraries  -  LibQtPod 0.3 RC1
LibQtPod provides access to the contents of an Apple iPod. The code was formerly part of the kio ipodslave, but is now a separate Qt-based library. LibQtPod library features reading and writing of the iTunesDB music database and provides access...
102.4 KB  
3D Graphic Tools  -  fbdump 0.4.2
fbdump is a simple tool that captures the contents of the visible portion of the Linux framebuffer device and writes it to the standard output as a PPM file. In other words, it takes a screenshot of anything running on the framebuffer. The...
10.24 KB  
3D Graphic Tools  -  Visprint 2.1
Visprint project makes fractal fingerprint png images based on the contents of any file. The image will be different for almost every file with even slightly different contents. Visprint uses the IFS fractal generation process, pioneered by...
14.34 KB  
Audio Tools  -  libgpod 0.5.2
libgpod is a shared library to access the contents of an iPod. libgpod library is based on code used in the gtkpod project. Starting with V0.96.CVS gtkpod depends on this library. This code was originally part of gtkpod itself. When the parsing...
808.96 KB  
Business  -  Baes RSSMailFeed 1.02
Baes RSSMailFeed is a program to send the contents of an RSS feed through email. I started this because a friend wanted a way to read my locked LiveJournal posts via email. Its easy enough to get LiveJournal posts via email, but more tricky when...
10.24 KB  
Automation Tools  -  Mail Contents of Front Browser 1.0
Mail Contents of Front Browser is a free Automator action that will add the contents of the front Safari browser to a new outgoing message in Mail.
40.96 KB  
Desktop Utilities  -  Decrypt and Extract Here Service Menu 1.1-4
Decrypt and Extract Here Service Menu installs a service menu for Konqueror that decrypts and extracts the contents of encrypted tarballs. Once install, a "Decrypt and Extract Here" entry is added to the Actions context menu in Konqueror. This...
13.31 KB  
Desktop Utilities  -  Garidio 1.0 Beta
Garidio is an application that allows users on a network to share the contents of their desktop clipboards with each other. It has been successfully tested on Mac OS X (Tiger), Windows XP (SP2), and Linux (Slackware, SuSE, and Ubuntu), but it...
30.72 KB  
Desktop Utilities  -  Zipper 1.2
Zipper is a tool for inspecting the contents of a compressed archive and for extracting. I know that theres a GNUstep port of the famous OpenUp application but I must admit that for a living I have to use Windoze at work. After a while I got...
460.8 KB  
Network & Internet  -  Syntax Desktop 2.3.1
Syntax Desktop is a publishing system used to manage the contents of a Web site. Syntax Desktop project has an attractive GUI with DHTML elements. You can use it to insert news, photos, documents, and tree data structures into your site. It...
4.6 MB  
Programming  -  FLEX-db Digital Asset Manager 3.0.9
FLEX-db - an enterprise Digital Asset Manager (DAM). It ingests and links metadata with files, creates thumbnails, and processes files using business rules. FLEX-db has a JSP client, Java app server for file input and output and an EJB metadata...
21.57 MB  
Programming  -  Libicom 0.9.0
The libicom library is a character based dynamicly linked library for Linux. It is used to remotely control the Icom IC-R8500 wide band receiver via an RS232 link. All call and return parameters to the control functions are character string based....
20.48 KB  
Programming  -  dotdesktop 0.3
Dotdesktop library provides ability to parse desktop entry file and access the information in a convenient way. Desktop entry file format is defined by, it is used to describe information about an application such as the name and...
327.68 KB  
Programming  -  Cedalion for Linux 0.2.6
Cedalion is a programming language that allows its users to add new abstractions and define (and use) internal DSLs. Its innovation is in the fact that it uses projectional editing to allow the new abstractions to have no syntactic limitations.
471.04 KB  
Programming  -  libyasl 0.2
Libyasl is a C++ class library to easily realize TCP/UDP/Multicast clientsand servers in IPv4 and IPv6 environments under GNU/Linux systems.
143.36 KB  
Libraries  -  wolfSSL 3.13.0
The wolfSSL embedded SSL/TLS library is a lightweight SSL library written in ANSI standard C and targeted for embedded and RTOS environments - primarily because of its small size, speed, and feature set. It is commonly used in standard operating...
3.88 MB  
Libraries  -  EuGTK 4.8.9
Makes it easy to develop good- looking, fast, cross-platform programs that run on Linux, OS X, and Windows. Euphoria is a very fast interpreted/compiled language with straight-forward syntax. EuGTK allows programming in a clean, object-oriented...
10.68 MB  
Libraries  -  Linux User Group Library Manager 1.0
The LUG Library Manager is a project to help Linux User Groups start their own library. A LUG library is helpful to the community at large because it increases access to information, and gives everyone the opportunity to become more knowledgeable.
5.35 KB  
Libraries  -  Module::MakefilePL::Parse 0.12
Module::MakefilePL::Parse is a Perl module to parse required modules from Makefile.PL. SYNOPSIS use Module::MakefilePL::Parse; open $fh, Makefile.PL; $parser = Module::MakefilePL::Parse->new( join("", ) ); $info = $parser->required;...
8.19 KB  
Libraries  -  sqlpp 0.06
sqlpp Perl package is a SQL preprocessor. sqlpp is a conventional cpp-alike preprocessor taught to understand SQL ( PgSQL, in particular) syntax specificities. In addition to the standard #define/#ifdef/#else/#endif cohort, provides also...
10.24 KB