Oolite
Loading...
Searching...
No Matches
OOJSScript(OOPrivate) Category Reference

Instance Methods

(NSString *) - scriptNameFromPath:
(NSDictionary *) - defaultPropertiesFromPath:
(NSString *) - scriptNameFromPath:
(NSDictionary *) - defaultPropertiesFromPath:
(void) - checkForTickle:

Detailed Description

Definition at line 95 of file OOJSScript.m.

Method Documentation

◆ checkForTickle:

- (void) checkForTickle: (JSContext*) context

Extends class OOJSScript.

Definition at line 585 of file OOJSScript.m.

585 :(JSContext*)context
586{
587 JSValue tickle = JS_GetPropertyStr(context, _jsSelf, "tickle");
588 if (JS_IsException(tickle)) {
589 JS_FreeValue(context, JS_GetException(context));
590 } else if (!JS_IsUndefined(tickle)) {
591 OOJSReportWarning(context, @"Script %@ appears to use the tickle() event handler, which is no longer supported.", [self name]);
592 }
593 JS_FreeValue(context, tickle);
594}
void OOJSReportWarning(JSContext *context, NSString *format,...)

References OOJSReportWarning().

Here is the call graph for this function:

◆ defaultPropertiesFromPath: [1/2]

- (NSDictionary *) defaultPropertiesFromPath: (NSString*) path

Extends class OOJSScript.

Definition at line 554 of file OOJSScript.m.

554 :(NSString*)path
555{
556 // remove file name, remove OXP subfolder, add manifest.plist
557 NSString* manifestPath = [[[path stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"manifest.plist"];
558 NSDictionary* manifest = OODictionaryFromFile(manifestPath);
559 NSMutableDictionary* properties = [NSMutableDictionary dictionaryWithCapacity:3];
560 /* __oolite.tmp.* is allocated for OXPs without manifests. Its
561 * values are meaningless and shouldn't be used here */
562 if (manifest != nil && ![[manifest oo_stringForKey:kOOManifestIdentifier] hasPrefix:@"__oolite.tmp."]) {
563 if ([manifest objectForKey:kOOManifestVersion] != nil) {
564 [properties setObject:[manifest oo_stringForKey:kOOManifestVersion] forKey:@"version"];
565 }
566 if ([manifest objectForKey:kOOManifestIdentifier] != nil) {
567 // used for system info
568 [properties setObject:[manifest oo_stringForKey:kOOManifestIdentifier] forKey:kLocalManifestProperty];
569 }
570 if ([manifest objectForKey:kOOManifestAuthor] != nil) {
571 [properties setObject:[manifest oo_stringForKey:kOOManifestAuthor] forKey:@"author"];
572 }
573 if ([manifest objectForKey:kOOManifestLicense] != nil) {
574 [properties setObject:[manifest oo_stringForKey:kOOManifestLicense] forKey:@"license"];
575 }
576 }
577 return properties;
578}
static NSString *const kOOManifestLicense
static NSString *const kOOManifestIdentifier
static NSString *const kOOManifestVersion
static NSString *const kOOManifestAuthor
NSDictionary * OODictionaryFromFile(NSString *path)
return nil

References kOOManifestAuthor, kOOManifestIdentifier, kOOManifestLicense, kOOManifestVersion, nil, and OODictionaryFromFile().

Here is the call graph for this function:

◆ defaultPropertiesFromPath: [2/2]

- (NSDictionary *) defaultPropertiesFromPath: (NSString *) path

Extends class OOJSScript.

◆ scriptNameFromPath: [1/2]

- (NSString *) scriptNameFromPath: (NSString*) path

Extends class OOJSScript.

Definition at line 522 of file OOJSScript.m.

522 :(NSString*)path
523{
524 NSString* lastComponent = nil;
525 NSString* truncatedPath = nil;
526 NSString* theName = nil;
527
528 if (path == nil)
529 theName = [NSString stringWithFormat:@"%p", self];
530 else {
531 lastComponent = [path lastPathComponent];
532 if (![lastComponent hasPrefix:@"script."])
533 theName = lastComponent;
534 else {
535 truncatedPath = [path stringByDeletingLastPathComponent];
536 if (NSOrderedSame == [[truncatedPath lastPathComponent] caseInsensitiveCompare:@"Config"]) {
537 truncatedPath = [truncatedPath stringByDeletingLastPathComponent];
538 }
539 if (NSOrderedSame == [[truncatedPath pathExtension] caseInsensitiveCompare:@"oxp"]) {
540 truncatedPath = [truncatedPath stringByDeletingPathExtension];
541 }
542
543 lastComponent = [truncatedPath lastPathComponent];
544 theName = lastComponent;
545 }
546 }
547
548 if (0 == [theName length])
549 theName = path;
550
551 return StrippedName([theName stringByAppendingString:@".anon-script"]);
552}
static NSString * StrippedName(NSString *string)
Definition OOJSScript.m:967

References nil, and StrippedName().

Here is the call graph for this function:

◆ scriptNameFromPath: [2/2]

- (NSString *) scriptNameFromPath: (NSString *) path

Extends class OOJSScript.


The documentation for this category was generated from the following files: