#include "matrix.h"
#include <omniORB2/proxyCall.h>

static const char* _0RL_library_version = omniORB_2_7;


// Proxy call descriptor class. Mangled signature:
//  _s0_cdouble_i_cunsigned_plong_i_cunsigned_plong_i_s0_cdouble
class _0RL_pc_12c774b6d979e38e_00000000
  : public OmniProxyCallDesc
{
public:
  inline _0RL_pc_12c774b6d979e38e_00000000(const char* _op, size_t _op_len, CORBA::ULong _a_first, CORBA::ULong _a_last, const Column& _a_c) :
    OmniProxyCallDesc(_op, _op_len),
    arg_first(_a_first),
    arg_last(_a_last),
    arg_c(_a_c)  {}

  virtual CORBA::ULong alignedSize(CORBA::ULong size_in);
  virtual void marshalArguments(GIOP_C&);
  virtual void unmarshalReturnedValues(GIOP_C&);
  inline Column* result() { return pd_result; }

private:
  CORBA::ULong arg_first;
  CORBA::ULong arg_last;
  const Column& arg_c;
  Column* pd_result;
};

CORBA::ULong _0RL_pc_12c774b6d979e38e_00000000::alignedSize(CORBA::ULong msgsize)
{
  msgsize = omni::align_to(msgsize,omni::ALIGN_4);
  msgsize += 4;
  msgsize = omni::align_to(msgsize,omni::ALIGN_4);
  msgsize += 4;
  msgsize = arg_c.NP_alignedSize(msgsize);
  return msgsize;
}

void _0RL_pc_12c774b6d979e38e_00000000::marshalArguments(GIOP_C& giop_client)
{
  arg_first >>= giop_client;
  arg_last >>= giop_client;
  arg_c >>= giop_client;
}

void _0RL_pc_12c774b6d979e38e_00000000::unmarshalReturnedValues(GIOP_C& giop_client)
{
  pd_result = new Column;
  *pd_result <<= giop_client;
}

Column * _proxy_Matrix::block_product(CORBA::ULong  first, CORBA::ULong  last, const Column & c)
{
  _0RL_pc_12c774b6d979e38e_00000000 _call_desc("block_product", 14, first, last, c);

  OmniProxyCallWrapper::invoke(this, _call_desc);
  return _call_desc.result();
}




CORBA::Boolean
_sk_Matrix::dispatch(GIOP_S &_0RL_s,const char *_0RL_op,CORBA::Boolean _0RL_response_expected)
{
  if (strcmp(_0RL_op,"block_product") == 0)
  {
    CORBA::ULong first;
    first <<= _0RL_s;
    CORBA::ULong last;
    last <<= _0RL_s;
    Column c;
    c <<= _0RL_s;
    _0RL_s.RequestReceived();
    Column_var _0RL_result;
    _0RL_result = block_product(first, last, c);
    size_t _0RL_msgsize = (size_t) GIOP_S::ReplyHeaderSize();
    _0RL_msgsize = (_0RL_result.operator->())->NP_alignedSize(_0RL_msgsize);
    _0RL_s.InitialiseReply(GIOP::NO_EXCEPTION,(CORBA::ULong)_0RL_msgsize);
    *(_0RL_result.operator->()) >>= _0RL_s;
    _0RL_s.ReplyCompleted();
    return 1;
  }
  else {
    return 0;
  }
}

_sk_Matrix::_sk_Matrix (const omniORB::objectKey& k)
{
  omniRopeAndKey l(0,(CORBA::Octet*)&k,(CORBA::ULong)sizeof(k));
  setRopeAndKey(l,0);
}

omniORB::objectKey
_sk_Matrix::_key()
{
  omniRopeAndKey l;
  getRopeAndKey(l);
  return (*((omniORB::objectKey*)l.key()));
}

Matrix_ptr
Matrix::_duplicate(Matrix_ptr obj)
{
  if (CORBA::is_nil(obj))
    return Matrix::_nil();
  CORBA::Object::_duplicate(obj);
  return obj;
}

Matrix_ptr
Matrix::_narrow(CORBA::Object_ptr obj)
{
  if (CORBA::is_nil(obj))
    return Matrix::_nil();
  Matrix_ptr e = (Matrix_ptr) (obj->PR_getobj()->_realNarrow(Matrix_IntfRepoID));
  if (e)
    return e;
  else
    return Matrix::_nil();
}

void *
Matrix::_widenFromTheMostDerivedIntf(const char *repoId,CORBA::Boolean is_cxx_type_id)
{
  if (is_cxx_type_id) return 0;
  if (!repoId)
    return (void *)((CORBA::Object_ptr)this);
  if (strcmp(Matrix_IntfRepoID,repoId) == 0)
    return (void *)this;
  else {
    return 0;
  }
}

CORBA::Boolean
Matrix::_0RL_is_a(const char *base_repoId) {
  if (strcmp(base_repoId,(const char *)Matrix_IntfRepoID)==0)
    return 1;
  else
    return 0;
}

Matrix_ptr
Matrix_Helper::_nil() {
  return Matrix::_nil();
}

CORBA::Boolean
Matrix_Helper::is_nil(Matrix_ptr p) {
  return CORBA::is_nil(p);
}

void
Matrix_Helper::release(Matrix_ptr p) {
  CORBA::release(p);
}

void
Matrix_Helper::duplicate(Matrix_ptr p) {
  CORBA::Object::_duplicate(p);
}

size_t
Matrix_Helper::NP_alignedSize(Matrix_ptr obj,size_t initialoffset) {
  return Matrix::NP_alignedSize(obj,initialoffset);
}

void
Matrix_Helper::marshalObjRef(Matrix_ptr obj,NetBufferedStream &s) {
  Matrix::marshalObjRef(obj,s);
}

Matrix_ptr Matrix_Helper::unmarshalObjRef(NetBufferedStream &s) {
  return Matrix::unmarshalObjRef(s);
}

void
Matrix_Helper::marshalObjRef(Matrix_ptr obj,MemBufferedStream &s) {
  Matrix::marshalObjRef(obj,s);
}

Matrix_ptr Matrix_Helper::unmarshalObjRef(MemBufferedStream &s) {
  return Matrix::unmarshalObjRef(s);
}

const char *
Matrix_proxyObjectFactory::irRepoId() const
{
  return (const char *)Matrix_IntfRepoID;
}

CORBA::Object_ptr
Matrix_proxyObjectFactory::newProxyObject(Rope *r,CORBA::Octet *key,size_t keysize,IOP::TaggedProfileList *profiles,CORBA::Boolean release)
{
  _proxy_Matrix *p = new _proxy_Matrix(r,key,keysize,profiles,release);
  if (!p) {
    throw CORBA::NO_MEMORY(0,CORBA::COMPLETED_NO);
  }
  return (CORBA::Object_ptr) p;
}

CORBA::Boolean
Matrix_proxyObjectFactory::is_a(const char *base_repoId) const
{
  return Matrix::_0RL_is_a(base_repoId);

}

Matrix_ptr
Matrix::_nil() {
  return Matrix_proxyObjectFactory::_nil();
}

static const Matrix_proxyObjectFactory Matrix_proxyObjectFactory;
Matrix_ptr Matrix_proxyObjectFactory::__nil_Matrix = 0;

