Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

An instrument for examining and modifying the internal state of Tcl objects

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 doc
Octocat-spinner-32 generic
Octocat-spinner-32 tclconfig
Octocat-spinner-32 tests
Octocat-spinner-32 win
Octocat-spinner-32 ChangeLog
Octocat-spinner-32 Makefile.in
Octocat-spinner-32 README
Octocat-spinner-32 README.FreeBSD
Octocat-spinner-32 aclocal.m4
Octocat-spinner-32 configure.in
Octocat-spinner-32 license.terms
Octocat-spinner-32 pkgIndex.tcl.in
README
This is Tweezer, a hackish tool for doing dangerous but potentially 
interesting things to Tcl objects... things that may surprise and delight... 
or cause your interpreter to dump core...

Using Tweezer you can sniff any Tcl object that you can contrive for
the tweezer to be able to see, such as a variable, proc, array element,
element of a list within a list, etc, find out its data type (internal 
representation), look at and manipulate its reference count, generate
a new reference, and even force an object to shimmer to a different internal 
representation, which may actually be useful for something.

It kind of lifts the veil on the objects that underly Tcl, that are normally
invisible to Tcl programs.

This extension is intended for experimentation and is in a relatively
primitive state.  I strongly recommend against using it for anything
real unless you are absolutely sure about what you're doing.  I welcome 
suggestions on how to improve this tool and creative flames on what a
horrible abomination it is.

Version 0.0

$Id: README,v 1.4 2004/12/26 05:56:57 karl Exp $

This package is a freely available open source package.  You can do
virtually anything you like with it, such as modifying it, redistributing
it, and selling it either in whole or in part.  See the file
"license.terms" for complete information.

Tweezer was written by Karl Lehenbauer.

USING THE TWEEZER
=================

package require tweezer

% set a 10
% tweezer type $a
int

% tweezer shimmer $a double
% tweezer type $a
double
% puts $a
10
% tweezer type $a
double

% set a "a b c d e f g h i j k l m n o p"
a b c d e f g h i j k l m n o p
% tweezer type $a
% lindex $a 4
e
% tweezer type $a
list
% tweezer shimmer [lindex $a 4] list
% tweezer type [lindex $a 4]
list


% proc die {} {if}
% tweezer shimmer [info body die] bytecode
wrong # args: no expression after "if" argument

% tweezer types
boolean index double end-offset wideInt list cmdName bytecode nsName procbody bytearray int {array search} string

foreach proc [info procs] {
    tweezer convert [info body $proc] bytecode
}

...pretty cool, huh?

TWEEZER QUICK REF
=================

tweezer types

    Return a list of all of the defined object types within Tcl.

tweezer type object

    Return the internal data type of an object.  If the object has
    no current internal representation, return nothing.
    
    To see the data type of a variable, reference the variable's contents

    tweezer type $var

    tweezer type $array(element)

    To see a proc body, use info body...

    tweezer type [info body myproc]

    To see the type of the fourth element of a list

    tweezer type [lindex $list 3]

tweezer shimmer object

    Shimmer an object to a different type

    To force the fifth element of a list to be an integer
    tweezer shimmer [lindex $list 4] int

    Attempting to shimmer objects to strange object types can cause coredumps.

    The name shimmer is possibly dumb.  It might be reasonable to just
    have "tweezer type" set the type if 4 arguments are present.

tweezer refcount object

    Return the object's reference count.

makeref

    Create and return a reference to an object without incrementing the
    object's reference count.  Dangerous.

duplicate

    Duplicate an object and return the new object.  This shouldn't be
    dangerous but may be dumb.

incr_refcount

    Increment an object's reference count.  Stupid name.

decr_refcount

    Decrement an object's reference count.  Another stupid name plus dangerous.

BUGS
====

After changing the type of a proc body to bytecode, it doesn't show up
as bytecode.  This used to work, maybe in earlier versions of Tcl 8.
It does still appear to force compilation of the proc.

CONTENTS
========

Makefile.in	Makefile template.  The configure script uses this file to
		produce the final Makefile.

README		This file

aclocal.m4	Generated file.  Do not edit.  Autoconf uses this as input
		when generating the final configure script.  See "tcl.m4"
		below.

configure	Generated file.  Do not edit.  This must be regenerated
		anytime configure.in or tclconfig/tcl.m4 changes.

configure.in	Configure script template.  Autoconf uses this file as input
		to produce the final configure script.

generic/tweezer.c	Tcl object tweezer and interface source code
generic/tcltweezer.c

generic/tweezer.h	Header files for the tweezer.


tclconfig/	This directory contains various template files that build
		the configure script.  They should not need modification.

	install-sh	Program used for copying binaries and script files
			to their install locations.

	tcl.m4		Collection of Tcl autoconf macros.  Included by
			aclocal.m4 to define SC_* macros.

UNIX BUILD
==========

Building under most UNIX systems is easy, just run the configure script
and then run make. 

	$ cd tweezer
	$ ./configure
	$ make
	$ make install

WINDOWS BUILD
=============

Nobody has yet attempted to build the tweezer under Windows.

The recommended method to build extensions under windows is to use the
Msys + Mingw build process. This provides a Unix-style build while
generating native Windows binaries. Using the Msys + Mingw build tools
means that you can use the same configure script as per the Unix build
to create a Makefile.

If you have VC++ then you may wish to use the files in the win
subdirectory and build the extension using just VC++. These files have
been designed to be as generic as possible but will require some
additional maintenance by the project developer to synchronise with
the TEA configure.in and Makefile.in files. Instructions for using the
VC++ makefile are written in the first part of the Makefile.vc
file.

INSTALLATION
============

The tweezers install like so:

         $exec_prefix
          /       \
        lib       bin
         |         |
   PACKAGEx.y   (dependent .dll files on Windows)
         |
  pkgIndex.tcl (.so|.dll files)

The main .so|.dll library file gets installed in the versioned PACKAGE
directory, which is OK on all platforms because it will be directly
referenced with by 'load' in the pkgIndex.tcl file.  Dependent DLL files on
Windows must go in the bin directory (or other directory on the user's
PATH) in order for them to be found.
Something went wrong with that request. Please try again.