MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / ptrAt

Method ptrAt

common/script/scriptargs.cpp:93–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91}
92
93void* ScriptArgs::ptrAt(int i, bool allowNull) const
94{
95 struct Value* value = at(i);
96 // Every pointer parameter — char*, char**, int*, struct directory*,
97 // struct JSON* — arrives as TypePointer; picoc allocates the argument slot
98 // from the prototype, so an array argument has already decayed by here.
99 if (value->Typ == nullptr || value->Typ->Base != TypePointer) {
100 fail("argument %d is declared %s, read as a pointer", i + 1, value->Typ != nullptr ? baseName(value->Typ->Base) : "untyped");
101 }
102 void* ptr = value->Val->Pointer;
103 if (ptr == nullptr && !allowNull) {
104 fail("argument %d must not be NULL", i + 1);
105 }
106 return ptr;
107}
108
109/* ---- integers ---------------------------------------------------------- */
110

Callers

nothing calls this directly

Calls 2

atFunction · 0.85
baseNameFunction · 0.85

Tested by

no test coverage detected