CORBA-MICO

 view release on metacpan or  search on metacpan

server.cc  view on Meta::CPAN

	retval = pmico_sv_to_servant (POPs);

	PUTBACK;
    }

    FREETMPS;
    LEAVE;

    if (exception)
	throw exception;

    return retval;
}

void
PMicoServantActivator::etherealize (const PortableServer::ObjectId& oid,
				    PortableServer::POA_ptr         adapter,
				    PortableServer::Servant         serv,
				    CORBA::Boolean                  cleanup_in_progress,
				    CORBA::Boolean                  remaining_activations)
{
    CORBA::Exception *exception;

    // only one thread into Perl
    MICOMT::AutoLock l(cmPerlEntryLock);

    PERL_SET_CONTEXT(this->thx);
    dSP;

    ENTER;
    SAVETMPS;

    PUSHMARK(SP);

    XPUSHs(sv_2mortal(newRV_inc(perlobj)));
    
    XPUSHs(sv_2mortal(pmico_oid_to_sv (&oid)));
    SV *tmp = sv_newmortal();
    PortableServer::POA_ptr adptr = PortableServer::POA::_duplicate(adapter);
    sv_setref_pv(tmp, "PortableServer::POA", (void *)adptr);
    XPUSHs(tmp);
    XPUSHs(sv_2mortal(pmico_servant_to_sv (serv)));
    XPUSHs(cleanup_in_progress ? &PL_sv_yes : &PL_sv_no);
    XPUSHs(remaining_activations ? &PL_sv_yes : &PL_sv_no);

    PUTBACK;

    exception = pmico_call_method ("etherealize", 0, NULL);

    FREETMPS;
    LEAVE;

    if (exception)
	throw exception;
}

PortableServer::Servant
PMicoServantLocator::preinvoke (const PortableServer::ObjectId& oid,
				PortableServer::POA_ptr   adapter,
				const char *                    operation,
				PortableServer::ServantLocator::Cookie& the_cookie)
{
    PortableServer::Servant retval;
    CORBA::Exception *exception;

    init_forward_request();

    dSP;

    ENTER;
    SAVETMPS;

    PUSHMARK(SP);

    XPUSHs(sv_2mortal(newRV_inc(perlobj)));
    
    XPUSHs(sv_2mortal(pmico_oid_to_sv (&oid)));
    SV *tmp = sv_newmortal();
    PortableServer::POA_ptr adptr = PortableServer::POA::_duplicate(adapter);
    sv_setref_pv(tmp, "PortableServer::POA", (void *)adptr);
    XPUSHs(tmp);
    XPUSHs(sv_2mortal(newSVpv((char *)operation, 0)));


    PUTBACK;

    exception = pmico_call_method ("preinvoke", 2, forward_request_seq);

    if (!exception) {
	SPAGAIN;
	
	retval = pmico_sv_to_servant (POPs);
	the_cookie = (void *)SvREFCNT_inc (POPs);

	PUTBACK;
    }

    FREETMPS;
    LEAVE;

    if (exception)
	throw exception;

    return retval;
}

void
PMicoServantLocator::postinvoke (const PortableServer::ObjectId& oid,
 				 PortableServer::POA_ptr   adapter,
				 const char *                    operation,
				 PortableServer::ServantLocator::Cookie the_cookie,
				 PortableServer::Servant         serv)

{
    CORBA::Exception *exception;

    dSP;

    ENTER;
    SAVETMPS;

    PUSHMARK(SP);

    XPUSHs(sv_2mortal(newRV_inc(perlobj)));
    
    XPUSHs(sv_2mortal(pmico_oid_to_sv (&oid)));
    SV *tmp = sv_newmortal();
    PortableServer::POA_ptr adptr = PortableServer::POA::_duplicate(adapter);
    sv_setref_pv(tmp, "PortableServer::POA", (void *)adptr);
    XPUSHs(tmp);
    XPUSHs(sv_2mortal(newSVpv((char *)operation, 0)));
    XPUSHs(sv_2mortal(pmico_servant_to_sv (serv)));
    // We gave "cookie" an extra refcount in preinvoke, we take
    // it back here.
    XPUSHs(sv_2mortal((SV *)the_cookie));

    PUTBACK;

    exception = pmico_call_method ("postinvoke", 0, NULL);

    FREETMPS;
    LEAVE;

    if (exception)
	throw exception;
}

// 
// PMicoServant 
//
 

PMicoServant::PMicoServant (SV *_perlobj)
{
    assert (SvROK(_perlobj));

    this->thx = (PerlInterpreter*)PERL_GET_THX;
    std::string repoid = pmico_get_repoid (_perlobj);
    PMicoIfaceInfo *info = pmico_find_interface_description (repoid.c_str());
    
    if (!info)
	info = pmico_load_contained (NULL, NULL, repoid.c_str());

    perlobj = SvRV(_perlobj);
    desc = info->desc;
}

PMicoServant::~PMicoServant ()
{
}



( run in 0.552 second using v1.01-cache-2.11-cpan-39bf76dae61 )