Mercurial > vim
comparison src/if_python.c @ 856:8cd729851562 v7.0g
updated for version 7.0g
author | vimboss |
---|---|
date | Sun, 30 Apr 2006 18:54:39 +0000 |
parents | 83a006f81bac |
children | 8fd2e00c44ae |
comparison
equal
deleted
inserted
replaced
855:d2a4f08396fe | 856:8cd729851562 |
---|---|
451 ++recurse; | 451 ++recurse; |
452 | 452 |
453 #ifdef DYNAMIC_PYTHON | 453 #ifdef DYNAMIC_PYTHON |
454 if (hinstPython && Py_IsInitialized()) | 454 if (hinstPython && Py_IsInitialized()) |
455 { | 455 { |
456 Python_RestoreThread(); /* enter python */ | 456 Python_RestoreThread(); /* enter python */ |
457 Py_Finalize(); | 457 Py_Finalize(); |
458 } | 458 } |
459 end_dynamic_python(); | 459 end_dynamic_python(); |
460 #else | 460 #else |
461 if (Py_IsInitialized()) | 461 if (Py_IsInitialized()) |
462 { | 462 { |
463 Python_RestoreThread(); /* enter python */ | 463 Python_RestoreThread(); /* enter python */ |
464 Py_Finalize(); | 464 Py_Finalize(); |
465 } | 465 } |
466 #endif | 466 #endif |
467 | 467 |
468 --recurse; | 468 --recurse; |
469 } | 469 } |
1103 char ptrBuf[NUMBUFLEN]; | 1103 char ptrBuf[NUMBUFLEN]; |
1104 | 1104 |
1105 /* Avoid infinite recursion */ | 1105 /* Avoid infinite recursion */ |
1106 if (depth > 100) | 1106 if (depth > 100) |
1107 { | 1107 { |
1108 Py_INCREF(Py_None); | 1108 Py_INCREF(Py_None); |
1109 result = Py_None; | 1109 result = Py_None; |
1110 return result; | 1110 return result; |
1111 } | 1111 } |
1112 | 1112 |
1113 /* Check if we run into a recursive loop. The item must be in lookupDict | 1113 /* Check if we run into a recursive loop. The item must be in lookupDict |
1114 * then and we can use it again. */ | 1114 * then and we can use it again. */ |
1115 sprintf(ptrBuf, "%ld", (long)our_tv); | 1115 sprintf(ptrBuf, "%ld", (long)our_tv); |
1116 result = PyDict_GetItemString(lookupDict, ptrBuf); | 1116 result = PyDict_GetItemString(lookupDict, ptrBuf); |
1117 if (result != NULL) | 1117 if (result != NULL) |
1118 Py_INCREF(result); | 1118 Py_INCREF(result); |
1119 else if (our_tv->v_type == VAR_STRING) | 1119 else if (our_tv->v_type == VAR_STRING) |
1120 { | 1120 { |
1121 result = Py_BuildValue("s", our_tv->vval.v_string); | 1121 result = Py_BuildValue("s", our_tv->vval.v_string); |
1122 PyDict_SetItemString(lookupDict, ptrBuf, result); | 1122 PyDict_SetItemString(lookupDict, ptrBuf, result); |
1123 } | 1123 } |
1124 else if (our_tv->v_type == VAR_NUMBER) | 1124 else if (our_tv->v_type == VAR_NUMBER) |
1125 { | 1125 { |
1126 char buf[NUMBUFLEN]; | 1126 char buf[NUMBUFLEN]; |
1127 | 1127 |
1128 /* For backwards compatibility numbers are stored as strings. */ | 1128 /* For backwards compatibility numbers are stored as strings. */ |
1129 sprintf(buf, "%ld", (long)our_tv->vval.v_number); | 1129 sprintf(buf, "%ld", (long)our_tv->vval.v_number); |
1130 result = Py_BuildValue("s", buf); | 1130 result = Py_BuildValue("s", buf); |
1131 PyDict_SetItemString(lookupDict, ptrBuf, result); | 1131 PyDict_SetItemString(lookupDict, ptrBuf, result); |
1132 } | 1132 } |
1133 else if (our_tv->v_type == VAR_LIST) | 1133 else if (our_tv->v_type == VAR_LIST) |
1134 { | 1134 { |
1135 list_T *list = our_tv->vval.v_list; | 1135 list_T *list = our_tv->vval.v_list; |
1136 listitem_T *curr; | 1136 listitem_T *curr; |
1137 | 1137 |
1138 result = PyList_New(0); | 1138 result = PyList_New(0); |
1139 PyDict_SetItemString(lookupDict, ptrBuf, result); | 1139 PyDict_SetItemString(lookupDict, ptrBuf, result); |
1140 | 1140 |
1141 if (list != NULL) | 1141 if (list != NULL) |
1142 { | 1142 { |
1143 for (curr = list->lv_first; curr != NULL; curr = curr->li_next) | 1143 for (curr = list->lv_first; curr != NULL; curr = curr->li_next) |
1144 { | 1144 { |
1148 } | 1148 } |
1149 } | 1149 } |
1150 } | 1150 } |
1151 else if (our_tv->v_type == VAR_DICT) | 1151 else if (our_tv->v_type == VAR_DICT) |
1152 { | 1152 { |
1153 result = PyDict_New(); | 1153 result = PyDict_New(); |
1154 PyDict_SetItemString(lookupDict, ptrBuf, result); | 1154 PyDict_SetItemString(lookupDict, ptrBuf, result); |
1155 | 1155 |
1156 if (our_tv->vval.v_dict != NULL) | 1156 if (our_tv->vval.v_dict != NULL) |
1157 { | 1157 { |
1158 hashtab_T *ht = &our_tv->vval.v_dict->dv_hashtab; | 1158 hashtab_T *ht = &our_tv->vval.v_dict->dv_hashtab; |
1159 int todo = ht->ht_used; | 1159 int todo = ht->ht_used; |
1174 } | 1174 } |
1175 } | 1175 } |
1176 } | 1176 } |
1177 else | 1177 else |
1178 { | 1178 { |
1179 Py_INCREF(Py_None); | 1179 Py_INCREF(Py_None); |
1180 result = Py_None; | 1180 result = Py_None; |
1181 } | 1181 } |
1182 | 1182 |
1183 return result; | 1183 return result; |
1184 } | 1184 } |
1185 | 1185 |