• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PredatorCZ / HavokLib / 89

06 Nov 2025 01:09PM UTC coverage: 63.837% (-3.2%) from 67.014%
89

push

github

PredatorCZ
s

3354 of 5254 relevant lines covered (63.84%)

129082.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.91
/python/hk_rootlevelcontainer.cpp
1
#include "hk_rootlevelcontainer.hpp"
2
#include <structmember.h>
3
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
4

5
static PyMemberDef hkNamedVariantPyMembers[] = {
6
    {"name", T_OBJECT_EX, offsetof(hkNamedVariantPy, name), 0, "Variant Name"},
7
    {"class_name", T_OBJECT_EX, offsetof(hkNamedVariantPy, className), 0,
8
     "Variant Class Name"},
9
    {"object", T_OBJECT_EX, offsetof(hkNamedVariantPy, object), 0,
10
     "Variant Object"},
11
    {NULL},
12
};
13

14
PyTypeObject *hkNamedVariantPy::GetType() {
3 ✔
15
  static PyTypeObject hkNamedVariantPyType{
16
      .tp_name = "hkNamedVariant",
17
      .tp_basicsize = sizeof(hkNamedVariantPy),
18
      .tp_flags = Py_TPFLAGS_DEFAULT,
19
      .tp_doc = "Havok Named Variant",
20
      .tp_members = (PyMemberDef *)hkNamedVariantPyMembers,
21
      .tp_init = (initproc)hkNamedVariantPy::Init,
22
      .tp_new = hkNamedVariantPy::New,
23
  };
24

25
  return &hkNamedVariantPyType;
3 ✔
26
}
27

28
PyObject *hkNamedVariantPy::New(PyTypeObject *type, PyObject *, PyObject *) {
2 ✔
29
  hkNamedVariantPy *self = (hkNamedVariantPy *)type->tp_alloc(type, 0);
2 ✔
30

31
  if (self) {
2 ✔
32
    self->name = PyUnicode_FromString("");
2 ✔
33
    if (!self->name) {
2 ✔
34
      Py_DECREF(self);
×
35
      return nullptr;
×
36
    }
37

38
    self->className = PyUnicode_FromString("");
2 ✔
39
    if (!self->className) {
2 ✔
40
      Py_DECREF(self);
×
41
      return nullptr;
×
42
    }
43

44
    self->object = Py_None;
2 ✔
45
    Py_INCREF(Py_None);
2 ✔
46
  }
47

48
  return (PyObject *)self;
2 ✔
49
}
50

51
int hkNamedVariantPy::Init(hkNamedVariantPy *self, PyObject *args,
2 ✔
52
                           PyObject *kwds) {
53
  static char *kwList[] = {"name", "class_name", "object", nullptr};
54

55
  if (!PyArg_ParseTupleAndKeywords(args, kwds, "|UUO", kwList, &self->name,
2 ✔
56
                                   &self->className, &self->object)) {
57
    return -1;
×
58
  }
59

60
  return 0;
2 ✔
61
}
62

63
static PyMappingMethods hkRootLevelContainerPyMappingMethods{
64
    (lenfunc)hkRootLevelContainerPy::Len,
65
    (binaryfunc)hkRootLevelContainerPy::Subscript,
66
    0,
67
};
68

69
PyTypeObject *hkRootLevelContainerPy::GetType() {
2 ✔
70
  static PyTypeObject hkRootLevelContainerPyType{
71
      .tp_name = "hkRootLevelContainer",
72
      .tp_basicsize = sizeof(hkRootLevelContainerPy),
73
      .tp_as_mapping = &hkRootLevelContainerPyMappingMethods,
74
      .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IS_ABSTRACT,
75
      .tp_doc = "Havok Root Level Container",
76
      .tp_iter = (getiterfunc)hkRootLevelContainerPy::Iter,
77
      .tp_iternext = (iternextfunc)hkRootLevelContainerPy::IterNext,
78
  };
79

80
  return &hkRootLevelContainerPyType;
2 ✔
81
}
82

83
PyObject *hkRootLevelContainerPy::Alloc(const IhkVirtualClass *cls) {
1 ✔
84
  auto cted = reinterpret_cast<hkRootLevelContainerPy *>(
85
      PyType_GenericAlloc(GetType(), 0));
1 ✔
86
  cted->hkClass = checked_deref_cast<const hkRootLevelContainer>(cls);
1 ✔
87

88
  return reinterpret_cast<PyObject *>(cted);
1 ✔
89
}
90

91
size_t hkRootLevelContainerPy::Len(hkRootLevelContainerPy *self) {
3 ✔
92
  return self->hkClass->Size();
3 ✔
93
}
94

95
PyObject *hkRootLevelContainerPy::Subscript(hkRootLevelContainerPy *self,
×
96
                                            PyObject *index) {
97
  const auto id = PyLong_AsSsize_t(index);
×
98
  return self->SubscriptRaw(id);
×
99
}
100

101
PyObject *hkRootLevelContainerPy::SubscriptRaw(size_t index) {
2 ✔
102
  auto cVar = hkClass->At(index);
2 ✔
103
  hkNamedVariantPy *hkVar = reinterpret_cast<hkNamedVariantPy *>(
104
      PyType_GenericAlloc(hkNamedVariantPy::GetType(), 0));
2 ✔
105
  hkVar->name = PyUnicode_FromStringAndSize(cVar.name.data(), cVar.name.size());
2 ✔
106
  hkVar->className =
2 ✔
107
      PyUnicode_FromStringAndSize(cVar.className.data(), cVar.className.size());
2 ✔
108

109
  JenHash classHash(cVar.className);
2 ✔
110

111
  auto foundCt = hkClasses.find(classHash);
2 ✔
112

113
  if (foundCt != hkClasses.end()) {
2 ✔
114
    hkVar->object = foundCt->second(cVar.pointer);
2 ✔
115
  }
116

117
  return reinterpret_cast<PyObject *>(hkVar);
2 ✔
118
}
119

120
PyObject *hkRootLevelContainerPy::Iter(hkRootLevelContainerPy *self) {
1 ✔
121
  self->iterPos = 0;
1 ✔
122
  return reinterpret_cast<PyObject *>(self);
1 ✔
123
}
124

125
PyObject *hkRootLevelContainerPy::IterNext(hkRootLevelContainerPy *self) {
3 ✔
126
  if (self->iterPos < self->Len(self)) {
3 ✔
127
    return self->SubscriptRaw(self->iterPos++);
2 ✔
128
  } else {
129
    PyErr_SetNone(PyExc_StopIteration);
1 ✔
130
    return nullptr;
1 ✔
131
  }
132
}
133

134
void hkRootLevelContainerPy::InitType(PyObject *module) {
1 ✔
135
  PyAddTypes<hkRootLevelContainerPy, hkNamedVariantPy>(module);
1 ✔
136
}
1 ✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc