Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OODebugMonitor(Private) Category Reference
+ Inheritance diagram for OODebugMonitor(Private):
+ Collaboration diagram for OODebugMonitor(Private):

Instance Methods

(void) - setUpDebugConsoleScript
 
(void) - javaScriptEngineWillReset:
 
(void) - disconnectDebuggerWithMessage:
 
(NSDictionary *) - mergedConfiguration
 
(NSMutableDictionary *) - normalizeConfigDictionary:
 
(id) - normalizeConfigValue:forKey:
 
(NSArray *) - loadSourceFile:
 
(oneway void) - jsEngine:context:error:stackSkip:showingLocation:withMessage: [implementation]
 
(oneway void) - jsEngine:context:logMessage:ofClass: [implementation]
 
(jsval) - oo_jsValueInContext: [implementation]
 

Detailed Description

Definition at line 53 of file OODebugMonitor.m.

Method Documentation

◆ disconnectDebuggerWithMessage:

- (void) disconnectDebuggerWithMessage: (NSString *) message

Extends class OODebugMonitor.

Definition at line 419 of file OODebugMonitor.m.

781 :(NSString *)message
782{
783 @try
784 {
785 [_debugger disconnectDebugMonitor:self message:message];
786 }
787 @catch (NSException *exception)
788 {
789 OOLog(@"debugMonitor.debuggerConnection.exception", @"Exception while attempting to disconnect debugger: %@ -- %@", [exception name], [exception reason]);
790 }
791
792 id debugger = _debugger;
793 _debugger = nil;
794 [debugger release];
795}
#define OOLog(class, format,...)
Definition OOLogging.h:88
return nil

◆ javaScriptEngineWillReset:

- (void) javaScriptEngineWillReset: (NSNotification *) notification

Extends class OODebugMonitor.

Definition at line 419 of file OODebugMonitor.m.

772 :(NSNotification *)notification
773{
774 DESTROY(_script);
775 _jsSelf = NULL;
776
778}
#define DESTROY(x)
Definition OOCocoa.h:77
void OOJSConsoleDestroy(void)

◆ jsEngine:context:error:stackSkip:showingLocation:withMessage:

- (oneway void) jsEngine: (in byref OOJavaScriptEngine *) engine
context: (in JSContext *) context
error: (in JSErrorReport *) errorReport
stackSkip: (in unsigned) stackSkip
showingLocation: (in BOOL) showLocation
withMessage: (in NSString *) message 
implementation

Extends class OODebugMonitor.

Definition at line 419 of file OODebugMonitor.m.

