├── .gitignore ├── EngineRoom-OSX ├── EngineRoom-OSX.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ └── EngineRoom-OSX.xcscheme ├── English.lproj │ ├── ConsoleWindow.xib │ ├── ERAboutWindow.xib │ ├── EngineRoom.xib │ ├── InfoPlist.strings │ └── LogPointsWindow.xib ├── Info.plist └── Sources-OSX │ ├── ConsoleWindowController.h │ ├── ConsoleWindowController.m │ ├── ERAboutWindowController.h │ ├── ERAboutWindowController.m │ ├── LogPointArrayController.h │ ├── LogPointArrayController.m │ ├── LogPointsWindowController.h │ └── LogPointsWindowController.m ├── EngineRoom-iOS ├── EngineRoom-iOS.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ └── EngineRoom-iOS.xcscheme └── Sources-iOS │ └── placeholder.txt ├── EngineRoom.xcodeproj └── project.pbxproj ├── EngineRoom ├── Convenience.h ├── CrossPlatform.h ├── CrossPlatform.m ├── CrossPlatform_Images.h ├── CrossPlatform_Images.m ├── CrossPlatform_NSString_CGGeometry.h ├── CrossPlatform_NSValue_CGGeometry.h ├── CrossPlatform_NSValue_CGGeometry.m ├── CrossPlatform_Target.h ├── CrossPlatform_Utilities.h ├── ERUtility │ ├── ERCGUtilities.h │ ├── ERColor.h │ ├── ERColor.m │ ├── ERColorTransformer.h │ ├── ERColorTransformer.m │ ├── ERUtility.h │ ├── ERUtility.m │ ├── ERValueConverter.h │ ├── ERValueConverter.m │ ├── ERValueTransformer.h │ ├── ERValueTransformer.m │ ├── NSBundle_ERExtensions.h │ ├── NSBundle_ERExtensions.m │ ├── NSObject_ERExtensions.h │ ├── NSObject_ERExtensions.m │ ├── NSPropertyListSerialization_ERExtensions.h │ └── NSPropertyListSerialization_ERExtensions.m ├── EngineRoom.h ├── EngineRoom.m ├── EngineRoomController.h ├── EngineRoomController.m ├── EngineRoom_Prefix.pch ├── LogPoint.h ├── LogPoint.m ├── er_compat.h ├── er_macros.h ├── er_symbols.h ├── er_util.c ├── er_util.h ├── logpoints.c ├── logpoints.h ├── logpoints.m ├── logpoints_api.h ├── logpoints_base_macros.h ├── logpoints_bk.h ├── logpoints_default.h ├── logpoints_default_kinds.h ├── logpoints_default_macros.h ├── logpoints_default_policy.h ├── logpoints_nslog.h ├── logpoints_private.h ├── logpoints_types.h ├── macros.pl ├── tracer.c ├── tracer.h └── tracer.m ├── HOWTO.txt ├── LICENSE.txt ├── README.markdown ├── Resources ├── AboutIcon.png ├── MenuIcon.png ├── Sam_Taeguk-fine-18.png ├── Sam_Taeguk-fine-54.png ├── Sam_Taeguk-fine-540.png ├── Sam_Taeguk-fine.svg ├── screenshot.png └── screenshot_free.png ├── Test-OSX ├── ClangExprDiagnostic.c ├── ClangTestCase.c ├── EngineRoomTest.xcodeproj │ └── project.pbxproj ├── EngineRoomTest_Prefix.pch ├── English.lproj │ ├── Credits.rtf │ ├── InfoPlist.strings │ ├── MainMenu.nib │ │ ├── designable.nib │ │ └── keyedobjects.nib │ └── MyDocument.nib │ │ ├── designable.nib │ │ └── keyedobjects.nib ├── Info.plist ├── MyDocument.h ├── MyDocument.m └── main.m ├── build.sh ├── experimental ├── LocalInvoker.c ├── arg.m ├── argtest.m ├── asmtest.m ├── build.sh ├── builtin_apply.m ├── caveman.h ├── fulltest.c ├── modern_caveman.m ├── perftest.m ├── str.m ├── tracer64_fail ├── tst.m └── voidcrash.m ├── scratch ├── Formats.txt ├── Notes.txt ├── TestCases.txt ├── logpoints_auto_format.h ├── logpoints_default_old.h ├── logpoints_doc.h ├── logpoints_functions.c.h ├── macros_overdone.pl ├── oldautogen.pl └── ste.txt ├── test ├── cavetest.c ├── lp_test.sh ├── lptest.c ├── lptest.m ├── t.c ├── t.sh └── tracer_test.sh └── tools └── patchLicense /.gitignore: -------------------------------------------------------------------------------- 1 | # xcode noise 2 | build 3 | *.pbxuser 4 | *.mode1v3 5 | *.mode2v3 6 | *.perspectivev3 7 | 8 | # xcode 4 9 | xcuserdata 10 | *.xcworkspace 11 | 12 | # SVN directories 13 | .svn 14 | 15 | # osx noise 16 | .DS_Store 17 | profile 18 | 19 | # emacs noise 20 | *~ 21 | *# 22 | \#* 23 | .#* 24 | 25 | # vi noise 26 | .*.swp 27 | -------------------------------------------------------------------------------- /EngineRoom-OSX/EngineRoom-OSX.xcodeproj/xcshareddata/xcschemes/EngineRoom-OSX.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 42 | 43 | 44 | 45 | 53 | 54 | 56 | 57 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /EngineRoom-OSX/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bkrpub/EngineRoom/fd63f69e7f7499963f677a464af5c9312c9924bd/EngineRoom-OSX/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /EngineRoom-OSX/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | org.jumper.${PRODUCT_NAME:rfc1034Identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleShortVersionString 20 | ${ER_VERSION} 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | ${ER_VERSION_BUNDLE} 25 | NSPrincipalClass 26 | 27 | ERValueTransformers 28 | 29 | ERLessThanZero 30 | SELF < 0 31 | ERLessThanOrEqualToZero 32 | SELF <= 0 33 | ERGreaterThanZero 34 | SELF > 0 35 | ERGreaterThanOrEqualToZero 36 | SELF >= 0 37 | EREqualToZero 38 | SELF == 0 39 | EREqualToOne 40 | SELF == 1 41 | ERNotEqualToZero 42 | SELF != 0 43 | ERNotEqualToOne 44 | SELF != 1 45 | ERSizeBaseTen 46 | 47 | #class 48 | ERStringExpressionTransformer 49 | predicate 50 | SELF < 1000000 51 | expression 52 | FUNCTION( SELF / 1000.0, 'er_formatDouble:', '%.1fkB' ) 53 | alternateExpression 54 | FUNCTION( SELF / 1000000.0, 'er_formatDouble:', '%.2fMB' ) 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /EngineRoom-OSX/Sources-OSX/ConsoleWindowController.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #import 24 | 25 | 26 | @interface ConsoleWindowController : NSWindowController { 27 | IBOutlet NSArrayController *messageArrayController; 28 | NSMutableArray *p_messages; 29 | } 30 | 31 | - (IBAction) clear: (id) sender; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /EngineRoom-OSX/Sources-OSX/ConsoleWindowController.m: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #import "ConsoleWindowController.h" 24 | #import "LogPoint.h" 25 | #import "logpoints_bk.h" 26 | 27 | 28 | @implementation ConsoleWindowController 29 | 30 | // all this global stuff is still a huge mess, more demo than anything 31 | 32 | NSArrayController *globalMessageArrayController = nil; 33 | LOGPOINT_EMITTER globalSavedEmitter = NULL; 34 | 35 | LOGPOINT_EMITTER_DECLARATION(logPointConsoleWindowEmitter) 36 | { 37 | if( NULL == logFormat || 0 == *logFormat ) { 38 | return LOGPOINT_NO; 39 | } 40 | 41 | if( NULL == payload ) { 42 | payload = ""; 43 | } 44 | 45 | char stackBuffer[LOGPOINT_EMITTER_STACKBUFFER]; 46 | size_t wantedSize = strlen(payload) + LOGPOINT_MAX_DECORATION_LENGTH; 47 | 48 | char *buffer = logPointAllocateBufferIfNeeded(stackBuffer, sizeof(stackBuffer), wantedSize); 49 | 50 | if( NULL != buffer ) { 51 | logPointFormat(lpp, langSpec1, langSpec2, buffer, wantedSize, NULL, NULL, logFormat, payload); 52 | 53 | #if MAINTAINER_WARNINGS 54 | #warning need to check return value 55 | #endif 56 | 57 | NSString *nsMsg = [NSString stringWithUTF8String: buffer]; 58 | 59 | NSLog(@"CONSOLE: %s", buffer); 60 | [globalMessageArrayController addObject: [NSDictionary dictionaryWithObjectsAndKeys: nsMsg, @"message", nil]]; 61 | 62 | logPointFreeBufferIfNeeded(buffer, stackBuffer); 63 | 64 | } else { 65 | NSLog(@"CONSOLE: logPoints: out of memory - payload: %s", payload); 66 | } 67 | 68 | return LOGPOINT_YES; 69 | } 70 | 71 | - (NSMutableArray *) messages 72 | { 73 | return [[p_messages retain] autorelease]; 74 | } 75 | 76 | - (void) setMessages: (id) newMessages 77 | { 78 | if( newMessages != p_messages ) { 79 | [p_messages autorelease]; 80 | p_messages = [newMessages retain]; 81 | } 82 | } 83 | 84 | - (id) init 85 | { 86 | self = [super initWithWindowNibName: @"ConsoleWindow" owner: self]; 87 | return self; 88 | } 89 | 90 | - (void) dealloc 91 | { 92 | logPointSetEmitter(globalSavedEmitter); 93 | globalSavedEmitter = NULL; 94 | 95 | [self setMessages: nil]; 96 | globalMessageArrayController = nil; 97 | 98 | [super dealloc]; 99 | } 100 | 101 | 102 | - (void) windowDidLoad 103 | { 104 | [super windowDidLoad]; 105 | 106 | [self setMessages: [NSMutableArray array]]; 107 | 108 | globalMessageArrayController = messageArrayController; 109 | 110 | globalSavedEmitter = logPointSetEmitter(logPointConsoleWindowEmitter); 111 | } 112 | 113 | - (IBAction) clear: (id) sender 114 | { 115 | [globalMessageArrayController removeObjects: [globalMessageArrayController arrangedObjects]]; 116 | } 117 | 118 | @end 119 | -------------------------------------------------------------------------------- /EngineRoom-OSX/Sources-OSX/ERAboutWindowController.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #import 24 | 25 | 26 | @interface ERAboutWindowController : NSWindowController { 27 | IBOutlet NSImageView *iconView; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /EngineRoom-OSX/Sources-OSX/ERAboutWindowController.m: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #import "ERAboutWindowController.h" 24 | 25 | @implementation ERAboutWindowController 26 | 27 | - (void) awakeFromNib 28 | { 29 | } 30 | 31 | - (id) init 32 | { 33 | self = [super initWithWindowNibName: @"ERAboutWindow" owner: self]; 34 | return self; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /EngineRoom-OSX/Sources-OSX/LogPointArrayController.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #import 24 | 25 | @interface LogPointArrayController : NSArrayController 26 | { 27 | } 28 | 29 | - (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /EngineRoom-OSX/Sources-OSX/LogPointArrayController.m: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #import "LogPointArrayController.h" 24 | #import "LogPoint.h" 25 | 26 | @implementation LogPointArrayController 27 | 28 | - (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex 29 | { 30 | (void) aTableView; 31 | (void) aTableColumn; 32 | (void) rowIndex; 33 | 34 | if( NO == [aCell isKindOfClass: [NSButtonCell class]] ) 35 | return; 36 | 37 | // LogPoint *logPoint = [[self arrangedObjects] objectAtIndex: rowIndex]; 38 | // [aCell setTitle: [logPoint stateSummary]]; 39 | 40 | //[aCell setShowsStateBy: [aCell showsStateBy] | NSContentsCellMask]; 41 | } 42 | 43 | @end 44 | 45 | -------------------------------------------------------------------------------- /EngineRoom-OSX/Sources-OSX/LogPointsWindowController.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #import 24 | 25 | 26 | @interface LogPointsWindowController : NSWindowController { 27 | IBOutlet NSTextField *infoField; 28 | IBOutlet NSTextField *sessionField; 29 | IBOutlet NSTextField *defaultField; 30 | } 31 | 32 | - (void) updateDefaultField; 33 | 34 | - (void) presentModalError: (NSError *) error; 35 | 36 | - (IBAction) enableLogPointsMatchedBySessionField: (id) sender; 37 | - (IBAction) disableLogPointsMatchedBySessionField: (id) sender; 38 | - (IBAction) enableOnlyLogPointsMatchedBySessionField: (id) sender; 39 | 40 | - (IBAction) applyAndSaveDefault: (id) sender; 41 | 42 | - (IBAction) enableAll: (id) sender; 43 | 44 | - (IBAction) disableAll: (id) sender; 45 | 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /EngineRoom-OSX/Sources-OSX/LogPointsWindowController.m: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #import "LogPointsWindowController.h" 24 | #import "LogPoint.h" 25 | #import "logpoints_bk.h" 26 | 27 | @implementation LogPointsWindowController ( WindowDelegate ) 28 | 29 | - (void)windowDidBecomeKey:(NSNotification *)notification 30 | { 31 | [self updateDefaultField]; 32 | } 33 | 34 | @end 35 | 36 | @implementation LogPointsWindowController 37 | 38 | - (id) init 39 | { 40 | self = [super initWithWindowNibName: @"LogPointsWindow" owner: self]; 41 | return self; 42 | } 43 | 44 | - (void) updateDefaultField 45 | { 46 | NSString *filter = [[NSUserDefaults standardUserDefaults] valueForKey: kLogPointFilterUserDefaultsKey]; 47 | [defaultField setStringValue: filter ? filter : @""]; 48 | } 49 | 50 | - (void) windowDidLoad 51 | { 52 | [super windowDidLoad]; 53 | [self updateDefaultField]; 54 | } 55 | 56 | - (void)didPresentErrorWithRecovery:(BOOL)didRecover contextInfo:(void *)contextInfo 57 | { 58 | // NSLog(@"didPresentErrorWithRecovery: %d ctx: %@", didRecover, contextInfo); 59 | } 60 | 61 | - (void) presentModalError: (NSError *) error 62 | { 63 | [[[self window] firstResponder] presentError: error modalForWindow:[self window] delegate: self didPresentSelector:@selector(didPresentErrorWithRecovery:contextInfo:) contextInfo: nil]; 64 | } 65 | 66 | - (IBAction) enableAll: (id) sender 67 | { 68 | [LogPoint makeAllLogPointsPerformSelector: @selector(activate)]; 69 | } 70 | 71 | - (IBAction) disableAll: (id) sender 72 | { 73 | [LogPoint makeAllLogPointsPerformSelector: @selector(deactivate)]; 74 | } 75 | 76 | 77 | - (IBAction) enableLogPointsMatchedBySessionField: (id) sender 78 | { 79 | NSError *error = nil; 80 | if( 0 > [LogPoint makeLogPointsMatchingFilterString: [sessionField stringValue] performSelector: @selector(activate) error: &error] ) { 81 | [self presentModalError: error]; 82 | } 83 | } 84 | 85 | - (IBAction) disableLogPointsMatchedBySessionField: (id) sender 86 | { 87 | NSError *error = nil; 88 | if( 0 > [LogPoint makeLogPointsMatchingFilterString: [sessionField stringValue] performSelector: @selector(deactivate) error: &error] ) { 89 | [self presentModalError: error]; 90 | } 91 | } 92 | 93 | - (IBAction) enableOnlyLogPointsMatchedBySessionField: (id) sender 94 | { 95 | NSError *error = nil; 96 | if( 0 > [LogPoint enableOnlyLogPointsMatchingFilterString: [sessionField stringValue] error: &error] ) { 97 | [self presentModalError: error]; 98 | } 99 | } 100 | 101 | - (IBAction) applyAndSaveDefault: (id) sender 102 | { 103 | NSError *error = nil; 104 | NSString *filter = [defaultField stringValue]; 105 | if( 0 > [LogPoint enableOnlyLogPointsMatchingFilterString: filter error: &error] ) { 106 | [self presentModalError: error]; 107 | } else { 108 | NSString *version = [[NSBundle bundleForClass: [LogPoint class]] valueForKeyPath: @"infoDictionary.CFBundleShortVersionString"]; 109 | 110 | [[NSUserDefaults standardUserDefaults] setValue: filter forKey: kLogPointFilterUserDefaultsKey]; 111 | [[NSUserDefaults standardUserDefaults] setValue: version forKey: kLogPointFilterVersionUserDefaultsKey]; 112 | [[NSUserDefaults standardUserDefaults] synchronize]; 113 | } 114 | } 115 | 116 | 117 | 118 | @end 119 | -------------------------------------------------------------------------------- /EngineRoom-iOS/EngineRoom-iOS.xcodeproj/xcshareddata/xcschemes/EngineRoom-iOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 40 | 41 | 42 | 43 | 49 | 50 | 52 | 53 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /EngineRoom-iOS/Sources-iOS/placeholder.txt: -------------------------------------------------------------------------------- 1 | nothing yet 2 | -------------------------------------------------------------------------------- /EngineRoom/Convenience.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __ER_CONVENIENCE_H__ 3 | #define __ER_CONVENIENCE_H__ 1 4 | 5 | #import 6 | 7 | #pragma mark - 8 | #pragma mark Localization 9 | 10 | /* extra nil is to avoid non-literal format without args warning */ 11 | #define ER_LOCALIZED_FORMAT(fmt, ...) [NSString stringWithFormat: NSLocalizedString((fmt), @""), ## __VA_ARGS__, nil] 12 | 13 | 14 | 15 | #pragma mark - 16 | #pragma mark NSError Tools 17 | 18 | #define ER_SET_NSERROR(errorPtr, theDomain, theCode, userInfoObjectsAndKeys, ...) \ 19 | do { if( nil != errorPtr ) \ 20 | *(errorPtr) = [NSError errorWithDomain: (theDomain) code: (theCode) userInfo: (userInfoObjectsAndKeys) ? [NSDictionary dictionaryWithObjectsAndKeys: (userInfoObjectsAndKeys), ## __VA_ARGS__, nil] : nil]; \ 21 | } while(0) 22 | 23 | #define ER_PRESENT_NSERROR_REASON(presenter, theDomain, theCode, reasonFormat, ...) \ 24 | ({ NSError *__presentError = nil; \ 25 | ER_SET_NSERROR((&__presentError), (theDomain), (theCode), ER_LOCALIZED_FORMAT(reasonFormat, ## __VA_ARGS__), NSLocalizedFailureReasonErrorKey); \ 26 | if( nil != __presentError ) { [((presenter) ? (NSResponder *)(presenter) : NSApp) presentError: __presentError]; } }) 27 | 28 | #define ER_SET_NSERROR_REASON(errorPtr, theDomain, theCode, reasonFormat, ...) \ 29 | ER_SET_NSERROR((errorPtr), (theDomain), (theCode), ER_LOCALIZED_FORMAT(reasonFormat, ## __VA_ARGS__), NSLocalizedFailureReasonErrorKey) 30 | 31 | #define ER_CHECK_NSERROR_REASON(assertion, errorPtr, theDomain, theCode, reasonFormat, ...) \ 32 | ({ BOOL __check = YES; if( ! (assertion) ) { ER_SET_NSERROR_REASON((errorPtr), (theDomain), (theCode), (reasonFormat), ## __VA_ARGS__); __check = NO; } __check; }) 33 | 34 | #define ER_CHECK_NSERROR_REASON_RETURN_NIL(assertion, errorPtr, theDomain, theCode, reasonFormat, ...) \ 35 | do{ if( NO == ER_CHECK_NSERROR_REASON((assertion), (errorPtr), (theDomain), (theCode), (reasonFormat), ## __VA_ARGS__) ) { return nil; } } while(0) 36 | 37 | #define ER_CHECK_NSERROR_REASON_RETURN_NO(assertion, errorPtr, theDomain, theCode, reasonFormat, ...) \ 38 | do{ if( NO == ER_CHECK_NSERROR_REASON((assertion), (errorPtr), (theDomain), (theCode), (reasonFormat), ## __VA_ARGS__) ) { return NO; } } while(0) 39 | 40 | 41 | #define ER_PRECONDITION_NSERROR_RETURN_NO(cond, errorPtr) \ 42 | ER_CHECK_NSERROR_REASON_RETURN_NO((cond), (errorPtr), NSPOSIXErrorDomain, EINVAL, @"errorPreconditionNotSatisfied: %s", #cond) 43 | 44 | #define ER_PRECONDITION_NSERROR_RETURN_NIL(cond, errorPtr) \ 45 | ER_CHECK_NSERROR_REASON_RETURN_NIL((cond), (errorPtr), NSPOSIXErrorDomain, EINVAL, @"errorPreconditionNotSatisfied: %s", #cond) 46 | 47 | 48 | #pragma mark - 49 | #pragma mark Good stuff from Mike Ash (posted on his blog, renamed for EngineRoom) 50 | 51 | #define ER_IDARRAY(...) (id []){ __VA_ARGS__ } 52 | #define ER_IDCOUNT(...) (sizeof(ER_IDARRAY(__VA_ARGS__)) / sizeof(id)) 53 | 54 | #define ER_ARRAY(...) [NSArray arrayWithObjects: ER_IDARRAY(__VA_ARGS__) count: ER_IDCOUNT(__VA_ARGS__)] 55 | 56 | #define ER_SET(...) [NSSet setWithObjects: ER_IDARRAY(__VA_ARGS__) count: ER_IDCOUNT(__VA_ARGS__)] 57 | 58 | // function is in ERUtility.m 59 | #define ER_DICT(...) ERDictionaryWithKeysAndObjects(ER_IDARRAY(__VA_ARGS__), ER_IDCOUNT(__VA_ARGS__) / 2) 60 | 61 | #define ER_NUMBER_YES [NSNumber numberWithBool: YES] 62 | #define ER_NUMBER_NO [NSNumber numberWithBool: NO] 63 | 64 | #define ER_NUMBER_0 [NSNumber numberWithInteger: 0] 65 | 66 | #endif 67 | /* __ER_CONVENIENCE_H__ */ 68 | -------------------------------------------------------------------------------- /EngineRoom/CrossPlatform.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #ifndef __CROSS_PLATFORM_H__ 24 | #define __CROSS_PLATFORM_H__ 1 25 | 26 | #import 27 | 28 | @interface CrossPlatform : NSObject { 29 | 30 | } 31 | 32 | @end 33 | 34 | #endif 35 | // __CROSS_PLATFORM_H__ 36 | -------------------------------------------------------------------------------- /EngineRoom/CrossPlatform.m: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #import "CrossPlatform.h" 24 | 25 | @implementation CrossPlatform 26 | 27 | @end 28 | 29 | -------------------------------------------------------------------------------- /EngineRoom/CrossPlatform_Images.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #import 24 | 25 | @interface CrossPlatform (Images) 26 | 27 | + (id) platformSpecificBitmapImageNamed: (NSString *) name; 28 | + (id) platformSpecificBitmapImageWithContentsOfURL: (NSURL *) URL error: (NSError **) error; 29 | 30 | + (CGImageRef) CGImageNamed: (NSString *) name; 31 | + (CGImageRef) cachedCGImageNamed: (NSString *) name; 32 | 33 | + (CGImageRef) CGImageWithContentsOfURL: (NSURL *) URL error: (NSError **) error; 34 | 35 | @end 36 | 37 | -------------------------------------------------------------------------------- /EngineRoom/CrossPlatform_Images.m: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #import "CrossPlatform_Images.h" 24 | 25 | static NSMutableDictionary *CGImageCache = nil; 26 | static id idNull = nil; 27 | 28 | void __attribute__((constructor)) construct(void) 29 | { 30 | #if TARGET_OS_IPHONE 31 | #elif TARGET_OS_OSX 32 | #else 33 | #error Unknown TARGET_OS 34 | #endif 35 | 36 | if( nil == CGImageCache ) { 37 | CGImageCache = [[NSMutableDictionary alloc] init]; 38 | } 39 | 40 | if( nil == idNull ) { 41 | idNull = [[NSNull null] retain]; 42 | } 43 | } 44 | 45 | 46 | @implementation CrossPlatform (Images) 47 | 48 | + (id) platformSpecificBitmapImageNamed: (NSString *) name 49 | { 50 | #if TARGET_OS_IPHONE 51 | return [UIImage imageNamed: name]; 52 | #else 53 | return [[[NSImage imageNamed: [name stringByDeletingPathExtension]] representations] objectAtIndex: 0]; 54 | #endif 55 | } 56 | 57 | + (id) platformSpecificBitmapImageWithContentsOfURL: (NSURL *) URL error: (NSError **) error 58 | { 59 | 60 | if( nil != error ) { 61 | *error = nil; 62 | } 63 | 64 | NSData *imageData = [NSData dataWithContentsOfURL: URL options: 0 error: error]; 65 | 66 | id image = imageData ? 67 | #if TARGET_OS_IPHONE 68 | [UIImage imageWithData: imageData] 69 | #else 70 | [NSBitmapImageRep imageRepWithData: imageData] 71 | #endif 72 | : nil; 73 | 74 | // NSLog(@"image for %@: %@", URL, image); 75 | 76 | return image; 77 | } 78 | 79 | + (CGImageRef) CGImageWithContentsOfURL: (NSURL *) URL error: (NSError **) error 80 | { 81 | return [[self platformSpecificBitmapImageWithContentsOfURL: URL error: error] CGImage]; 82 | } 83 | 84 | + (CGImageRef) CGImageNamed: (NSString *) name 85 | { 86 | return [[self platformSpecificBitmapImageNamed: name] CGImage]; 87 | } 88 | 89 | + (CGImageRef) cachedCGImageNamed: (NSString *) name 90 | { 91 | id image = nil; 92 | 93 | @synchronized(CGImageCache) { 94 | image = [CGImageCache objectForKey: name]; 95 | 96 | if( nil == image ) { 97 | image = (id) [[self platformSpecificBitmapImageNamed: name] CGImage]; 98 | [CGImageCache setObject: image ? image : idNull forKey: name]; 99 | } 100 | } 101 | 102 | return (CGImageRef) ( image == idNull ? NULL : image ); 103 | } 104 | 105 | @end 106 | -------------------------------------------------------------------------------- /EngineRoom/CrossPlatform_NSString_CGGeometry.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #ifndef __CROSS_PLATFORM_CGGEOMETRY_H__ 24 | #define __CROSS_PLATFORM_CGGEOMETRY_H__ 1 25 | 26 | #import 27 | 28 | #if TARGET_OS_OSX 29 | 30 | #define CGPointFromString(s) NSPointToCGPoint( NSPointFromString( s ) ) 31 | #define CGSizeFromString(s) NSSizeToCGSize( NSSizeFromString( s ) ) 32 | #define CGRectFromString(s) NSRectToCGRect( NSRectFromString( s ) ) 33 | 34 | #define NSStringFromCGPoint(p) NSStringFromPoint( NSPointFromCGPoint( p ) ) 35 | #define NSStringFromCGSize(s) NSStringFromSize( NSSizeFromCGSize( s ) ) 36 | #define NSStringFromCGRect(r) NSStringFromRect( NSRectFromCGRect( r ) ) 37 | 38 | #endif 39 | 40 | #endif 41 | // __CROSS_PLATFORM_CGGEOMETRY_H__ 42 | -------------------------------------------------------------------------------- /EngineRoom/CrossPlatform_NSValue_CGGeometry.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #import 24 | 25 | @interface NSValue ( CrossPlatform_CGGeometry ) 26 | 27 | #if TARGET_OS_OSX 28 | 29 | + (NSValue *) valueWithCGPoint: (CGPoint) point; 30 | + (NSValue *) valueWithCGSize: (CGSize) size; 31 | + (NSValue *) valueWithCGRect: (CGRect) rect; 32 | 33 | - (CGPoint) CGPointValue; 34 | - (CGSize) CGSizeValue; 35 | - (CGRect) CGRectValue; 36 | 37 | #endif 38 | 39 | @end 40 | 41 | 42 | -------------------------------------------------------------------------------- /EngineRoom/CrossPlatform_NSValue_CGGeometry.m: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #import "CrossPlatform_NSValue_CGGeometry.h" 24 | 25 | @implementation NSValue ( CrossPlatform_CGGeometry ) 26 | 27 | #if TARGET_OS_OSX 28 | 29 | + (NSValue *) valueWithCGPoint: (CGPoint) point { return [NSValue valueWithPoint: NSPointFromCGPoint(point)]; } 30 | + (NSValue *) valueWithCGSize: (CGSize) size { return [NSValue valueWithSize: NSSizeFromCGSize(size)]; } 31 | + (NSValue *) valueWithCGRect: (CGRect) rect { return [NSValue valueWithRect: NSRectFromCGRect(rect)]; } 32 | 33 | - (CGPoint) CGPointValue { return NSPointToCGPoint([self pointValue]); } 34 | - (CGSize) CGSizeValue { return NSSizeToCGSize([self sizeValue]); } 35 | - (CGRect) CGRectValue { return NSRectToCGRect([self rectValue]); } 36 | 37 | #endif 38 | 39 | @end 40 | 41 | -------------------------------------------------------------------------------- /EngineRoom/CrossPlatform_Target.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #ifndef __CROSS_PLATFORM_TARGET_H__ 24 | #define __CROSS_PLATFORM_TARGET_H__ 1 25 | 26 | #import 27 | 28 | #if TARGET_OS_MAC && ! TARGET_OS_IPHONE 29 | // since TARGET_OS_MAC is defined for IPHONE too 30 | #define TARGET_OS_OSX 1 31 | #endif 32 | 33 | #if TARGET_OS_IPHONE 34 | #import 35 | #endif 36 | 37 | #if TARGET_OS_OSX 38 | #import 39 | #endif 40 | 41 | #endif 42 | // __CROSS_PLATFORM_TARGET_H__ 43 | 44 | -------------------------------------------------------------------------------- /EngineRoom/CrossPlatform_Utilities.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #ifndef __CROSS_PLATFORM_UTILITIES_H__ 24 | #define __CROSS_PLATFORM_UTILITIES_H__ 1 25 | 26 | #import 27 | 28 | #import 29 | #import 30 | 31 | 32 | #if TARGET_OS_IPHONE 33 | 34 | typedef CGRect CPRect; 35 | typedef CGPoint CPPoint; 36 | typedef CGSize CPSize; 37 | 38 | #define CPView UIView 39 | #define CPViewController UIViewController 40 | #define CPApplication UIApplication 41 | #define CPColor UIColor 42 | #define CPRectFill(r) UIRectFill(r) 43 | 44 | #define CPWidth(r) CGRectGetWidth(r) 45 | #define CPHeight(r) CGRectGetHeight(r) 46 | #define CPMinX(r) CGRectGetMinY(r) 47 | #define CPMaxX(r) CGRectGetMaxX(r) 48 | #define CPMinY(r) CGRectGetMinY(r) 49 | #define CPMaxY(r) CGRectGetMaxY(r) 50 | #define CPMidX(r) CGRectGetMidX(r) 51 | #define CPMidY(r) CGRectGetMidY(r) 52 | 53 | #define CPPointFromNSValue(v) [(v) CGPointValue] 54 | #define CPSizeFromNSValue(v) [(v) CGSizeValue] 55 | #define CPRectFromNSValue(v) [(v) CGRectValue] 56 | 57 | #define CGPointFromNSValue(v) CPPointFromNSValue(v) 58 | #define CGSizeFromNSValue(v) CPRectFromNSValue(v) 59 | #define CGRectFromNSValue(v) CPRectFromNSValue(v) 60 | 61 | #define NSPointFromCGPoint(x) (x) 62 | #define NSSizeFromCGSize(x) (x) 63 | #define NSRectFromCGRect(x) (x) 64 | 65 | #define NSPointToCGPoint(x) (x) 66 | #define NSSizeToCGSize(x) (x) 67 | #define NSRectToCGRect(x) (x) 68 | 69 | #endif 70 | 71 | #if TARGET_OS_OSX 72 | 73 | #define CPView NSView 74 | #define CPViewController NSViewController 75 | #define CPApplication NSApplication 76 | #define CPColor NSColor 77 | #define CPRectFill(r) NSRectFill(r) 78 | 79 | typedef NSRect CPRect; 80 | typedef NSPoint CPPoint; 81 | typedef NSSize CPSize; 82 | 83 | #define CPWidth(r) NSWidth(r) 84 | #define CPHeight(r) NSHeight(r) 85 | #define CPMinX(r) NSMinX(r) 86 | #define CPMaxX(r) NSMaxX(r) 87 | #define CPMinY(r) NSMinY(r) 88 | #define CPMaxY(r) NSMaxY(r) 89 | #define CPMidX(r) NSMidX(r) 90 | #define CPMidY(r) NSMidY(r) 91 | 92 | #define CPPointFromNSValue(v) [(v) pointValue] 93 | #define CPSizeFromNSValue(v) [(v) sizeValue] 94 | #define CPRectFromNSValue(v) [(v) rectValue] 95 | 96 | #define CGPointFromNSValue(v) NSPointToCGPoint( CPPointFromNSValue(v) ) 97 | #define CGSizeFromNSValue(v) NSSizeToCGSize( CPSizeFromNSValue(v) ) 98 | #define CGRectFromNSValue(v) NSRectToCGRect( CPRectFromNSValue(v) ) 99 | 100 | #define CGPointFromString(s) NSPointToCGPoint( NSPointFromString( s ) ) 101 | #define CGSizeFromString(s) NSSizeToCGSize( NSSizeFromString( s ) ) 102 | #define CGRectFromString(s) NSRectToCGRect( NSRectFromString( s ) ) 103 | 104 | #define NSStringFromCGPoint(p) NSStringFromPoint( NSPointFromCGPoint( p ) ) 105 | #define NSStringFromCGSize(s) NSStringFromSize( NSSizeFromCGSize( s ) ) 106 | #define NSStringFromCGRect(r) NSStringFromRect( NSRectFromCGRect( r ) ) 107 | 108 | #endif 109 | 110 | 111 | #endif 112 | // __CROSS_PLATFORM_UTILITIES_H__ 113 | -------------------------------------------------------------------------------- /EngineRoom/ERUtility/ERCGUtilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // ERCGUtilities.h 3 | // EngineRoom-iOS 4 | // 5 | // Created by Bjoern Kriews on 20.11.11. 6 | // Copyright (c) 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #ifndef EngineRoom_iOS_ERCGUtilities_h 10 | #define EngineRoom_iOS_ERCGUtilities_h 11 | 12 | // these CGAffine Utilities were kindly put into the public domain by Jeff LaMarche 13 | // I like to recommend his blog at http://iphonedevelopment.blogspot.com/ 14 | 15 | #import 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #define ERDegreesToRadian(x) (M_PI * x / 180.0) 22 | #define ERRadiansToDegrees(x) (180.0 * x / M_PI) 23 | 24 | static inline ERCGAffineTransform CGAffineTransformMakeShear(CGFloat shearX, CGFloat shearY) 25 | { 26 | return CGAffineTransformMake(1.f, shearY, shearX, 1.f, 0.f, 0.f); 27 | } 28 | static inline ERCGAffineTransform CGAffineTransformShear(CGAffineTransform transform, CGFloat shearX, CGFloat shearY) 29 | { 30 | CGAffineTransform sheared = ERCGAffineTransformMakeShear(shearX, shearY); 31 | return CGAffineTransformConcat(transform, sheared); 32 | } 33 | static inline CGFloat ERCGAffineTransformGetDeltaX(CGAffineTransform transform) {return transform.tx;}; 34 | static inline CGFloat ERCGAffineTransformGetDeltaY(CGAffineTransform transform) {return transform.ty;}; 35 | static inline CGFloat ERCGAffineTransformGetScaleX(CGAffineTransform transform) {return sqrtf( (transform.a * transform.a) + (transform.c * transform.c) );}; 36 | static inline CGFloat ERCGAffineTransformGetScaleY(CGAffineTransform transform) {return sqrtf( (transform.b * transform.b) + (transform.d * transform.d) );}; 37 | static inline CGFloat ERCGAffineTransformGetShearX(CGAffineTransform transform) {return transform.b;}; 38 | static inline CGFloat ERCGAffineTransformGetShearY(CGAffineTransform transform) {return transform.c;}; 39 | static inline CGFloat ERCGPointAngleBetweenPoints(CGPoint first, CGPoint second) 40 | { 41 | CGFloat dy = second.y - first.y; 42 | CGFloat dx = second.x - first.x; 43 | return atan2f(dy, dx); 44 | } 45 | static inline CGFloat ERCGAffineTransformGetRotation(CGAffineTransform transform) 46 | { 47 | // No exact way to get rotation out without knowing order of all previous operations 48 | // So, we'll cheat. We'll apply the transformation to two points and then determine the 49 | // angle betwen those two points 50 | 51 | CGPoint testPoint1 = CGPointMake(-100.f, 0.f); 52 | CGPoint testPoint2 = CGPointMake(100.f, 0.f); 53 | CGPoint transformed1 = CGPointApplyAffineTransform(testPoint1, transform); 54 | CGPoint transformed2 = CGPointApplyAffineTransform(testPoint2, transform); 55 | return ERCGPointAngleBetweenPoints(transformed1, transformed2); 56 | } 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /EngineRoom/ERUtility/ERColor.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010, Bjoern Kriews 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 12 | software without specific prior written permission. 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 14 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 15 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 16 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 17 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 18 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 19 | */ 20 | 21 | #import 22 | 23 | @interface ERColor : NSObject { 24 | NSString *m_genericRGBAString; 25 | CGColorRef m_CGColor; 26 | #if TARGET_OS_OSX 27 | NSColor *m_NSColor; 28 | #endif 29 | } 30 | 31 | + (ERColor *) colorWithGenericRGBAString: (NSString *) genericRGBAString; 32 | 33 | + (ERColor *) colorWithCGColor: (CGColorRef) cgColor; 34 | 35 | #if TARGET_OS_OSX 36 | + (ERColor *) colorWithNSColor: (NSColor *) nsColor; 37 | #endif 38 | 39 | - (id) initWithGenericRGBAString: (NSString *) genericRGBAString; 40 | 41 | - (id) initWithCGColor: (CGColorRef) cgColor; 42 | 43 | #if TARGET_OS_OSX 44 | - (id) initWithNSColor: (NSColor *) nsColor; 45 | #endif 46 | 47 | - (NSString *) genericRGBAString; 48 | - (void) setGenericRGBAString: (NSString *) genericRGBAString; 49 | 50 | // not yet settable or observable 51 | - (NSString *) genericRGBString; 52 | - (NSString *) genericRGBCSSString; 53 | - (NSString *) genericRGBACSSString; 54 | 55 | - (CGColorRef) CGColor; 56 | - (void) setCGColor: (CGColorRef) CGColor; 57 | 58 | - (CGFloat)alphaValue; 59 | 60 | #if TARGET_OS_OSX 61 | - (NSColor *) NSColor; 62 | - (void) setNSColor: (NSColor *) nsColor; 63 | #endif 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /EngineRoom/ERUtility/ERColorTransformer.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #if TARGET_OS_OSX 4 | @interface ERColorNSColorTransformer : ERValueTransformer 5 | @end 6 | #endif 7 | 8 | @interface ERColorCGColorTransformer : ERValueTransformer 9 | @end 10 | 11 | @interface ERColorGenericRGBAStringTransformer : ERValueTransformer 12 | @end 13 | -------------------------------------------------------------------------------- /EngineRoom/ERUtility/ERColorTransformer.m: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | #import 4 | 5 | #if TARGET_OS_OSX 6 | #define RETURN_WITH_CONTROLLERMARKER_CHECK(in, out) { id __in = (in); return __in == nil || NSIsControllerMarker( __in ) ? nil : (id)(out); } 7 | #else 8 | #define RETURN_WITH_CONTROLLERMARKER_CHECK(in, out) { id __in = (in); return __in == nil ? nil : (id)(out); } 9 | #endif 10 | 11 | 12 | 13 | #if TARGET_OS_OSX 14 | #import 15 | 16 | @implementation ERColorNSColorTransformer 17 | 18 | + (Class)transformedValueClass { return [NSColor class]; } 19 | 20 | + (BOOL)allowsReverseTransformation { return YES; } 21 | 22 | - (id)transformedValue:(id)erColor { RETURN_WITH_CONTROLLERMARKER_CHECK(erColor, ((ERColor *)erColor).NSColor); } 23 | 24 | - (id)reverseTransformedValue:(id)nsColor { RETURN_WITH_CONTROLLERMARKER_CHECK(nsColor, [ERColor colorWithNSColor: nsColor]); } 25 | 26 | @end 27 | 28 | #endif 29 | 30 | @implementation ERColorCGColorTransformer 31 | 32 | + (Class)transformedValueClass { return [NSObject class]; } 33 | 34 | + (BOOL)allowsReverseTransformation { return YES; } 35 | 36 | - (id)transformedValue:(id)erColor { RETURN_WITH_CONTROLLERMARKER_CHECK(erColor, ((ERColor *)erColor).CGColor); } 37 | 38 | - (id)reverseTransformedValue:(id)cgColor { RETURN_WITH_CONTROLLERMARKER_CHECK(cgColor, [ERColor colorWithCGColor: (CGColorRef)cgColor]); } 39 | 40 | @end 41 | 42 | @implementation ERColorGenericRGBAStringTransformer 43 | 44 | + (Class)transformedValueClass { return [NSString class]; } 45 | 46 | + (BOOL)allowsReverseTransformation { return YES; } 47 | 48 | - (id)transformedValue:(id)erColor { RETURN_WITH_CONTROLLERMARKER_CHECK(erColor, ((ERColor *)erColor).genericRGBAString); } 49 | 50 | - (id)reverseTransformedValue:(id)genericRGBAString { 51 | RETURN_WITH_CONTROLLERMARKER_CHECK(genericRGBAString, [ERColor colorWithGenericRGBAString: genericRGBAString]); 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /EngineRoom/ERUtility/ERUtility.h: -------------------------------------------------------------------------------- 1 | // 2 | // ERUtility.h 3 | // EngineRoom-OSX 4 | // 5 | // Created by Bjoern Kriews on 2/5/11. 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // categories, all methods prefixed with er_ 12 | #import 13 | #import 14 | #import 15 | 16 | extern NSString *ERUtilityBundleIdentifierWorkspace; 17 | 18 | extern NSString *ERUtilityOptionExportOpenWithBundleIdentifier; 19 | extern NSString *ERUtilityOptionExportBaseTypesAsPropertyList; 20 | extern NSString *ERUtilityOptionExportDateFormat; 21 | 22 | extern NSDictionary *ERDictionaryWithKeysAndObjects(id *array, NSUInteger count); 23 | 24 | 25 | @interface ERUtility : NSObject { 26 | 27 | } 28 | 29 | + (NSString *) XMLCompatibleUUIDString; 30 | 31 | + (NSString *) UUIDString; 32 | 33 | + (NSURL *) exportPropertyListItem: (id) item baseURL: (NSURL *) baseURL basename: (NSString *) basename type: (NSString *) type options: (NSDictionary *) options error: (NSError **) outError; 34 | 35 | 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /EngineRoom/ERUtility/ERValueConverter.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | // this stuff is still under quarantine 5 | 6 | #if NS_BLOCKS_AVAILABLE 7 | 8 | typedef id (^ERValueConverterBlock)(id value, NSDictionary *valueConverters, id userInfo); 9 | 10 | extern NSString *kERValueConverterCGPointFromString; 11 | extern NSString *kERValueConverterStringFromCGPoint; 12 | 13 | extern ERValueConverterBlock ERValueConverterCGPointValueFromString; 14 | extern ERValueConverterBlock ERValueConverterStringFromCGPointValue; 15 | 16 | extern NSString *kERValueConverterCGSizeValueFromString; 17 | extern NSString *kERValueConverterStringFromCGSizeValue; 18 | 19 | extern ERValueConverterBlock ERValueConverterCGSizeValueFromString; 20 | extern ERValueConverterBlock ERValueConverterStringFromCGSizeValue; 21 | 22 | extern NSString *kERValueConverterCGRectValueFromString; 23 | extern NSString *kERValueConverterStringFromCGRectValue; 24 | 25 | extern ERValueConverterBlock ERValueConverterCGRectValueFromString; 26 | extern ERValueConverterBlock ERValueConverterStringFromCGRectValue; 27 | 28 | extern NSString *kERValueConverterCGAffineTransformFromString; 29 | extern NSString *kERValueConverterStringFromCGAffineTransform; 30 | 31 | extern NSString *kERValueConverterCATransform3DFromString; 32 | extern NSString *kERValueConverterStringFromCATransform3D; 33 | 34 | extern NSString *kERValueConverterERColorFromGenericRGBAString; 35 | extern NSString *kERValueConverterGenericRGBAStringFromERColor; 36 | 37 | extern ERValueConverterBlock ERValueConverterERColorFromGenericRGBAString; 38 | extern ERValueConverterBlock ERValueConverterGenericRGBAStringFromERColor; 39 | 40 | extern NSString *kERValueConverterCGColorFromGenericRGBAString; 41 | extern NSString *kERValueConverterGenericRGBAStringFromCGColor; 42 | 43 | extern ERValueConverterBlock ERValueConverterCGColorFromGenericRGBAString; 44 | extern ERValueConverterBlock ERValueConverterGenericRGBAStringFromCGColor; 45 | 46 | #if TARGET_OS_OSX 47 | extern NSString *kERValueConverterNSColorFromGenericRGBAString; 48 | extern NSString *kERValueConverterGenericRGBAStringFromNSColor; 49 | 50 | extern ERValueConverterBlock ERValueConverterNSColorFromGenericRGBAString; 51 | extern ERValueConverterBlock ERValueConverterGenericRGBAStringFromNSColor; 52 | #endif 53 | 54 | extern NSString *kERValueConverterDictionaryFromDictionary; 55 | extern ERValueConverterBlock ERValueConverterDictionaryFromDictionary; 56 | 57 | extern NSString *kERValueConverterArrayFromArray; 58 | extern ERValueConverterBlock ERValueConverterArrayFromArray; 59 | 60 | extern NSDictionary *ERValueConvertersByName(void); 61 | 62 | 63 | @interface ERValueConverter : NSObject { 64 | @private 65 | 66 | } 67 | 68 | @end 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /EngineRoom/ERUtility/ERValueTransformer.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | // this stuff is still under quarantine 5 | 6 | #define kERValueTransformersInfoPlistKey @"ERValueTransformers" 7 | 8 | #define kERValueTransformerKeyPrefix @"#" 9 | 10 | #define kERValueTransformerClassKey @"#class" 11 | //#define kERValueTransformerNameKey @"#name" 12 | 13 | 14 | @interface ERValueTransformer : NSValueTransformer {} 15 | 16 | + (void) registerSelf; 17 | 18 | // allocates kERValueTransformerClassKey, sets remaining attributes not prefixed with # 19 | + (NSValueTransformer *) transformerWithDictionary: (NSDictionary *) dict error: (NSError **) outError; 20 | 21 | + (BOOL) registerNamedTransformers: (NSDictionary *) namedTransformers error: (NSError **) outError; 22 | 23 | // uses mainBundle and ER bundle if bundles is nil 24 | + (BOOL) registerTransformersFromBundles: (NSArray *) bundles error: (NSError **) outError; 25 | 26 | 27 | - (void) registerWithName: (NSString *) name; 28 | 29 | #if ERVALUETRANSFORMERAUTOREGISTRATION 30 | + (void) registerSelfAndSubclasses; 31 | #endif 32 | 33 | 34 | @end 35 | 36 | @interface ERToNumberTransformer : ERValueTransformer {} 37 | @end 38 | 39 | @interface ERToStringTransformer : ERValueTransformer {} 40 | @end 41 | 42 | 43 | @interface ERNumberToBoolTransformer : ERToNumberTransformer {} 44 | - (BOOL) boolForDouble: (double) value; 45 | // no reverse support 46 | @end 47 | 48 | @interface ERNumberToDoubleTransformer : ERToNumberTransformer {} 49 | - (double) doubleForDouble: (double) value; 50 | 51 | // override allowsReverseTransformation to use this 52 | - (double) reverseDoubleForDouble: (double) value; 53 | 54 | @end 55 | 56 | @interface ERExpressionTransformer : ERValueTransformer { 57 | NSPredicate *m_predicate; 58 | NSExpression *m_expression; 59 | NSExpression *m_alternateExpression; 60 | NSPredicate *m_reversePredicate; 61 | NSExpression *m_reverseExpression; 62 | NSExpression *m_reverseAlternateExpression; 63 | } 64 | 65 | @property(nonatomic, retain) id predicate; 66 | @property(nonatomic, retain) id expression; 67 | @property(nonatomic, retain) id alternateExpression; 68 | 69 | @property(nonatomic, retain) id reversePredicate; 70 | @property(nonatomic, retain) id reverseExpression; 71 | @property(nonatomic, retain) id reverseAlternateExpression; 72 | 73 | // use only expressions which form a valid predicate in the form: ( expression ) = 0 74 | - (NSExpression *) expressionWithString: (NSString *) expressionString; 75 | 76 | 77 | @end 78 | 79 | 80 | @interface ERNumberExpressionTransformer : ERExpressionTransformer {} 81 | @end 82 | 83 | @interface ERStringExpressionTransformer : ERExpressionTransformer {} 84 | @end 85 | 86 | 87 | #if 0 88 | @interface ERPredicateEvaluatorTransformer : ERToNumberTransformer { 89 | NSPredicate *m_predicate; 90 | } 91 | 92 | + (void) registerWithName: (NSString *) name predicate: (NSPredicate *) predicate; 93 | + (void) registerWithName: (NSString *) name predicateFormat: (NSString *) format, ...; 94 | 95 | - (id) initWithPredicate: (NSPredicate *) predicate; 96 | - (id) initWithPredicateFormat: (NSString *) format, ...; 97 | 98 | @end 99 | 100 | @interface ERExpressionEvaluatorTransformer : ERValueTransformer { 101 | NSExpression *m_expression; 102 | } 103 | 104 | + (void) registerWithName: (NSString *) name expression: (NSExpression *) expression; 105 | 106 | // see initWithExpressionFormat 107 | + (void) registerWithName: (NSString *) name expressionFormat: (NSString *) format, ...; 108 | 109 | - (id) initWithExpression: (NSExpression *) expression; 110 | 111 | // based on a great hack by Dave De Long 112 | // see http://funwithobjc.tumblr.com/post/1553469975/abusing-nspredicate 113 | // parses it as "yourstuff = 0" and takes the left side 114 | // some expressions don't work, i.e. an identifier without a comparison 115 | - (id) initWithExpressionFormat: (NSString *) format, ...; 116 | 117 | - (id) initWithExpressionFormat: (NSString *) format arguments: (va_list) args; 118 | 119 | @end 120 | #endif 121 | 122 | 123 | @interface ERLogarithmicTransformer : ERNumberToDoubleTransformer { 124 | double power; 125 | } 126 | 127 | + (void) registerWithPower: (double) power forName: (NSString *) name; 128 | 129 | - (id) initWithPower: (double) power; 130 | 131 | @end 132 | 133 | @interface ERSignInverterTransformer : ERNumberToDoubleTransformer {} 134 | @end 135 | 136 | @interface ERAbsoluteValueTransformer : ERNumberToDoubleTransformer {} 137 | @end 138 | 139 | @interface ERLocalizerTransformer : ERToStringTransformer {} 140 | @end 141 | 142 | // useful for arrays of NSDictionaryControllerKeyValuePair, 143 | // use it i.e. to bind the content of a popup through a VT, 144 | // NOT the contentValues ! use localizedKey in the contentValues 145 | @interface ERKeyValuePairKeyLocalizerTransformer : ERValueTransformer {} 146 | @end 147 | 148 | // useful if you want to bind i.e. a TextField to a controllers selectedObjects 149 | // for debugging purposes and you are tired of seeing Proxy objects or (, ) 150 | @interface ERArrayWithArrayTransformer : ERValueTransformer {} 151 | @end 152 | 153 | #if ER_NOT_YET 154 | 155 | @interface ERArrayOfObjectsToPropertyListTransformer : ERValueTransformer {} 156 | @end 157 | 158 | #endif 159 | -------------------------------------------------------------------------------- /EngineRoom/ERUtility/NSBundle_ERExtensions.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | extern NSString *kERBundleBuildConfiguration; 5 | 6 | @interface NSBundle (ResourceExtensions) 7 | 8 | - (NSURL *) er_URLForResource: (NSString *) name withExtension: (NSString *) extension error: (NSError **) outError; 9 | 10 | - (NSData *) er_dataResource: (NSString *) name ofType: (NSString *) type options: (NSUInteger) dataOptions error: (NSError **) outError; 11 | 12 | - (NSString *) er_stringResource: (NSString *) name ofType: (NSString *) type encoding: (NSStringEncoding) encoding error: (NSError **) outError; 13 | 14 | - (NSString *) er_stringResource: (NSString *) name ofType: (NSString *) type error: (NSError **) outError; 15 | 16 | - (id) er_propertyListResource: (NSString *) name ofType: (NSString *) type options: (NSUInteger) plistOptions error: (NSError **) outError; 17 | 18 | @end 19 | 20 | @interface NSBundle (ERInfoDictionaryExtensions) 21 | 22 | - (NSString *) er_machineReadableVersionString; 23 | 24 | - (NSString *) er_humanReadableVersionString; 25 | 26 | @end -------------------------------------------------------------------------------- /EngineRoom/ERUtility/NSBundle_ERExtensions.m: -------------------------------------------------------------------------------- 1 | 2 | #import "Convenience.h" 3 | 4 | #import 5 | 6 | #import 7 | 8 | NSString *kERBundleBuildConfiguration = @"ERBundleBuildConfiguration"; 9 | 10 | @implementation NSBundle (ERResourceExtensions) 11 | 12 | - (NSURL *) er_URLForResource: (NSString *) name withExtension: (NSString *) extension error: (NSError **) outError 13 | { 14 | ER_PRECONDITION_NSERROR_RETURN_NIL(name != nil, outError); 15 | 16 | NSURL *URL = [self URLForResource: name withExtension: extension ?: @""]; 17 | 18 | ER_CHECK_NSERROR_REASON_RETURN_NIL(nil != URL, outError, NSPOSIXErrorDomain, ENOENT, @"NO_SUCH_RESOURCE: %@%@%@", name, extension ? @"." : @"", extension ?: @""); 19 | 20 | return URL; 21 | } 22 | 23 | - (NSData *) er_dataResource: (NSString *) name ofType: (NSString *) type options: (NSUInteger) dataOptions error: (NSError **) outError 24 | { 25 | NSURL *URL = [self er_URLForResource: name withExtension: type error: outError]; 26 | 27 | if( nil == URL ) { 28 | return nil; 29 | } 30 | 31 | return [NSData dataWithContentsOfURL: URL options: dataOptions error: outError]; 32 | } 33 | 34 | - (id) er_propertyListResource: (NSString *) name ofType: (NSString *) type options: (NSUInteger) plistOptions error: (NSError **) outError 35 | { 36 | NSData *data = [self er_dataResource: name ofType: type options: 0 error: outError]; 37 | return data ? [NSPropertyListSerialization er_propertyListWithData: data options: plistOptions error: outError] : nil; 38 | } 39 | 40 | - (NSString *) er_stringResource: (NSString *) name ofType: (NSString *) type encoding: (NSStringEncoding) encoding error: (NSError **) outError 41 | { 42 | NSURL *URL = [self er_URLForResource: name withExtension: type error: outError]; 43 | NSString *string = URL ? [NSString stringWithContentsOfURL: URL encoding: encoding error: outError] : nil; 44 | return string; 45 | } 46 | 47 | - (NSString *) er_stringResource: (NSString *) name ofType: (NSString *) type error: (NSError **) outError 48 | { 49 | NSURL *URL = [self er_URLForResource: name withExtension: type error: outError]; 50 | NSString *string = URL ? [NSString stringWithContentsOfURL: URL usedEncoding: nil error: outError] : nil; 51 | return string; 52 | } 53 | 54 | @end 55 | 56 | @implementation NSBundle (ERInfoDictionaryExtensions) 57 | 58 | - (NSString *) er_machineReadableVersionString 59 | { 60 | NSString *shortVersion = [self objectForInfoDictionaryKey: @"CFBundleShortVersionString"] ?: (id)@"noShortVersion"; 61 | NSString *version = [self objectForInfoDictionaryKey: (id)kCFBundleVersionKey] ?: (id)@"noVersion"; 62 | NSString *name = [self objectForInfoDictionaryKey: (id)kCFBundleNameKey] ?: (id)@"noName"; 63 | 64 | NSString *config = [self objectForInfoDictionaryKey: (id)kERBundleBuildConfiguration]; 65 | 66 | return [NSString stringWithFormat: @"%@-%@%s%@-%@", 67 | name, 68 | shortVersion, 69 | config ? "-" : "", config ?: @"", 70 | version 71 | ]; 72 | } 73 | 74 | - (NSString *) er_humanReadableVersionString 75 | { 76 | NSString *shortVersion = [self objectForInfoDictionaryKey: @"CFBundleShortVersionString"] ?: (id)@"noShortVersion"; 77 | NSString *version = [self objectForInfoDictionaryKey: (id)kCFBundleVersionKey] ?: (id)@"noVersion"; 78 | NSString *name = [self objectForInfoDictionaryKey: (id)kCFBundleNameKey] ?: (id)@"noName"; 79 | 80 | NSString *config = [self objectForInfoDictionaryKey: (id)kERBundleBuildConfiguration]; 81 | 82 | return [NSString stringWithFormat: @"%@ %@ (%@%s%@)", 83 | name, 84 | shortVersion, 85 | config ?: @"", config ? " " : "", 86 | version 87 | ]; 88 | } 89 | 90 | @end 91 | -------------------------------------------------------------------------------- /EngineRoom/ERUtility/NSObject_ERExtensions.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | @interface NSObject (ERBundleExtensions) 5 | 6 | - (NSBundle *) er_classBundle; 7 | 8 | - (NSString *) er_pathForClassResource: (NSString *) name ofType: (NSString *) type; 9 | 10 | - (NSString *) er_pathForMainResource: (NSString *) name ofType: (NSString *) type; 11 | 12 | - (NSString *) er_pathForMainOrClassResource: (NSString *) name ofType: (NSString *) type; 13 | 14 | 15 | - (NSData *) er_classDataResource: (NSString *) name ofType: (NSString *) type options: (NSUInteger) dataOptions error: (NSError **) outError; 16 | 17 | - (id) er_classPropertyListResource: (NSString *) name ofType: (NSString *) type options: (NSUInteger) plistOptions error: (NSError **) outError; 18 | 19 | - (NSData *) er_mainOrClassDataResource: (NSString *) name ofType: (NSString *) type options: (NSUInteger) dataOptions error: (NSError **) outError; 20 | 21 | - (id) er_mainOrClassPropertyListResource: (NSString *) name ofType: (NSString *) type options: (NSUInteger) plistOptions error: (NSError **) outError; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /EngineRoom/ERUtility/NSObject_ERExtensions.m: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | #import 4 | 5 | @implementation NSObject (ERBundleExtensions) 6 | 7 | #if 0 8 | + (NSBundle *) er_classBundle 9 | { 10 | return [NSBundle bundleForClass: self]; 11 | } 12 | 13 | + (NSString *) er_pathForClassResource: (NSString *) name ofType: (NSString *) type 14 | { 15 | // should walk the inheritance tree 16 | return [[self er_classBundle] pathForResource: name ofType: type]; 17 | } 18 | 19 | + (NSString *) pathForMainResource: (NSString *) name ofType: (NSString *) type 20 | { 21 | return [[NSBundle mainBundle] pathForResource: name ofType: type]; 22 | } 23 | 24 | + (NSString *) er_pathForMainOrClassResource: (NSString *) name ofType: (NSString *) type 25 | { 26 | NSString *path = [self er_pathForMainResource: name ofType: type]; 27 | return path ? path : [self er_pathForClassResource: name ofType: type]; 28 | } 29 | 30 | #endif 31 | 32 | - (NSBundle *) er_classBundle 33 | { 34 | return [NSBundle bundleForClass: [self class]]; 35 | } 36 | 37 | - (NSString *) er_pathForClassResource: (NSString *) name ofType: (NSString *) type 38 | { 39 | // should walk the inheritance tree 40 | return [[self er_classBundle] pathForResource: name ofType: type]; 41 | } 42 | 43 | - (NSString *) er_pathForMainResource: (NSString *) name ofType: (NSString *) type 44 | { 45 | return [[NSBundle mainBundle] pathForResource: name ofType: type]; 46 | } 47 | 48 | - (NSString *) er_pathForMainOrClassResource: (NSString *) name ofType: (NSString *) type 49 | { 50 | NSString *path = [self er_pathForMainResource: name ofType: type]; 51 | return path ? path : [self er_pathForClassResource: name ofType: type]; 52 | } 53 | 54 | - (NSData *) er_classDataResource: (NSString *) name ofType: (NSString *) type options: (NSUInteger) dataOptions error: (NSError **) outError 55 | { 56 | return [[self er_classBundle] er_dataResource: name ofType: type options: dataOptions error: outError]; 57 | } 58 | 59 | - (id) er_classPropertyListResource: (NSString *) name ofType: (NSString *) type options: (NSUInteger) plistOptions error: (NSError **) outError 60 | { 61 | return [[self er_classBundle] er_propertyListResource: name ofType: type options: plistOptions error: outError]; 62 | } 63 | 64 | - (NSData *) er_mainOrClassDataResource: (NSString *) name ofType: (NSString *) type options: (NSUInteger) dataOptions error: (NSError **) outError 65 | { 66 | return [[NSBundle mainBundle] er_dataResource: name ofType: type options: dataOptions error:outError] ?: 67 | [[self er_classBundle] er_dataResource: name ofType: type options: dataOptions error:outError]; 68 | } 69 | 70 | - (id) er_mainOrClassPropertyListResource: (NSString *) name ofType: (NSString *) type options: (NSUInteger) plistOptions error: (NSError **) outError 71 | { 72 | return [[NSBundle mainBundle] er_propertyListResource: name ofType: type options: plistOptions error:outError] ?: 73 | [[self er_classBundle] er_propertyListResource: name ofType: type options: plistOptions error:outError]; 74 | } 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /EngineRoom/ERUtility/NSPropertyListSerialization_ERExtensions.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface NSPropertyListSerialization ( ERBackPortExtensions ) 4 | 5 | // compiled to the same as without er_ prefix for OSX >= 10.6 and IOS >= 4.0, an approximation for older systems 6 | + (id) er_propertyListWithData: (NSData *) data options: (NSUInteger) options error: (NSError **) outError; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /EngineRoom/ERUtility/NSPropertyListSerialization_ERExtensions.m: -------------------------------------------------------------------------------- 1 | 2 | #import "NSPropertyListSerialization_ERExtensions.h" 3 | 4 | #import 5 | 6 | @implementation NSPropertyListSerialization ( ERBackPortExtensions ) 7 | 8 | + (id) er_propertyListWithData: (NSData *) data options: (NSUInteger) options error: (NSError **) outError 9 | { 10 | id plist; 11 | 12 | #if ( TARGET_OS_OSX && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6 ) || \ 13 | ( TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_4_0 ) 14 | plist = [self propertyListWithData: data options: NSPropertyListMutableContainers format: NULL error: outError]; 15 | #else 16 | NSString *errorString = nil; 17 | plist = [self propertyListFromData: data mutabilityOption: NSPropertyListMutableContainers format: NULL errorDescription: &errorString]; 18 | 19 | if( nil == plist && nil != outError ) { 20 | *outError = [NSError errorWithDomain: NSPOSIXErrorDomain code: EINVAL userInfo: 21 | [NSDictionary dictionaryWithObjectsAndKeys: 22 | errorString, NSLocalizedFailureReasonErrorKey, 23 | errorString, NSLocalizedString(@"CANT_PARSE_PLIST", @"can not parse property list data"), 24 | nil]]; 25 | } 26 | #endif 27 | 28 | return plist; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /EngineRoom/EngineRoom.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #import 24 | 25 | #ifdef __ENGINE_ROOM_M__ 26 | #define ENGINE_ROOM_GLOBAL(var, value) var = (value) 27 | #else 28 | #define ENGINE_ROOM_GLOBAL(var, value) extern var 29 | #endif 30 | 31 | ENGINE_ROOM_GLOBAL(NSString *kEngineRoomInstallMenuUserDefaultsKey, @"engineRoomInstallMenu"); 32 | 33 | #import 34 | 35 | #if TARGET_OS_OSX 36 | #import 37 | #import 38 | #endif 39 | 40 | @interface EngineRoom : NSObject { 41 | #if TARGET_OS_OSX 42 | IBOutlet NSMenuItem *engineRoomMenuItem; 43 | #endif 44 | 45 | EngineRoomController *m_engineRoomController; 46 | 47 | NSUserDefaults *m_standardUserDefaults; 48 | NSDictionary *m_engineRoomDefaults; 49 | } 50 | 51 | + (id) sharedEngineRoom; 52 | 53 | - (id) configurationValueForKey: (NSString *) key; 54 | 55 | - (NSBundle *) bundle; 56 | 57 | - (NSDictionary *) infoDictionary; 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /EngineRoom/EngineRoom.m: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | // controls definition of globals, see EngineRoom.h 24 | #define __ENGINE_ROOM_M__ 1 25 | 26 | #import "EngineRoom.h" 27 | 28 | @implementation EngineRoom 29 | 30 | static EngineRoom *sharedEngineRoom = nil; 31 | 32 | #pragma mark - 33 | #pragma mark Initialization 34 | 35 | void __attribute__ ((constructor)) engineRoomConstructor(void) 36 | { 37 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 38 | [EngineRoom sharedEngineRoom]; 39 | [pool drain]; 40 | } 41 | 42 | + (id)sharedEngineRoom 43 | { 44 | @synchronized(self) { 45 | if (sharedEngineRoom == nil) { 46 | [[[super alloc] init] release]; // assignment not done here, release only to satisfy static analyzer 47 | } 48 | } 49 | 50 | //NSLog(@"sharedEngineRoom is %@", sharedEngineRoom); 51 | 52 | return sharedEngineRoom; 53 | } 54 | 55 | + (id)allocWithZone:(NSZone *)zone 56 | { 57 | @synchronized(self) { 58 | if (sharedEngineRoom == nil) { 59 | return [super allocWithZone:zone]; 60 | } 61 | } 62 | return sharedEngineRoom; 63 | } 64 | 65 | - (id)init 66 | { 67 | Class myClass = [self class]; 68 | @synchronized(myClass) { 69 | if (sharedEngineRoom == nil) { 70 | if ( (self = [super init] ) ) { 71 | sharedEngineRoom = self; 72 | 73 | m_standardUserDefaults = [[NSUserDefaults standardUserDefaults] retain]; 74 | m_engineRoomDefaults = [[m_standardUserDefaults persistentDomainForName: [[NSBundle bundleForClass: [self class]] bundleIdentifier]] retain]; 75 | } 76 | } 77 | } 78 | return sharedEngineRoom; 79 | } 80 | 81 | - (id)copyWithZone:(NSZone *)zone { return self; } 82 | 83 | - (id)retain { return self; } 84 | 85 | - (NSUInteger)retainCount { return UINT_MAX; /* denotes an object that cannot be released */ } 86 | 87 | - (oneway void)release { /* do nothing */ } 88 | 89 | - (id)autorelease { return self; } 90 | 91 | - (void) awakeFromNib 92 | { 93 | if( nil == m_engineRoomController ) { 94 | m_engineRoomController = [[EngineRoomController sharedEngineRoomController] retain]; 95 | #if TARGET_OS_OSX 96 | [m_engineRoomController installInMenuItem: engineRoomMenuItem]; 97 | #endif 98 | 99 | #if TARGET_OS_IPHONE 100 | NSLog(@"%s: no iOS specific install routine yet", __PRETTY_FUNCTION__); 101 | #endif 102 | 103 | } else { 104 | // awaking outside of MainMenu nib 105 | } 106 | } 107 | 108 | #pragma mark - 109 | #pragma mark Configuration 110 | 111 | - (id) configurationValueForKey: (NSString *) key 112 | { 113 | id globalValue = [m_engineRoomDefaults valueForKey: key]; 114 | return globalValue ? globalValue : [m_standardUserDefaults valueForKey: key]; 115 | } 116 | 117 | - (NSBundle *) bundle 118 | { 119 | return [NSBundle bundleForClass: [self class]]; 120 | } 121 | 122 | - (NSDictionary *) infoDictionary 123 | { 124 | return [[self bundle] infoDictionary]; 125 | } 126 | 127 | - (NSString *) version 128 | { 129 | return [[self infoDictionary] objectForKey: (id)kCFBundleVersionKey]; 130 | } 131 | 132 | - (NSDictionary *) localizedInfoDictionary 133 | { 134 | return [[self bundle] localizedInfoDictionary]; 135 | } 136 | 137 | 138 | @end 139 | -------------------------------------------------------------------------------- /EngineRoom/EngineRoomController.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #import 24 | 25 | @interface EngineRoomController : NSObject { 26 | #if TARGET_OS_OSX 27 | IBOutlet NSMenu *engineRoomMenu; 28 | #endif 29 | NSArray *engineRoomTopLevelObjects; 30 | } 31 | 32 | + (EngineRoomController *) sharedEngineRoomController; 33 | 34 | #if TARGET_OS_OSX 35 | - (void) traceResponderChain: (id) currentResponder position: (NSInteger *) position; 36 | 37 | - (IBAction) logKeyWindowUndoStack: (id) sender; 38 | - (IBAction) logMainWindowUndoStack: (id) sender; 39 | 40 | - (IBAction) logResponderChain: (id) sender; 41 | 42 | - (void) installInMenuItem: (NSMenuItem *) menuItem; 43 | 44 | #endif 45 | 46 | 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /EngineRoom/EngineRoom_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'EngineRoom' target in the 'EngineRoom' project. 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /EngineRoom/LogPoint.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #import 24 | 25 | #import "logpoints_api.h" 26 | 27 | extern NSString *kLogPointFilterUserDefaultsKey; 28 | extern NSString *kLogPointFilterVersionUserDefaultsKey; 29 | 30 | extern NSString *kLogPointDumpUserDefaultsKey; 31 | extern NSString *kLogPointDumpFormatUserDefaultsKey; 32 | extern NSString *kLogPointLogFormatUserDefaultsKey; 33 | 34 | @interface LogPoint : NSObject 35 | { 36 | @private 37 | 38 | LOGPOINT *raw; 39 | NSArray *cachedKeys; 40 | 41 | size_t kindLength; 42 | size_t keysLength; 43 | size_t symbolNameLength; 44 | size_t fileLength; 45 | size_t labelLength; 46 | size_t formatInfoLength; 47 | 48 | size_t imageLength; 49 | const char *imageFileName; 50 | size_t imageFileNameLength; 51 | 52 | const char *fileName; 53 | size_t fileNameLength; 54 | 55 | unichar methodType; 56 | 57 | const char *className; 58 | size_t classNameLength; 59 | 60 | const char *selectorName; 61 | size_t selectorNameLength; 62 | } 63 | 64 | // called automagically by a constructor symbolName 65 | + (BOOL) setup; 66 | 67 | + (lp_return_t) setErrorPtr: (NSError **) outError withCode: (lp_return_t) code userInfo: (NSDictionary *) userInfo; 68 | 69 | + (lp_return_t) makeAllLogPointsPerformSelector: (SEL) sel; 70 | 71 | + (lp_return_t) makeLogPointsMatchingFilterString: (NSString *) filter performSelector: (SEL) sel error: (NSError **) outError; 72 | + (lp_return_t) enableOnlyLogPointsMatchingFilterString: (NSString *) filter error: (NSError **) outError; 73 | 74 | + (lp_return_t) makeLogPointsMatchingPredicate: (NSPredicate *) predicate performSelector: (SEL) sel error: (NSError **) outError; 75 | + (lp_return_t) enableOnlyLogPointsMatchingPredicate: (NSPredicate *) predicate error: (NSError **) outError; 76 | 77 | + (NSPredicate *) predicateFromTextualRepresentation: (id) textual error: (NSError **) outError; 78 | 79 | + (NSArray *) sharedLogPoints; 80 | 81 | // to be able to use an instance in IB for binding 82 | - (NSArray *) sharedLogPoints; 83 | 84 | - (id) initWithRawPointer: (void *) rawPointer; 85 | - (void *) rawPointer; 86 | 87 | - (NSString *) kind; 88 | 89 | - (NSString *) commaSeparatedKeys; 90 | - (NSArray *) keys; 91 | 92 | - (NSString *) symbolName; 93 | 94 | - (unichar) methodType; 95 | - (NSString *) methodTypeAsString; 96 | - (NSString *) className; 97 | - (NSString *) selectorName; 98 | - (NSString *) selectorNameWithTypePrefix; 99 | - (NSString *) symbolNameOrSelectorName; 100 | 101 | - (NSString *) symbolNameOrSelectorNameForDisplay; 102 | - (NSString *) symbolNameOrSelectorNameWithTypePrefixForDisplay; 103 | 104 | - (NSString *) sourcePath; 105 | - (NSString *) sourceFileName; 106 | 107 | - (NSString *) binaryPath; 108 | - (NSString *) binaryFileName; 109 | 110 | - (NSInteger) line; 111 | 112 | - (NSInteger) count; 113 | - (void) setCount: (int) newCount; 114 | 115 | - (void *) address; 116 | - (NSString *) addressAsString; 117 | 118 | - (NSString *) formatInfo; 119 | - (NSString *) label; 120 | 121 | - (void) activate; 122 | - (void) deactivate; 123 | 124 | - (BOOL) isActive; 125 | - (void) setActive: (BOOL) flag; 126 | 127 | - (BOOL) isHard; 128 | - (void) setHard: (BOOL) flag; 129 | 130 | - (BOOL) isInDynamicCode; 131 | - (void) setInDynamicCode: (BOOL) flag; 132 | 133 | - (BOOL) isBroken; 134 | - (void) setBroken: (BOOL) flag; 135 | 136 | @end 137 | -------------------------------------------------------------------------------- /EngineRoom/er_compat.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | // used internally for now, may be exported later, can not simply be compiled for 32 and 64 24 | 25 | #ifndef __ER_COMPAT_H__ 26 | #define __ER_COMPAT_H__ 1 27 | 28 | #ifdef __APPLE__ 29 | 30 | #import 31 | 32 | #ifdef __OBJC__ 33 | 34 | #import 35 | #import 36 | 37 | #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 38 | #define COMPAT_OBJECT_GETCLASS(cls) object_getClass(cls) 39 | #define COMPAT_CLASS_GETNAME(cls) class_getName(cls) 40 | #define COMPAT_METHOD_GETNAME(m) method_getName(m) 41 | #define COMPAT_METHOD_GETIMPLEMENTATION(m) method_getImplementation(m) 42 | #define COMPAT_CLASS_ISMETACLASS(cls) class_isMetaClass( cls ) 43 | #define COMPAT_CLASS_COPYMETHODLIST(cls, countPtr) class_copyMethodList( (cls), (countPtr) ) 44 | #else 45 | /* wrappers for weak references to 2.0 objc runtime functions or substitutes */ 46 | #define COMPAT_OBJECT_GETCLASS(cls) ( object_getClass ? object_getClass(cls) : (cls)->isa ) 47 | #define COMPAT_CLASS_GETNAME(cls) ( class_getName ? class_getName(cls) : (cls)->isa->name ) 48 | #define COMPAT_METHOD_GETNAME(m) ( method_getName ? method_getName(m) : (m)->method_name ) 49 | #define COMPAT_METHOD_GETIMPLEMENTATION(m) ( method_getName ? method_getImplementation(m) : (m)->method_imp ) 50 | #define COMPAT_CLASS_ISMETACLASS(cls) ( class_isMetaClass ? class_isMetaClass( cls ) : ( cls->info & CLS_META ? YES : NO ) ) 51 | #define COMPAT_CLASS_COPYMETHODLIST(cls, countPtr) ( (class_copyMethodList ? class_copyMethodList : class_copyMethodList_emulation)( (cls), (countPtr) ) ) 52 | #endif 53 | 54 | #endif 55 | /* __OBJC__ */ 56 | 57 | #endif 58 | /* __APPLE__ */ 59 | 60 | 61 | #endif 62 | /* __ER_COMPAT_H__ */ 63 | -------------------------------------------------------------------------------- /EngineRoom/er_macros.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #ifndef __ER_MACROS_H__ 24 | #define __ER_MACROS_H__ 25 | 26 | #define _ER_VERSION 1.1.17r0 27 | #define _ER_VERSION_HEX 0x0111700 28 | /* Apples CFBundleVersion has arcane restrictions 29 | Bundle: MMmf.fr.r Hex: 0xMMmffrr MAJORMAJOR.minor.fixfixreleaserelease 30 | */ 31 | 32 | #ifndef ER_VERSION 33 | #define ER_VERSION _ER_VERSION 34 | #define ER_VERSION_HEX _ER_VERSION_HEX 35 | #else 36 | #if _ER_VERSION_HEX != ER_VERSION_HEX 37 | #error EngineRoom: Version number in er_macros.h does not match external definition 38 | #endif 39 | #endif 40 | 41 | /* 42 | * expands to the number of arguments (up to 20) it was given 43 | * returns 1 for 1 AND zero arguments, see ER_COUNT_ARGS_PLUS1 for a solution 44 | * credit for the technique goes to Steven Fuerst 45 | * http://locklessinc.com/articles/overloading/ 46 | */ 47 | #define ER_COUNT_NONZERO_ARGS(...) _ER_COUNT_NONZERO_ARGS_HELPER(__VA_ARGS__, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1) 48 | #define _ER_COUNT_NONZERO_ARGS_HELPER(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _, ...) _ 49 | 50 | /* expands to the number of arguments plus 1 - and works for the no argument case */ 51 | #define ER_COUNT_ARGS_PLUS1(...) ER_COUNT_NONZERO_ARGS(dummy, ## __VA_ARGS__) 52 | 53 | /* helper macro to convert preprocessor symbols into strings */ 54 | #define _ER_STRINGIFY(s) #s 55 | #define ER_STRINGIFY(s) _ER_STRINGIFY(s) 56 | 57 | /* helper macro to combine tokens */ 58 | #define ER_CAT(A, B) _ER_CAT_HELPER(A, B) 59 | #define _ER_CAT_HELPER(A, B) A ## B 60 | 61 | /* 62 | * #define something ER_VARARGS_TO_ONELESSTHAN(something, ## __VA_ARGS__) 63 | * transforms: 64 | * something() -> somethingOneLessThan1() 65 | * something(x) -> somethingOneLessThan2(x) 66 | * something(x,y) -> somethingOneLessThan3(x,y) 67 | * something(x,y,z) -> somethingOneLessThan4(x,y,z) 68 | * 69 | * which is useful if you need to inspect or stringify arguments 70 | */ 71 | #define ER_VARARGS_TO_NONZERO_ARGS(prefix, ...) ER_CAT( prefix, ER_COUNT_NONZERO_ARGS(__VA_ARGS__))(__VA_ARGS__) 72 | #define ER_VARARGS_TO_ONELESSTHAN(prefix, ...) ER_CAT( ER_CAT(prefix, OneLessThan), ER_COUNT_ARGS_PLUS1(__VA_ARGS__))(__VA_ARGS__) 73 | 74 | #endif 75 | /* __ER_MACROS_H__ */ 76 | -------------------------------------------------------------------------------- /EngineRoom/er_symbols.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #ifndef __ER_SYMBOLS_H__ 24 | #define __ER_SYMBOLS_H__ 25 | 26 | // work in progress 27 | #define ER_SYMBOL_VISIBLE /* __attribute__((visibility("default"))) */ 28 | #define ER_SYMBOL_VISIBLE_EMBEDDED /* __attribute__((visibility("default"))) */ 29 | #define ER_SYMBOL_HIDDEN /* __attribute__((visibility("hidden"))) */ 30 | #define ER_SYMBOL_WEAK_IMPORT __attribute__((weak_import)) 31 | 32 | #if MAINTAINER_WARNINGS 33 | #warning BK: match up with unused from er_util 34 | #endif 35 | #define ER_SYMBOL_USED /* __attribute__((visibility("used"))) */ 36 | 37 | 38 | #ifdef ER_EMBEDDED_NAME 39 | 40 | #define ER_EMBEDDED_NAME_AS_STRING ER_STRINGIFY(ER_EMBEDDED_NAME) 41 | 42 | #define ER_SYMBOL_EMBEDDED_NAME(symbolName) ER_CAT( ER_CAT(ER_EMBEDDED_NAME, _), symbolName) 43 | 44 | #if ER_EMBEDDED_IGNORE_GLOBAL 45 | #define ER_ADDRESS_OF_GLOBAL_OR_EMBEDDED(symbolName) ( &ER_SYMBOL_EMBEDDED_NAME(symbolName) ) 46 | #else 47 | #define ER_ADDRESS_OF_GLOBAL_OR_EMBEDDED(symbolName) ( NULL == &symbolName ? &ER_SYMBOL_EMBEDDED_NAME(symbolName) : &symbolName ) 48 | #endif 49 | 50 | #else 51 | /* ! ER_EMBEDDED_NAME */ 52 | 53 | #define ER_EMBEDDED_NAME_AS_STRING "" 54 | 55 | #define ER_SYMBOL_EMBEDDED_NAME(symbolName) symbolName 56 | 57 | #define ER_ADDRESS_OF_GLOBAL_OR_EMBEDDED(symbolName) (&symbolName) 58 | 59 | #endif 60 | /* ER_EMBEDDED_NAME */ 61 | 62 | #endif 63 | /* __ER_SYMBOLS_H__ */ 64 | -------------------------------------------------------------------------------- /EngineRoom/er_util.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #include "er_util.h" 24 | 25 | void * UTIL_NO_INSTRUMENT 26 | util_map_image(const char *file, size_t *lengthPtr) 27 | { 28 | struct stat sb; 29 | int fd; 30 | void *image; 31 | 32 | if( NULL != lengthPtr ) 33 | *lengthPtr = 0; 34 | 35 | if( NULL == file ) 36 | utilReturnWithMessage(NULL, "can not map NULL file"); 37 | 38 | if( 0 != stat(file, &sb) ) 39 | utilReturnWithMessage(NULL, "can not stat %s (%s)", file, strerror(errno)); 40 | 41 | if( 0 > ( fd = open(file, O_RDONLY) ) ) 42 | utilReturnWithMessage(NULL, "can not open %s (%s)", file, strerror(errno)); 43 | 44 | image = mmap(NULL, (size_t) sb.st_size, PROT_READ, MAP_PRIVATE, fd, (off_t) 0); 45 | close(fd); 46 | 47 | if( (void *) -1 == image ) 48 | utilReturnWithMessage(NULL, "can not mmap %s (%s)", file, strerror(errno)); 49 | 50 | if( NULL != lengthPtr ) 51 | *lengthPtr = (size_t) sb.st_size; 52 | 53 | return image; 54 | } 55 | 56 | void UTIL_NO_INSTRUMENT 57 | util_unmap_image(void *image, size_t length) 58 | { 59 | munmap(image, length); 60 | } 61 | 62 | 63 | int util_asprintf(char **ret, const char *fmt, ...) 64 | { 65 | va_list ap; 66 | va_start(ap, fmt); 67 | int n = util_vasprintf(ret, fmt, ap); 68 | va_end(ap); 69 | return n; 70 | } 71 | 72 | int util_vasprintf(char **ret, const char *fmt, va_list ap) 73 | { 74 | char dummy; 75 | char *buf = &dummy; 76 | va_list ap_copy; 77 | 78 | if( ret == NULL ) { 79 | return -1; 80 | } 81 | 82 | va_copy(ap_copy, ap); 83 | 84 | int len = vsnprintf(buf, 1, (fmt), ap_copy); /* 1, not 0 for Solaris, man vsnprintf -> NOTES */ 85 | 86 | if( len < 0 ) { 87 | *ret = NULL; 88 | return -1; 89 | } 90 | 91 | buf = malloc((size_t) len + 1); 92 | 93 | if( NULL == buf ) { 94 | *ret = NULL; 95 | return -1; 96 | } 97 | 98 | len = vsnprintf(buf, (size_t)len+1, (fmt), ap); 99 | 100 | *ret = buf; 101 | return len; 102 | } 103 | 104 | int util_log_asprintf(char **result, const char *fmt, ...) 105 | { 106 | va_list args; 107 | va_start(args, fmt); 108 | 109 | int ret = util_log_vasprintf(result, fmt, args); 110 | 111 | va_end(args); 112 | 113 | return ret; 114 | } 115 | 116 | int util_log_vasprintf(char **result, const char *fmt, va_list args) 117 | { 118 | int ret; 119 | 120 | struct timeval tv; 121 | struct timezone tz; 122 | struct tm tm_gmt; 123 | 124 | if( result ) 125 | *result = NULL; 126 | 127 | gettimeofday(&tv, &tz); 128 | 129 | time_t tt = tv.tv_sec; 130 | gmtime_r(&tt, &tm_gmt); 131 | 132 | char timestamp[ sizeof("YYYY-MM-DD HH:MM:SS") ]; 133 | 134 | strftime(timestamp, sizeof(timestamp), "%Y-%m-%d %H:%M:%S", &tm_gmt); 135 | 136 | char *msg = NULL; 137 | 138 | if( NULL != fmt ) 139 | util_vasprintf(&msg, fmt, args); 140 | 141 | #if 1 142 | ret = util_asprintf(result, "%10llu.%06d %s %llu %s", 143 | (unsigned long long)tv.tv_sec, (int) tv.tv_usec, timestamp, (unsigned long long) getpid(), 144 | msg ? msg : ""); 145 | #else 146 | int minutes = tm_gmt.tm_hour * 60 + tm_gmt.tm_min - tz.tz_minuteswest; 147 | 148 | if( minutes < 0 ) 149 | minutes = 24 * 60 - ( -minutes % ( 24 * 60 ) ); 150 | 151 | if( minutes >= 24*60 ) 152 | minutes %= ( 24 * 60 ); 153 | 154 | ret = util_asprintf(result, "%s.%06dZ %02d:%02d %llu %s", 155 | timestamp, (int)tv.tv_usec, minutes / 60, minutes % 60, 156 | (unsigned long long) getpid(), 157 | msg ? msg : ""); 158 | #endif 159 | 160 | free(msg); 161 | 162 | return ret; 163 | } 164 | 165 | 166 | -------------------------------------------------------------------------------- /EngineRoom/er_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #ifndef __ER_UTIL_H__ 24 | #define __ER_UTIL_H__ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | #include 42 | 43 | #include 44 | #include 45 | 46 | #include 47 | 48 | #if defined(__linux__) 49 | /* needed for link.h (dl_iterate_phdr) and vasprintf on linux */ 50 | #define _GNU_SOURCE /* as documented */ 51 | #define __USE_GNU /* as needed by vasprintf */ 52 | #include 53 | #endif 54 | 55 | #if defined(__linux__) || defined(__APPLE__) 56 | #include 57 | #endif 58 | 59 | #ifdef ER_CONFIG_FILE 60 | #include ER_CONFIG_FILE 61 | #endif 62 | 63 | #define UTIL_EMPTY ({ }) 64 | 65 | #if defined(__GNUC__) || defined(__sun) 66 | #define UTIL_UNUSED __attribute__((unused)) 67 | #else 68 | #define UTIL_UNUSED /* unused variable */ 69 | #endif 70 | 71 | #ifdef __GNUC__ 72 | #define UTIL_NO_INSTRUMENT __attribute__((__no_instrument_function__)) 73 | #else 74 | #define UTIL_NO_INSTRUMENT /**/ 75 | #endif 76 | 77 | /* osf is completely unsupported, linux alpha untested, this is just a "well known" list */ 78 | #if defined(__LP64__) || defined(__powerpc64__) || defined(__osf__) || defined(__64BIT__) || defined(_LP64) 79 | #define UTIL_64BIT 1 80 | #define UTIL_INVALID_POINTER ((void*)0xFFFFFFFFFFFFFFFFLL) 81 | #else 82 | #define UTIL_INVALID_POINTER ((void*)0xFFFFFFFF) 83 | #endif 84 | 85 | #define UTIL_PTR_AS_ULL(p) ((unsigned long long)(uintptr_t)(p)) 86 | 87 | 88 | #define __UTIL_FUNCTION__ __func__ 89 | #ifdef __GNUC__ 90 | #define __UTIL_PRETTY_FUNCTION__ __PRETTY_FUNCTION__ 91 | #else 92 | #define __UTIL_PRETTY_FUNCTION__ __func__ 93 | #endif 94 | 95 | #define UTIL_PATH_SEPARATOR '/' 96 | 97 | 98 | #define utilMessage(fmt, ...) fprintf(stderr, "%s: " fmt "\n", __PRETTY_FUNCTION__, ## __VA_ARGS__ ) 99 | #define utilReturnWithMessage(ret, fmt, ...) do{ utilMessage("ERROR " fmt, ## __VA_ARGS__ ); return ret; }while(0) 100 | 101 | #define utilDebugIf(enable, fmt, ...) do{ if( enable ) utilMessage(#enable " " fmt, ## __VA_ARGS__ ); }while(0) 102 | #define utilDebug(enable, fmt, ...) do{ utilMessage(fmt, ## __VA_ARGS__ ); }while(0) 103 | 104 | 105 | #ifdef __APPLE__ 106 | 107 | #include 108 | 109 | #ifdef UTIL_64BIT 110 | #define UTIL_MACH_HEADER const struct mach_header_64 111 | #define UTIL_SEGMENT_COMMAND struct segment_command_64 112 | #define UTIL_NLIST const struct nlist_64 113 | #else 114 | #define UTIL_MACH_HEADER const struct mach_header 115 | #define UTIL_SEGMENT_COMMAND struct segment_command 116 | #define UTIL_NLIST const struct nlist 117 | #endif 118 | 119 | #endif 120 | /* __APPLE__ */ 121 | 122 | #if __OBJC__ 123 | 124 | /* 125 | * macros to retain and autorelease CoreFoundation objects correctly with and without GC 126 | */ 127 | 128 | // read: http://developer.apple.com/documentation/Cocoa/Conceptual/GarbageCollection/Articles/gcCoreFoundation.html 129 | // also: http://www.cocoabuilder.com/archive/message/cocoa/2008/8/7/215098 130 | 131 | 132 | #define UTIL_AUTORELEASE_CF_AS_ID(cf) ({ CFTypeRef __utilARcf = (CFTypeRef) (cf); __utilARcf ? [(id) CFMakeCollectable( __utilARcf ) autorelease] : nil; }) 133 | 134 | // I am still not entirely sure if this is right: 135 | #define UTIL_RETAIN_CF(cf) ({ CFTypeRef __utilRTcf = (CFTypeRef) (cf); __utilRTcf ? ( __typeof__((cf)) ) [(id) CFMakeCollectable( __utilRTcf ) retain] : NULL; }) 136 | 137 | #define UTIL_AUTORELEASE_CF(cf) ( ( __typeof__((cf)) ) UTIL_AUTORELEASE_CF_AS_ID(cf) ) 138 | 139 | #define ER_AUTORELEASE_CF(cf) UTIL_AUTORELEASE_CF(cf) 140 | #define ER_AUTORELEASE_CF_AS_ID(cf) UTIL_AUTORELEASE_CF_AS_ID(cf) 141 | #define ER_RETAIN_CF(cf) UTIL_RETAIN_CF(cf) 142 | 143 | #endif 144 | 145 | 146 | #define util_watch_start(name) struct timeval name##_util_watch; gettimeofday(&name##_util_watch, NULL); 147 | #define util_watch_seconds(name) ({ util_watch_start(name##_read); \ 148 | (name##_read_util_watch.tv_sec + 1e-6 * name##_read_util_watch.tv_usec) - (name##_util_watch.tv_sec + 1e-6 * name##_util_watch.tv_usec); }) 149 | 150 | 151 | void *util_map_image(const char *file, size_t *lengthPtr); 152 | void util_unmap_image(void *image, size_t length); 153 | 154 | int util_asprintf(char **ret, const char *fmt, ...); 155 | int util_vasprintf(char **ret, const char *fmt, va_list ap); 156 | 157 | /* prepends cross-timezone-sortable timestamp, human readable timestamp, pid */ 158 | int util_log_asprintf(char **ret, const char *fmt, ...); 159 | int util_log_vasprintf(char **ret, const char *fmt, va_list ap); 160 | 161 | #endif 162 | /* __ER_UTIL_H__ */ 163 | -------------------------------------------------------------------------------- /EngineRoom/logpoints.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #ifndef __LOGPOINTS_H__ 24 | #define __LOGPOINTS_H__ 25 | 26 | #ifdef __OBJC__ 27 | #import 28 | #import 29 | #endif 30 | 31 | #include "logpoints_api.h" 32 | 33 | #define kLogPointKindNone NULL 34 | #define kLogPointKeysNone NULL 35 | #define kLogPointLabelNone NULL 36 | #define kLogPointFormatNone NULL 37 | #define kLogPointFormatInfoNone NULL 38 | 39 | #endif 40 | /* __LOGPOINTS_H__ */ 41 | 42 | -------------------------------------------------------------------------------- /EngineRoom/logpoints_default.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | 24 | #ifndef __LOGPOINTS_DEFAULT_H__ 25 | #define __LOGPOINTS_DEFAULT_H__ 1 26 | 27 | /* make sure to include the policy first (for ENABLE defines/overrides to work) */ 28 | #include "logpoints_default_policy.h" 29 | 30 | #include "logpoints_default_macros.h" 31 | 32 | #include "logpoints_default_kinds.h" 33 | 34 | /* (?) enabled ? 35 | #define lplog(fmt, ...) LOGPOINT_FUNCTION_C( LOGPOINT_NOFLAGS, "lplog", kLogPointKeysNone, kLogPointLabelNone, fmt, ## __VA_ARGS__ ) 36 | */ 37 | 38 | #endif 39 | /* __LOGPOINTS_DEFAULT_H__ */ 40 | -------------------------------------------------------------------------------- /EngineRoom/logpoints_default_kinds.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #ifndef __LOGPOINTS_DEFAULT_KINDS_H__ 24 | #define __LOGPOINTS_DEFAULT_KINDS_H__ 1 25 | 26 | /* the following constants must be declared as char[] to be used in static initializers */ 27 | 28 | /* syslog equivalents */ 29 | LOGPOINT_EXTERN_C(kLogPointKindDebug[], const char, "DEBUG"); 30 | LOGPOINT_EXTERN_C(kLogPointKindInfo[], const char, "INFO"); 31 | LOGPOINT_EXTERN_C(kLogPointKindNotice[], const char, "NOTICE"); 32 | LOGPOINT_EXTERN_C(kLogPointKindWarning[], const char, "WARNING"); 33 | LOGPOINT_EXTERN_C(kLogPointKindError[], const char, "ERROR"); 34 | LOGPOINT_EXTERN_C(kLogPointKindCritical[], const char, "CRITICAL"); 35 | LOGPOINT_EXTERN_C(kLogPointKindAlert[], const char, "ALERT"); 36 | LOGPOINT_EXTERN_C(kLogPointKindEmergency[], const char, "EMERGENCY"); 37 | 38 | LOGPOINT_EXTERN_C(kLogPointKindTrace[], const char, "TRACE"); 39 | 40 | LOGPOINT_EXTERN_C(kLogPointKindNote[], const char, "NOTE"); 41 | LOGPOINT_EXTERN_C(kLogPointKindFixMe[], const char, "FIXME"); 42 | LOGPOINT_EXTERN_C(kLogPointKindToDo[], const char, "TODO"); 43 | 44 | LOGPOINT_EXTERN_C(kLogPointKindSwitch[], const char, "SWITCH"); 45 | 46 | LOGPOINT_EXTERN_C(kLogPointKindAssert[], const char, "ASSERT"); 47 | 48 | #endif 49 | /* __LOGPOINTS_DEFAULT_KINDS_H__ */ 50 | -------------------------------------------------------------------------------- /EngineRoom/logpoints_default_policy.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #ifndef __LOGPOINTS_DEFAULT_POLICY_H__ 24 | #define __LOGPOINTS_DEFAULT_POLICY_H__ 25 | 26 | /* compile time feature enable defaults - make sure that these are always included before logpoints.h */ 27 | 28 | /* undef'ing this will disable all kinds of logging */ 29 | #ifndef LOGPOINT_ENABLE_LPLOG 30 | #define LOGPOINT_ENABLE_LPLOG 1 31 | #endif 32 | 33 | #ifndef LOGPOINT_COUNT 34 | #ifdef LOGPOINT_RELEASE_BUILD 35 | #define LOGPOINT_COUNT 0 36 | #else 37 | #define LOGPOINT_COUNT 1 38 | #endif 39 | #endif 40 | 41 | #ifndef LOGPOINT_COUNT_INACTIVE 42 | #ifdef LOGPOINT_RELEASE_BUILD 43 | #define LOGPOINT_COUNT_INACTIVE 0 44 | #else 45 | #define LOGPOINT_COUNT_INACTIVE 1 46 | #endif 47 | #endif 48 | 49 | #ifndef LOGPOINT_ENABLE_TRACE 50 | #define LOGPOINT_ENABLE_TRACE 1 51 | #endif 52 | 53 | #ifndef LOGPOINT_ENABLE_ASSERT 54 | #define LOGPOINT_ENABLE_ASSERT 1 55 | #endif 56 | 57 | #ifndef LOGPOINT_ENABLE_NOTES 58 | #ifdef LOGPOINT_RELEASE_BUILD 59 | #define LOGPOINT_ENABLE_NOTES 0 60 | #else 61 | #define LOGPOINT_ENABLE_NOTES 1 62 | #endif 63 | #endif 64 | 65 | #ifndef LOGPOINT_ENABLE_SWITCH 66 | #define LOGPOINT_ENABLE_SWITCH 1 67 | #endif 68 | 69 | 70 | #ifndef LOGPOINT_ENABLE_DEBUG 71 | #define LOGPOINT_ENABLE_DEBUG 1 72 | #endif 73 | 74 | #ifndef LOGPOINT_ENABLE_INFO 75 | #define LOGPOINT_ENABLE_INFO 1 76 | #endif 77 | 78 | #ifndef LOGPOINT_ENABLE_NOTICE 79 | #define LOGPOINT_ENABLE_NOTICE 1 80 | #endif 81 | 82 | #ifndef LOGPOINT_ENABLE_WARNING 83 | #define LOGPOINT_ENABLE_WARNING 1 84 | #endif 85 | 86 | #ifndef LOGPOINT_ENABLE_ERROR 87 | #define LOGPOINT_ENABLE_ERROR 1 88 | #endif 89 | 90 | #ifndef LOGPOINT_ENABLE_CRITICAL 91 | #define LOGPOINT_ENABLE_CRITICAL 1 92 | #endif 93 | 94 | #ifndef LOGPOINT_ENABLE_ALERT 95 | #define LOGPOINT_ENABLE_ALERT 1 96 | #endif 97 | 98 | #ifndef LOGPOINT_ENABLE_EMERGENCY 99 | #define LOGPOINT_ENABLE_EMERGENCY 1 100 | #endif 101 | 102 | 103 | /* default flag sets */ 104 | 105 | #define LOGPOINT_FLAGS_DEBUG ( LOGPOINT_PRIORITIZED | LOGPOINT_DEBUG ) 106 | #define LOGPOINT_FLAGS_INFO ( LOGPOINT_PRIORITIZED | LOGPOINT_INFO ) 107 | #define LOGPOINT_FLAGS_NOTICE ( LOGPOINT_PRIORITIZED | LOGPOINT_NOTICE ) 108 | #define LOGPOINT_FLAGS_WARNING ( LOGPOINT_PRIORITIZED | LOGPOINT_WARNING | LOGPOINT_HARD | LOGPOINT_ACTIVE ) 109 | #define LOGPOINT_FLAGS_ERROR ( LOGPOINT_PRIORITIZED | LOGPOINT_ERROR | LOGPOINT_HARD | LOGPOINT_ACTIVE ) 110 | #define LOGPOINT_FLAGS_CRITICAL ( LOGPOINT_PRIORITIZED | LOGPOINT_CRITICAL | LOGPOINT_HARD | LOGPOINT_ACTIVE ) 111 | #define LOGPOINT_FLAGS_ALERT ( LOGPOINT_PRIORITIZED | LOGPOINT_ALERT | LOGPOINT_HARD | LOGPOINT_ACTIVE ) 112 | #define LOGPOINT_FLAGS_EMERGENCY ( LOGPOINT_PRIORITIZED | LOGPOINT_EMERGENCY | LOGPOINT_HARD | LOGPOINT_ACTIVE ) 113 | 114 | #define LOGPOINT_FLAGS_TRACE ( LOGPOINT_DEBUG ) 115 | #define LOGPOINT_FLAGS_NOTE ( LOGPOINT_NOTE ) 116 | 117 | #define LOGPOINT_FLAGS_SWITCH ( LOGPOINT_SWITCH ) /* SILENT flag depends on number of arguments to macro */ 118 | 119 | #define LOGPOINT_FLAGS_ASSERT ( LOGPOINT_EMERGENCY | LOGPOINT_ASSERT | LOGPOINT_HARD | LOGPOINT_ACTIVE ) 120 | 121 | 122 | #ifndef LOGPOINT_PARAMETER_SEPARATOR 123 | #define LOGPOINT_PARAMETER_SEPARATOR " ~ " 124 | #endif 125 | 126 | #endif 127 | /* __LOGPOINTS_DEFAULT_POLICY_H__ */ 128 | -------------------------------------------------------------------------------- /EngineRoom/logpoints_nslog.h: -------------------------------------------------------------------------------- 1 | #ifndef __LOGPOINTS_NSLOG_H__ 2 | #define __LOGPOINTS_NSLOG_H__ 1 3 | 4 | #define lpNSLog(fmt, ...) ( (void) lplog_c_printf_v1( LOGPOINT_FLAGS_DEBUG | LOGPOINT_NSSTRING, "NSLog", kLogPointKeysNone, kLogPointLabelNone, kLogPointFormatInfoNone, fmt, ## __VA_ARGS__ ) ) 5 | /* (?) lpNSLogv */ 6 | 7 | /* this is convenient but will prevent using the symbol NSLog as a function pointer */ 8 | #define NSLog lpNSLog 9 | 10 | #endif 11 | /* __LOGPOINTS_NSLOG_H__ */ 12 | -------------------------------------------------------------------------------- /HOWTO.txt: -------------------------------------------------------------------------------- 1 | 2 | ** this documentation does not yet exist ** work in progress ** 3 | 4 | Using EngineRoom in your Application 5 | ------------------------------------ 6 | 7 | Recommendations: 8 | Put the EngineRoom folder beneath your project folder. 9 | Use a shared build directory (Xcode -> Preferences -> Building) 10 | 11 | These instructions are for use with the above setup. 12 | Not using a shared build directory will need more project adjustments. 13 | 14 | Now open your project, select the project itself and choose 15 | Add -> Existing files. 16 | 17 | Navigate to 18 | 19 | OSX: EngineRoom/EngineRoom-OSX and choose EngineRoom-OSX.xcodeproj 20 | iOS: EngineRoom/EngineRoom-iOS and choose EngineRoom-iOS.xcodeproj 21 | 22 | Do not tick "Copy". 23 | 24 | On opening the new entry it should reveal 25 | 26 | OSX: EngineRoom.framework 27 | iOS: libEngineRoom.a 28 | 29 | OSX: Create a new Copy Files Build Phase with target "Frameworks" and drag the 30 | framework to it (from the EngineRoom project). 31 | 32 | Option-Drag the framework from there to your targets 'Link Binary with Libraries'. 33 | 34 | iOS: Drag the libEngineRoom.a from the EngineRoom project to your targets 'Link Binary with Libraries' 35 | 36 | Open the inspector for your target, Tab "General", 37 | add EngineRoom-OSX as a dependency. 38 | 39 | iOS: Add '-all_load' and '-ObjC' to 'Other Linker Flags' 40 | (needed to load the ObjC classes and the initFunction) 41 | 42 | OSX: Open your MainMenu NIB and add an NSObject, set its class to EngineRoom, 43 | this will provide you with a LogPoint Menu. 44 | If you prefer a MenuItem, add one and connect EngineRoom's engineRoomMenuItem outlet to it. 45 | And try clicking the item. 46 | 47 | 48 | I recommend adding 49 | 50 | --- 8< --- 51 | 52 | #import 53 | #import 54 | 55 | // useful for testing - makes your NSLog()s into logpoints 56 | #import 57 | 58 | --- >8 --- 59 | 60 | to your prefix header (Other Sources -> YourProject_Prefix.pch) 61 | 62 | Now recompile and run. 63 | 64 | On OSX: 65 | hit Option-Command-. 66 | You can enter predicates in the textfields to activate LogPoints. 67 | 68 | There is shorthand available - still a moving target - therefore undocumented: 69 | 70 | but here is an example: 71 | 72 | if you enter: 73 | 74 | :selectorPrefix ; @ClassPrefix ; #keyword ; ?drag 75 | 76 | EngineRoom will activate LogPoints matching the following predicate: 77 | 78 | ( symbolNameOrSelectorNameForDisplay BEGINSWITH 'selectorPrefix' ) OR 79 | ( className BEGINSWITH 'ClassPrefix' ) OR 80 | ( keys CONTAINS 'keyword' ) OR 81 | ( formatInfo CONTAINS 'drag' ) 82 | 83 | formatInfo is (more or less) the format string you gave to your log message. 84 | 85 | 86 | The startup filter is written to your apps user defaults and can be modified like this: 87 | 88 | $ defaults write your.app.identifier logPointFilter '...' 89 | 90 | $ defaults write your.app.identifier logPointDump -bool YES 91 | 92 | will produce a dump of all logpoints for testing purposes 93 | 94 | Both of these keys can be included in your Info.plist to be used 95 | as a fallback if no defaults are set. 96 | 97 | iOS: 98 | The last paragraph above is the way to set filters for now. 99 | 100 | 101 | 102 | Useful hints: 103 | 104 | In Xcode, double click on the opening bracket of and 105 | hit Cmd-Shift-Opt-D (Open this quickly). 106 | (This does not work if a Find Panel is active - close it) 107 | 108 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The EngineRoom code is open sourced under the New BSD License. 2 | 3 | It is released with a permissive license to avoid headaches from parsing legalese. 4 | Nonetheless, a notice in your about box is the preferred form of fulfilling the 5 | license terms. 6 | 7 | If you like this software (or not), please let me know: engineroom 0x40 jumper 0x2e org. 8 | 9 | Regards, Bjoern 10 | 11 | 12 | LICENSE TERMS: 13 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 14 | 15 | Redistribution and use in source and binary forms, with or without modification, 16 | are permitted provided that the following conditions are met: 17 | 18 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 19 | 20 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 21 | in the documentation and/or other materials provided with the distribution. 22 | 23 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 24 | software without specific prior written permission. 25 | 26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 27 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 28 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 31 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | -------------------------------------------------------------------------------- /Resources/AboutIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bkrpub/EngineRoom/fd63f69e7f7499963f677a464af5c9312c9924bd/Resources/AboutIcon.png -------------------------------------------------------------------------------- /Resources/MenuIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bkrpub/EngineRoom/fd63f69e7f7499963f677a464af5c9312c9924bd/Resources/MenuIcon.png -------------------------------------------------------------------------------- /Resources/Sam_Taeguk-fine-18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bkrpub/EngineRoom/fd63f69e7f7499963f677a464af5c9312c9924bd/Resources/Sam_Taeguk-fine-18.png -------------------------------------------------------------------------------- /Resources/Sam_Taeguk-fine-54.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bkrpub/EngineRoom/fd63f69e7f7499963f677a464af5c9312c9924bd/Resources/Sam_Taeguk-fine-54.png -------------------------------------------------------------------------------- /Resources/Sam_Taeguk-fine-540.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bkrpub/EngineRoom/fd63f69e7f7499963f677a464af5c9312c9924bd/Resources/Sam_Taeguk-fine-540.png -------------------------------------------------------------------------------- /Resources/Sam_Taeguk-fine.svg: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | image/svg+xml 14 | 15 | 16 | 17 | 18 | 19 | 29 | 40 | 52 | 53 | -------------------------------------------------------------------------------- /Resources/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bkrpub/EngineRoom/fd63f69e7f7499963f677a464af5c9312c9924bd/Resources/screenshot.png -------------------------------------------------------------------------------- /Resources/screenshot_free.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bkrpub/EngineRoom/fd63f69e7f7499963f677a464af5c9312c9924bd/Resources/screenshot_free.png -------------------------------------------------------------------------------- /Test-OSX/ClangExprDiagnostic.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | void func(void) 24 | { 25 | ({ floor(3.14); }); 26 | ({ 3.0; }); 27 | } 28 | -------------------------------------------------------------------------------- /Test-OSX/ClangTestCase.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | void test(void) 24 | { 25 | __label__ out; 26 | out: return; 27 | } 28 | -------------------------------------------------------------------------------- /Test-OSX/EngineRoomTest_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'EngineRoomTest' target in the 'EngineRoomTest' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /Test-OSX/English.lproj/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} 2 | {\colortbl;\red255\green255\blue255;} 3 | \paperw9840\paperh8400 4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural 5 | 6 | \f0\b\fs24 \cf0 Engineering: 7 | \b0 \ 8 | Some people\ 9 | \ 10 | 11 | \b Human Interface Design: 12 | \b0 \ 13 | Some other people\ 14 | \ 15 | 16 | \b Testing: 17 | \b0 \ 18 | Hopefully not nobody\ 19 | \ 20 | 21 | \b Documentation: 22 | \b0 \ 23 | Whoever\ 24 | \ 25 | 26 | \b With special thanks to: 27 | \b0 \ 28 | Mom\ 29 | } 30 | -------------------------------------------------------------------------------- /Test-OSX/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bkrpub/EngineRoom/fd63f69e7f7499963f677a464af5c9312c9924bd/Test-OSX/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /Test-OSX/English.lproj/MainMenu.nib/keyedobjects.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bkrpub/EngineRoom/fd63f69e7f7499963f677a464af5c9312c9924bd/Test-OSX/English.lproj/MainMenu.nib/keyedobjects.nib -------------------------------------------------------------------------------- /Test-OSX/English.lproj/MyDocument.nib/keyedobjects.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bkrpub/EngineRoom/fd63f69e7f7499963f677a464af5c9312c9924bd/Test-OSX/English.lproj/MyDocument.nib/keyedobjects.nib -------------------------------------------------------------------------------- /Test-OSX/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDocumentTypes 8 | 9 | 10 | CFBundleTypeExtensions 11 | 12 | ???? 13 | 14 | CFBundleTypeIconFile 15 | 16 | CFBundleTypeName 17 | DocumentType 18 | CFBundleTypeOSTypes 19 | 20 | ???? 21 | 22 | CFBundleTypeRole 23 | Editor 24 | NSDocumentClass 25 | MyDocument 26 | 27 | 28 | CFBundleExecutable 29 | ${EXECUTABLE_NAME} 30 | CFBundleIconFile 31 | 32 | CFBundleIdentifier 33 | org.jumper.EngineRoomTest 34 | CFBundleInfoDictionaryVersion 35 | 6.0 36 | CFBundleName 37 | ${PRODUCT_NAME} 38 | CFBundlePackageType 39 | APPL 40 | CFBundleSignature 41 | ???? 42 | CFBundleVersion 43 | 00040.20.01 44 | NSMainNibFile 45 | MainMenu 46 | NSPrincipalClass 47 | NSApplication 48 | 49 | 50 | -------------------------------------------------------------------------------- /Test-OSX/MyDocument.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #import 24 | 25 | @interface MyDocument : NSDocument 26 | { 27 | } 28 | 29 | - (IBAction) generateWarning: (id) sender; 30 | 31 | - (IBAction) takeTestValueFrom: (id) sender; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Test-OSX/MyDocument.m: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #import "MyDocument.h" 24 | #import 25 | #import 26 | #import 27 | 28 | #define dbug lpdebug 29 | #define dbug_return return_lpdebug 30 | 31 | @implementation MyDocument 32 | 33 | - (IBAction) generateWarning: (id) sender 34 | { 35 | lpkwarningf("interface", "please do not press this (%@) again\n%@", sender, tracerBacktraceAsString(0)); 36 | } 37 | 38 | - (IBAction) takeTestValueFrom: (id) sender 39 | { 40 | lpkdebugf("action", "sender: %@", sender); 41 | 42 | /*dbug([sender frame]);*/ 43 | 44 | NSString *string = [sender stringValue]; 45 | 46 | if( lpkswitchf("action,expandInput", "trying to expand %@", string) ) { 47 | if( [string isEqualToString: @"*"] ) { 48 | [sender setStringValue: @"42"]; 49 | } 50 | } 51 | 52 | int length = [[sender stringValue] length]; 53 | 54 | if( length ) { 55 | dbug(length); 56 | dbug([sender doubleValue]); 57 | dbug( NSMakeSize(length, length) ); 58 | } else { 59 | lpkerrorf("interface,entry", "empty value from %@", sender); 60 | } 61 | 62 | 63 | } 64 | 65 | - (id)init 66 | { 67 | self = [super init]; 68 | if (self) { 69 | 70 | // Add your subclass-specific initialization here. 71 | // If an error occurs here, send a [self release] message and return nil. 72 | 73 | } 74 | 75 | dbug_return(self); 76 | } 77 | 78 | - (NSString *)windowNibName 79 | { 80 | dbug_return(@"MyDocument"); 81 | } 82 | 83 | - (void)windowControllerDidLoadNib:(NSWindowController *) aController 84 | { 85 | [super windowControllerDidLoadNib:aController]; 86 | // Add any code here that needs to be executed once the windowController has loaded the document's window. 87 | } 88 | 89 | - (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError 90 | { 91 | // Insert code here to write your document to data of the specified type. If the given outError != NULL, ensure that you set *outError when returning nil. 92 | 93 | // You can also choose to override -fileWrapperOfType:error:, -writeToURL:ofType:error:, or -writeToURL:ofType:forSaveOperation:originalContentsURL:error: instead. 94 | 95 | // For applications targeted for Panther or earlier systems, you should use the deprecated API -dataRepresentationOfType:. In this case you can also choose to override -fileWrapperRepresentationOfType: or -writeToFile:ofType: instead. 96 | 97 | if ( outError != NULL ) { 98 | *outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:unimpErr userInfo:NULL]; 99 | } 100 | return nil; 101 | } 102 | 103 | - (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError 104 | { 105 | // Insert code here to read your document from the given data of the specified type. If the given outError != NULL, ensure that you set *outError when returning NO. 106 | 107 | // You can also choose to override -readFromFileWrapper:ofType:error: or -readFromURL:ofType:error: instead. 108 | 109 | // For applications targeted for Panther or earlier systems, you should use the deprecated API -loadDataRepresentation:ofType. In this case you can also choose to override -readFromFile:ofType: or -loadFileWrapperRepresentation:ofType: instead. 110 | 111 | if ( outError != NULL ) { 112 | *outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:unimpErr userInfo:NULL]; 113 | } 114 | return YES; 115 | } 116 | 117 | @end 118 | -------------------------------------------------------------------------------- /Test-OSX/main.m: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #import 24 | 25 | int main(int argc, char *argv[]) 26 | { 27 | return NSApplicationMain(argc, (const char **) argv); 28 | } 29 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | VERSION="1.1.11r2" 4 | 5 | CONFIGURATIONS="Release" 6 | IOS_SDKS="iphoneos iphonesimulator" 7 | IOS_VERSION="" 8 | 9 | set -e 10 | set -x 11 | 12 | BUILD_DIR="$(mktemp -d -t EngineRoom-build)" 13 | [ -z "$BUILD_DIR" ] && echo 1>&2 "$0: could not create temporary build directory" && exit 1 14 | 15 | options="BUILD_DIR=$BUILD_DIR" 16 | 17 | for conf in $CONFIGURATIONS ; do 18 | output="$BUILD_DIR/EngineRoom-$VERSION-$conf" 19 | mkdir -p "$output" 20 | done 21 | 22 | 23 | cd EngineRoom-OSX 24 | 25 | product=EngineRoom.framework 26 | 27 | for conf in $CONFIGURATIONS ; do 28 | output="$BUILD_DIR/EngineRoom-$VERSION-$conf" 29 | 30 | xcodebuild $options -configuration $conf clean 31 | xcodebuild $options -configuration $conf build 32 | mv "$BUILD_DIR/$conf/$product" "$output" 33 | done 34 | 35 | cd .. 36 | 37 | cd EngineRoom-iOS 38 | 39 | product=libEngineRoom.a 40 | 41 | for conf in $CONFIGURATIONS ; do 42 | output="$BUILD_DIR/EngineRoom-$VERSION-$conf" 43 | 44 | lipo_inputs="" 45 | for sdk in $IOS_SDKS ; do 46 | xcodebuild $options -sdk "$sdk$IOS_VERSION" -configuration $conf clean 47 | xcodebuild $options -sdk "$sdk$IOS_VERSION" -configuration $conf build 48 | lipo_inputs="$lipo_inputs $BUILD_DIR/$conf-$sdk/$product" 49 | done 50 | 51 | mkdir "$output/lib" 52 | lipo -create $lipo_inputs -output "$output/lib/$product" 53 | cp -r "$BUILD_DIR/$conf-$sdk/include" "$output" 54 | done 55 | 56 | cd .. 57 | 58 | echo 59 | echo Build results in 60 | echo "$BUILD_DIR" 61 | -------------------------------------------------------------------------------- /experimental/LocalInvoker.c: -------------------------------------------------------------------------------- 1 | ER_SYMBOL_VISIBLE_EMBEDDED LOGPOINT_INVOKER_DECLARATION( ER_SYMBOL_EMBEDDED_NAME( logPointInvokerDefault ) ) 2 | { 3 | #ifdef MAINTAINER_WARNINGS 4 | #warning local client test 5 | #warning no non-objc support 6 | #endif 7 | 8 | va_list args; 9 | va_start(args, fmt); 10 | 11 | NSString *msg = nil; 12 | 13 | if( nil != fmt ) { 14 | NSString *nsfmt = LOGPOINT_IS_NSSTRING(*lpp) ? (id)fmt : [[NSString alloc] initWithUTF8String: (const char *)fmt]; 15 | 16 | msg = [[NSString alloc] initWithFormat: nsfmt arguments: args]; 17 | 18 | if( LOGPOINT_IS_NSSTRING(*lpp) ) { 19 | [nsfmt release]; 20 | } 21 | } 22 | 23 | NSLog(@"%s: %s %@", __FUNCTION__, lpp->kind, msg ?: @"NO PAYLOAD"); 24 | [msg release]; 25 | 26 | va_end(args); 27 | return LOGPOINT_YES; 28 | } 29 | 30 | #endif 31 | /* LOCAL_INVOKER */ 32 | -------------------------------------------------------------------------------- /experimental/arg.m: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #include 24 | #import 25 | 26 | #define LP_ARGS __builtin_apply_args() 27 | #define LP_FUNC __PRETTY_FUNCTION__ 28 | 29 | 30 | void *retself(void *self, void *_cmd) 31 | { 32 | return self; 33 | } 34 | 35 | void *getself(void *args) 36 | { 37 | __builtin_return( __builtin_apply((void (*)()) retself, args, 2 * sizeof(void*) ) ); 38 | } 39 | 40 | 41 | void logger(const char *tag, id realself, void *args) 42 | { 43 | id fakeself = (*tag =='+' || *tag == '-') ? getself(args) : NULL; 44 | 45 | printf("%-40.40s: self: %p getself: %p\n", tag, realself, fakeself); 46 | if( realself != fakeself ) { fprintf(stderr, "FAIL !!!!\n"); /*exit(1);*/ } 47 | } 48 | 49 | void cFuncVoid(void) 50 | { 51 | logger(LP_FUNC, NULL, LP_ARGS); 52 | } 53 | 54 | int cFuncArgs(int a, int b) 55 | { 56 | logger(LP_FUNC, NULL, LP_ARGS); 57 | return a+b; 58 | } 59 | 60 | @interface ArgTest : NSObject 61 | 62 | - (float) xFromPoint: (NSPoint) p; 63 | - (NSRect) rectFromPoint: (NSPoint) p width: (float) width height: (int) height; 64 | - (void) nop; 65 | + (void) classNop; 66 | 67 | @end 68 | 69 | @implementation ArgTest 70 | 71 | - (float) xFromPoint: (NSPoint) p 72 | { 73 | logger(LP_FUNC, self, LP_ARGS); 74 | return p.x; 75 | } 76 | 77 | - (NSRect) rectFromPoint: (NSPoint) p width: (float) width height: (int) height 78 | { 79 | logger(LP_FUNC, self, LP_ARGS); 80 | return NSMakeRect(p.x,p.y,width,height); 81 | } 82 | 83 | - (void) nop 84 | { 85 | logger(LP_FUNC, self, LP_ARGS); 86 | } 87 | 88 | 89 | + (void) classNop 90 | { 91 | logger(LP_FUNC, self, LP_ARGS); 92 | } 93 | 94 | 95 | 96 | @end 97 | 98 | int main(int argc, char **argv) 99 | { 100 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 101 | 102 | cFuncArgs(23,42); 103 | 104 | ArgTest *a = [[ArgTest alloc] init]; 105 | 106 | float x = [a xFromPoint: NSMakePoint(1.2,3.4)]; 107 | 108 | printf("x: %f\n", x); 109 | 110 | NSRect r = [a rectFromPoint: NSMakePoint(1.2,3.4) width: 5.6 height: 7.8]; 111 | 112 | printf("r: %s\n", [NSStringFromRect(r) UTF8String]); 113 | 114 | [a nop]; 115 | 116 | [ArgTest classNop]; /* had semi-reproducible crashes with -fomit-frame-pointer on x86_64 */ 117 | 118 | [pool release]; 119 | 120 | return 0; 121 | } 122 | 123 | -------------------------------------------------------------------------------- /experimental/argtest.m: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #include 24 | #import 25 | 26 | #define LP_ARGS __builtin_apply_args(), __builtin_frame_address(0) 27 | #define LP_FUNC __PRETTY_FUNCTION__ 28 | 29 | 30 | void *retself(void *self, void *_cmd) 31 | { 32 | /* printf("retself: %p %p\n", self, _cmd); */ 33 | return self; 34 | } 35 | 36 | void *getself(void *args) 37 | { 38 | __builtin_return( __builtin_apply((void (*)()) retself, args, 3 * sizeof(void*) ) ); 39 | 40 | //void **argp = *(void ***) args; 41 | //return argp[0]; 42 | 43 | //return NULL; 44 | } 45 | 46 | 47 | void logger(const char *tag, id realself, id *selfaddr, void *args, void *frame) 48 | { 49 | void **f = (void**) frame; 50 | void **a = (void**) args; 51 | // fprintf(stderr, "%-20.20s: self: %p &self: %p frame: %p = %p %p %p %p\n", tag, realself, selfaddr, f, f[0], f[1], f[2], f[3]); 52 | fprintf(stderr, "%-20.20s: self: %p &self: %p args: %p = %p %p %p %p\n", tag, realself, selfaddr, a, a[0], a[1], a[2], a[3]); 53 | 54 | #if 0 55 | id fakeself = (*tag =='+' || *tag == '-') ? getself(args) : NULL; 56 | 57 | printf("%-40.40s: self: %p getself: %p\n", tag, realself, fakeself); 58 | if( realself != fakeself ) { fprintf(stderr, "FAIL !!!!\n"); /*exit(1);*/ } 59 | #endif 60 | } 61 | 62 | void funcVoid(id self, char *_cmd) 63 | { 64 | logger(LP_FUNC, self, &self, LP_ARGS); 65 | } 66 | 67 | void *funcId(id self, char *_cmd) 68 | { 69 | logger(LP_FUNC, self, &self, LP_ARGS); 70 | return self; 71 | } 72 | 73 | void cFuncVoid(void) 74 | { 75 | logger(LP_FUNC, NULL, NULL, LP_ARGS); 76 | } 77 | 78 | int cFuncArgs(int a, int b) 79 | { 80 | logger(LP_FUNC, NULL, NULL, LP_ARGS); 81 | return a+b; 82 | } 83 | 84 | 85 | 86 | @interface ArgTest : NSObject 87 | 88 | + (void) classVoid; 89 | + (id) classId; 90 | - (void) instanceVoid; 91 | - (int) heightFromPoint: (NSPoint) p width: (float) width height: (int) height; 92 | - (float) originFromPoint: (NSPoint) p width: (float) width height: (int) height; 93 | - (NSRect) rectFromPoint: (NSPoint) p width: (float) width height: (int) height; 94 | 95 | @end 96 | 97 | @implementation ArgTest 98 | 99 | + (void) classVoid 100 | { 101 | logger(LP_FUNC, self, &self, LP_ARGS); 102 | } 103 | 104 | + (id) classId 105 | { 106 | logger(LP_FUNC, self, &self, LP_ARGS); 107 | return [[self alloc] init]; 108 | } 109 | 110 | - (void) instanceVoid 111 | { 112 | logger(LP_FUNC, self, &self, LP_ARGS); 113 | } 114 | 115 | - (int) heightFromPoint: (NSPoint) p width: (float) width height: (int) height 116 | { 117 | logger(LP_FUNC, self, &self, LP_ARGS); 118 | return height; 119 | } 120 | 121 | 122 | - (float) originFromPoint: (NSPoint) p width: (float) width height: (int) height 123 | { 124 | logger(LP_FUNC, self, &self, LP_ARGS); 125 | return p.x; 126 | } 127 | 128 | - (NSRect) rectFromPoint: (NSPoint) p width: (float) width height: (int) height 129 | { 130 | logger(LP_FUNC, self, &self, LP_ARGS); 131 | return NSMakeRect(p.x,p.y,width,height); 132 | } 133 | 134 | @end 135 | 136 | int main(int argc, char **argv) 137 | { 138 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 139 | 140 | void *ret; 141 | 142 | /* 143 | funcVoid((void*)0x23, (void*)0x42); 144 | ret = funcId((void*)0x23, (void*)0x42); 145 | 146 | printf("funcId: %p\n", ret); 147 | */ 148 | 149 | cFuncVoid(); 150 | 151 | 152 | int sum = cFuncArgs(23,42); 153 | 154 | printf("cFuncArgs: %d\n", sum); 155 | 156 | [ArgTest classVoid]; 157 | ArgTest *a = [ArgTest classId]; 158 | 159 | printf("classId: %p\n", a); 160 | 161 | [a instanceVoid]; 162 | 163 | 164 | int h = [a heightFromPoint: NSMakePoint(1.2,3.4) width: 5.6 height: 7.8]; 165 | 166 | printf("h: %d\n", h); 167 | 168 | 169 | float o = [a originFromPoint: NSMakePoint(1.2,3.4) width: 5.6 height: 7.8]; 170 | 171 | printf("o: %f\n", o); 172 | 173 | NSRect r = [a rectFromPoint: NSMakePoint(1.2,3.4) width: 5.6 height: 7.8]; 174 | 175 | printf("r: %s\n", [NSStringFromRect(r) UTF8String]); 176 | 177 | [pool release]; 178 | 179 | return 0; 180 | } 181 | 182 | -------------------------------------------------------------------------------- /experimental/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | name=$1 5 | 6 | osx32="-arch i386 -arch ppc -framework Foundation -mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk" 7 | osx64="-arch x86_64 -arch ppc64 -framework Foundation -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk" 8 | 9 | set -x 10 | 11 | mkdir -p tmp 12 | 13 | gcc -ggdb $osx32 -o tmp/$name $name.m 14 | gcc -ggdb $osx64 -o tmp/$name-64 $name.m 15 | gcc -fomit-frame-pointer -Os $osx32 -o tmp/$name-rel $name.m 16 | #gcc -fomit-frame-pointer -Os $osx64 -o tmp/$name-64-rel $name.m 17 | gcc -Os $osx64 -o tmp/$name-64-rel $name.m 18 | 19 | set +x 20 | 21 | echo debug 32 22 | tmp/$name 23 | echo debug 64 24 | tmp/$name-64 25 | echo release 32 26 | tmp/$name-rel 27 | echo release 64 28 | tmp/$name-64-rel 29 | 30 | -------------------------------------------------------------------------------- /experimental/builtin_apply.m: -------------------------------------------------------------------------------- 1 | 2 | /* catches self, needs a trick to return it cleanly */ 3 | /* not applicable because clang does not support builtin_apply */ 4 | 5 | void *logpoint_catchSelf(void *slf) 6 | { 7 | fprintf(stderr, "slf: %p\n", slf); 8 | return slf; 9 | } 10 | 11 | void *logpoint_returnSelf(void *ret) 12 | { 13 | fprintf(stderr, "ret2: %p\n", ret); 14 | __builtin_return(ret); 15 | } 16 | 17 | - (void) amethod 18 | { 19 | void *args = __builtin_apply_args(); 20 | 21 | fprintf(stderr, "self: %p\n", self); 22 | 23 | void *ret = __builtin_apply( (void (*)() ) logpoint_catchSelf, args, sizeof(void*) + sizeof(SEL)); 24 | fprintf(stderr, "ret: %p\n", ret); 25 | } 26 | -------------------------------------------------------------------------------- /experimental/fulltest.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #include 24 | 25 | void getoff(int *p1, int *p2) 26 | { 27 | void *frame = __builtin_frame_address(0); 28 | void *vp1 = &p1; 29 | void *vp2 = &p2; 30 | 31 | printf("diff: %d, %d\n", vp1-frame, vp2-frame); 32 | 33 | *p1 = ( vp1 > frame ? (int)(vp1-frame) : -(int)(frame-vp1) ) / sizeof(void*); 34 | *p2 = ( vp2 > frame ? (int)(vp2-frame) : -(int)(frame-vp2) ) / sizeof(void*); 35 | 36 | printf("frame: %p &p1: %p &p2: %p sovp: %d p1: %d p2: %d\n", 37 | frame, vp1, vp2, sizeof(void*), *p1, *p2); 38 | 39 | 40 | } 41 | 42 | void func(void *a, char *b) 43 | { 44 | int f1, f2; 45 | getoff(&f1, &f2); 46 | 47 | void **frame = __builtin_frame_address(0); 48 | 49 | printf("frame: %p &a: %p &b: %p a: %p b: %p frame[%d]: %p frame[%d]: %p\n", 50 | frame, &a, &b, a, b, f1, frame[f1], f2, frame[f2]); 51 | 52 | } 53 | 54 | struct objc_args { void *self_arg; void *cmd_arg; }; 55 | 56 | void *retself(void *self, void *_cmd) 57 | { 58 | printf("retself: %p %p\n", self, _cmd); 59 | return self; 60 | } 61 | 62 | void *getself(void *args) 63 | { 64 | __builtin_return( __builtin_apply((void (*)()) retself, args, 2 * sizeof(void*) ) ); 65 | } 66 | 67 | void testself(void *self, char *_cmd) 68 | { 69 | void *myself = getself( __builtin_apply_args() ); 70 | 71 | printf("myself: %p\n", myself); 72 | } 73 | 74 | main() 75 | { 76 | testself((void*)0x23, (void*)0x42); 77 | 78 | } 79 | -------------------------------------------------------------------------------- /experimental/perftest.m: -------------------------------------------------------------------------------- 1 | int i; 2 | int iter = 1000000; 3 | int j; 4 | 5 | util_watch_start(withlp); 6 | j = 0; 7 | for( i = 0 ; i < iter ; ++i ) { 8 | NSLog(@"INLOOP %@", [NSString stringWithFormat: @"%ld", (long) j]); 9 | ++j; 10 | } 11 | double withlp = util_watch_seconds(withlp); 12 | NSLog(@"with: %.9f each: %.9f", withlp, withlp / j); 13 | 14 | util_watch_start(withoutlp); 15 | j = 0; 16 | for( i = 0 ; i < iter ; ++i ) { 17 | ++j; 18 | } 19 | double withoutlp = util_watch_seconds(withoutlp); 20 | 21 | NSLog(@"wout: %.9f each: %.9f", withoutlp, withoutlp / j); 22 | 23 | NSLog(@"cost per lp: %.9f on %ld iter: %.9f", withlp / j - withoutlp / j, (long) j, withlp - withoutlp); 24 | 25 | -------------------------------------------------------------------------------- /experimental/str.m: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | // gcc -o str str.m -framework Foundation 24 | 25 | #import 26 | 27 | int main(int argc, const char **argv) 28 | { 29 | unichar characters[] = { 'o', 'e', ':', 0xf6, ' ', 'p', 'h', 'i', ':', 0x278 }; 30 | 31 | CFStringRef str = CFStringCreateWithCharacters(kCFAllocatorDefault, characters, sizeof(characters) / sizeof(characters[0])); 32 | 33 | CFStringBuiltInEncodings encoding = argc>1 ? strtol(argv[1], NULL, 16) : kCFStringEncodingUTF8; 34 | UInt8 lossByte = argc>2 ? *argv[2] : 0; 35 | 36 | 37 | CFIndex strlen = CFStringGetLength(str); 38 | CFIndex buflen = CFStringGetMaximumSizeForEncoding( strlen, encoding ) + 1; 39 | CFIndex usedbuflen = 0; 40 | CFIndex converted = 0; 41 | 42 | NSLog(@"str: '%@' strlen=%d buflen=%d", str, (int)strlen, (int)buflen); 43 | 44 | UInt8 *buffer = malloc( buflen * sizeof(UInt8) ); 45 | 46 | //CFStringCreateExternalRepresentation(CFAllocatorRef alloc, CFStringRef theString, CFStringEncoding encoding, UInt8 lossByte); 47 | 48 | converted = CFStringGetBytes(str, CFRangeMake(0, strlen), encoding, lossByte, false, buffer, buflen - 1, &usedbuflen); 49 | 50 | buffer[usedbuflen] = 0; 51 | 52 | NSLog(@"converted=%d usedbuflen=%d", (int)converted, (int) usedbuflen); 53 | 54 | printf("pf buffer: '%s'\n", buffer); 55 | NSLog(@"ns1 buffer: '%s'\n", buffer); 56 | NSLog(@"ns2 buffer: '%@'\n", [[NSString alloc] initWithUTF8String: buffer]); 57 | NSLog(@"ns3 buffer: '%@'\n", [[NSString alloc] initWithFormat: @"%s", buffer]); 58 | 59 | return 0; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /experimental/tracer64_fail: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bkrpub/EngineRoom/fd63f69e7f7499963f677a464af5c9312c9924bd/experimental/tracer64_fail -------------------------------------------------------------------------------- /experimental/tst.m: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #import 24 | #include 25 | 26 | @interface Foo : NSObject 27 | + (void) bar; 28 | - (void) baz; 29 | - (NSRect) rect; 30 | - (NSRect) rect: (NSRect) r foo: (id) x; 31 | - (unsigned long long) ull; 32 | - (unsigned long long) ull: (NSRect) r foo: (id) x; 33 | - (double) dbl; 34 | - (double) dbl: (NSRect) r foo: (id) x; 35 | @end 36 | 37 | #define SHOW do{ id *f = (id*) __builtin_frame_address(0); fprintf(stderr, "%-20.20s: self: %p &self: %p frame: %p = %p %p %p %p\n", __PRETTY_FUNCTION__, self, &self, f, f[0], f[1], f[2], f[3]); }while(0) 38 | 39 | @implementation Foo 40 | + (void) bar 41 | { 42 | SHOW; 43 | } 44 | 45 | - (void) baz 46 | { 47 | SHOW; 48 | } 49 | 50 | - (NSRect) rect 51 | { 52 | SHOW; 53 | return NSZeroRect; 54 | } 55 | 56 | - (NSRect) rect: (NSRect) r foo: (id) x 57 | { 58 | SHOW; 59 | return NSMakeRect(r.origin.x+1,r.origin.y+1,r.size.width,r.size.height); 60 | } 61 | 62 | - (unsigned long long) ull 63 | { 64 | SHOW; 65 | return (unsigned long long) 0ULL; 66 | } 67 | 68 | - (unsigned long long) ull: (NSRect) r foo: (id) x 69 | { 70 | SHOW; 71 | return (unsigned long long) r.origin.x; 72 | } 73 | 74 | - (double) dbl 75 | { 76 | SHOW; 77 | return (double) 0; 78 | } 79 | 80 | - (double) dbl: (NSRect) r foo: (id) x 81 | { 82 | SHOW; 83 | return (double) r.origin.x; 84 | } 85 | 86 | 87 | 88 | @end 89 | 90 | 91 | int main(int argc, const char **argv) 92 | { 93 | // int x = __builtin_choose_expression( self, 1, 0); 94 | // int myself __attribute__ ((alias ("self"))); 95 | 96 | Foo *f = [[Foo alloc] init]; 97 | 98 | NSRect r; 99 | unsigned long long ull; 100 | double d; 101 | 102 | [Foo bar]; 103 | [f baz]; 104 | r = [f rect]; 105 | r = [f rect: NSZeroRect foo: @"blah"]; 106 | ull = [f ull]; 107 | ull = [f ull: NSZeroRect foo: @"blah"]; 108 | d = [f dbl]; 109 | d= [f dbl: NSZeroRect foo: @"blah"]; 110 | 111 | return 0; 112 | } 113 | -------------------------------------------------------------------------------- /experimental/voidcrash.m: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #include 24 | #import 25 | 26 | @interface ArgTest : NSObject 27 | 28 | + (BOOL) noCrash; 29 | + (void) crash; 30 | 31 | @end 32 | 33 | @implementation ArgTest 34 | 35 | + (BOOL) noCrash 36 | { 37 | void *args = __builtin_apply_args(); 38 | printf("args: %p\n", args); 39 | return args ? YES : NO; 40 | } 41 | 42 | + (void) crash 43 | { 44 | void *args = __builtin_apply_args(); 45 | printf("args: %p\n", args); 46 | } 47 | 48 | @end 49 | 50 | int main(int argc, char **argv) 51 | { 52 | [ArgTest noCrash]; 53 | [ArgTest crash]; 54 | return 0; 55 | } 56 | 57 | -------------------------------------------------------------------------------- /scratch/Formats.txt: -------------------------------------------------------------------------------- 1 | 2 | just a note for myself 3 | 4 | case '!': /* logpoints extension */ 5 | 6 | case 'A': /* address */ 7 | case 'b': /* binary filename (without path) / %#b with */ 8 | case 'B': /* label or %#B for formatInfo */ 9 | case 'C': /* class or %#C for class with category */ 10 | case 'e': /* line number */ 11 | case 'f': /* filename */ 12 | case 'F': /* flags */ 13 | case 'i': /* uid %#i euid */ 14 | case 'I': /* gid %#I egid */ 15 | case 'k': /* kind, need to add upper/lower */ 16 | case 'M': /* method */ 17 | case 'K': /* keys */ 18 | case 'N': /* number of passes/invocations (depends on LOGPOINT_COUNT_ALWAYS) */ 19 | case 'O': /* object info / %#O for class name */ 20 | case 'p': /* priority %#p priorityname */ 21 | case 'P': /* pid %#P ppid */ 22 | case 'S': /* symbol */ 23 | case 'T': /* thread */ 24 | case 'U': /* time (unixtime as double, %#w for usec, %#.3w for msec ) */ 25 | case 'W': /* when (formatted time, UTC, %#W for local, usage: %W|%Y-%m-%d %H:%M:%S| delimiter is arbitrary) */ 26 | case '?': /* embedded name */ 27 | case '<': /* output next character if previous % expansion was non-NULL, > is handled above */ 28 | -------------------------------------------------------------------------------- /scratch/Notes.txt: -------------------------------------------------------------------------------- 1 | 2 | lpdebugf(@"" no warning fro wrong string type - auto-detect? 3 | 4 | Test outside xcode for embedded stuff (in XCode, all apps are linked against us) 5 | 6 | data: fuer image logs 7 | 8 | #ifdef DEBUG 9 | #if __ppc64__ || __ppc__ 10 | #define DebugBreak() \ 11 | if(AmIBeingDebugged()) \ 12 | { \ 13 | __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \ 14 | : : : "memory","r0","r3","r4" ); \ 15 | } 16 | #else 17 | #define DebugBreak() if(AmIBeingDebugged()) {__asm__("int $3\n" : : );} 18 | #endif 19 | 20 | bool AmIBeingDebugged(void); 21 | #else 22 | #define DebugBreak() 23 | #endif 24 | 25 | 26 | userData ( think switch on a specific value ) 27 | 28 | CFPlugin 29 | 30 | Flags: TERSE VERBOSE ... (include what?) format ? 31 | 32 | NSUserDefaults logPointFilter does not work if not yet registered (and not set) 33 | 34 | retrigger for loaded plugins 35 | 36 | UserDefaults: 37 | addSuiteNamed: instead of homebrew 38 | 39 | PluginLoader 40 | 41 | RTTI / C++ reflection ? clang... typeinfo libelf-tc 42 | 43 | NSError detect in format objc value 44 | debugDescription? 45 | 46 | lplog_vprintf 47 | 48 | lplog_printf_rvalue 49 | 50 | lplog_printf_return 51 | 52 | 53 | 54 | 55 | Uli: 56 | #if DEBUG 57 | #define PROPERTY(propName) NSStringFromSelector(@selector(propName)) 58 | #else 59 | #define PROPERTY(propName) @#propName 60 | #endif 61 | 62 | asl support 63 | key,value -> keys a=b,... 64 | 65 | threading 66 | lock for single handle? - hmm 67 | 68 | 69 | cpp -MM Makefile gen 70 | 71 | check what happens if more args than auto macros 72 | 73 | clock macros util_watch 74 | 75 | __-[class(category) selector]_block_invoke_n 76 | 77 | DOM Macros 78 | 79 | UDP/TCP 80 | 81 | HUD 82 | 83 | interp 84 | 85 | Object NSBrowser (select, dump) [CoreData?] 86 | 87 | usage in blocks (PRETTY_FUNCTION) 88 | 89 | typeof(&((a)[0])) __x 90 | 91 | https://gnunet.org/coverage/usr/include/curl/typecheck-gcc.h.gcov.html 92 | 93 | http://locklessinc.com/articles/overloading/ 94 | 95 | http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html 96 | 97 | 98 | lpdebugv(fmt, va_args) 99 | 100 | NS_FORMAT_FUNCTION(1,2) 101 | 102 | ..NSWarn() 103 | ..NSErr() 104 | 105 | google-toolbox-for-mac 106 | 107 | Thread-safe emit? 108 | 109 | 110 | cffmt release ns bug 111 | 112 | format string for composer 113 | "%{%Y%m%d} %k %l %f %% %m 114 | %k kind 115 | %w keys 116 | %c class 117 | %o pointer 118 | %a address 119 | %f function 120 | %F file 121 | %l line 122 | 123 | how to handle assertions? 124 | log first? then assertion handler? 125 | switch assertions to errors 126 | 127 | embed without linkage (i.e. AFCache) 128 | Weak Linkage? @loader_path... @executable_path... 129 | Macro fuer function-names mit local prefix 130 | weak functions (test for null before call) 131 | 132 | visualization of logging density 133 | 134 | detect and auto-enable new ones? 135 | format lines and diff? 136 | 137 | lpFilterSimple / auto setup from ENV 138 | 139 | UTIL64 sizeof(long)? 140 | 141 | utilDebug? enable? 142 | 143 | ret check in vasprintf 144 | 145 | git/svn detect - too far? 146 | 147 | __attribute__((overloadable)) with clang for formatting 148 | hack clang 149 | 150 | check tracerDump output versus tracerBacktraceAsString 151 | 152 | check scanClassList on 10.4 153 | 154 | __msg in Macros (extra parameter for LOGPOINT_CREATE needed) 155 | 156 | versioning 157 | 158 | 159 | #import 160 | 161 | uint64_t start = mach_absolute_time(); 162 | 163 | // do stuff to be timed 164 | 165 | uint64_t end = mach_absolute_time(); 166 | uint64_t elapsed = end - start; 167 | 168 | mach_timebase_info_data_t info; 169 | if (mach_timebase_info (&info) != KERN_SUCCESS) { 170 | printf ("mach_timebase_info failed\n"); 171 | } 172 | 173 | uint64_t nanosecs = elapsed * info.numer / info.denom; 174 | uint64_t millisecs = nanosecs / 1000000; 175 | 176 | 177 | ibtool --connections DimensionsPanel.xib 178 | -------------------------------------------------------------------------------- /scratch/TestCases.txt: -------------------------------------------------------------------------------- 1 | 2 | void (^globalBlock)(void) = ^(void) { lpcdebug(); } 3 | 4 | void cFunction(DOMCSSRuleList *ruleList) 5 | { 6 | lpcdebug(); 7 | 8 | globalBlock(); 9 | 10 | void (^cFunctionLocalBlock)(void) = ^(void){ lpcdebug() }; 11 | 12 | cFunctionLocalBlock(); 13 | } 14 | 15 | - (void) objectiveCMethod 16 | { 17 | lpdebug(); 18 | 19 | void (^objectiveCMethodLocalBlock)(void) = ^(void){ lpdebug() }; 20 | 21 | objectiveCMethodLocalBlock(); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /scratch/logpoints_auto_format.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #ifndef __LOGPOINTS_AUTO_FORMAT_H__ 24 | #define __LOGPOINTS_AUTO_FORMAT_H__ 1 25 | 26 | #if __OBJC__ 27 | 28 | /* TESTING NSValue *__cmnsv = [[NSValue alloc] initWithBytes: &__cmv objCType: type]; */ /* NSValue secretly supports 'D'... */ 29 | 30 | #define LOGPOINT_FORMAT_VALUE(v, label) ({ \ 31 | __typeof__ (v) __valueToFormat = (v) ; \ 32 | char *type = __builtin_types_compatible_p( __typeof__(__valueToFormat), long double) ? "D" : @encode( __typeof__ (__valueToFormat) ); \ 33 | (logPointFormatObjCType ? logPointFormatObjCType : local_logPointFormatObjCType)(type, (void*)&__valueToFormat, (label)); /* returns autoreleased string */ \ 34 | }) 35 | 36 | /* 37 | * internal helper function in logpoints.m, returns autoreleased string describing the @encode type at *data 38 | */ 39 | id logPointFormatObjCType(const char *type, void *data, const char *label) __attribute__((weak_import)); 40 | 41 | #endif 42 | /* __OBJC__ */ 43 | 44 | #endif 45 | /* __LOGPOINTS_AUTO_FORMAT_H__ */ 46 | 47 | -------------------------------------------------------------------------------- /scratch/logpoints_doc.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #ifndef __LOGPOINTS_H__ 24 | #define __LOGPOINTS_H__ 25 | 26 | #ifdef __OBJC__ 27 | #import 28 | #import 29 | #endif 30 | 31 | #include "logpoints_api.h" 32 | 33 | /* 34 | * 35 | * this file declares the macros used to create logpoints in code 36 | * these are an "interface layer" to the guts of the logpoint code, 37 | * you should use these to define a frontend for your usage 38 | */ 39 | 40 | /* C String Versions */ 41 | 42 | /* 43 | * for generic use in any part of a C, C++, ObjC or ObjC++ source file 44 | */ 45 | #define LOGPOINT_FUNCTION_C2(flags, kind, keys, label, fmtInfo, fmt, ...) LOGPOINT_CREATE( (flags) | LOGPOINT_C, (kind), (keys), (label), NULL, NULL, fmtInfo, fmt, ## __VA_ARGS__ ) 46 | 47 | /* 48 | * only for use in Objective C methods in ObjC or ObjC++ source files, forwards "self" and "_cmd" to the logpoint invocation 49 | */ 50 | #define LOGPOINT_METHOD_OBJC2(flags, kind, keys, label, fmtInfo, fmt, ...) LOGPOINT_CREATE( (flags) | LOGPOINT_OBJC, (kind), (keys), (label), self, _cmd, fmtInfo, fmt, ## __VA_ARGS__ ) 51 | 52 | /* 53 | * only for use in C++ methods in ObjC or ObjC++ source files, forwards "this" to the logpoint invocation 54 | */ 55 | #define LOGPOINT_METHOD_CXX2(flags, kind, keys, label, fmtInfo, fmt, ...) LOGPOINT_CREATE( (flags) | LOGPOINT_OBJC, (kind), (keys), (label), this, NULL, fmtInfo, fmt, ## __VA_ARGS__ ) 56 | 57 | #ifdef __OBJC__ 58 | 59 | /* NSString versions - I have not yet decided if these will stay - these accept an NS/CFString for the format argument */ 60 | 61 | /* 62 | * for use in any part of a C, C++, ObjC or ObjC++ source file 63 | */ 64 | #define LOGPOINT_FUNCTION_C_NS2(flags, kind, keys, label, fmtInfo, fmt, ...) LOGPOINT_FUNCTION_C2( (flags) | LOGPOINT_NSSTRING, (kind), (keys), (label), fmtInfo, fmt, ## __VA_ARGS__ ) 65 | 66 | /* 67 | * only for use in Objective C methods in ObjC or ObjC++ source files, forwards "self" and "_cmd" to the logpoint invocation 68 | */ 69 | #define LOGPOINT_METHOD_OBJC_NS2(flags, kind, keys, label, fmtInfo, fmt, ...) LOGPOINT_METHOD_OBJC2( (flags) | LOGPOINT_NSSTRING, (kind), (keys), (label), fmtInfo, fmt, ## __VA_ARGS__ ) 70 | 71 | /* 72 | * only for use in C++ methods in ObjC or ObjC++ source files, forwards "this" to the logpoint invocation 73 | */ 74 | #define LOGPOINT_METHOD_CXX_NS2(flags, kind, keys, label, fmtInfo, fmt, ...) LOGPOINT_METHOD_CXX2( (flags) | LOGPOINT_NSSTRING, (kind), (keys), (label), fmtInfo, fmt, ## __VA_ARGS__ ) 75 | 76 | #endif 77 | /* __OBJC__ */ 78 | 79 | 80 | /* auto-value support (type introspection) is publicly available only for ObjC (see experimental for other gruesome stuff) */ 81 | #ifdef __OBJC__ 82 | 83 | //#include "logpoints_auto_value.h" 84 | 85 | #define LOGPOINT_METHOD_OBJC_AUTO_EXPR(flags, kind, keys, label, valueLabel, value) ({ \ 86 | __typeof__(value) __valueTmp = (value); \ 87 | id __msg = LOGPOINT_FORMAT_VALUE(__valueTmp, (valueLabel)); \ 88 | LOGPOINT_METHOD_OBJC2( (flags), (kind), (keys), (label), (valueLabel), "%@", __msg ); \ 89 | __valueTmp; }) 90 | 91 | #define LOGPOINT_FUNCTION_C_AUTO_EXPR(flags, kind, keys, label, valueLabel, value) ({ \ 92 | __typeof__(value) __valueTmp = (value); \ 93 | id __msg = LOGPOINT_FORMAT_VALUE(__valueTmp, (valueLabel)); \ 94 | LOGPOINT_FUNCTION_C2( (flags), (kind), (keys), (label), (valueLabel), "%@", __msg ); \ 95 | __valueTmp; }) 96 | 97 | #endif 98 | /* __OBJC__ */ 99 | 100 | 101 | /* the following constants must be declared as char[] to be used in static initializers */ 102 | 103 | /* syslog equivalents */ 104 | LOGPOINT_EXTERN_C(kLogPointKindDebug[], const char, "DEBUG"); 105 | LOGPOINT_EXTERN_C(kLogPointKindInfo[], const char, "INFO"); 106 | LOGPOINT_EXTERN_C(kLogPointKindNotice[], const char, "NOTICE"); 107 | LOGPOINT_EXTERN_C(kLogPointKindWarning[], const char, "WARNING"); 108 | LOGPOINT_EXTERN_C(kLogPointKindError[], const char, "ERROR"); 109 | LOGPOINT_EXTERN_C(kLogPointKindCritical[], const char, "CRITICAL"); 110 | LOGPOINT_EXTERN_C(kLogPointKindAlert[], const char, "ALERT"); 111 | LOGPOINT_EXTERN_C(kLogPointKindEmergency[], const char, "EMERGENCY"); 112 | 113 | LOGPOINT_EXTERN_C(kLogPointKindTrace[], const char, "TRACE"); 114 | 115 | LOGPOINT_EXTERN_C(kLogPointKindNote[], const char, "NOTE"); 116 | LOGPOINT_EXTERN_C(kLogPointKindFixMe[], const char, "FIXME"); 117 | LOGPOINT_EXTERN_C(kLogPointKindToDo[], const char, "TODO"); 118 | 119 | LOGPOINT_EXTERN_C(kLogPointKindSwitch[], const char, "SWITCH"); 120 | 121 | LOGPOINT_EXTERN_C(kLogPointKindAssert[], const char, "ASSERT"); 122 | 123 | 124 | #define kLogPointKindNone NULL 125 | #define kLogPointKeysNone NULL 126 | #define kLogPointLabelNone NULL 127 | #define kLogPointFormatNone NULL 128 | #define kLogPointFormatInfoNone NULL 129 | #endif 130 | /* __LOGPOINTS_H__ */ 131 | 132 | -------------------------------------------------------------------------------- /scratch/logpoints_functions.c.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #ifndef __LOGPOINTS_FUNCTIONS_C_H__ 24 | #define __LOGPOINTS_FUNCTIONS_C_H__ 25 | 26 | #endif 27 | /* __LOGPOINTS_FUNCTIONS_C_H__ */ 28 | 29 | -------------------------------------------------------------------------------- /scratch/ste.txt: -------------------------------------------------------------------------------- 1 | lperror("preconditionFail, documentMerge", "error: %@", error); 2 | lperror("postConditionFail, documentMerge", "error: %@", error); 3 | LPTRACE; 4 | LPLog(@"%@", tracerBacktraceAsString(0)); 5 | LPLog(@"%@", tracerBacktraceAsString(0)); 6 | if( lpswitch("dictionaryRepresentationDump", NULL) ) { 7 | if( lpswitch("dictionaryRepresentationDump", NULL) ) { 8 | lperror("preconditionFail, documentAction", "documentCount: %ld targetRow: %ld dragRowIndexes: %@ documents: %@", 9 | lperror("postConditionFail, documentAction", "sources: %@ %@ targets: %@ %@", 10 | LPTRACE; 11 | LPLog(@"un-observing asset %@ %p (pBlob: %@)", [m_representedObject valueForKey: @"name"], m_representedObject, [m_representedObject valueForKey: @"primaryBlob"]); 12 | LPLog(@"observing asset %@ %p (pBlob: %@)", [m_representedObject valueForKey: @"name"], m_representedObject, [m_representedObject valueForKey: @"primaryBlob"]); 13 | -------------------------------------------------------------------------------- /test/cavetest.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #include 24 | 25 | #define cavemanFormatStructTimezone(tz, label) \ 26 | cavemanFormat("struct timezone: %s = GMT %+0.2d%02d (%d minutes west) DST: %d", label, \ 27 | -((tz)->tz_minuteswest) / 60, (tz)->tz_minuteswest % 60, (tz)->tz_minuteswest, (tz)->tz_dsttime) 28 | 29 | void *cavemanFormatStructTimeval(struct timeval *tv, const char *label); 30 | 31 | #define cavemanSupportedUserCType(value) \ 32 | cavemanTypeIs_opt_const((value), struct timeval ) || \ 33 | cavemanTypeIs_opt_const((value), struct timezone ) || \ 34 | 0 35 | 36 | #define cavemanFormatUserCTypes(value, localvalue, label) \ 37 | if( cavemanTypeIs_opt_const((value), struct timeval ) ) \ 38 | cavemanReturn = cavemanFormatStructTimeval( (struct timeval *) &(localvalue), (label) ); \ 39 | if( cavemanTypeIs_opt_const((value), struct timezone ) ) \ 40 | cavemanReturn = cavemanFormatStructTimezone( (struct timezone *) &(localvalue), (label) ); \ 41 | ; 42 | 43 | #include "caveman.h" 44 | 45 | void *cavemanFormatStructTimeval(struct timeval *tv, const char *label) 46 | { 47 | struct timezone tz; 48 | gettimeofday(NULL, &tz); 49 | time_t t = (time_t) (tv)->tv_sec; 50 | char buf[26]; 51 | return (void *) cavemanFormat("struct timeval: %s = %llu.%06llu = %.24s %+0.2d%02d", 52 | label, (unsigned long long) t, (unsigned long long) tv->tv_usec, 53 | ctime_r(&t, buf), -tz.tz_minuteswest / 60, tz.tz_minuteswest % 60); 54 | } 55 | 56 | 57 | void arrays(char carray[], int iarray[]) 58 | { 59 | caveman(carray); 60 | caveman(iarray); 61 | } 62 | 63 | int main(int argc, const char *argv[]) 64 | { 65 | caveman(argc); 66 | caveman(&argc); 67 | caveman(argv); 68 | caveman(argv[0]); 69 | caveman(*argv[0]); 70 | caveman(argv[1]); 71 | 72 | const char * const cptr = "test"; 73 | caveman(cptr); 74 | caveman(*cptr); 75 | 76 | const signed char * const scptr = (signed char *) "test"; 77 | caveman(scptr); 78 | caveman(*scptr); 79 | 80 | const unsigned char * const ucptr = (unsigned char *) "test"; 81 | caveman(ucptr); 82 | caveman(*ucptr); 83 | 84 | char carray[2]; 85 | carray[0]='*'; 86 | carray[1]=0; 87 | cavearray(carray); 88 | /* caveman(carray); */ 89 | 90 | int iarray[] = {23,42}; 91 | cavearray(iarray); 92 | /* caveman(iarray); */ 93 | 94 | caveman("test"); 95 | 96 | arrays(carray, iarray); 97 | 98 | /* 99 | BOOL booly = NO; 100 | caveman(booly); 101 | */ 102 | 103 | char aChar = -2; 104 | caveman(aChar); 105 | caveman(&aChar); 106 | 107 | unsigned char signedChar = -2; 108 | caveman(signedChar); 109 | caveman(&signedChar); 110 | 111 | unsigned char unsignedChar = 0xfe; 112 | caveman(unsignedChar); 113 | caveman(&unsignedChar); 114 | 115 | unsigned const short ushorty = 0x423; 116 | caveman(ushorty); 117 | caveman(&ushorty); 118 | 119 | unsigned const long ulongy = 0x423; 120 | caveman(ulongy); 121 | caveman(&ulongy); 122 | 123 | unsigned const long long ulonglongy = 0x423; 124 | caveman(ulonglongy); 125 | caveman(&ulonglongy); 126 | 127 | const float aFloat = 23.42; 128 | caveman(aFloat); 129 | caveman(&aFloat); 130 | 131 | const double aDouble = 23.42; 132 | caveman(aDouble); 133 | caveman(&aDouble); 134 | 135 | const long double aLongDouble = 23.42; 136 | caveman(aLongDouble); 137 | caveman(&aLongDouble); 138 | 139 | cavestr(argv[0]); 140 | cavestr(argv[1]); 141 | 142 | struct timeval tv; 143 | struct timezone tz; 144 | gettimeofday(&tv, &tz); 145 | caveman(tv.tv_sec); 146 | caveman(tv.tv_usec); 147 | caveman(tv); 148 | caveman(tz.tz_minuteswest); 149 | caveman(tz); 150 | 151 | enum { MinusOne = -1, One = 1, Two = 2 } anEnum = Two; 152 | caveman(anEnum); 153 | 154 | #ifdef TESTBAD 155 | struct { int x; } bad; 156 | caveman(bad); 157 | #endif 158 | 159 | return 0; 160 | } 161 | -------------------------------------------------------------------------------- /test/lp_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | set -x 4 | 5 | mkdir -p tmp 6 | 7 | [ -z "$LP_FILTER" ] && export LP_FILTER="setup,calc,visualize" 8 | 9 | CSOURCES="lptest.c logpoints.c er_util.c" 10 | CMSOURCES="lptest.c logpoints.m er_util.c" 11 | MSOURCES="lptest.m logpoints.m er_util.c" 12 | 13 | config='-DINTERNAL_WARNINGS' 14 | 15 | if [ $(uname -s) = "Darwin" ] ; then 16 | CSOURCES="$CSOURCES tracer.c" 17 | CMSOURCES="$CMSOURCES tracer.m -framework Foundation" 18 | MSOURCES="$MSOURCES tracer.m -framework Foundation" 19 | 20 | gcc -Wall $config -ggdb -arch i386 -arch ppc -o tmp/lptest_c_32 $CSOURCES 21 | gcc -Wall $config -ggdb -arch i386 -arch ppc -o tmp/lptest_cm_32 $CMSOURCES 22 | gcc -Wall $config -ggdb -arch i386 -arch ppc -o tmp/lptest_m_32 $MSOURCES 23 | gcc -Wall $config -ggdb -arch x86_64 -arch ppc64 -o tmp/lptest_c_64 $CSOURCES 24 | gcc -Wall $config -ggdb -arch x86_64 -arch ppc64 -o tmp/lptest_cm_64 $CMSOURCES 25 | gcc -Wall $config -ggdb -arch x86_64 -arch ppc64 -o tmp/lptest_m_64 $MSOURCES 26 | tmp/lptest_c_32 27 | tmp/lptest_cm_32 28 | tmp/lptest_m_32 29 | tmp/lptest_c_64 30 | tmp/lptest_cm_64 31 | tmp/lptest_m_64 32 | 33 | fi 34 | 35 | if [ $(uname -s) = "Linux" ] ; then 36 | 37 | gcc -Wall $config -ggdb -m32 -o tmp/lptest_c_32 $CSOURCES 38 | gcc -Wall $config -ggdb -m64 -o tmp/lptest_c_64 $CSOURCES 39 | tmp/lptest_c_32 40 | tmp/lptest_c_64 41 | fi 42 | 43 | if [ $(uname -s) = "SunOS" ] ; then 44 | 45 | gcc -Wall $config -ggdb -m32 -o tmp/lptest_c_32 $CSOURCES 46 | gcc -Wall $config -ggdb -m64 -o tmp/lptest_c_64 $CSOURCES 47 | tmp/lptest_c_32 48 | tmp/lptest_c_64 49 | fi 50 | 51 | -------------------------------------------------------------------------------- /test/lptest.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include "logpoints_bk.h" 28 | 29 | int foo(int bar) 30 | { 31 | lpcInt("calculation", bar); 32 | 33 | if( lpcswitch("fullmoon", "multiply result by 2" ) ) { 34 | bar *= 2; 35 | } 36 | 37 | lpcdebug("calculation", "result bar: %d", bar); 38 | 39 | dbug_return_int(bar); 40 | } 41 | 42 | int main(int argc, char **argv) 43 | { 44 | // filter is a comma separated list of substrings to search 45 | // the current simple filter searches only the keys given to the logpoints 46 | logPointEnableSimple(getenv("LP_FILTER")); 47 | 48 | dbug(argc); 49 | dbug(&argc); 50 | dbug(argv); 51 | dbug(argv[0]); 52 | dbug(*argv[0]); 53 | dbug(argv[1]); 54 | dbug(getenv("LP_FILTER")); 55 | 56 | if( argv[1] && 0 == strcmp( argv[1], "-d" ) ) { 57 | logPointDumpAll(); 58 | exit(0); 59 | } 60 | 61 | int x = 23; 62 | int y = 42; 63 | 64 | if( lpcdebugswitch("halfmoon", "increment x/y before use" ) ) { 65 | ++x; 66 | ++y; 67 | } 68 | 69 | lpcInt("setup,parameters", argc); 70 | 71 | printf("1. foo(%d) is %d\n", x, foo(x)); 72 | printf("2. foo(%d) is %d\n", y, foo(y)); 73 | 74 | lpcerror("shutdown", "this message is always on"); 75 | 76 | return 0; 77 | } 78 | 79 | -------------------------------------------------------------------------------- /test/lptest.m: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of EngineRoom, Copyright (c) 2007-2010 Bjoern Kriews, Hamburg - All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 10 | in the documentation and/or other materials provided with the distribution. 11 | 12 | Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this 13 | software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 16 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 17 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 20 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | #include "logpoints_bk.h" 27 | 28 | #import 29 | 30 | @interface LogPointTest : NSObject 31 | - (void) someMethod: (id) someArg; 32 | @end 33 | 34 | @implementation LogPointTest 35 | 36 | - (void) someMethod: (id) someArg 37 | { 38 | lpdebug1("calculation", someArg); 39 | 40 | if( lpdebugswitch("objcbomb", NULL) ) { 41 | lperror("objcbomb", "the switch is on but the bulb is done"); 42 | LPAssert( 1 == 0, @"bulb bad" ); 43 | } 44 | } 45 | 46 | @end 47 | 48 | void foo(int bar) 49 | { 50 | lpcdebug("calculation", "%d", bar); 51 | lpcInt("calculation", bar); 52 | 53 | if( lpcswitch("cbomb", NULL) ) { 54 | lpcerror("cbomb", "the switch is on but the bulb is done"); 55 | LPCAssert( 1 == 0, @"bulb bad" ); 56 | } 57 | 58 | usleep(15000); 59 | } 60 | 61 | int main(int argc, char **argv) 62 | { 63 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 64 | 65 | logPointEnableSimple(getenv("LP_FILTER")); 66 | 67 | dbugC(argc); 68 | dbugC(&argc); 69 | dbugC(argv); 70 | dbugC(argv[0]); 71 | dbugC(*argv[0]); 72 | dbugC(argv[1]); 73 | dbugC(getenv("LP_FILTER")); 74 | 75 | if( argv[1] && 0 == strcmp( argv[1], "-d" ) ) { 76 | logPointDumpAll(); 77 | exit(0); 78 | } 79 | 80 | lpcInt("setup,parameters", argc); 81 | 82 | 83 | dbug_oC(@"constantnsstring"); 84 | dbug_oC(CFSTR("constantcfstring")); 85 | 86 | NSMutableString *nsstr = nil; 87 | dbug_oC(nsstr); 88 | nsstr = [[NSMutableString alloc] init]; 89 | dbug_oC(nsstr); 90 | [nsstr appendString: @"nonempty"]; 91 | dbug_oC(nsstr); 92 | 93 | CFStringRef cfstr = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("cf fmt")); 94 | CFArrayRef cfarr = CFStringCreateArrayBySeparatingStrings(kCFAllocatorDefault, cfstr, CFSTR(" ")); 95 | dbug_cfC(cfstr); 96 | dbug_cfC(cfarr); 97 | 98 | foo(23); 99 | foo(42); 100 | 101 | lpcerror("shutdown", "not yet implemented"); 102 | 103 | LogPointTest *t = [[LogPointTest alloc] init]; 104 | [t someMethod: @"TestArg"]; 105 | [t release]; 106 | 107 | [pool release]; 108 | 109 | return 0; 110 | } 111 | 112 | -------------------------------------------------------------------------------- /test/t.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #import 4 | 5 | #import 6 | 7 | @interface Foo : NSObject 8 | + (id) barArgc: (int) argc argv: (char **) argv; 9 | @end 10 | 11 | @implementation Foo 12 | 13 | + (id) barArgc: (int) argc argv: (char **) argv 14 | { 15 | NSRect rect = { { 1, 2 }, { 3, 4 } }; 16 | NSRange range = { 23, 42 }; 17 | 18 | struct timeval tv; 19 | 20 | gettimeofday(&tv, NULL); 21 | 22 | lpdebug(rect, tv); 23 | 24 | NSNumber *argcNumber = lpdebug_expr( [NSNumber numberWithInteger: argc] ); 25 | 26 | return_lpwarning( argcNumber ); 27 | } 28 | 29 | @end 30 | 31 | 32 | int main(int argc, char **argv) { 33 | 34 | logPointEnableSimple(""); 35 | 36 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 37 | 38 | lpcdebug(argc, argv, argv[0], *argv[0]); 39 | 40 | LOGPOINT *lp; 41 | if( ( lp = lpcassertf(argv[1], "need an argument") ) ) { 42 | lpcdebug(lp); 43 | } 44 | 45 | [Foo barArgc: argc argv: argv]; 46 | 47 | NSLog(@"we are %@", @"original"); 48 | 49 | #import "logpoints_nslog.h" 50 | 51 | NSLog(@"we are %@", @"substituted"); 52 | 53 | [pool drain]; 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /test/t.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CFLAGS="" 4 | #CFLAGS=" -Wno-unused-value" 5 | #clang $CFLAGS -I../EngineRoom -I.. -x objective-c -E t.c -framework Foundation > t.tmp 6 | 7 | set -x 8 | gcc $CFLAGS -I../EngineRoom -I.. -x objective-c -o t t.c ../EngineRoom/logpoints.m -framework Foundation ; ./t $@ 9 | clang $CFLAGS -I../EngineRoom -I.. -x objective-c -o t t.c ../EngineRoom/logpoints.m -framework Foundation ; ./t $@ 10 | -------------------------------------------------------------------------------- /test/tracer_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | set -x 4 | 5 | stresstest="-framework AppKit -framework Quartz -framework QuartzCore -framework WebKit -framework ApplicationServices -framework CoreServices" 6 | 7 | commonopt="-finstrument-functions -mmacosx-version-min=10.4" 8 | # gcc 4.3: -finstrument-functions-exclude-file-list=/include 9 | 10 | mkdir -p tmp 11 | outfiles="" 12 | for arch in i386 x86_64 ppc ppc64 ; do 13 | for opt in "-fno-omit-frame-pointer -O0" "-fomit-frame-pointer -Os" ; do 14 | out=$(echo "tmp/tracer_${arch}_$opt" | sed 's/-/_/g;s/ //g;') 15 | 16 | outc=${out}_c.out 17 | outm=${out}_m.out 18 | binc=${out}_c.bin 19 | binm=${out}_m.bin 20 | 21 | echo -n "testing $binc: " 22 | if { gcc -arch $arch $opt $commonopt -DTRACER_TEST -Wall -o $binc er_util.c tracer.c && ./$binc; } >$outc 2>&1 ; then 23 | echo DONE ; else echo FAIL ; fi 24 | outfiles="$outfiles $outc" 25 | echo -n "testing $binm: " 26 | if { gcc -arch $arch $opt $commonopt -DTRACER_TEST -Wall -o $binm er_util.c tracer.m -framework Foundation $stresstest && ./$binm ; } >$outm 2>&1 ; then 27 | echo DONE ; else echo FAIL ; fi 28 | outfiles="$outfiles $outm" 29 | done 30 | done 31 | 32 | echo 33 | tar czf tmp/out.tar.gz $outfiles 34 | ls -l tmp/out.tar.gz 35 | 36 | exit 0 37 | -------------------------------------------------------------------------------- /tools/patchLicense: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # Usage: tools/patchLicense LICENSE.txt $( find . -name "*.[chm]" | grep -v filestoavoid ) 4 | 5 | use strict; 6 | use warnings; 7 | 8 | my $licenseFile = shift @ARGV; 9 | 10 | my @files = @ARGV; 11 | 12 | die "Usage: $0 licensefile-containing-marker files...\n" unless $licenseFile and @files; 13 | 14 | my @license = map { s/\s*$//; $_ } qx{ sed '1,/^LICENSE TERMS/d' $licenseFile }; 15 | 16 | 17 | for my $file ( @files ) { 18 | warn "# working on $file\n"; 19 | 20 | open(FILE, "<", "$file") or die "$0: can't open '$file' for reading ($!)\n"; 21 | 22 | my @lines = ; 23 | 24 | close(FILE); 25 | 26 | shift @lines while($lines[0] =~ /^\s*$/ ); # skip whitespace 27 | 28 | shift @lines while $lines[0] =~ m!^\s*//!; # skip // lines 29 | 30 | shift @lines while($lines[0] =~ /^\s*$/ ); # skip whitespace 31 | 32 | if( $lines[0] =~ m!^\s*/\*! ) { 33 | shift @lines while( $lines[0] !~ m!\*/! ); # skip /* ... */ 34 | shift @lines if $lines[0] =~ m!\*/\s*$!; 35 | } 36 | 37 | shift @lines while($lines[0] =~ /^\s*$/ ); # skip whitespace 38 | 39 | unshift @lines, "/*\n", ( map { length($_) ? " " . "$_\n" : "$_\n" } @license ) , "*/\n", "\n"; # add license 40 | 41 | push @lines, "\n" unless $lines[-1] =~ /\n/; # end trailing newline 42 | 43 | open(FILE, ">", $file) or die "$0: can't open '$file' for writing ($!)\n"; 44 | print FILE @lines; 45 | close(FILE); 46 | } 47 | 48 | exit 0; 49 | --------------------------------------------------------------------------------