3
// pyContext.cc Created on: 2002/01/17
4
// Author : Duncan Grisby (dpg1)
6
// Copyright (C) 2002 AT&T Laboratories Cambridge
8
// This file is part of the omniORBpy library
10
// The omniORBpy library is free software; you can redistribute it
11
// and/or modify it under the terms of the GNU Lesser General
12
// Public License as published by the Free Software Foundation;
13
// either version 2.1 of the License, or (at your option) any later
16
// This library is distributed in the hope that it will be useful,
17
// but WITHOUT ANY WARRANTY; without even the implied warranty of
18
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
// GNU Lesser General Public License for more details.
21
// You should have received a copy of the GNU Lesser General Public
22
// License along with this library; if not, write to the Free
23
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
30
// $Id: pyContext.cc,v 1.1.4.3 2005/06/24 17:36:08 dgrisby Exp $
31
// $Log: pyContext.cc,v $
32
// Revision 1.1.4.3 2005/06/24 17:36:08 dgrisby
33
// Support for receiving valuetypes inside Anys; relax requirement for
34
// old style classes in a lot of places.
36
// Revision 1.1.4.2 2003/05/20 17:10:23 dgrisby
37
// Preliminary valuetype support.
39
// Revision 1.1.4.1 2003/03/23 21:51:57 dgrisby
40
// New omnipy3_develop branch.
42
// Revision 1.1.2.2 2003/03/14 15:29:22 dgrisby
43
// Remove const char* -> char* warnings.
45
// Revision 1.1.2.1 2002/01/18 15:49:44 dpg1
46
// Context support. New system exception construction. Fix None call problem.
51
OMNI_USING_NAMESPACE(omni)
55
omniPy::validateContext(PyObject* c_o, CORBA::CompletionStatus compstatus)
57
if (!isInstance(c_o, pyCORBAContextClass))
58
OMNIORB_THROW(BAD_PARAM, BAD_PARAM_WrongPythonType, compstatus);
62
omniPy::marshalContext(cdrStream& stream, PyObject* p_o, PyObject* c_o)
64
PyObject* values = PyObject_CallMethod(c_o, (char*)"_get_values",
67
PyObject* items = PyDict_Items(values);
68
CORBA::ULong count = PyList_GET_SIZE(items);
69
CORBA::ULong mlen = count * 2;
72
for (CORBA::ULong i=0; i < count; i++) {
73
PyObject* item = PyList_GET_ITEM(items, i);
74
omniPy::marshalRawPyString(stream, PyTuple_GET_ITEM(item, 0));
75
omniPy::marshalRawPyString(stream, PyTuple_GET_ITEM(item, 1));
80
if (omniORB::trace(1)) {
83
l << "Exception trying to get Context values:\n";
90
OMNIORB_THROW(TRANSIENT, TRANSIENT_PythonExceptionInORB,
96
omniPy::unmarshalContext(cdrStream& stream)
98
PyObject* dict = PyDict_New();
103
OMNIORB_THROW(MARSHAL,
104
MARSHAL_InvalidContextList,
105
CORBA::COMPLETED_MAYBE);
107
CORBA::ULong count = mlen / 2;
109
for (CORBA::ULong i=0; i < count; i++) {
110
PyObject* k = omniPy::unmarshalRawPyString(stream);
111
PyObject* v = omniPy::unmarshalRawPyString(stream);
112
PyDict_SetItem(dict, k, v);
116
PyObject* r = PyObject_CallFunction(omniPy::pyCORBAContextClass,
117
(char*)"sON", "", Py_None, dict);
119
if (omniORB::trace(1)) {
122
l << "Exception trying to construct Context:\n";
129
OMNIORB_THROW(TRANSIENT, TRANSIENT_PythonExceptionInORB,
130
CORBA::COMPLETED_NO);
137
omniPy::filterContext(PyObject* p_o, PyObject* c_o)
139
PyObject* values = PyObject_CallMethod(c_o, (char*)"_get_values",
143
PyObject* r = PyObject_CallFunction(omniPy::pyCORBAContextClass,
144
(char*)"sON", "", Py_None, values);
147
if (omniORB::trace(1)) {
150
l << "Exception trying to filter Context:\n";
157
OMNIORB_THROW(TRANSIENT, TRANSIENT_PythonExceptionInORB,
158
CORBA::COMPLETED_NO);