Skip to content

Commit

Permalink
Private definitions for XSData...
Browse files Browse the repository at this point in the history
  • Loading branch information
macmade committed Sep 7, 2014
1 parent e7fb64a commit 9908c5b
Show file tree
Hide file tree
Showing 7 changed files with 196 additions and 29 deletions.
6 changes: 1 addition & 5 deletions XSFoundation/source/XS/Classes/XSData/__XSData_Constructor.c
Expand Up @@ -73,11 +73,7 @@

XSDataRef __XSData_Constructor( XSDataRef object )
{
return object;

/*
object->lock = XSRecursiveLock_Create();
( ( struct __XSData * )object )->lock = XSRecursiveLock_Create();

return object;
*/
}
30 changes: 29 additions & 1 deletion XSFoundation/source/XS/Classes/XSData/__XSData_Copy.c
Expand Up @@ -73,7 +73,35 @@

XSDataRef __XSData_Copy( XSDataRef source, XSDataRef destination )
{
( void )source;
( ( struct __XSData * )destination )->lock = XSRecursiveLock_Create();
( ( struct __XSData * )destination )->properties = source->properties;
( ( struct __XSData * )destination )->length = source->length;
( ( struct __XSData * )destination )->capacity = source->capacity;
( ( struct __XSData * )destination )->releaseType = source->releaseType;

__XSData_Lock( source );

if( source->buffer != NULL )
{
if( source->releaseType == XSData_BufferReleaseTypeRelease && ( source->properties & __XSData_PropertiesMutable ) == 0 )
{
( ( struct __XSData * )destination )->buffer = XSRetain( source->buffer );
}
else
{
( ( struct __XSData * )destination )->releaseType = XSData_BufferReleaseTypeRelease;
( ( struct __XSData * )destination )->buffer = XSAlloc( source->capacity );

if( destination->buffer == NULL )
{
XSFatalError( "Error allocating memory for the XSData buffer" );
}

memcpy( ( ( struct __XSData * )destination )->buffer, source->buffer, source->length );
}
}

__XSData_Unlock( source );

return destination;
}
7 changes: 0 additions & 7 deletions XSFoundation/source/XS/Classes/XSData/__XSData_Destructor.c
Expand Up @@ -73,11 +73,6 @@

void __XSData_Destructor( XSDataRef object )
{
( void )object;

/*
XSRecursiveLock_Lock( object->lock );
switch( object->releaseType )
{
case XSData_BufferReleaseTypeRelease:
Expand All @@ -95,7 +90,5 @@ void __XSData_Destructor( XSDataRef object )
break;
}

XSRecursiveLock_Unlock( object->lock );
XSRelease( object->lock );
*/
}
12 changes: 4 additions & 8 deletions XSFoundation/source/XS/Classes/XSData/__XSData_Equals.c
Expand Up @@ -73,9 +73,6 @@

bool __XSData_Equals( XSDataRef object1, XSDataRef object2 )
{
return object1 == object2;

/*
bool equals;

if( object1 == object2 )
Expand All @@ -85,8 +82,8 @@ bool __XSData_Equals( XSDataRef object1, XSDataRef object2 )

equals = false;

XSRecursiveLock_Lock( object1->lock );
XSRecursiveLock_Lock( object2->lock );
__XSData_Lock( object1 );
__XSData_Lock( object2 );

if( object1->length != object2->length )
{
Expand All @@ -109,9 +106,8 @@ bool __XSData_Equals( XSDataRef object1, XSDataRef object2 )

end:

XSRecursiveLock_Unlock( object1->lock );
XSRecursiveLock_Unlock( object2->lock );
__XSData_Unlock( object1 );
__XSData_Unlock( object2 );

return equals;
*/
}
80 changes: 80 additions & 0 deletions XSFoundation/source/XS/Classes/XSData/__XSData_Lock.c
@@ -0,0 +1,80 @@
/*******************************************************************************
* XSFoundation - XEOS C Foundation Library
*
* Copyright (c) 2010-2014, Jean-David Gadina - www.xs-labs.com
* All rights reserved.
*
* XEOS Software License - Version 1.0 - December 21, 2012
*
* Permission is hereby granted, free of charge, to any person or organisation
* obtaining a copy of the software and accompanying documentation covered by
* this license (the "Software") to deal in the Software, with or without
* modification, without restriction, including without limitation the rights
* to use, execute, display, copy, reproduce, transmit, publish, distribute,
* modify, merge, prepare derivative works of the Software, and to permit
* third-parties to whom the Software is furnished to do so, all subject to the
* following conditions:
*
* 1. Redistributions of source code, in whole or in part, must retain the
* above copyright notice and this entire statement, including the
* above license grant, this restriction and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice and this entire statement, including the above license grant,
* this restriction and the following disclaimer in the documentation
* and/or other materials provided with the distribution, unless the
* Software is distributed by the copyright owner as a library.
* A "library" means a collection of software functions and/or data
* prepared so as to be conveniently linked with application programs
* (which use some of those functions and data) to form executables.
*
* 3. The Software, or any substancial portion of the Software shall not
* be combined, included, derived, or linked (statically or
* dynamically) with software or libraries licensed under the terms
* of any GNU software license, including, but not limited to, the GNU
* General Public License (GNU/GPL) or the GNU Lesser General Public
* License (GNU/LGPL).
*
* 4. All advertising materials mentioning features or use of this
* software must display an acknowledgement stating that the product
* includes software developed by the copyright owner.
*
* 5. Neither the name of the copyright owner nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT OWNER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE, TITLE AND NON-INFRINGEMENT ARE DISCLAIMED.
*
* IN NO EVENT SHALL THE COPYRIGHT OWNER, CONTRIBUTORS OR ANYONE DISTRIBUTING
* THE SOFTWARE BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN ACTION OF CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF OR IN CONNECTION WITH
* THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/

/* $Id$ */

