mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 09:02:01 +00:00
(SIGNATURE_FORMAT_STRING): New macro.
([Coder -writeSignature]): Use it. ([Coder +readSignatureFromCStream:getClassname:formatVersion:]): Likewise, and receive (char*) instead of (char**). All callers changed. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@798 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c03157191d
commit
53017ca679
1 changed files with 9 additions and 6 deletions
|
@ -130,22 +130,25 @@ my_object_is_class(id object)
|
||||||
return DEFAULT_FORMAT_VERSION;
|
return DEFAULT_FORMAT_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define SIGNATURE_FORMAT_STRING \
|
||||||
|
@"GNU Objective C Class Library %s version %d\n"
|
||||||
|
|
||||||
- (void) writeSignature
|
- (void) writeSignature
|
||||||
{
|
{
|
||||||
/* Careful: the string should not contain newlines. */
|
/* Careful: the string should not contain newlines. */
|
||||||
[[cstream stream] writeFormat:
|
[[cstream stream] writeFormat: SIGNATURE_FORMAT_STRING,
|
||||||
@"GNU Objective C Class Library %s version %d\n",
|
|
||||||
object_get_class_name(self),
|
object_get_class_name(self),
|
||||||
format_version];
|
format_version];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void) readSignatureFromCStream: (id <CStreaming>) cs
|
+ (void) readSignatureFromCStream: (id <CStreaming>) cs
|
||||||
getClassname: (char **) namePtr
|
getClassname: (char *) name
|
||||||
formatVersion: (int*) version
|
formatVersion: (int*) version
|
||||||
{
|
{
|
||||||
int got;
|
int got;
|
||||||
|
|
||||||
got = [[cs stream] readFormat: @"GNU %a version %d\n", namePtr, version];
|
got = [[cs stream] readFormat: SIGNATURE_FORMAT_STRING,
|
||||||
|
name, version];
|
||||||
if (got != 2)
|
if (got != 2)
|
||||||
[NSException raise:CoderSignatureMalformedException
|
[NSException raise:CoderSignatureMalformedException
|
||||||
format:@"Coder found a malformed signature"];
|
format:@"Coder found a malformed signature"];
|
||||||
|
@ -181,12 +184,12 @@ my_object_is_class(id object)
|
||||||
+ coderReadingFromStream: (id <Streaming>) stream
|
+ coderReadingFromStream: (id <Streaming>) stream
|
||||||
{
|
{
|
||||||
id cs = [CStream cStreamReadingFromStream: stream];
|
id cs = [CStream cStreamReadingFromStream: stream];
|
||||||
char *name;
|
char name[128]; /* Max classname length. */
|
||||||
int version;
|
int version;
|
||||||
id new_coder;
|
id new_coder;
|
||||||
|
|
||||||
[self readSignatureFromCStream: cs
|
[self readSignatureFromCStream: cs
|
||||||
getClassname: &name
|
getClassname: name
|
||||||
formatVersion: &version];
|
formatVersion: &version];
|
||||||
|
|
||||||
new_coder = [[objc_lookup_class(name) alloc]
|
new_coder = [[objc_lookup_class(name) alloc]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue