//--------------------------------------------------------------------------------------- // Actor@named(Name name) <ThisClass_> static void mthdc_named(SkInvokedMethod * scope_p, SkInstance ** result_pp) { if (result_pp) // Do nothing if result not desired { // Find actor SkClass * sk_class_p; UClass * ue_class_p; SkInstance * instance_p; SkInstance * name_p = scope_p->get_arg(SkArg_1); AActor * actor_p = find_named( name_p->get_class() == SkUEName::get_class() ? name_p->as<SkUEName>() : AStringToFName(name_p->as<SkString>()), scope_p, &sk_class_p, &ue_class_p, &instance_p); #if (SKOOKUM & SK_DEBUG) if (!actor_p) { SK_ERRORX(a_str_format("Tried to get instance named '%s' from class '%s', but no such instance exists!\n", scope_p->get_arg<SkString>(SkArg_1).as_cstr(), ((SkMetaClass *)scope_p->get_topmost_scope())->get_class_info()->get_name().as_cstr_dbg())); } #endif // Create instance from our actor, even if null *result_pp = instance_p ? instance_p : SkUEActor::new_instance(actor_p, ue_class_p, sk_class_p); } }
rdelete(char *name) /* Delete a (closed) file from ram-disk. */ { Temp_file *tpf; char ***platters; char **tracks; char *sectors; int i; if ((tpf = find_named(name)) == NULL) return(NULL); if (tpf->flags & TF_OPEN) { return(rerr = Err_in_use); } platters = tpf->platters; while ((tracks = *platters) != NULL) { i = TRD_TRACK; while (--i >= 0 && (sectors = *tracks++) != NULL) tfree_sector(sectors); tfree_sector(*platters++); } tfree_sector(tpf->platters); tpf->flags = 0; return(Success); }
Rfile ropen(char *name, int mode) /* Open a file on ram-disk */ { Temp_file *tpf; int flags; if ((flags = flags_for_mode(mode)) < Success) return(NULL); if ((tpf = find_named(name)) != NULL) { if (tpf->flags & TF_OPEN) { rerr = Err_in_use; return(NULL); } tpf->filep = 0; tpf->flags = flags; tpf->omode = mode; return(tpf); } if ((flags&TF_READ)) { rerr = Err_no_file; return(NULL); } if ((tpf = find_empty_slot()) != NULL) { strncpy(tpf->name, name, TFNAME_SIZE-1); tpf->flags = flags; tpf->omode = mode; } return(tpf); }
Errcode rexists(char *name) /* Return Success if a file is on the ram-disk. */ { if (find_named(name) == NULL) return(rerr); return(Success); }
//--------------------------------------------------------------------------------------- // Actor@object_id_find(Name name) <ThisClass_|None> static void mthdc_object_id_find(SkInvokedMethod * scope_p, SkInstance ** result_pp) { if (result_pp) // Do nothing if result not desired { // Find actor SkClass * sk_class_p; UClass * ue_class_p; SkInstance * instance_p; AActor * actor_p = find_named( scope_p->get_arg<SkUEName>(SkArg_1), scope_p, &sk_class_p, &ue_class_p, &instance_p); // Create instance from our actor, or return nil if none found *result_pp = instance_p ? instance_p : (actor_p ? SkUEActor::new_instance(actor_p, ue_class_p, sk_class_p) : SkBrain::ms_nil_p); } }
Rfile rcreate(char *name,int mode) /* Create a file on ram-disk. */ { Temp_file *tpf; int flags; if ((flags = flags_for_mode(mode)) < Success) return(NULL); if ((tpf = find_named(name)) != NULL) if (rdelete(name) < Success) return(NULL); if ((tpf = find_empty_slot()) == NULL) return(NULL); strncpy(tpf->name, name, TFNAME_SIZE-1); tpf->flags = flags; tpf->omode = mode; return(tpf); }
//--------------------------------------------------------------------------------------- // Actor@find_named(Name name) <ThisClass_|None> static void mthdc_find_named(SkInvokedMethod * scope_p, SkInstance ** result_pp) { if (result_pp) // Do nothing if result not desired { // Find actor SkClass * sk_class_p; UClass * ue_class_p; SkInstance * instance_p; SkInstance * name_p = scope_p->get_arg(SkArg_1); AActor * actor_p = find_named( name_p->get_class() == SkUEName::get_class() ? name_p->as<SkUEName>() : AStringToFName(name_p->as<SkString>()), scope_p, &sk_class_p, &ue_class_p, &instance_p); // Create instance from our actor, or return nil if none found *result_pp = instance_p ? instance_p : (actor_p ? SkUEActor::new_instance(actor_p, ue_class_p, sk_class_p) : SkBrain::ms_nil_p); } }