Oolite
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

Definition at line 419 of file OODebugMonitor.m.

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

◆ javaScriptEngineWillReset:

- (void) javaScriptEngineWillReset: (NSNotification *)  notification

Definition at line 419 of file OODebugMonitor.m.

768 :(NSNotification *)notification
769{
770 DESTROY(_script);
771 _jsSelf = NULL;
772
774}
#define DESTROY(x)
Definition OOCocoa.h:75
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

Definition at line 419 of file OODebugMonitor.m.

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

◆ jsEngine:context:logMessage:ofClass:

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

Definition at line 419 of file OODebugMonitor.m.

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

◆ loadSourceFile:

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

Definition at line 419 of file OODebugMonitor.m.

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

◆ mergedConfiguration

- (NSDictionary *) mergedConfiguration

Definition at line 419 of file OODebugMonitor.m.

795{
796 NSMutableDictionary *result = nil;
797
798 result = [NSMutableDictionary dictionary];
799 if (_configFromOXPs != nil) [result addEntriesFromDictionary:_configFromOXPs];
800 if (_configOverrides != nil) [result addEntriesFromDictionary:_configOverrides];
801
802 return result;
803}

◆ normalizeConfigDictionary:

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

Definition at line 419 of file OODebugMonitor.m.

824 :(NSDictionary *)dictionary
825{
826 NSMutableDictionary *result = nil;
827 NSString *key = nil;
828 id value = nil;
829
830 result = [NSMutableDictionary dictionaryWithCapacity:[dictionary count]];
831 foreachkey (key, dictionary)
832 {
833 value = [dictionary objectForKey:key];
834 value = [self normalizeConfigValue:value forKey:key];
835
836 if (key != nil && value != nil) [result setObject:value forKey:key];
837 }
838
839 return result;
840}
#define foreachkey(VAR, DICT)
Definition OOCocoa.h:353

◆ normalizeConfigValue:forKey:

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

Definition at line 419 of file OODebugMonitor.m.

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

◆ oo_jsValueInContext:

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

Definition at line 419 of file OODebugMonitor.m.

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

◆ setUpDebugConsoleScript

- (void) setUpDebugConsoleScript

Definition at line 419 of file OODebugMonitor.m.

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