- Timestamp:
- Aug 3, 2008, 11:04:29 PM (16 years ago)
- Location:
- trunk/src/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/RpBindingsDict.cc
r1011 r1084 15 15 RpDict DICT_TEMPLATE_L ObjDict_Lib; 16 16 RpDict DICT_TEMPLATE_U ObjDictUnits; 17 RpDict DICT_TEMPLATE_V ObjDict_Void; 17 18 18 19 /**********************************************************************/ … … 35 36 int dictKey = key; 36 37 int newEntry = 0; 38 bool ci = false; 37 39 38 40 if (objectName) { … … 45 47 } 46 48 long int dictKey_long = dictKey; 47 ObjDict_Lib.set(dictKey_long,objectName,NULL,&newEntry );49 ObjDict_Lib.set(dictKey_long,objectName,NULL,&newEntry,ci); 48 50 retVal = dictKey; 49 51 } … … 94 96 void 95 97 cleanLibDict () { 96 // clean up the dictionary97 98 98 RpDictEntry DICT_TEMPLATE_L *hPtr; 99 // RpDictIterator DICT_TEMPLATE iter(fortObjDict_Lib);100 99 // should rp_quit clean up the dict or some function in RpBindingsCommon.h 101 100 RpDictIterator DICT_TEMPLATE_L iter(ObjDict_Lib); … … 104 103 105 104 while (hPtr) { 106 // Py_DECREF(*(hPtr->getValue()));107 105 hPtr->erase(); 108 106 hPtr = iter.next(); 109 107 } 110 108 111 // if (fortObjDict_Lib.size()) {112 109 if (ObjDict_Lib.size()) { 113 110 // probably want to change the warning sometime … … 135 132 int dictNextKey = ObjDictUnits.size() + 1; 136 133 int newEntry = 0; 134 bool ci = false; 137 135 138 136 if (objectName != "") { … … 141 139 // the new entry. 142 140 long int dictNextKey_long = dictNextKey; 143 ObjDictUnits.set(dictNextKey_long,objectName, NULL, &newEntry);141 ObjDictUnits.set(dictNextKey_long,objectName,NULL,&newEntry,ci); 144 142 retVal = dictNextKey; 145 143 } … … 189 187 void 190 188 cleanUnitsDict () { 191 // clean up the dictionary192 193 189 RpDictEntry DICT_TEMPLATE_U *hPtr; 194 190 // should rp_quit clean up the dict or some function in RpBindingsCommon.h … … 207 203 } 208 204 } 205 206 /**********************************************************************/ 207 // FUNCTION: storeObject_Void() 208 /// Store an object into the general dictionary. 209 /** 210 * This function stores a void* object pointed to by 'objectName' 211 * into the general dictionary. This is helpful for writing bindings 212 * for languages that can not accept pointers to provide back to the 213 * function's caller. 214 * 215 * Returns the key of the object in the dictionary 216 * On Error, returns 0 (which also means nothing can be stored at 0) 217 */ 218 219 size_t 220 storeObject_Void(void* objectName, size_t key) { 221 222 size_t retVal = 0; 223 size_t dictKey = key; 224 int newEntry = 0; 225 bool ci = false; 226 227 if (objectName) { 228 // dictionary returns a reference to the inserted value 229 // no error checking to make sure it was successful in entering 230 // the new entry. 231 232 if (dictKey == 0) { 233 dictKey = ObjDict_Void.size() + 1; 234 } 235 ObjDict_Void.set(dictKey,objectName,NULL,&newEntry,ci); 236 retVal = dictKey; 237 } 238 239 return retVal; 240 } 241 242 /**********************************************************************/ 243 // FUNCTION: getObject_Void() 244 /// Get an object from the general dictionary. 245 /** 246 * This function retrieves the void* object associated with the key 247 * 'objKey' from the general dictionary and returns its address to the 248 * caller. This is helpful for writing bindings for languages that can 249 * not accept pointers to provide back to the function's caller. 250 * 251 * Returns the address of the void* object in the dictionary 252 */ 253 254 void* 255 getObject_Void(size_t objKey) { 256 257 RpDictEntry DICT_TEMPLATE_V* voidEntry = &(ObjDict_Void.getNullEntry()); 258 RpDictEntry DICT_TEMPLATE_V* nullEntry = &(ObjDict_Void.getNullEntry()); 259 260 voidEntry = &(ObjDict_Void.find(objKey)); 261 262 if ( (!voidEntry->isValid()) || (voidEntry == nullEntry) ) { 263 return NULL; 264 } 265 266 return *(voidEntry->getValue()); 267 268 } 269 270 /**********************************************************************/ 271 // FUNCTION: cleanVoidDict() 272 /// Clean the library dictionary, removing all entries in the dictionary 273 /** 274 * This function removes all entries from the library dictionary. 275 * 276 * \sa {storeObject_Lib,getObject_Lib} 277 */ 278 279 void 280 cleanVoidDict () { 281 RpDictEntry DICT_TEMPLATE_V *hPtr; 282 // should rp_quit clean up the dict or some function in RpBindingsCommon.h 283 RpDictIterator DICT_TEMPLATE_V iter(ObjDict_Void); 284 285 hPtr = iter.first(); 286 287 while (hPtr) { 288 hPtr->erase(); 289 hPtr = iter.next(); 290 } 291 292 if (ObjDict_Lib.size()) { 293 // probably want to change the warning sometime 294 // printf("\nWARNING: internal dictionary is not empty..deleting\n"); 295 } 296 297 } 298 -
trunk/src/core/RpBindingsDict.h
r1011 r1084 30 30 #define DICT_TEMPLATE_L <long,RpLibrary*> 31 31 #define DICT_TEMPLATE_U <long,std::string> 32 #define DICT_TEMPLATE_V <size_t,void*> 32 33 33 34 // global declaration of library and units dictionaries … … 37 38 extern RpDict DICT_TEMPLATE_L ObjDict_Lib; 38 39 extern RpDict DICT_TEMPLATE_U ObjDictUnits; 40 extern RpDict DICT_TEMPLATE_V ObjDict_Void; 39 41 40 42 41 43 int storeObject_Lib(RpLibrary* objectName, int key=0); 42 44 int storeObject_UnitsStr(std::string objectName); 45 size_t storeObject_Void(void* objectName, size_t key=0); 43 46 44 47 RpLibrary* getObject_Lib(int objKey); 45 48 const RpUnits* getObject_UnitsStr(int objKey); 49 void* getObject_Void(size_t objKey); 46 50 47 51 void cleanLibDict(); 48 52 void cleanUnitsDict(); 53 void cleanVoidDict(); 49 54 50 55 #ifdef __cplusplus
Note: See TracChangeset
for help on using the changeset viewer.