ObjFW  Check-in [7a49441656]

Overview
Comment:Multiple changes, see details.

* Use config.h.
* Check whether to use sel_get_name or sel_getName.
* Rename freeWithData to freeIncludingData.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7a4944165605186f60af72f0603f255ad980351cb0929ba85dfa0ba7a6004ddd
User & Date: js on 2008-10-09 00:25:31
Other Links: manifest | tags
Context
2008-10-11
20:26
Move length from base string class to subclasses & others. check-in: 7b15048e25 user: js tags: trunk
2008-10-09
00:25
Multiple changes, see details. check-in: 7a49441656 user: js tags: trunk
2008-10-08
23:15
Multiple changes, see details. check-in: b597d49f43 user: js tags: trunk
Changes

Modified autogen.sh from [a642be08d3] to [d0ae45f9ae].

1
2
3

4
#!/bin/sh
aclocal -I m4 || exit 1
autoconf || exit 1

./configure $@



>

1
2
3
4
5
#!/bin/sh
aclocal -I m4 || exit 1
autoconf || exit 1
autoheader || exit 1
./configure $@

Modified configure.ac from [2601770269] to [01c1f78ef7].

15
16
17
18
19
20
21








22
23

24
		;;
esac

OBJCFLAGS="$OBJCFLAGS -fconstant-string-class=OFConstString -fobjc-exceptions"

BUILDSYS_SHARED_LIB









AC_SUBST(PACKAGE, objfw)
AC_CONFIG_FILES(buildsys.mk)

AC_OUTPUT







>
>
>
>
>
>
>
>


>

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
		;;
esac

OBJCFLAGS="$OBJCFLAGS -fconstant-string-class=OFConstString -fobjc-exceptions"

BUILDSYS_SHARED_LIB

AC_CHECK_LIB(objc, sel_get_name,
	[AC_DEFINE(HAVE_SEL_GET_NAME, 1, [Whether we have sel_get_name])])
AC_CHECK_LIB(objc, sel_getName,
	[AC_DEFINE(HAVE_SEL_GETNAME, 1, [Whether we have sel_getName])])

test x"$have_sel_name" = x"no" -a x"$have_selname" = x"no" && \
	AC_ERROR(You need either sel_get_name or sel_getName in libobjc!)

AC_SUBST(PACKAGE, objfw)
AC_CONFIG_FILES(buildsys.mk)
AC_CONFIG_HEADERS(config.h)
AC_OUTPUT

Modified src/Makefile from [3ff534d15e] to [c014f45fb9].

22
23
24
25
26
27
28

29
30
31
32
	   OFListObject.h	\
	   OFObject.h		\
	   OFString.h		\
	   OFWideString.h

include ../buildsys.mk


OBJCFLAGS += ${LIB_CFLAGS}
LD = ${OBJC}
LDFLAGS += ${LIB_LDFLAGS}
LIBS += -lobjc







>




22
23
24
25
26
27
28
29
30
31
32
33
	   OFListObject.h	\
	   OFObject.h		\
	   OFString.h		\
	   OFWideString.h

include ../buildsys.mk

CPPFLAGS += -I..
OBJCFLAGS += ${LIB_CFLAGS}
LD = ${OBJC}
LDFLAGS += ${LIB_LDFLAGS}
LIBS += -lobjc

Modified src/OFCString.m from [dae2c6c4a3] to [7d58812826].

1
2
3
4
5
6
7
8
9
10


11
12
13
14
15
16
17
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */



#import <stdlib.h>
#import <string.h>

#import "OFCString.h"
#import "OFExceptions.h"











>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "config.h"

#import <stdlib.h>
#import <string.h>

#import "OFCString.h"
#import "OFExceptions.h"

Modified src/OFConstCString.m from [8e3e77d979] to [35f5f8dc91].

1
2
3
4
5
6
7
8
9
10


11
12
13
14
15
16
17
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */



#import <string.h>
#import "OFConstCString.h"