871 :(in byref OOJavaScriptEngine *)engine
872 context:(in JSContext *)context
873 error:(in JSErrorReport *)errorReport
874 stackSkip:(in unsigned)stackSkip
875 showingLocation:(in BOOL)showLocation
876 withMessage:(in NSString *)message
877{
878 NSString *colorKey = nil;
879 NSString *prefix = nil;
880 NSString *filePath = nil;
881 NSString *sourceLine = nil;
882 NSString *scriptLine = nil;
883 NSMutableString *formattedMessage = nil;
884 NSRange emphasisRange;
885 NSString *showKey = nil;
886
887 if (_debugger == nil) return;
888
889 if (errorReport->flags & JSREPORT_WARNING)
890 {
891 colorKey = @"warning";
892 prefix = @"Warning";
893 }
894 else if (errorReport->flags & JSREPORT_EXCEPTION)
895 {
896 colorKey = @"exception";
897 prefix = @"Exception";
898 }
899 else
900 {
901 colorKey = @"error";
902 prefix = @"Error";
903 }
904
905 if (errorReport->flags & JSREPORT_STRICT)
906 {
907 prefix = [prefix stringByAppendingString:@" (strict mode)"];
908 }
909
910 // Prefix and subsequent colon should be bold:
911 emphasisRange = NSMakeRange(0, [prefix length] + 1);
912
913 formattedMessage = [NSMutableString stringWithFormat:@"%@: %@", prefix, message];
914
915 // Note that the "active script" isn't necessarily the one causing the
916 // error, since one script can call another's methods.
917
918 // avoid windows DEP exceptions!
920 scriptLine = [[thisScript weakRefUnderlyingObject] displayName];
921 [thisScript release];
922
923 if (scriptLine != nil)
924 {
925 [formattedMessage appendFormat:@"\n Active script: %@", scriptLine];
926 }
927
928 if (showLocation && stackSkip == 0)
929 {
930 // Append file name and line
931 if (errorReport->filename != NULL) filePath = [NSString stringWithUTF8String:errorReport->filename];
932 if ([filePath length] != 0)
933 {
934 [formattedMessage appendFormat:@"\n %@, line %u", [filePath lastPathComponent], errorReport->lineno];
935
936 // Append source code
937 sourceLine = [self sourceCodeForFile:filePath line:errorReport->lineno];
938 if (sourceLine != nil)
939 {
940 [formattedMessage appendFormat:@":\n %@", sourceLine];
941 }
942 }
943 }
944
945 [self appendJSConsoleLine:formattedMessage
946 colorKey:colorKey
947 emphasisRange:emphasisRange];
948
949 if (errorReport->flags & JSREPORT_WARNING) showKey = @"show-console-on-warning";
950 else showKey = @"show-console-on-error"; // if not a warning, it's a proper error.
951 if (OOBooleanFromObject([self configurationValueForKey:showKey], NO))
952 {
953 [self showJSConsole];
954 }
955}
BOOL OOBooleanFromObject(id object, BOOL defaultValue)
OOJSScript * currentlyRunningScript()
Definition OOJSScript.m:339

◆ jsEngine:context:logMessage:ofClass:

- (oneway void) jsEngine: (in byref OOJavaScriptEngine *) engine
context: (in JSContext *) context
logMessage: (in NSString *) message
ofClass: (in NSString *) messageClass 
implementation

Extends class OODebugMonitor.

Definition at line 419 of file OODebugMonitor.m.

958 :(in byref OOJavaScriptEngine *)engine
959 context:(in JSContext *)context
960 logMessage:(in NSString *)message
961 ofClass:(in NSString *)messageClass
962{
963 [self appendJSConsoleLine:message colorKey:@"log"];
964 if (OOBooleanFromObject([self configurationValueForKey:@"show-console-on-log"], NO))
965 {
966 [self showJSConsole];
967 }
968}

◆ loadSourceFile:

- (NSArray *) loadSourceFile: (NSString *) filePath

Extends class OODebugMonitor.

Definition at line 419 of file OODebugMonitor.m.

810 :(NSString *)filePath
811{
812 NSString *contents = nil;
813 NSArray *lines = nil;
814
815 if (filePath == nil) return nil;
816
817 contents = [NSString stringWithContentsOfUnicodeFile:filePath];
818 if (contents == nil) return nil;
819
820 /* Extract lines from file.
821FIXME: this works with CRLF and LF, but not CR.
822 */
823 lines = [contents componentsSeparatedByString:@"\n"];
824 return lines;
825}

◆ mergedConfiguration

- (NSDictionary *) mergedConfiguration

Extends class OODebugMonitor.

Definition at line 419 of file OODebugMonitor.m.

799{
800 NSMutableDictionary *result = nil;
801
802 result = [NSMutableDictionary dictionary];
803 if (_configFromOXPs != nil) [result addEntriesFromDictionary:_configFromOXPs];
804 if (_configOverrides != nil) [result addEntriesFromDictionary:_configOverrides];
805
806 return result;
807}

◆ normalizeConfigDictionary:

- (NSMutableDictionary *) normalizeConfigDictionary: (NSDictionary *) dictionary

Extends class OODebugMonitor.

Definition at line 419 of file OODebugMonitor.m.

