MCPcopy Create free account
hub / github.com/ZDoom/Raze / CreateDerivedClass

Method CreateDerivedClass

source/common/objects/dobjtype.cpp:539–591  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

537//==========================================================================
538
539PClass *PClass::CreateDerivedClass(FName name, unsigned int size, bool *newlycreated, int fileno)
540{
541 assert(size >= Size);
542 PClass *type;
543 bool notnew;
544
545 const PClass *existclass = FindClass(name);
546
547 if (newlycreated) *newlycreated = false;
548 if (existclass != nullptr)
549 {
550 // This is a placeholder so fill it in
551 if (existclass->Size == TentativeClass)
552 {
553 type = const_cast<PClass*>(existclass);
554 if (!IsDescendantOf(type->ParentClass))
555 {
556 I_Error("%s must inherit from %s but doesn't.", name.GetChars(), type->ParentClass->TypeName.GetChars());
557 }
558 DPrintf(DMSG_SPAMMY, "Defining placeholder class %s\n", name.GetChars());
559 notnew = true;
560 }
561 else
562 {
563 // a different class with the same name already exists. Let the calling code deal with this.
564 return nullptr;
565 }
566 }
567 else
568 {
569 type = new PClass;
570 notnew = false;
571 }
572
573 type->TypeName = name;
574 type->bRuntimeClass = true;
575 Derive(type, name);
576 type->Size = size;
577 if (size != TentativeClass)
578 {
579 NewClassType(type, fileno);
580 if (newlycreated) *newlycreated = true;
581 type->Virtuals = Virtuals;
582 }
583 else
584 type->bOptional = false;
585
586 if (!notnew)
587 {
588 type->InsertIntoHash(false);
589 }
590 return type;
591}
592
593//==========================================================================
594//

Callers 2

FinalizeSetupMethod · 0.80
CreateClassTypesMethod · 0.80

Calls 5

I_ErrorFunction · 0.85
DPrintfFunction · 0.85
NewClassTypeFunction · 0.85
InsertIntoHashMethod · 0.80
GetCharsMethod · 0.45

Tested by

no test coverage detected