@implementation OFConstCString
- initWithConstCString: (const char*)str
{










>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "config.h"

#import <string.h>
#import "OFConstCString.h"

@implementation OFConstCString
- initWithConstCString: (const char*)str
{

Modified src/OFConstWideCString.m from [700b4e543c] to [eee891da1e].

1
2
3
4
5
6
7
8
9
10


11
12
13
14
15
16
17
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */



#import <wchar.h>
#import "OFConstWideCString.h"

@implementation OFConstWideCString
- initWithConstWideCString: (const wchar_t*)str
{










>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "config.h"

#import <wchar.h>
#import "OFConstWideCString.h"

@implementation OFConstWideCString
- initWithConstWideCString: (const wchar_t*)str
{

Modified src/OFExceptions.m from [6d13800ff5] to [bb044cd27c].

1
2
3
4
5
6
7
8
9
10
11


12
13
14
15






16
17
18
19
20
21
22
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */



#import <stdio.h>
#import <stdlib.h>

#import "OFExceptions.h"







@implementation OFException
+ newWithObject: (id)obj
{
	return [[OFException alloc] initWithObject: obj];
}












>
>




>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "config.h"

#import <stdio.h>
#import <stdlib.h>

#import "OFExceptions.h"

#if defined HAVE_SEL_GET_NAME
#define SEL_NAME(x) sel_get_name(x)
#elif defined HAVE_SEL_GETNAME
#define SEL_NAME(x) sel_getName(x)
#endif

@implementation OFException
+ newWithObject: (id)obj
{
	return [[OFException alloc] initWithObject: obj];
}

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
						     andSelector: sel];
}

- initWithObject: (id)obj
     andSelector: (SEL)sel
{
	if ((self = [super init]))
		/* FIXME: Is casting SEL to char* portable? */
		asprintf(&errstr, "ERROR: Requested selector %s not "
		    "implemented in %s!\n", (char*)sel, [obj name]);

	return self;
}
@end

@implementation OFMemNotPartOfObjException
+ newWithObject: (id)obj







<

|







82
83
84
85
86
87
88

89
90
91
92
93
94
95
96
97
						     andSelector: sel];
}

- initWithObject: (id)obj
     andSelector: (SEL)sel
{
	if ((self = [super init]))

		asprintf(&errstr, "ERROR: Requested selector %s not "
		    "implemented in %s!\n", SEL_NAME(sel), [obj name]);

	return self;
}
@end

@implementation OFMemNotPartOfObjException
+ newWithObject: (id)obj

Modified src/OFFile.m from [ab4b7dd898] to [2de0039279].

1
2
3
4
5
6
7
8
9
10


11
12
13
14
15
16
17
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */



#import <stdio.h>
#import <stdint.h>
#import <unistd.h>
#import <sys/types.h>
#import <sys/stat.h>











>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "config.h"

#import <stdio.h>
#import <stdint.h>
#import <unistd.h>
#import <sys/types.h>
#import <sys/stat.h>

Modified src/OFList.h from [08759996d3] to [f955344801].

16
17
18
19
20
21
22
23
24
25
26
27
28
{
	OFListObject *first;
	OFListObject *last;
}

- init;
- free;
- freeWithData;
- (OFListObject*)first;
- (OFListObject*)last;
- (void)add: (OFListObject*)ptr;
- (void)addNew: (void*)ptr;
@end







|





16
17
18
19
20
21
22
23
24
25
26
27
28
{
	OFListObject *first;
	OFListObject *last;
}

- init;
- free;
- freeIncludingData;
- (OFListObject*)first;
- (OFListObject*)last;
- (void)add: (OFListObject*)ptr;
- (void)addNew: (void*)ptr;
@end

Modified src/OFList.m from [47da29ca93] to [361533dbeb].

1
2
3
4
5
6
7
8
9
10
11


12
13
14
15
16
17
18
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */



#import "OFList.h"

@implementation OFList
- init
{
	if ((self = [super init])) {
		first = nil;











>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "config.h"

#import "OFList.h"

@implementation OFList
- init
{
	if ((self = [super init])) {
		first = nil;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
		next = [iter next];
		[iter free];
	}

	return [super free];
}

- freeWithData
{
	OFListObject *iter, *next;

	for (iter = first; iter != nil; iter = next) {
		next = [iter next];
		[iter freeWithData];
	}

	first = last = nil;
	return [super free];
}

- (OFListObject*)first







|





|







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
		next = [iter next];
		[iter free];
	}

	return [super free];
}

- freeIncludingData
{
	OFListObject *iter, *next;

	for (iter = first; iter != nil; iter = next) {
		next = [iter next];
		[iter freeIncludingData];
	}

	first = last = nil;
	return [super free];
}

- (OFListObject*)first
67
68
69
70
71
72
73
74
75
76
	[last setNext: ptr];

	last = ptr;
}

- (void)addNew: (void*)ptr
{
	return [self add: [OFListObject new: ptr]];
}
@end







|


69
70
71
72
73
74
75
76
77
78
	[last setNext: ptr];

	last = ptr;
}

