mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Minor mframe fix
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@15166 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ce0b794ad5
commit
73d92b0b72
4 changed files with 112 additions and 120 deletions
|
@ -8,6 +8,9 @@
|
|||
* Source/Additions/GSObjCRuntime.m: Tidied function name conventions.
|
||||
* Headers/gnustep/base/GSObjCRuntime.h: ditto.
|
||||
* Source/NSKeyValueCoding.m: Use new function names.
|
||||
* Source/mframe.m: When scanning arguments, skip type information
|
||||
for things poionted to by a pointer - more efficient than scanning
|
||||
the fine structure and then throwing away the scanned information.
|
||||
|
||||
2002-11-27 Manuel Guesdon <mguesdon@orange-concept.com>
|
||||
|
||||
|
|
|
@ -95,6 +95,9 @@
|
|||
+ (NSString*) charsetFromEncoding: (NSStringEncoding)enc;
|
||||
+ (NSData*) decodeBase64: (NSData*)source;
|
||||
+ (NSString*) decodeBase64String: (NSString*)source;
|
||||
+ (GSMimeDocument*) documentWithContent: (id)newContent
|
||||
type: (NSString*)type
|
||||
name: (NSString*)name;
|
||||
+ (NSData*) encodeBase64: (NSData*)source;
|
||||
+ (NSString*) encodeBase64String: (NSString*)source;
|
||||
+ (NSStringEncoding) encodingFromCharset: (NSString*)charset;
|
||||
|
@ -128,10 +131,6 @@
|
|||
- (void) setContent: (id)newContent
|
||||
type: (NSString*)type
|
||||
name: (NSString*)name;
|
||||
- (void) setContent: (id)newContent
|
||||
type: (NSString*)type
|
||||
subtype: (NSString*)subtype
|
||||
name: (NSString*)name;
|
||||
- (void) setHeader: (GSMimeHeader*)info;
|
||||
|
||||
@end
|
||||
|
|
|
@ -3111,6 +3111,21 @@ static NSCharacterSet *tokenSet = nil;
|
|||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to return an autoreleased document using the
|
||||
* specified content, type, and name value. This calls the
|
||||
* -setContent:type:name: method to set up the document.
|
||||
*/
|
||||
+ (GSMimeDocument*) documentWithContent: (id)newContent
|
||||
type: (NSString*)type
|
||||
name: (NSString*)name
|
||||
{
|
||||
GSMimeDocument *doc = AUTORELEASE([self new]);
|
||||
|
||||
[doc setContent: newContent type: type name: name];
|
||||
return doc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode the source data to base64 encoding and return the result.
|
||||
*/
|
||||
|
@ -3845,23 +3860,16 @@ static NSCharacterSet *tokenSet = nil;
|
|||
*/
|
||||
if (isMultipart == YES)
|
||||
{
|
||||
[self setContent: content
|
||||
type: @"multipart"
|
||||
subtype: @"mixed"
|
||||
name: nil];
|
||||
[self setContent: content type: @"multipart/mixed" name: nil];
|
||||
}
|
||||
else if ([content isKindOfClass: [NSString class]] == YES)
|
||||
{
|
||||
[self setContent: content
|
||||
type: @"text"
|
||||
subtype: @"plain"
|
||||
name: nil];
|
||||
[self setContent: content type: @"text/plain" name: nil];
|
||||
}
|
||||
else if ([content isKindOfClass: [NSData class]] == YES)
|
||||
{
|
||||
[self setContent: content
|
||||
type: @"application"
|
||||
subtype: @"octet-stream"
|
||||
type: @"application/octet-stream"
|
||||
name: nil];
|
||||
}
|
||||
else
|
||||
|
@ -4066,7 +4074,7 @@ static NSCharacterSet *tokenSet = nil;
|
|||
|
||||
/**
|
||||
* Convenience method calling -setContent:type:name: to set document
|
||||
* content and type without specifying a name ... useful for top-level
|
||||
* content and type with a nil value for name ... useful for top-level
|
||||
* documents rather than parts within a document (parts should really
|
||||
* be named).
|
||||
*/
|
||||
|
@ -4076,55 +4084,6 @@ static NSCharacterSet *tokenSet = nil;
|
|||
[self setContent: newContent type: type name: nil];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method calling -setContent:type:subtype:name: to set
|
||||
* content and type. If the type argument contains a slash '/')
|
||||
* then it is split into type and subtype parts, otherwise, the
|
||||
* subtype is assumed to be nil.
|
||||
*/
|
||||
- (void) setContent: (id)newContent
|
||||
type: (NSString*)type
|
||||
name: (NSString*)name
|
||||
{
|
||||
NSString *subtype = nil;
|
||||
|
||||
if (type != nil)
|
||||
{
|
||||
NSRange r;
|
||||
|
||||
r = [type rangeOfString: @"/"];
|
||||
if (r.length > 0)
|
||||
{
|
||||
subtype = [type substringFromIndex: NSMaxRange(r)];
|
||||
type = [type substringToIndex: r.location];
|
||||
}
|
||||
else if ([type isEqual: @"text"] == YES)
|
||||
{
|
||||
subtype = @"plain";
|
||||
}
|
||||
else if ([type isEqual: @"multipart"] == YES)
|
||||
{
|
||||
subtype = @"mixed";
|
||||
}
|
||||
else
|
||||
{
|
||||
subtype = @"octet-stream";
|
||||
}
|
||||
}
|
||||
[self setContent: newContent
|
||||
type: type
|
||||
subtype: subtype
|
||||
name: name];
|
||||
}
|
||||
|
||||
- (void) setContent: (id)newContent
|
||||
type: (NSString*)type
|
||||
subType: (NSString*)subtype
|
||||
name: (NSString*)name
|
||||
{
|
||||
[self setContent: newContent type: type subtype: subtype name: name];
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Convenience method to set the content of the document along with
|
||||
* creating a content-type header for it.
|
||||
|
@ -4144,11 +4103,63 @@ static NSCharacterSet *tokenSet = nil;
|
|||
*/
|
||||
- (void) setContent: (id)newContent
|
||||
type: (NSString*)type
|
||||
subtype: (NSString*)subtype
|
||||
name: (NSString*)name
|
||||
{
|
||||
GSMimeHeader *hdr;
|
||||
NSString *val;
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
NSString *subtype = nil;
|
||||
GSMimeHeader *hdr = nil;
|
||||
|
||||
if (type == nil)
|
||||
{
|
||||
type = @"text";
|
||||
}
|
||||
|
||||
if ([type isEqual: @"text"] == YES)
|
||||
{
|
||||
subtype = @"plain";
|
||||
}
|
||||
else if ([type isEqual: @"multipart"] == YES)
|
||||
{
|
||||
subtype = @"mixed";
|
||||
}
|
||||
else if ([type isEqual: @"application"] == YES)
|
||||
{
|
||||
subtype = @"octet-stream";
|
||||
}
|
||||
else
|
||||
{
|
||||
GSMimeParser *p = AUTORELEASE([GSMimeParser new]);
|
||||
NSScanner *scanner = [NSScanner scannerWithString: type];
|
||||
|
||||
hdr = AUTORELEASE([GSMimeHeader new]);
|
||||
if ([p scanHeaderBody: scanner into: hdr] == NO)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Unable to parse type information"];
|
||||
}
|
||||
}
|
||||
|
||||
if (hdr == nil)
|
||||
{
|
||||
NSString *val;
|
||||
|
||||
val = [NSString stringWithFormat: @"%@/%@", type, subtype];
|
||||
hdr = [GSMimeHeader alloc];
|
||||
hdr = [hdr initWithName: @"content-type" value: val parameters: nil];
|
||||
[hdr setObject: type forKey: @"Type"];
|
||||
[hdr setObject: subtype forKey: @"SubType"];
|
||||
AUTORELEASE(hdr);
|
||||
}
|
||||
else
|
||||
{
|
||||
type = [hdr objectForKey: @"Type"];
|
||||
subtype = [hdr objectForKey: @"SubType"];
|
||||
}
|
||||
|
||||
if (name != nil)
|
||||
{
|
||||
[hdr setParameter: name forKey: @"name"];
|
||||
}
|
||||
|
||||
if ([type isEqualToString: @"multipart"] == NO
|
||||
&& [type isEqualToString: @"application"] == NO
|
||||
|
@ -4160,18 +4171,8 @@ static NSCharacterSet *tokenSet = nil;
|
|||
}
|
||||
|
||||
[self setContent: newContent];
|
||||
|
||||
val = [NSString stringWithFormat: @"%@/%@", type, subtype];
|
||||
hdr = [GSMimeHeader alloc];
|
||||
hdr = [hdr initWithName: @"content-type" value: val parameters: nil];
|
||||
[hdr setObject: type forKey: @"Type"];
|
||||
[hdr setObject: subtype forKey: @"SubType"];
|
||||
if (name != nil)
|
||||
{
|
||||
[hdr setParameter: name forKey: @"name"];
|
||||
}
|
||||
[self setHeader: hdr];
|
||||
RELEASE(hdr);
|
||||
RELEASE(arp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -205,6 +205,7 @@ mframe_next_arg(const char *typePtr, NSArgumentInfo *info)
|
|||
{
|
||||
NSArgumentInfo local;
|
||||
BOOL flag;
|
||||
BOOL negative = NO;
|
||||
|
||||
if (info == 0)
|
||||
{
|
||||
|
@ -330,9 +331,7 @@ mframe_next_arg(const char *typePtr, NSArgumentInfo *info)
|
|||
}
|
||||
else
|
||||
{
|
||||
typePtr = mframe_next_arg(typePtr, &local);
|
||||
info->isReg = local.isReg;
|
||||
info->offset = local.offset;
|
||||
typePtr = objc_skip_typespec(typePtr);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -452,47 +451,37 @@ mframe_next_arg(const char *typePtr, NSArgumentInfo *info)
|
|||
}
|
||||
|
||||
/*
|
||||
* If we had a pointer argument, we will already have gathered
|
||||
* (and skipped past) the argframe offset information - so we
|
||||
* don't need to (and can't) do it here.
|
||||
* May tell the caller if the item is stored in a register.
|
||||
*/
|
||||
if (info->type[0] != _C_PTR || info->type[1] == '?')
|
||||
if (*typePtr == '+')
|
||||
{
|
||||
BOOL negative = NO;
|
||||
|
||||
/*
|
||||
* May tell the caller if the item is stored in a register.
|
||||
*/
|
||||
if (*typePtr == '+')
|
||||
{
|
||||
typePtr++;
|
||||
info->isReg = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
info->isReg = NO;
|
||||
}
|
||||
/*
|
||||
* Cope with negative offsets.
|
||||
*/
|
||||
if (*typePtr == '-')
|
||||
{
|
||||
typePtr++;
|
||||
negative = YES;
|
||||
}
|
||||
/*
|
||||
* May tell the caller what the stack/register offset is for
|
||||
* this argument.
|
||||
*/
|
||||
info->offset = 0;
|
||||
while (isdigit(*typePtr))
|
||||
{
|
||||
info->offset = info->offset * 10 + (*typePtr++ - '0');
|
||||
}
|
||||
if (negative == YES)
|
||||
{
|
||||
info->offset = -info->offset;
|
||||
}
|
||||
typePtr++;
|
||||
info->isReg = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
info->isReg = NO;
|
||||
}
|
||||
/*
|
||||
* Cope with negative offsets.
|
||||
*/
|
||||
if (*typePtr == '-')
|
||||
{
|
||||
typePtr++;
|
||||
negative = YES;
|
||||
}
|
||||
/*
|
||||
* May tell the caller what the stack/register offset is for
|
||||
* this argument.
|
||||
*/
|
||||
info->offset = 0;
|
||||
while (isdigit(*typePtr))
|
||||
{
|
||||
info->offset = info->offset * 10 + (*typePtr++ - '0');
|
||||
}
|
||||
if (negative == YES)
|
||||
{
|
||||
info->offset = -info->offset;
|
||||
}
|
||||
|
||||
return typePtr;
|
||||
|
|
Loading…
Reference in a new issue