/*!
* @file __XSData_Lock.c
* @copyright (c) 2010-2014 - Jean-David Gadina - www.xs-labs.com
* @author Jean-David Gadina - www.xs-labs.com
* @abstract Definition for __XSData_Lock
*/

#include <XS/XS.h>
#include <XS/__private/Classes/XSDataRef.h>

void __XSData_Lock( XSDataRef Data )
{
if( XSData_IsMutable( Data ) )
{
XSRecursiveLock_Lock( Data->lock );
}
}
10 changes: 2 additions & 8 deletions XSFoundation/source/XS/Classes/XSData/__XSData_ToString.c
Expand Up @@ -73,16 +73,11 @@

const char * __XSData_ToString( XSDataRef object )
{
( void )object;

return NULL;

/*
XSStringRef description;
const XSUInt8 * bytes;
XSUInteger length;

XSRecursiveLock_Lock( object->lock );
__XSData_Lock( object );

length = object->length;
bytes = object->buffer;
Expand All @@ -99,8 +94,7 @@ const char * __XSData_ToString( XSDataRef object )

description = XSString_StringByAppendingCString( description, ">" );

XSRecursiveLock_Unlock( object->lock );
__XSData_Unlock( object );

return XSString_GetCString( description );
*/
}
80 changes: 80 additions & 0 deletions XSFoundation/source/XS/Classes/XSData/__XSData_Unlock.c
@@ -0,0 +1,80 @@
/*******************************************************************************
* XSFoundation - XEOS C Foundation Library
*
* Copyright (c) 2010-2014, Jean-David Gadina - www.xs-labs.com
* All rights reserved.
*
* XEOS Software License - Version 1.0 - December 21, 2012
*
* Permission is hereby granted, free of charge, to any person or organisation
* obtaining a copy of the software and accompanying documentation covered by
* this license (the "Software") to deal in the Software, with or without
* modification, without restriction, including without limitation the rights
* to use, execute, display, copy, reproduce, transmit, publish, distribute,
* modify, merge, prepare derivative works of the Software, and to permit
* third-parties to whom the Software is furnished to do so, all subject to the
* following conditions:
*
* 1. Redistributions of source code, in whole or in part, must retain the
* above copyright notice and this entire statement, including the
* above license grant, this restriction and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice and this entire statement, including the above license grant,
* this restriction and the following disclaimer in the documentation
* and/or other materials provided with the distribution, unless the
* Software is distributed by the copyright owner as a library.
* A "library" means a collection of software functions and/or data
* prepared so as to be conveniently linked with application programs
* (which use some of those functions and data) to form executables.
*
* 3. The Software, or any substancial portion of the Software shall not
* be combined, included, derived, or linked (statically or
* dynamically) with software or libraries licensed under the terms
* of any GNU software license, including, but not limited to, the GNU
* General Public License (GNU/GPL) or the GNU Lesser General Public
* License (GNU/LGPL).
*
* 4. All advertising materials mentioning features or use of this
* software must display an acknowledgement stating that the product
* includes software developed by the copyright owner.
*
* 5. Neither the name of the copyright owner nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT OWNER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE, TITLE AND NON-INFRINGEMENT ARE DISCLAIMED.
*
* IN NO EVENT SHALL THE COPYRIGHT OWNER, CONTRIBUTORS OR ANYONE DISTRIBUTING
* THE SOFTWARE BE LIABLE FOR ANY CLAIM, DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN ACTION OF CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF OR IN CONNECTION WITH
* THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/

/* $Id$ */

/*!
* @file __XSData_Unlock.c
* @copyright (c) 2010-2014 - Jean-David Gadina - www.xs-labs.com
* @author Jean-David Gadina - www.xs-labs.com
* @abstract Definition for __XSData_Unlock
*/

#include <XS/XS.h>
#include <XS/__private/Classes/XSDataRef.h>

void __XSData_Unlock( XSDataRef Data )
{
if( XSData_IsMutable( Data ) )
{
XSRecursiveLock_Unlock( Data->lock );
}
}

0 comments on commit 9908c5b

Please sign in to comment.