- (void)addNew: (void*)ptr
{
	return [self add: [OFListObject newWithData: ptr]];
}
@end

Modified src/OFListObject.h from [25e264f941] to [7460e3daf6].

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
@interface OFListObject: OFObject
{
	void	     *data;
	OFListObject *next;
	OFListObject *prev;
}

+ new: (void*)ptr;
- init: (void*)ptr;
- freeWithData;
- (void*)data;
- (OFListObject*)next;
- (OFListObject*)prev;
- (void)setNext: (OFListObject*)ptr;
- (void)setPrev: (OFListObject*)ptr;
@end







|
|
|






14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
@interface OFListObject: OFObject
{
	void	     *data;
	OFListObject *next;
	OFListObject *prev;
}

+ newWithData: (void*)ptr;
- initWithData: (void*)ptr;
- freeIncludingData;
- (void*)data;
- (OFListObject*)next;
- (OFListObject*)prev;
- (void)setNext: (OFListObject*)ptr;
- (void)setPrev: (OFListObject*)ptr;
@end

Modified src/OFListObject.m from [d372822c89] to [ed517ec6ff].

1
2
3
4
5
6
7
8
9
10
11


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */



#import <stdlib.h>
#import "OFListObject.h"

@implementation OFListObject
+ new: (void*)ptr
{
	return [[OFListObject alloc] init: ptr];
}

- init: (void*)ptr
{
	if ((self = [super init])) {
		next = nil;
		prev = nil;
		data = ptr;
	}
	return self;
}

- freeWithData
{
	if (data != NULL)
		free(data);
	return [super free];
}

- (void*)data











>
>




|

|


|









|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "config.h"

#import <stdlib.h>
#import "OFListObject.h"

@implementation OFListObject
+ newWithData: (void*)ptr
{
	return [[OFListObject alloc] initWithData: ptr];
}

- initWithData: (void*)ptr
{
	if ((self = [super init])) {
		next = nil;
		prev = nil;
		data = ptr;
	}
	return self;
}

- freeIncludingData
{
	if (data != NULL)
		free(data);
	return [super free];
}

- (void*)data

Modified src/OFObject.m from [c1de4ea884] to [85971766c6].

1
2
3
4
5
6
7
8
9
10


11
12
13
14
15
16
17
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */



#import <stdlib.h>

#import "OFObject.h"
#import "OFExceptions.h"

@implementation OFObject










>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "config.h"

#import <stdlib.h>

#import "OFObject.h"
#import "OFExceptions.h"

@implementation OFObject

Modified src/OFString.m from [a57e73bfa3] to [595a703a5e].

1
2
3
4
5
6
7
8
9
10


11
12
13
14
15
16
17
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */



#import <stdlib.h>
#import <string.h>

#import "OFString.h"
#import "OFConstCString.h"
#import "OFConstWideCString.h"










>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "config.h"

#import <stdlib.h>
#import <string.h>

#import "OFString.h"
#import "OFConstCString.h"
#import "OFConstWideCString.h"

Modified src/OFWideCString.m from [581afa2b30] to [a475d7a419].

1
2
3
4
5
6
7
8
9
10
11


12
13
14

15
16
17
18
19
20
21
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */



#import <stdlib.h>
#import <string.h>
#import <wchar.h>

#import "OFWideCString.h"
#import "OFExceptions.h"

@implementation OFWideCString
- initWithWideCString: (wchar_t*)str
{
	if ((self = [super init])) {











>
>



>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "config.h"

#import <stdlib.h>
#import <string.h>
#import <wchar.h>

#import "OFWideCString.h"
#import "OFExceptions.h"

@implementation OFWideCString
- initWithWideCString: (wchar_t*)str
{
	if ((self = [super init])) {

Modified tests/OFList/OFList.m from [27298bf4ec] to [1645530892].

54
55
56
57
58
59
60
61
62
63
64
65
	if (!strcmp([(OFString*)[[list last] data] cString], strings[2]))
		puts("Last element is expected element. GOOD!");
	else {
		puts("Last element is not expected element!");
		return 1;
	}
 
	[iter free];
	[list free];

	return 0;
}







<
|



54
55
56
57
58
59
60

61
62
63
64
	if (!strcmp([(OFString*)[[list last] data] cString], strings[2]))
		puts("Last element is expected element. GOOD!");
	else {
		puts("Last element is not expected element!");
		return 1;
	}
 

	[list freeIncludingData];

	return 0;
}