Internals - Online Linux Manual PageSection : 3pm
Updated : 2020-11-09
Source : perl v5.32.0
Note : User Contributed Perl Documentation
NAMETk::Internals − what is Perl Tk interface doing when you call Tk functions. This information is worse than useless for "perlTk" users, but can of some help for people interested in using modified Tk source with "perlTk". This document is under construction. The information is believed to be pertinent to the version of "portableTk" available when it was created. All the details are subject to change.
DESCRIPTIONPreCompiling Before the actual compilation stage a script scans the source and extracts the subcommands of different commands. This information resides in the file pTk/Methods.def. Compilation During compilation the above file is included in the source of booting routine of dynamic (or static) library. More precisely, the booting code of module Tk calls the subroutine Boot_Glue() from the module tkGlue.c, and this subroutine includes the file (with appropriate macro definitions). Inside use Tk; The module bootstraps the C code, then loads the Perl libraries. The heart of the Perl code is contained in the Tk::Widget library, all the widgets inherit from this module. Code for toplevels is loaded from Tk::MainWindow. During bootstrap of the C glue code the Xevent::? codes and a handful of Tk::Widget and Tk::Image routines are defined. (Much more XSUBs are created from Tk.xs code.) The widget subcommands are glued to Perl basing on the list included from pTk/Methods.def. In fact all the subcommands are glued to XSUBs that are related to the same C subroutine XStoWidget(), but have different data parts. During the Perl code bootstrap the method Tk::Widget::import is called. This call requires all the code from particular widget packages. Code from the widget packages calls an obscure command like (bless \"Text")−>WidgetClass;
This command (actually Tk::Widget::WidgetClass()) creates three routines: Tk::Widget::Text(), Tk::Widget::isText(), and Tk::Text::isText(). The first one is basically new of Tk::Text, the other two return constants. It also puts the class into depository. Inside $top = MainWindow−>new; This is quite intuitive. This call goes direct to Tk::MainWindow::new, that calls XSUB Tk::MainWindow::CreateMainWindow, that calls C subroutine Tk_CreateMainWindow(). It is a Tk subroutine, so here black magic ends (almost). The only remaining black magic is that the Tk initialization routine creates a lot of commands, but the subroutine for creation is usurped by portableTk and the commands are created in the package Tk. They are associated to XSUBs that are related to one of three C subroutines XStoSubCmd(), XStoBind(), or XStoTk(), but have different data parts. The result of the call is blessed into Tk::MainWindow, as it should. Inside $top−>title('Text demo'); The package Tk::Toplevel defines a lot of subroutines on the fly on some list. All the commands from the list are converted to the corresponding subcommands of wm method of the widget. Here subcommand is a command with some particular second argument (in this case "title"). Recall that the first argument is $self. Now Tk::Toplevel @ISA Tk::Widget, that in turn @ISA Tk. So a call to $top−>wm('title','Text demo') calls Tk::wm, that is defined during call to Tk_CreateMainWindow(). As it is described above, the XSUB associated to XStoSubCmd() is called. This C routine is defined in tkGlue.c. It gets the data part of XSUB, creates a SV with the name of the command, and calls Call_Tk() with the XSUB data as the first argument, and with the name of XSUB stuffed into the Perl stack in the place there tk expects it. (In fact it can also reorder the arguments if it thinks it is what you want). The latter procedure extracts name of tk procedure and clientData from the first argument and makes a call, using Perl stack as argv for the procedure. A lot of black magic is performed afterwards to convert result of the procedure to a Perl array return. Inside $text = $top−>Text(background => $txtBg); Above we discussed how the command Tk::Widget::Text is created. The above command calls it via inheritance. It is translated to Tk::Text::new($top, background => $txtBg);
The package Tk::Text has no method new, so the Tk::Widget::new is called. In turn it calls Tk::Text−>DoInit($top), that is Tk::Widget::DoInit(Tk::Text,$top), that initializes the bindings if necessary. Then it creates the name for the widget of the form .text0, and calls Tk::text('.text0', background => $txtBg) (note lowercase). The result of the call is blessed into Tk::Text, and the method bindtags for this object is called. Now the only thing to discuss is who defines the methods text and bindtags. The answer is that they are defined in tkWindow.c, and these commands are created in the package Tk in the same sweep that created the command Tk::wm discussed above. So the the same C code that corresponds to the processing of corresponding TCL commands is called here as well (this time via XStoTk interface). Inside $text−>insert('insert','Hello, world!'); As we discussed above, the subcommands of widget procedures correspond to XSUB XStoWidget. This XSUB substitutes the first argument $text (that is a hash reference) to an appropriate value from this hash, adds the additional argument after the first one that contains the name of the subcommand extracted from the data part of XSUB, and calls the corresponding Tk C subroutine via Call_Tk. Ilya Zakharevich <ilya@math.ohio−state.edu> 0
Johanes Gumabo
Data Size : 19,260 byte
man-Tk::Internals.3pmBuild : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 3 / 188,876
Visitor ID : :
Visitor IP : 18.219.81.129 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.
ERROR : Need New Coding : (parse_manual_page_|249|Tk::Internals.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\|
) (htmlprn|149|Tk::Internals.3pm|36/37|.el══─{─══. ds -- — |.el══─{─══. ds -- \|\(em\|
) (parse_manual_page_|249|Tk::Internals.3pm|43|br══─}─══|'br══─}─══
) (htmlprn|149|Tk::Internals.3pm|43|'br══─}─══ |'br══─}─══
)