MCPcopy Create free account
hub / github.com/libgit2/pygit2 / _cache_enums

Function _cache_enums

src/pygit2.c:376–411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

374 "defined in pygit2.enums.\n");
375
376PyObject *
377_cache_enums(PyObject *self, PyObject *args)
378{
379 (void) args;
380
381 /* In case this is somehow being called several times, let go of old references */
382 forget_enums();
383
384 PyObject *enums = PyImport_ImportModule("pygit2.enums");
385 if (enums == NULL) {
386 return NULL;
387 }
388
389#define CACHE_PYGIT2_ENUM(name) do { \
390 name##Enum = PyObject_GetAttrString(enums, #name); \
391 if (name##Enum == NULL) { goto fail; } \
392} while (0)
393
394 CACHE_PYGIT2_ENUM(DeltaStatus);
395 CACHE_PYGIT2_ENUM(DiffFlag);
396 CACHE_PYGIT2_ENUM(FileMode);
397 CACHE_PYGIT2_ENUM(FileStatus);
398 CACHE_PYGIT2_ENUM(MergeAnalysis);
399 CACHE_PYGIT2_ENUM(MergePreference);
400 CACHE_PYGIT2_ENUM(ObjectType);
401 CACHE_PYGIT2_ENUM(ReferenceType);
402
403#undef CACHE_PYGIT2_ENUM
404
405 Py_RETURN_NONE;
406
407fail:
408 Py_DECREF(enums);
409 forget_enums();
410 return NULL;
411}
412
413void
414free_module(void *self)

Callers 1

__init__.pyFile · 0.85

Calls 1

forget_enumsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…