Maybe. It may not be constant across threads, I can't remember which things are shared and which are duplicated when you "clone" a new thread.
Ok I'll look into that. (If it's not constant, that's a pity, since with ithreads, the stash is not accessible from the cop struct, which means there is no constant package related pointer at all and I'll have to do an additional hash lookup (i.e. convert to stash) (or at least strcmp, if I somehow tried to cache the pointers) for the package string for each hash access.)
>I'm not sure what you mean with "the [statement] that provided the >calling XSUB".
Suppose in some .xs file I have
MODULE = Bar PACKAGE = Bar
DoCall(SV *hvref) CODE: { SV **svp = hv_fetch((HV *)SvRV(hvref),"d",1,0); // will call your FETCH }
And then over in perl:
package Foo; Bar::DoCall(\%oneofYourHahes);
Should you be checking Bar (the notional package name of XSUB accessing the hash) or Foo (the "current package")?
Package Bar is the relevant one. It's Bar's author who accesses the hash and thus it's him who should have set up the hash the way he wants to access it later on.
But I guess there's no way for me to learn that there's a package "Bar" involved, right?
> >Class::PredefinedFields::Tie::{FETCH,STORE,..} must know that >$obj->{d}=1 is in package main. > >(And Class::PredefinedFields::import must know that use >Class::PredefinedFields is in package Foo, but I'm not yet sure I'll >implement the import function in XS.) > >>The other thing to stir into the mix is the effect of eval {} >>which complicates the stack stuff... > >I've noticed the several cx_type's. But it shouldn't matter since I >simply want the *last* statement that's calling me.
If you get into stack tracing though the eval {} still gets you
eval { $obj->{d} = 1 };
You _immediate_ "caller" is the eval. An presumably user put it there so he can "catch" your croak-s ...
Hmm, I see.
Well, the eval in this case should have the correct package, so it should not be a problem in your example, but it might be here:
package A;
eval { package B;
$obj->{d} = 1 };
So you mean that CopSTASHPV(PL_curcop) will return "A" in that case?
In my caller test code I don't see that problem since I'm calling an xsub (Chj::Caller::caller) in the normal way, like
package A;
eval { package B;
print Chj::caller::caller,"\n" }; # prints correctly "B"I'll have to see how tie behaves.
Christian.
