OverlayComp* OverlayComp::TopComp() { OverlayComp* comp = this; OverlayComp* parent = (OverlayComp*)comp->GetParent(); while (parent) comp = (OverlayComp*) comp->GetParent(); return comp; }
int FrameFileScript::ReadPathName (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { FrameFileComp* filecomp = (FrameFileComp*)addr1; char pathname[BUFSIZ]; if (ParamList::parse_pathname(in, pathname, BUFSIZ, filecomp->GetBaseDir()) != 0) return -1; /* check pathname for recursion */ OverlayComp* parent = (OverlayComp*) filecomp->GetParent(); while (parent != nil) { if (parent->GetPathName() && strcmp(parent->GetPathName(), pathname) == 0) { cerr << "framefile recursion not allowed (" << pathname << ")\n"; return -1; } parent = (OverlayComp*) parent->GetParent(); } filecomp->SetPathName(pathname); FrameIdrawComp* child = nil; FrameCatalog* catalog = (FrameCatalog*)unidraw->GetCatalog(); catalog->SetParent(filecomp); if( catalog->FrameCatalog::Retrieve(pathname, (Component*&)child)) { catalog->SetParent(nil); catalog->Forget(child); filecomp->Append(child); return 0; } else { catalog->SetParent(nil); return -1; } }
void GrParentFunc::execute() { ComValue compv(stack_arg(0)); reset_stack(); if(compv.is_object() && compv.object_compview()) { ComponentView* compview = (ComponentView*)compv.obj_val(); OverlayComp* comp = (OverlayComp*)compview->GetSubject(); if (comp && comp->GetParent()) { ComValue retval(new OverlayViewRef((OverlayComp*)comp->GetParent()), ((OverlayComp*)comp->GetParent())->classid()); push_stack(retval); return; } } push_stack(ComValue::nullval()); return; }
int OverlayFileScript::ReadPathName (istream& in, void* addr1, void* addr2, void* addr3, void* addr4) { OverlayFileComp* filecomp = (OverlayFileComp*)addr1; const char* paramname = ParamList::CurrParamStruct()->name(); filecomp->SetPopenFlag(strcmp(paramname, "popen")==0); char pathname[BUFSIZ]; if (filecomp->GetPopenFlag()) { if (ParamList::parse_string(in, pathname, BUFSIZ) != 0) return -1; } else { if (ParamList::parse_pathname(in, pathname, BUFSIZ, filecomp->GetBaseDir()) != 0) return -1; } /* check pathname for recursion */ OverlayComp* parent = (OverlayComp*) filecomp->GetParent(); while (!filecomp->GetPopenFlag() && parent != nil) { if (parent->GetPathName() && strcmp(parent->GetPathName(), pathname) == 0) { cerr << "pathname recursion not allowed (" << pathname << ")\n"; return -1; } parent = (OverlayComp*) parent->GetParent(); } filecomp->SetPathName(pathname); if (!filecomp->GetPopenFlag()) { OverlayIdrawComp* child = nil; OverlayCatalog* catalog = (OverlayCatalog*) unidraw->GetCatalog(); catalog->SetParent(filecomp); if( catalog->OverlayCatalog::Retrieve(pathname, (Component*&)child)) { catalog->SetParent(nil); catalog->Forget(child); filecomp->Append(child); return 0; } else { catalog->SetParent(nil); return -1; } } else { OvImportCmd impcmd((Editor*)nil); FILE* fptr = popen(pathname, "r"); if (fptr) { FILEBUF(fbuf, fptr, ios_base::in); istream ifs(&fbuf); OverlayComp* child = (OverlayComp*) impcmd.Import(ifs); if (child) { filecomp->Append(child); return 0; } fclose(fptr); } return -1; } }