Skip to content
Tcl Source Code View Ticket
Login

View Ticket

unregistered ObjType's okay

Closed / Fixed450545ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 25 years ago
Descriptionplain2001-08-13 17:31:34
Tcl_ObjType(3) states that writers of new object types
need to
call tcl_RegisterObjType.  tk, for one, does not do
this
with any of the ObjTypes it manipulates.  It certainly
is not
self-evident that extensions can maintain private
Object
types unknown to the tcl core.  If maintaining private
Object types is considered legal,  then the Tcl_Obj(3)
man page
should state this.

For example, tcl might decide to verify that typePtr in
the
Tcl_Obj structure is something valid, possibly by
checking
against the registered types.  This would break tk.
dgpplain2001-08-14 04:30:48
Logged In: YES 
user_id=80530


I agree with this report that Tk ought to
register its Tcl_ObjType's with appropriate
calls to Tcl_RegisterObjType.  This would
allow things like Tcl_ConvertToType to work
with the Tk types.

From that perspective, this is a Tk bug.
dkfplain2001-08-14 17:00:08
Logged In: YES 
user_id=79902

Here's a patch to fix Tk by registering all its object types
dkfplain2001-08-14 17:00:09
File Added - 9520: tkobj.patch
msoferplain2001-08-14 18:52:06
Logged In: YES 
user_id=148712

Comments and patch clearly mark this as a Tk bug. Jeff, I'm
passing the ball to you :)
dgpplain2001-08-15 02:28:50
Logged In: YES 
user_id=80530


The Tcl_ObjType's that are no longer static
after this patch is applied -- shouldn't
they be renamed to have a "tk" prefix?
dkfplain2001-08-15 16:24:45
Logged In: YES 
user_id=79902

That's a much larger change, and Tk wasn't exactly clean in
that respect either.  Still, here's a revised version (which
is also unfortunately a much larger patch...)
dkfplain2001-08-15 16:24:46
File Added - 9564: tkobj.patch
dkfplain2001-08-15 16:25:15
File Deleted - 9520:
dgpplain2001-08-15 22:03:54
Logged In: YES 
user_id=80530


Much better.  One more question:  should the new
internal function TkRegisterObjTypes() go into
the internal stub table ?  How does one decide
whether a new non-static internal function goes
in the internal stub table or not?
dkfplain2001-08-15 22:35:21
Logged In: YES 
user_id=79902

I don't think its useful to put TkRegisterObjTypes() in the
stub table; it only really needs calling when Tk is first
loaded (currently it is called immediately after stub table
initialisation IIRC, which should be good enough.)  Calling
it again will just keep the reinit the types to the same
value, which ought to be harmless enough...
dgpplain2001-08-15 22:39:42
Logged In: YES 
user_id=80530

So membership in the internal stub table is just a
judgment call, then?  In that case, I agree it's
not helpful to put it in.

The patch looks good.  I've applied it and no new
test failures result.  If you're looking for 
approval for commit, you've got it from me.
dkfplain2001-08-15 22:45:25
Logged In: YES 
user_id=79902

Checked in.  I'll let Jeff figure out whether to close this
bug... :^)
hobbsplain2001-08-21 03:14:40
Logged In: YES 
user_id=72656

I'm going to leave it as-is, because while it is 
not "necessary", I think it is the good citizenship thing 
to do.  I don't see the problem in making people 
(suggesting that they) register when it isn't strictly 
necessary in the code.
Log in (anonymous is fine) to add a comment.

Attachments: