mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-06 17:12:50 +00:00
Inlineable range functions.
This commit is contained in:
1 parent
55ca956f50
commit
e9ba326610
3 files changed
+34
-16
No files matched your search
@@ -20,14 +20,12 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "CPRange.h"
|
||||
|
||||
@import "CPArray.j"
|
||||
@import "CPObject.j"
|
||||
@import "CPRange.j"
|
||||
|
||||
#define _CPMaxRange(aRange) ((aRange).location + (aRange).length)
|
||||
#define _CPMakeRange(aLocation, aLength) { location:(aLocation), length:aLength }
|
||||
#define _CPMakeRangeCopy(aRange) { location:(aRange).location, length:(aRange).length }
|
||||
|
||||
/*!
|
||||
@class CPIndexSet
|
||||
@ingroup foundation
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* CPRange.h
|
||||
* Foundation
|
||||
*
|
||||
* Created by Alexander Ljungberg.
|
||||
* Copyright 2012, SlevenBits Ltd.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#define _CPMaxRange(aRange) ((aRange).location + (aRange).length)
|
||||
#define _CPMakeRange(aLocation, aLength) { location:(aLocation), length:aLength }
|
||||
#define _CPMakeRangeCopy(aRange) { location:(aRange).location, length:(aRange).length }
|
||||
+7
-12
@@ -20,6 +20,10 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#define _function(inline) function inline { return _##inline; }
|
||||
|
||||
#include "CPRange.h"
|
||||
|
||||
/*!
|
||||
@addtogroup foundation
|
||||
@{
|
||||
@@ -32,10 +36,7 @@
|
||||
@group CPRange
|
||||
@return CPRange the new range object
|
||||
*/
|
||||
function CPMakeRange(location, length)
|
||||
{
|
||||
return { location: location, length: length };
|
||||
}
|
||||
_function(CPMakeRange(location, length))
|
||||
|
||||
/*!
|
||||
Makes a copy of a CPRange.
|
||||
@@ -43,10 +44,7 @@ function CPMakeRange(location, length)
|
||||
@group CPRange
|
||||
@return CPRange the copy of the range
|
||||
*/
|
||||
function CPMakeRangeCopy(aRange)
|
||||
{
|
||||
return { location:aRange.location, length:aRange.length };
|
||||
}
|
||||
_function(CPMakeRangeCopy(aRange))
|
||||
|
||||
/*!
|
||||
Determines if a range is empty \c length is 0.
|
||||
@@ -65,10 +63,7 @@ function CPEmptyRange(aRange)
|
||||
@group CPRange
|
||||
@return int the range maximum
|
||||
*/
|
||||
function CPMaxRange(aRange)
|
||||
{
|
||||
return aRange.location + aRange.length;
|
||||
}
|
||||
_function(CPMaxRange(aRange))
|
||||
|
||||
/*!
|
||||
Determines if two CPRanges are equal.
|
||||
|
||||
Reference in new issue
Block a user