Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added delete file/s in context menu in Commit view. #95

Open
wants to merge 237 commits into
base: experimental
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
237 commits
Select commit Hold shift + click to select a range
a7ce2ab
Bug fix: Context lines slider can now update diff views in real time.
andreberg Oct 20, 2009
6c04aea
Bug fix: Change improper usage of dot notation.
andreberg Oct 20, 2009
08284e9
Bug fix: Increase width of Amend text label.
andreberg Oct 20, 2009
dca051c
Xcode project update: Change base SDK and deployement target to 10.6.
andreberg Oct 20, 2009
75e8a5b
Bug fix: Make QuickLook panel work by using the now public API.
andreberg Oct 20, 2009
380973b
Bug fix: Various smaller fixes regarding GC, dot notation, etc...
andreberg Oct 20, 2009
87df0b1
Lower the fade and timeout interval for the context range slider.
andreberg Oct 20, 2009
0cfc5b1
Bug fix: small error in rsync detection between MacPorts and builtin.
andreberg Oct 20, 2009
76298f1
Bug fix: the QuickLook panel now really starts its nice morphing anim…
andreberg Oct 21, 2009
e936253
Xcode project update. Just a small build name change
andreberg Oct 24, 2009
4f7e155
Adding relitive dates to history view
hardkrash Jul 13, 2009
93f1ea0
Unescape the filename to ensure that filenames containing '&' are dis…
leachbj Sep 25, 2009
c13474e
Added weeks to the strings of time.
hardkrash Jul 13, 2009
003977d
FIX: memory leak(delete will not be called) and graph glitch
niw Sep 9, 2009
73fcb78
FIX: bug
niw Sep 9, 2009
11cc30b
Add on window selection refresh.
rastersize Jul 17, 2009
fcbe01b
Xcode build name again. Just ignore it.
andreberg Oct 24, 2009
350be10
Merge branch 'ab/fqueue_stage' into devel
andreberg Oct 24, 2009
c76c922
Add missing changes for commit 11cc30 from rastersize's fork
andreberg Oct 24, 2009
286b727
Merge branch 'ab/fqueue_stage' into devel
andreberg Oct 24, 2009
7bf4ed5
Bug fix: Change notification to avoid display freezes when the QuickL…
andreberg Oct 24, 2009
0df2d3f
Merge branch 'fqueue' into devel
andreberg Oct 24, 2009
75abf03
Add 10.6 delegate protocols to silence compiler warnings.
andreberg Oct 24, 2009
fed2cc4
Update checkbox buttons to non scaling to get rid of the XIB compiler…
andreberg Oct 24, 2009
a2ebc4a
Add stderr to PBEasyPipe output for helpful messages to Console.
andreberg Oct 26, 2009
611687e
Use the newer libgit2 method for extracting a hex digest from an obje…
Oct 24, 2009
fa929eb
Use the libgit2 allocfmt method, instead of hacking it by hand.
Oct 24, 2009
cdc4f52
Add a menu item and an action for pushing a repo up.
Oct 24, 2009
4b74a3f
Disable the push menu item for branches which don't have a remote.
Oct 24, 2009
b580c03
DRY up the menu adding code
Oct 25, 2009
2b0000c
Add menu and toolbar changes from cyberfox
andreberg Oct 26, 2009
5b0051e
Rudimentary clone capability from the File menu.
Oct 26, 2009
7eb3616
Disable toolbar entries when they are processing, as at least some mi…
Oct 26, 2009
3c113a3
Update the submodule to point to the actual libgit2 repository.
Oct 26, 2009
b7ec771
Add alternative icons for Rebase, Push and Pull.
andreberg Oct 26, 2009
e80bcef
Update menu entry title to better match rest: 'Detailed View' -> 'Det…
andreberg Oct 26, 2009
d4a7df1
Remove superfluous resources and underutilized localizations.
andreberg Oct 31, 2009
7d19e1c
Disable 'Save' menu item if no document is open.
andreberg Oct 31, 2009
fb0fbff
Combine scatterred error domains and codes into one central file.
andreberg Oct 31, 2009
5be7451
Add sanity check to PBEasyPipe that checks if a working dir really is…
andreberg Oct 31, 2009
2a6f59b
Synthesize repositoryPath for external access.
andreberg Oct 31, 2009
1fed883
Loading message restricted to DEBUG_BUILD.
andreberg Oct 31, 2009
d5688db
Exert other options before falling back to PBGitRepository's global s…
andreberg Oct 31, 2009
7c1b9d9
Add pullButton: IBAction.
andreberg Oct 31, 2009
0d42c59
Override openDocumentWithContentsOfURL:... to provide sanity checks f…
andreberg Oct 31, 2009
4396081
Add new PNG templates for Pull, Push, Rebase and Clone.
andreberg Oct 31, 2009
7892ac4
Update toolbars to incorporate the new buttons.
andreberg Oct 31, 2009
b76f755
Safety measure: Replace unneeded stringWithFormat with stringWithStri…
andreberg Oct 31, 2009
421d6fd
Bug fix: Wrong usage of dot notation.
andreberg Nov 3, 2009
93a027c
Bug fix: Make new buttons actually work.
andreberg Nov 3, 2009
0f50cd6
Bug fix: reconnect the search field predicates so the field works again.
andreberg Nov 4, 2009
2cc3c73
Filter debug log output by getenv adressable Xcode environment vars.
andreberg Nov 4, 2009
d04c639
Update tooltips for Push, Pull and Rebase buttons to better reflect w…
andreberg Nov 7, 2009
4c4203a
Update PBGitErrors to include some error messages dealing with missin…
andreberg Nov 7, 2009
f1fcb18
Improve error and tooltip descriptions.
andreberg Nov 7, 2009
1551084
Update context menu to include remote target and other dynamic title …
andreberg Nov 7, 2009
9e72dba
PBRefController: Switch the app modal Delete Remote panel to a window…
brotherbard Nov 8, 2009
d8f27db
Fix finding the correct contextual menu when Subject is not the first…
brotherbard Nov 8, 2009
f97cfbb
Add name of branch/remote to Checkout and Delete contextual menu items.
brotherbard Nov 8, 2009
2b45994
Update the current branch when changes are made (like checking out a …
brotherbard Nov 8, 2009
0377181
Disable the Checkout menu item when the branch is the current branch.
brotherbard Nov 8, 2009
5e12643
Bug fix: Move updating the current branch to the checkoutRef method.
brotherbard Nov 8, 2009
b6d6e0d
Bug fix: Correct dot notation misuse.
andreberg Nov 8, 2009
22ba33f
Disable/re-enable Push, Pull and Rebase buttons depending on selected…
andreberg Nov 8, 2009
4cdf634
Replace pre-10.6 workaround with public - [NSSavePanel setShowsHidden…
andreberg Nov 8, 2009
1a7b4cb
Update branch menu after deletion of a branch.
andreberg Nov 8, 2009
1ade0f0
Remove completely wrong TODO comment.
andreberg Nov 8, 2009
2c6fd97
Cosmetic: Move showMessageSheet convenience method to the proper prag…
andreberg Nov 8, 2009
12f26bc
Update height for split view partials.
andreberg Nov 8, 2009
c52aedf
Add an "Add Remote" button to the toolbar that adds and fetches a rem…
brotherbard Nov 8, 2009
d365bd4
Add a "Create Tag" button to the toolbar.
brotherbard Nov 8, 2009
6740c68
Fix the tooltip for the Add Remote toolbar item.
brotherbard Nov 8, 2009
37dcdf2
Adjust split view height of the commit webview.
andreberg Nov 8, 2009
0be790d
merge andreberg/master
brotherbard Nov 9, 2009
a26bca8
Add drop down menus to the push and pull toolbar items.
brotherbard Nov 9, 2009
666d135
Add template PNG for the "Add Remote" button.
andreberg Nov 9, 2009
8520abd
Polish sheets and dialogs (struts, autosizing, min/max size etc.).
andreberg Nov 9, 2009
9c4949e
Add disclosure triangles to the template images for Push, Pull, Rebas…
andreberg Nov 10, 2009
2558fef
Comment the toolbar item toggle method out since we no longer need to…
andreberg Nov 10, 2009
ff550e8
More cleanup and feature adding for the Push, Pull and Rebase popup b…
andreberg Nov 10, 2009
5363724
Bug fix: Pull button now really has the correct image (not the Push b…
andreberg Nov 10, 2009
d4a8bc9
Update and homogenize tooltips of the toolbar items to better explain…
andreberg Nov 10, 2009
06d3b9b
Bug fix: Re-enable the toolbar item validation.
andreberg Nov 10, 2009
b391749
Added hover css for diff history view refs - branch tags, and 'Gist i…
fbartho Feb 23, 2010
25577e0
Modified the Commit TableView to support filtering on All fields simu…
fbartho Feb 24, 2010
a7d8f02
Added hover css to the "Stage" "Discard" and "Unstage" buttons so tha…
fbartho Mar 3, 2010
a1cd543
Added support for urls in commit log messages. This means jira:// url…
fbartho Mar 4, 2010
241b44b
Typo wording fixed.
fbartho Mar 6, 2010
782981a
Merge branch 'stable'
Mar 13, 2010
0999c13
Added hover css for diff history view refs - branch tags, and 'Gist i…
fbartho Feb 23, 2010
6b19dab
Modified the Commit TableView to support filtering on All fields simu…
fbartho Feb 24, 2010
158b569
Added hover css to the "Stage" "Discard" and "Unstage" buttons so tha…
fbartho Mar 3, 2010
8b238d1
wording improved for commit typo fix.
fbartho Mar 19, 2010
93d18b3
URL regex adjusted so it now handles any <protocol>://<url> combinati…
fbartho Mar 19, 2010
16cdb6f
Simplify install.sh script by removing a superfluous string compariso…
andreberg Mar 23, 2010
38177ed
Merge remote branch 'brotherbard/experimental' into local branch 'bb/…
andreberg Mar 24, 2010
884a2fc
Post merge fix: Move remote XIBs into English.lproj and make them loc…
andreberg Mar 24, 2010
3816278
Post merge fix: Remove unused KBPopUpToolbaritem files.
andreberg Mar 24, 2010
8516743
Move the jQuery lib from html/js into html/lib where it should have b…
andreberg Mar 24, 2010
c22e888
Add a note to .gitmodules telling why we need to keep using Pieter's …
andreberg Mar 24, 2010
7d14bff
Make some of the sheets resizable (you never know how much a user wan…
andreberg Mar 24, 2010
d276c5e
PBGitHistoryView.xib: Set Key Equiv. of QuickLook button to Space.
andreberg Mar 24, 2010
eb23f42
Remove the bad file descriptor #warning since that was likely caused …
andreberg Mar 24, 2010
79c928d
Remove my 10.6 QuickLook panel code since Nathan's implementation han…
andreberg Mar 24, 2010
e6d2591
Post merge fix: Remove some of my left over code for the 10.6 QuickLo…
andreberg Mar 24, 2010
d1eff3c
Bugfix?: this seems to fix the "malloc refcount underflow" errors tha…
andreberg Mar 24, 2010
b6272c0
Post merge fix: Set Base SDK back to 10.5
andreberg Mar 24, 2010
4832f3b
Code cleanup: Remove unneeded #imports, empty methods, declare id ret…
andreberg Mar 24, 2010
45e8aab
Post merge fix: Since we're 10.5 SDK again, we cannot use non-informa…
andreberg Mar 24, 2010
5598eef
Add preference options for refreshing the view + controller automatic…
andreberg Mar 24, 2010
3541acf
Post merge fix: Use the git_oid_mkhex function again from Pieter's li…
andreberg Mar 24, 2010
752bb7c
Post merge fix: Delete some left over code from my 10.6 QuickLook pre…
andreberg Mar 24, 2010
8426304
Move error domains into their own PBGitXErrors file pair.
andreberg Mar 24, 2010
97550f2
Bugfix: This caused "no var named button" exceptions in the web view.
andreberg Mar 24, 2010
22f916f
Give the showHideAllFiles action at least a chance to call the public…
andreberg Mar 24, 2010
e5b5e4c
SCNetworkCheckReachabilityByName will be deprecated anyways, so repla…
andreberg Mar 24, 2010
7d6f966
Make the view controllers __weak to silence some underflow refcount e…
andreberg Mar 24, 2010
ca0fa1e
Some personal preferences for the history web view's #message.
andreberg Mar 24, 2010
e6f7350
Remove the superfluous string comparison shell function.
andreberg Mar 24, 2010
bca58a7
First stab at an executable that can be put into the SSH_ASKPASS envi…
uliwitness Mar 24, 2010
6c4c40d
Set the environment variables for our tool. We have a rudimentary but…
uliwitness Feb 19, 2010
abe09c4
Label on password window so it's less cryptic.
uliwitness Mar 13, 2010
6a542d4
Cannot use non-informal protocols with Base SDK 10.5.
andreberg Mar 24, 2010
b4d3093
Remove some left over image links from Xcode's project.pbproj.
andreberg Mar 24, 2010
065a83b
Merge branch 'master' into devel
andreberg Mar 24, 2010
0f18ffd
Make remaining sheets resizable as well.
andreberg Mar 24, 2010
d9778b2
Merge branch 'master' into devel
andreberg Mar 24, 2010
a100ff3
Set a copy of the "Push" message strings for the alert panel message …
andreberg Mar 24, 2010
1922798
Merge branch 'master' into devel
andreberg Mar 24, 2010
a3ede54
Bugfix: Bad files descriptor should be history now.
andreberg Mar 24, 2010
95e0503
Add a string truncation category because on a very large commit the s…
andreberg Mar 24, 2010
804f620
Remove finalizers with only observer unregistering code since GC guid…
andreberg Mar 24, 2010
d999eff
Remove superfluous (and crash prone) entries from the context menu of…
andreberg Mar 24, 2010
925c227
Add Cmd+Shift+F for "Reveal in Finder" and Cmd+Shift+T for "Open Term…
andreberg Mar 24, 2010
1fa1c4d
Add Cmd+Shift+F for "Reveal in Finder" and Cmd+Shift+T for "Open Term…
andreberg Mar 24, 2010
00545fb
Add a preference option for truncating very large info sheet content …
andreberg Mar 24, 2010
1488beb
Small tweak to the response of the Context diff slider.
andreberg Mar 24, 2010
27a8c8a
Merge branch 'refs/heads/devel'
andreberg Mar 24, 2010
5b5118c
Xcode: Set Clang as default compiler for all build configurations.
andreberg Mar 24, 2010
0177e20
changed calls to git_oid_mkhex() to git_oid_to_string() to make it co…
roddi Mar 25, 2010
97e3d18
Bugfix: obj.realSha() in history.js returns nil/undefined more often …
andreberg Mar 25, 2010
e004c64
Update .gitmodules to point to the actual libgit2 host now.
andreberg Mar 25, 2010
facf2ba
Simplify Xcode's build settings on project and target level by using …
andreberg Mar 26, 2010
344fb8c
Wrap CWQuicklook.h in deployment target defines so it compiles cleanl…
andreberg Mar 26, 2010
404dee7
Move some settings from Install.xcconfig that are intended for Releas…
andreberg Mar 26, 2010
0dc2781
Delete some overlooked overwrites in Xcode's Project build settings d…
andreberg Mar 26, 2010
7b28685
Incorporate roddi/gitx aed059eb ("corrected script file permissions").
andreberg Mar 26, 2010
5018524
Install gitx (the CLI) via Install.sh.
andreberg Mar 26, 2010
f0a3502
Make the gitx arguments "--all" and "--local" (new) switch to the cor…
andreberg Mar 26, 2010
ad766c5
Delete some non functional left overs from a previous merge.
andreberg Mar 26, 2010
557ff4e
Switch DEBUG_INFORMATION_FORMAT from DWARF with dSYM to DWARF in Rele…
andreberg Mar 26, 2010
d43e72f
Tweak to the context slider response time (hopefully final this time).
andreberg Mar 26, 2010
d12b923
Stability: employ more sanity checks when parsing author details from…
andreberg Mar 30, 2010
4428373
Make the prefs panel update all open document views on close.
andreberg Mar 30, 2010
a763dd8
Add a property to PBGitRepository that indicates if we are launching …
andreberg Mar 30, 2010
75fbde6
Make comment about "Subtle Dangers of DO" a lot smaller
andreberg Mar 30, 2010
34c404a
Stability: employ more sanity checks when parsing author details from…
andreberg Mar 30, 2010
156d67f
Add -debugDescription and -description to PBGitRef
andreberg Mar 30, 2010
25b47bb
Reinstate the -finalize method to remove ourselves as observer.
andreberg Mar 30, 2010
5915288
Add readonly __weak superController access to PBViewController.
andreberg Mar 30, 2010
7e986fb
Add in left-out (id) return labels to some methods in PBGitCommit.
andreberg Mar 30, 2010
3158d0f
Apply Nathan Kissinger's bugfixes to NSFileHandleExt.m (s. GitX Googl…
andreberg Apr 5, 2010
d76072f
Add -description and/or -debugDescription methods to PBGitCommit, PBG…
andreberg Apr 5, 2010
8e55c30
Make building and installing possible right from within Xcode.
andreberg Apr 5, 2010
229387c
Populate the revList if empty in -commitForSHA:
andreberg Apr 5, 2010
a45f865
Make default (id) explicit for some method decls/defs in PBGitHistory…
andreberg Apr 5, 2010
5fb70a8
Make ApplicationController a singleton class.
andreberg Apr 5, 2010
7b74367
Add -description and -debugDescription methods to PBSourceViewItem.m
andreberg Apr 5, 2010
85b2de9
Disable hidden entries in MainMenu.xib/File and remove the saveAs: ta…
andreberg Apr 5, 2010
93483cb
Adjust the last two panels in Preferences.xib in width to match the f…
andreberg Apr 5, 2010
69d23e9
Move Remote segmented controls from Sidebar to Repository window's to…
andreberg Apr 5, 2010
8bc8a73
Put at-sign in front of multi-line continued string.
andreberg Apr 5, 2010
23a1ddd
Remove a superfluous semicolon in PBCommitList.m
andreberg Apr 5, 2010
8df20db
Add PBStringFromBranchFilterType() function for debugging purposes to…
andreberg Apr 5, 2010
ba63642
Add a method declaration to PBGitRevSpecifier.h to silence a compiler…
andreberg Apr 5, 2010
5cb73b4
Bug fix: correct visible index scrolling in PBGitHistoryController an…
andreberg Apr 5, 2010
4b4912a
Add some more checking/validation methods to PBGitRepository.
andreberg Apr 5, 2010
0c26fb5
Remove launchedFromCLI ivar from PBGitRepository.
andreberg Apr 5, 2010
7761d2f
Add shell script methods to PBGitRepository.
andreberg Apr 5, 2010
bc44ebf
Add new Error constants to PBGitXErrors, mostly for CLI support
andreberg Apr 5, 2010
3f7b662
Minor file layout changes to PBGitHistoryController.
andreberg Apr 5, 2010
c85fa2f
Declare sidebarController property as __weak in PBGitWindowController.
andreberg Apr 5, 2010
4ed7911
Multiple changes to -selectCommit: from PBGitHistoryController.
andreberg Apr 5, 2010
f704c99
Add a NSUserDefaultsDidChangeNotification listener to PBGitHistoryCon…
andreberg Apr 5, 2010
1d4e4c5
Only update selectedCommit in [PBGitHistoryController updateKeys] whe…
andreberg Apr 5, 2010
11688c9
If launched from CLI return immediately from observeValueForKeyPath...
andreberg Apr 5, 2010
bee02b1
Add a check for hasPrefix:@"refs/" to isSimpleRef logic in PBGitRevSp…
andreberg Apr 5, 2010
8ddcc6c
Add DO directional/value qualifier keywords to PBCLIProxy
andreberg Apr 5, 2010
f87cfa6
Add #import "BMScript.h" to PBSourceViewItem since it needs it for de…
andreberg Apr 5, 2010
10daa22
Major overhaul of the handling/effect of CLI args (gitx/PBCLIProxy).
andreberg Apr 5, 2010
d1474bd
Improving configuration of NSArrayController in PBGitHistoryView.
andreberg Apr 5, 2010
d54dca4
Remove debugging NSLog clutter and other left-over code.
andreberg Apr 5, 2010
bfb7149
Merge branch 'master' into fbartho
fbartho May 4, 2010
9a5efab
added missing delegate protocol declaration to remove warnings for 10.6
roddi May 17, 2010
39ec231
Merge commit 'brotherbard/experimental'
dgrijalva Jun 2, 2010
535ef4e
fixed warnings and analyser hits
roddi Jun 8, 2010
fe31a90
initial blame functionality
laullon Jun 9, 2010
852006e
initial blame functionality on tree view
laullon Jun 10, 2010
6d7a0a5
HTML Blame
laullon Jun 10, 2010
8a68343
reload html
Jun 11, 2010
5ebb673
highlight test
Jun 11, 2010
a3a9173
SyntaxHighlighter functional
laullon Jun 11, 2010
1a4556e
SyntaxHighlighter Object-C brush
laullon Jun 11, 2010
1c3364d
source and diff view on history
Jun 11, 2010
81166cb
scrollbar horizontal & toolbar class
Jun 11, 2010
6e20f39
MGScopeBar org verison
laullon Jun 13, 2010
26d9adc
Common file viewer for historic and commit views
laullon Jun 14, 2010
3d123f7
initial File log
laullon Jun 14, 2010
1c350db
Merge commit 'refs/remotes/andreberg/master' into test_merge
laullon Jun 14, 2010
34f5ed7
merge end
laullon Jun 14, 2010
5a7dd3f
Merge commit 'refs/remotes/roddi/sidebar'
laullon Jun 15, 2010
8b357d4
log work
laullon Jun 15, 2010
fd47c99
Merge in changes from brotherbard's work into my own branch.
fbartho Jun 16, 2010
3edd890
Changed regex for urlifying commit history views so that it now doesn…
fbartho Jun 16, 2010
3755c46
Improved appearance of urls in commit history message.
fbartho Jun 16, 2010
936a3b4
diff working
Jun 16, 2010
9c75e6f
Merge remote branch 'refs/remotes/fbartho/fbartho'
Jun 16, 2010
c73d759
log commit link
Jun 16, 2010
93803ce
Better diff display
laullon Jun 19, 2010
74ab910
Config object to JavaScript
laullon Jun 21, 2010
ed8ad4b
only commit files on file view
laullon Jun 19, 2010
b4f6ba2
Only Commit / All Files
Jun 24, 2010
cdd011d
cosmetic
Jun 24, 2010
d2c7cfc
merge to master
laullon Sep 27, 2010
6a81b7b
Add hidden preference to use a split column guide in commit messages
lilyball Nov 10, 2010
2ebb924
Add missing semicolons
kelan Sep 12, 2010
753f3fb
Nicer style for the "long diff" message
kelan Sep 12, 2010
03ea45f
Add diffstat info to the list of files in the commit view
kelan Sep 11, 2010
6ba1858
Fix contextual menu for files in new filelist
kelan Dec 18, 2010
903e9db
Tweaked colors in new file list a bit
kelan Dec 18, 2010
3b38beb
Add clickable commit SHAs in blame view
kamal Feb 15, 2011
56a38e2
Put SHA on same line as author
kamal Feb 15, 2011
e7823cc
Merge branch 'experimental' of git://github.com/brotherbard/gitx into…
Feb 17, 2011
007a742
Merge git://github.com/kamal/gitx into experimental
Feb 17, 2011
ae516b8
Merge git://github.com/kelan/gitx into experimental
Feb 17, 2011
455cf57
Merge git://github.com/kballard/gitx into experimental
Feb 17, 2011
18f0ad7
Implemented "delete" context command in stage view.
Feb 17, 2011
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "libgit2"]
path = libgit2
url = git://github.com/pieter/libgit2.git
path = libgit2
url = git://repo.or.cz/libgit2.git
298 changes: 298 additions & 0 deletions BMDefines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,298 @@
//
// BMDefines.h
// BMScriptTest
//
// Created by Andre Berg on 27.09.09.
// Copyright 2009 Berg Media. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*!
* @file BMDefines.h
*
* Provides defines mostly for debugging.
* This file may be included by any project as it does not really contain project-specific symbols.
* Consists mainly of stuff I have gathered from multiple sources or defined in my own work to help
* ease debugging and/or cross-platform development.
*/

#import <Foundation/Foundation.h>
#import <objc/objc.h>
#import <objc/objc-runtime.h>
#include <TargetConditionals.h>

/// @cond HIDDEN
#ifdef __cplusplus
extern "C" {
#endif

#ifndef _BM_DEFINES_H_
#define _BM_DEFINES_H_ 1
/// @endcond


/*!
* @addtogroup project_defines Project Defines
* @{
*/

// Determine runtine environment
#if !defined(__MACOSX_RUNTIME__) && !defined(__GNUSTEP_RUNTIME__)
#if defined(__APPLE__) && defined(__MACH__) && !defined(GNUSTEP)
/*!
* @def MACOSX_RUNTIME
* Determine runtime environment.
* Defined if running on Mac OS X. GNUStep will not have this defined.
*/
#define __MACOSX_RUNTIME__
#endif // If not Mac OS X, GNUstep?
#if defined(GNUSTEP) && !defined(__MACOSX_RUNTIME__)
/*!
* @def __GNUSTEP_RUNTIME__
* Determine runtime environment.
* Defined if running GNUStep. Mac OS X will not have this defined.
*/
#define __GNUSTEP_RUNTIME__
#endif // Not Mac OS X or GNUstep, that's a problem.
#endif // !defined(__MACOSX_RUNTIME__) && !defined(__GNUSTEP_RUNTIME__)

// If the above did not set the run time environment, error out.
#if !defined(__MACOSX_RUNTIME__) && !defined(__GNUSTEP_RUNTIME__)
#error Unable to determine run time environment, automatic Mac OS X and GNUstep detection failed
#endif

/*!
* @def ENABLE_MACOSX_GARBAGE_COLLECTION
* Preprocessor definition to enable Mac OS X 10.5 (Leopard) Garbage Collection.
* This preprocessor define enables support for Garbage Collection on Mac OS X 10.5 (Leopard).
*
* Traditional retain / release functionality remains allowing the framework to be used in either
* Garbage Collected enabled applications or reference counting applications.
*
* The framework dynamically picks which mode to use at run-time base on whether or not the
* Garbage Collection system is active.
*
* @sa <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/GarbageCollection/index.html" class="external">Garbage Collection Programming Guide</a>
* @sa <a href="http://developer.apple.com/documentation/Cocoa/Reference/NSGarbageCollector_class/index.html" class="external">NSGarbageCollector Class Reference</a>
*/
#if defined(__MACOSX_RUNTIME__) && defined(MAC_OS_X_VERSION_10_5) && defined(__OBJC_GC__)
#define ENABLE_MACOSX_GARBAGE_COLLECTION
#define BM_STRONG_REF __strong
#define BM_WEAK_REF __weak
#else
#define BM_STRONG_REF
#define BM_WEAK_REF
#endif

#if defined(ENABLE_MACOSX_GARBAGE_COLLECTION) && !defined(MAC_OS_X_VERSION_10_5)
#error The Mac OS X Garbage Collection feature requires at least Mac OS X 10.5
#endif


/*!
* A note to Clang's static analyzer.
* It tells about the returning onwnership intentions of methods.
* The header documentation of Apple follows:
* "Marks methods and functions which return an object that needs to be released by the caller but whose names are not consistent with Cocoa naming rules. The recommended fix to this is the rename the methods or functions, but this macro can be used to let the clang static analyzer know of any exceptions that cannot be fixed."
*
*/
#ifndef NS_RETURNS_RETAINED
#if defined(__clang__)
#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
#else
#define NS_RETURNS_RETAINED
#endif
#endif


// To simplify support for 64bit (and Leopard in general),
// provide the type defines for non Leopard SDKs
#if !(MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)

// NSInteger/NSUInteger and Max/Mins
#ifndef NSINTEGER_DEFINED
#if __LP64__ || NS_BUILD_32_LIKE_64
typedef long NSInteger;
typedef unsigned long NSUInteger;
#else
typedef int NSInteger;
typedef unsigned int NSUInteger;
#endif
#define NSIntegerMax LONG_MAX
#define NSIntegerMin LONG_MIN
#define NSUIntegerMax ULONG_MAX
#define NSINTEGER_DEFINED 1
#endif // NSINTEGER_DEFINED

// CGFloat
#ifndef CGFLOAT_DEFINED
#if defined(__LP64__) && __LP64__
// This really is an untested path (64bit on Tiger?)
typedef double CGFloat;
#define CGFLOAT_MIN DBL_MIN
#define CGFLOAT_MAX DBL_MAX
#define CGFLOAT_IS_DOUBLE 1
#else /* !defined(__LP64__) || !__LP64__ */
typedef float CGFloat;
#define CGFLOAT_MIN FLT_MIN
#define CGFLOAT_MAX FLT_MAX
#define CGFLOAT_IS_DOUBLE 0
#endif /* !defined(__LP64__) || !__LP64__ */
#define CGFLOAT_DEFINED 1
#endif // CGFLOAT_DEFINED

// NS_INLINE
#if !defined(NS_INLINE)
#if defined(__GNUC__)
#define NS_INLINE static __inline__ __attribute__((always_inline))
#elif defined(__MWERKS__) || defined(__cplusplus)
#define NS_INLINE static inline
#elif defined(_MSC_VER)
#define NS_INLINE static __inline
#elif defined(__WIN32__)
#define NS_INLINE static __inline__
#endif
#endif

#endif // MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5

/*!
* @def BM_C99(keyword)
* C99 conformance defines.
* Make it possible to safely use keywords and features of the C99 standard.
* @param keyword a C99 keyword (e.g. restrict)
*/
#if __STDC_VERSION__ >= 199901L
#define BM_C99(keyword) keyword
#else
#define BM_C99(keyword)
#endif

/*!
* @def BM_REQUIRES_NIL_TERMINATION
* Used to mark variadic methods and functions as requiring nil termination.
* Nil termination means the last argument of their variable argument list must be nil.
*/
#if !defined(BM_REQUIRES_NIL_TERMINATION)
#if TARGET_OS_WIN32
#define BM_REQUIRES_NIL_TERMINATION
#else
#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 5549)
#define BM_REQUIRES_NIL_TERMINATION __attribute__((sentinel(0,1)))
#else
#define BM_REQUIRES_NIL_TERMINATION __attribute__((sentinel))
#endif
#endif
#endif

/*!
* @def BM_EXTERN
* Defines for the extern keyword.
* Makes it possible to use extern in the proper sense in C++ context included.
*/
/*!
* @def BM_PRIVATE_EXTERN
* Defines for the __private_extern__ Apple compiler directive.
* Makes a symbol public in the binrary (e.g. a library), but hidden outside of it.
*/
#ifdef __cplusplus
#define BM_EXTERN extern "C"
#define BM_PRIVATE_EXTERN __private_extern__
#else
#define BM_EXTERN extern
#define BM_PRIVATE_EXTERN __private_extern__
#endif

/*!
* @def BM_ATTRIBUTES
* Macro wrapper around GCC <a href="http://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/Attribute-Syntax.html#Attribute-Syntax" class="external">__attribute__</a> syntax.
* @note When a compiler other than GCC 4+ is used, #BM_ATTRIBUTES evaluates to an empty string, removing itself and its arguments from the code to be compiled.</p>
*/
/*!
* @def BM_EXPECTED
* Macro wrapper around GCC <a href="http://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/Other-Builtins.html#index-g_t_005f_005fbuiltin_005fexpect-2284" class="external">__builtin_expect</a> syntax.
*
* From GCC docs: "You may use __builtin_expect to provide the compiler with branch prediction information. In general, you should prefer to use actual profile feedback for this (-fprofile-arcs), as programmers are notoriously bad at predicting how their programs actually perform. However, there are applications in which this data is hard to collect.
*
* The return value is the value of exp, which should be an integral expression. The value of c must be a compile-time constant. The semantics of the built-in are that it is expected that exp == c."
*
* And from <a href="http://regexkit.sourceforge.net" class="external">RegexKit Framework</a> docs (the origin of this macro):
*
* <div class="box important"><div class="table"><div class="row"><div class="label cell">Important:</div><div class="message cell"><span class="code">BM_EXPECTED</span> should only be used when the likelihood of the prediction is nearly certain. <b><i>DO NOT GUESS</i></b>.</div></div></div></div>
*
* BM_EXPECTED [...] is used to provide the compiler with branch prediction information for conditional statements.
*
* An example of an appropriate use is parameter validation checks at the start of a function, such as <span class="code nobr">(aPtr == NULL)</span>. Since callers are always expected to pass a valid pointer, the likelihood of the conditional evaluating to true is extremely unlikely. This allows the compiler to schedule instructions to minimize branch miss-prediction penalties. For example:
<div class="sourcecode">if(BM_EXPECTED((aPtr == NULL), 0)) { abort(); }</div>
*
* @note If a compiler other than GCC 4+ is used then the macro leaves the conditional expression unaltered.
*/
#if defined (__GNUC__) && (__GNUC__ >= 4)
#define BM_STATIC_INLINE static __inline__ __attribute__((always_inline))
#define BM_STATIC_PURE_INLINE static __inline__ __attribute__((always_inline, pure))
#define BM_EXPECTED(cond, expect) __builtin_expect(cond, expect)
#define BM_ALIGNED(boundary) __attribute__ ((aligned(boundary)))
#define BM_ATTRIBUTES(attr, ...) __attribute__((attr, ##__VA_ARGS__))
#else
#define BM_STATIC_INLINE static __inline__
#define BM_STATIC_PURE_INLINE static __inline__
#define BM_EXPECTED(cond, expect) cond
#define BM_ALIGNED(boundary)
#define BM_ATTRIBUTES(attr, ...)
#endif


/*!
* @def BM_DEBUG_RETAIN_INIT
* Defines a macro which supplies replacement methods for -[retain] and -[release].
* This macro is normally used in a global context (e.g. outside main) and followed by BM_DEBUG_RETAIN_SWIZZLE(className) in a local context, which then actually registers the replacement for the Class 'className' with the runtime.
* @attention This is only intended for <b>debugging purposes</b>. Has no effect if Garbage Collection is enabled.
*/
#define BM_DEBUG_RETAIN_INIT \
IMP oldRetain;\
IMP oldRelease;\
id newRetain(id self, SEL _cmd) {\
NSUInteger rc = [self retainCount];\
NSLog(@"%s[0x%x]: retain, rc = %d -> %d",\
class_getName([self class]), self, rc, rc + 1);\
return (*oldRetain)(self, _cmd);\
}\
void newRelease(id self, SEL _cmd) {\
NSUInteger rc = [self retainCount];\
NSLog(@"%s[0x%x]: retain, rc = %d -> %d", \
class_getName([self class]), self, rc, rc - 1);\
(*oldRetain)(self, _cmd);\
}

/*!
* @def BM_DEBUG_RETAIN_SWIZZLE(className)
* Swizzles (or replaces) the methods defined by #BM_DEBUG_RETAIN_INIT for className.
* This macro is normally used in a (function) local scope, provided a #BM_DEBUG_RETAIN_INIT declaration at the beginning of the file (in global context). BM_DEBUG_RETAIN_SWIZZLE(className) then actually registers the replacements defined by #BM_DEBUG_RETAIN_INIT for the Class 'className' with the runtime.
* @attention This is only intended for <b>debugging purposes</b>. Has no effect if Garbage Collection is enabled.
* @param className the name of the class to replace the methods for (e.g. <span class="sourcecode darkgray">[SomeClass class]</span>).
*/
#define BM_DEBUG_RETAIN_SWIZZLE(className) \
oldRetain = class_getMethodImplementation((className), @selector(retain));\
class_replaceMethod((className), @selector(retain), (IMP)&newRetain, "@@:");\
oldRelease = class_getMethodImplementation((className), @selector(release));\
class_replaceMethod((className), @selector(release), (IMP)&newRelease, "v@:");

/*!
* @}
*/

#endif // _BM_DEFINES_H_

#ifdef __cplusplus
} /* extern "C" */
#endif
Loading