@@ -101,47 +101,36 @@ static unsigned int len( const CompoundObject &o )
101101 return o.members ().size ();
102102}
103103
104- static ObjectPtr getItem ( const CompoundObject &o, const char * n )
104+ static ObjectPtr getItem ( const CompoundObject &o, const InternedString & n )
105105{
106106 CompoundObject::ObjectMap::const_iterator it = o.members ().find ( n );
107107 if ( it==o.members ().end () )
108108 {
109- PyErr_SetString ( PyExc_KeyError, n );
109+ PyErr_SetString ( PyExc_KeyError, n. c_str () );
110110 throw_error_already_set ();
111111 }
112112 return it->second ;
113113}
114114
115- static void setItem ( CompoundObject &o, const char * n, Object &v )
115+ static void setItem ( CompoundObject &o, const InternedString & n, Object &v )
116116{
117117 o.members ()[n] = &v;
118118}
119119
120- static void delItem ( CompoundObject &o, const char * n )
120+ static void delItem ( CompoundObject &o, const InternedString & n )
121121{
122122 CompoundObject::ObjectMap::iterator it = o.members ().find ( n );
123123 if ( it==o.members ().end () )
124124 {
125- PyErr_SetString ( PyExc_KeyError, n );
125+ PyErr_SetString ( PyExc_KeyError, n. c_str () );
126126 throw_error_already_set ();
127127 }
128128 o.members ().erase ( it );
129129}
130130
131- static bool contains ( const CompoundObject &o, const char * n )
131+ static bool contains ( const CompoundObject &o, const InternedString & n )
132132{
133- CompoundObject::ObjectMap::const_iterator it = o.members ().find ( n );
134- if ( it==o.members ().end () )
135- {
136- return false ;
137- }
138- return true ;
139- }
140-
141- static bool has_key ( const CompoundObject &o, const char *n )
142- {
143- CompoundObject::ObjectMap::const_iterator it = o.members ().find ( n );
144- return ( it != o.members ().end () );
133+ return o.members ().find ( n ) != o.members ().end ();
145134}
146135
147136static boost::python::list keys ( const CompoundObject &o )
@@ -226,7 +215,7 @@ class CompoundObjectFromPythonDict
226215 {
227216 key = keys[i];
228217 value = v[key];
229- extract<const char * > keyElem (key);
218+ extract<InternedString > keyElem (key);
230219 if (!keyElem.check ())
231220 {
232221 PyErr_SetString (PyExc_TypeError, " Incompatible key type. Only strings accepted." );
@@ -279,7 +268,7 @@ static CompoundObjectPtr copyConstructor( ConstCompoundObjectPtr other )
279268}
280269
281270// / binding for get method
282- static ObjectPtr get ( const CompoundObject &o, const char * key, ObjectPtr defaultValue )
271+ static ObjectPtr get ( const CompoundObject &o, const IECore::InternedString & key, ObjectPtr defaultValue )
283272{
284273 CompoundObject::ObjectMap::const_iterator it = o.members ().find ( key );
285274 if ( it == o.members ().end () )
@@ -307,7 +296,7 @@ void bindCompoundObject()
307296 .def ( " __setitem__" , &setItem )
308297 .def ( " __delitem__" , &delItem )
309298 .def ( " __contains__" , &contains )
310- .def ( " has_key" , &has_key )
299+ .def ( " has_key" , &contains )
311300 .def ( " keys" , &keys )
312301 .def ( " values" , &values )
313302 .def ( " items" , &items )
0 commit comments