diff --git a/Foundation/CPIndexSet.j b/Foundation/CPIndexSet.j index eac5a42a3..c0a13c3d4 100644 --- a/Foundation/CPIndexSet.j +++ b/Foundation/CPIndexSet.j @@ -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 diff --git a/Foundation/CPRange.h b/Foundation/CPRange.h new file mode 100644 index 000000000..f20a08f7a --- /dev/null +++ b/Foundation/CPRange.h @@ -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 } diff --git a/Foundation/CPRange.j b/Foundation/CPRange.j index a4816b385..d96bbb834 100755 --- a/Foundation/CPRange.j +++ b/Foundation/CPRange.j @@ -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.