828 :(NSDictionary *)dictionary
829{
830 NSMutableDictionary *result = nil;
831 NSEnumerator *keyEnum = nil;
832 NSString *key = nil;
833 id value = nil;
834
835 result = [NSMutableDictionary dictionaryWithCapacity:[dictionary count]];
836 for (keyEnum = [dictionary keyEnumerator]; (key = [keyEnum nextObject]); )
837 {
838 value = [dictionary objectForKey:key];
839 value = [self normalizeConfigValue:value forKey:key];
840
841 if (key != nil && value != nil) [result setObject:value forKey:key];
842 }
843
844 return result;
845}

◆ normalizeConfigValue:forKey:

- (id) normalizeConfigValue: (id) value
forKey: (NSString *) key 

Extends class OODebugMonitor.

Definition at line 419 of file OODebugMonitor.m.

848 :(id)value forKey:(NSString *)key
849{
850 OOColor *color = nil;
851 BOOL boolValue;
852
853 if (value != nil)
854 {
855 if ([key hasSuffix:@"-color"] || [key hasSuffix:@"-colour"])
856 {
857 color = [OOColor colorWithDescription:value];
858 value = [color normalizedArray];
859 }
860 else if ([key hasPrefix:@"show-console"])
861 {
862 boolValue = OOBooleanFromObject(value, NO);
863 value = [NSNumber numberWithBool:boolValue];
864 }
865 }
866
867 return value;
868}
OOColor * colorWithDescription:(id description)
Definition OOColor.m:127
NSArray * normalizedArray()
Definition OOColor.m:511

◆ oo_jsValueInContext:

- (jsval) oo_jsValueInContext: (JSContext *) context
implementation

Extends class OODebugMonitor.

Definition at line 419 of file OODebugMonitor.m.

971 :(JSContext *)context
972{
973 if (_jsSelf == NULL)
974 {
975 _jsSelf = DebugMonitorToJSConsole(context, self);
976 if (_jsSelf != NULL)
977 {
978 if (!OOJSAddGCObjectRoot(context, &_jsSelf, "debug console"))
979 {
980 _jsSelf = NULL;
981 }
982 }
983 }
984
985 if (_jsSelf != NULL) return OBJECT_TO_JSVAL(_jsSelf);
986 else return JSVAL_NULL;
987}
JSObject * DebugMonitorToJSConsole(JSContext *context, OODebugMonitor *monitor)
#define OOJSAddGCObjectRoot(context, root, name)

◆ setUpDebugConsoleScript

- (void) setUpDebugConsoleScript

Extends class OODebugMonitor.

Definition at line 419 of file OODebugMonitor.m.

740{
741 JSContext *context = OOJSAcquireContext();
742 /* The path to the console script is saved in this here static variable
743 so that we can reload it when resetting into strict mode.
744 -- Ahruman 2011-02-06
745 */
746 static NSString *path = nil;
747
748 if (path == nil)
749 {
750 path = [[ResourceManager pathForFileNamed:@"oolite-debug-console.js" inFolder:@"Scripts"] retain];
751 }
752 if (path != nil)
753 {
754 NSDictionary *jsProps = [NSDictionary dictionaryWithObjectsAndKeys:
755 self, @"console",
756 JSSpecialFunctionsObjectWrapper(context), @"special",
757 nil];
758 _script = [[OOJSScript scriptWithPath:path properties:jsProps] retain];
759 }
760
761 // If no script, just make console visible globally as debugConsole.
762 if (_script == nil)
763 {
764 JSObject *global = [[OOJavaScriptEngine sharedEngine] globalObject];
765 JS_DefineProperty(context, global, "debugConsole", [self oo_jsValueInContext:context], NULL, NULL, JSPROP_ENUMERATE);
766 }
767
768 OOJSRelinquishContext(context);
769}
OOINLINE JSContext * OOJSAcquireContext(void)
OOINLINE void OOJSRelinquishContext(JSContext *context)
id scriptWithPath:properties:(NSString *path,[properties] NSDictionary *properties)
Definition OOJSScript.m:112
OOJavaScriptEngine * sharedEngine()
NSString * pathForFileNamed:inFolder:(NSString *fileName,[inFolder] NSString *folderName)

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