MCPcopy Create free account
hub / github.com/bytedance/sonic-cpp / EndObject

Method EndObject

include/sonic/dom/schema_handler.h:232–271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230 }
231
232 sonic_force_inline bool EndObject(uint32_t pairs) {
233 if (parent_node_ && parent_node_->IsObject()) {
234 parent_node_ = parent_st_.back();
235 parent_st_.pop_back();
236 cur_node_ = nullptr;
237 found_node_count_ = found_count_st_.back();
238 found_count_st_.pop_back();
239 return true;
240 }
241 // all object is need create
242 NodeType *obj_ptr;
243 void *obj_member_ptr;
244 if (parent_ == 0) {
245 obj_ptr = parent_st_.back();
246 obj_member_ptr = &st_[0];
247 parent_st_.pop_back();
248 // resotre parent node ptr
249 parent_node_ = parent_st_.back();
250 parent_st_.pop_back();
251 cur_node_ = nullptr;
252 np_ = 0;
253 parent_ = 0;
254 } else {
255 obj_ptr = &(st_[parent_]);
256 obj_member_ptr = &st_[parent_ + 1];
257 np_ = parent_ + 1;
258 parent_ = obj_ptr->o.next.ofs;
259 }
260 NodeType &obj = *obj_ptr;
261 obj.setLength(pairs, kObject);
262 if (pairs) {
263 void *mem = obj.template containerMalloc<MemberType>(pairs, *alloc_);
264 obj.setChildren(mem);
265 internal::Xmemcpy<sizeof(MemberType)>(
266 (void *)obj.getObjChildrenFirstUnsafe(), obj_member_ptr, pairs);
267 } else {
268 obj.setChildren(nullptr);
269 }
270 return true;
271 }
272
273 sonic_force_inline bool EndArray(uint32_t count) {
274 // Assert cur_node != nullptr!!

Callers

nothing calls this directly

Calls 3

IsObjectMethod · 0.80
setChildrenMethod · 0.80

Tested by

no test coverage detected