Re: Getting Information on a Calling Class



Hal Vaughan <hal@xxxxxxxxxxxxxxxxxxxx> writes:
I have a case where I'd like to return different data depending
on which class is calling the current class.
Is there any way to get the instance of the object that called
a method?

interface Caller
{
}
class Callee
{
public void callMe( Caller caller )
{
doSomethingWith( caller );
}
}
class ACaller implements Caller
{
public void someMethod()
{
Callee callee = new Callee();
callee.callMe( this );
}
}

--
Lew

.



Relevant Pages

  • Re: calling convention
    ... caller and callee communicate, be it via the stack or registers. ... without consideration of calling convention.. ...
    (microsoft.public.vc.language)
  • Re: Best way to implement default parameters
    ... The examples Dmitry posted for Ada would have the programmer explicitly ... caller, we can _still_ have them determined by the caller simply by having ... quoted text is that the callee has both the default values and the behavior ... intended to show where "compile defaults into the callee" can be ...
    (comp.lang.misc)
  • Re: Surprise
    ... S, and PC to the callee entry address (actually from a dispatch table, ... For routines ... nn, caller cleans the remainder. ... C varargs, however, can provide from each call site different number ...
    (comp.lang.fortran)
  • Re: [RFC] Splitting kernel headers and deprecating __KERNEL__
    ... >> the callee (which may not even exist when the contract is created). ... >> post conditions are expressed less formally than an Eiffel interface. ... it's a contract between the caller and callee. ...
    (Linux-Kernel)
  • Re: Best way to implement default parameters
    ... In other words the callee can change the ... values it uses for default without requiring the caller to know. ... how foo is declared in the current version of the module. ... after the compilation of the call to foo, ...
    (comp.lang.misc)