示例#1
0
void
	NSURLConnection::sendAsynchronousRequest_queue_completionHandler
	(NSURLRequest* request ,NSOperationQueue* queue ,NSCodeBlock block)
{
	char uni[20];
	sprintf(uni,"%d",request);

	FILE *fp;
	char outfilename[200];
	strcpy(outfilename,CCFileUtils::fullPathFromRelativePath(""));
	strcat(outfilename,uni);
	strcat(outfilename,"DATA.png");
	fp = fopen(outfilename,"wb");

	CURL* curl = request->URL()->getcurl();
	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeData);
	curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
	CURLcode code = curl_easy_perform(curl);
	
	fclose(fp);

	NSData* data = NSData::dataWithContentsOfFile(NSSTR(outfilename));
	//todo NSErro class for nil
	block(nil,data,nil);
}
示例#2
0
文件: NewtEnv.c 项目: morgant/NEWT0
void NewtInitSysEnv(void)
{
	struct {
		char *			name;
		newtRefVar  	slot;
		const char *	defaultValue;
	} envs[] = {
		{"NEWTLIB",		NSSYM0(NEWTLIB),	__LIBDIR__ ":."},
		{"PLATFORM",	NSSYM(PLATFORM),	__PLATFORM__},
		{"DYLIBSUFFIX",	NSSYM(DYLIBSUFFIX),	__DYLIBSUFFIX__},
		{NULL,			kNewtRefUnbind,		NULL}
	};

	newtRefVar  env;
	newtRefVar  proto;
	newtRefVar  v;
	uint16_t	i;

	env = NcMakeFrame();
	proto = NcMakeFrame();

	for (i = 0; envs[i].name != NULL; i++)
	{
		NcSetSlot(proto, envs[i].slot, NewtMakeString(envs[i].defaultValue, true));
	}

	/* NEWTLIB is a special case, it can be overridden from the value in
	   the global variables. */
	v = NewtGetEnv("NEWTLIB");
	if (NewtRefIsString(v))
	{
		v = NcSplit(v, NewtMakeCharacter(':'));
		NcSetSlot(proto, NSSYM0(NEWTLIB), v);
	}
	else
	{
		newtRefVar default_newtlib_array[] = {NSSTR(__LIBDIR__), NSSTR(".")};
		newtRefVar default_newtlib = NewtMakeArray2(
				kNewtRefNIL,
				sizeof(default_newtlib_array) / sizeof(newtRefVar),
				default_newtlib_array);
		NcSetSlot(proto, NSSYM0(NEWTLIB), default_newtlib);
	}

	NcSetSlot(env, NSSYM0(_proto), NewtPackLiteral(proto));
    NcSetSlot(GLOBALS, NSSYM0(_ENV_), env);
}
示例#3
0
文件: NewtStr.c 项目: ekoeppen/NEWT0
newtRef NsSPrintObject(newtRefArg rcvr, newtRefArg r)
{
    newtRefVar	str;

    str = NSSTR("");

	NcStrCat(str, r);

    return str;
}
示例#4
0
文件: NewtStr.c 项目: ekoeppen/NEWT0
newtRef NsSplit(newtRefArg rcvr, newtRefArg r, newtRefArg sep)
{
	newtRefVar  result;

    if (! NewtRefIsString(r))
        return NewtThrow(kNErrNotAString, r);

	switch (NewtGetRefType(sep, true))
	{
		case kNewtCharacter:
			{
				newtRefVar  v;
				char *		next;
				char *		s;
				int			c;

				s = NewtRefToString(r);
				c = NewtRefToCharacter(sep);

				result = NewtMakeArray(kNewtRefUnbind, 0);

				while (*s)
				{
					next = strchr(s, c);
					if (next == NULL) break;

					v = NewtMakeString2(s, next - s, false);
					NcAddArraySlot(result, v);
					s = next + 1;
				}

				if (s == NewtRefToString(r))
					v = r;
				else
					v = NSSTR(s);

				NcAddArraySlot(result, v);
			}
			break;

		default:
			{
				newtRefVar	initObj[] = {r};

				result = NewtMakeArray2(kNewtRefNIL, sizeof(initObj) / sizeof(newtRefVar), initObj);
			}
			break;
	}

    return result;
}
示例#5
0
UIBarButtonItem*
	UIBarButtonItem::initWithTitle_style_target_action(NSString* ctitle ,UIBarButtonItemStyle cstyle, NSActionTarget* ctarget,SEL_PP caction)
{
	if(super::init())
	{
	self->action = caction;
	self->target = ctarget;
	self->style = cstyle;
	self->title = ctitle;

	NSMutableDictionary* dict = NSMutableDictionary::dictionaryWithObjectAndKeys(
		UIFont::fontWithName_size(NSSTR("Arial"),1.0f),UITextAttributeFont,
		UIColor::whiteColor(),UITextAttributeTextColor);
	//nil to be fixed
	//self->setTitleTextAttributes_forState(dict,nil);
	}
	return self;
}
示例#6
0
文件: NewtFns.c 项目: pablomarx/NEWT0
newtRef NcStringer(newtRefArg r)
{
    newtRef *	slots;
    newtRefVar	str;
    uint32_t	len;
    uint32_t	i;

    if (! NewtRefIsArray(r))
        return NewtThrow(kNErrNotAnArray, r);

    str = NSSTR("");

    len = NewtArrayLength(r);
    slots = NewtRefToSlots(r);

    for (i = 0; i < len; i++)
    {
        NcStrCat(str, slots[i]);
    }

    return str;
}
NSPathDirectoryEnumerator*
	NSPathDirectoryEnumerator::initWithPath(NSString * path)
{
		self->directoryIndex = 0;
		self->directory = NSMutableArray::alloc()->init();
		struct dirent *directoryEntry;
	    DIR *directoryRef;
		directoryRef = opendir(path->cStringUsingEncoding(NSASCIIStringEncoding));
		while((directoryEntry = readdir(directoryRef)))
		{
			if(directoryEntry->d_name[0] == '.')
			{
				continue;
			}
			NSString* fileType ;
			if(S_ISREG(directoryEntry->d_type))
			{
				fileType = NSFileTypeRegular;
			}else if(S_ISDIR(directoryEntry->d_type))
			{
				fileType = NSFileTypeDirectory;
			}else if(S_ISCHR(directoryEntry->d_type))
			{
				fileType = NSFileTypeCharacterSpecial;
			}else if(S_ISBLK(directoryEntry->d_type))
			{
				fileType = NSFileTypeBlockSpecial;
			}else if(S_ISSOCK(directoryEntry->d_type))
			{
				fileType = NSFileTypeSocket;
			}
			NSDictionary* attributefile = NSDictionary::alloc()->initWithObjectsAndKeys(
				fileType ,NSFileType,NSSTR(directoryEntry->d_name),NSFileEntry,nil);
			self->directory->addObject(attributefile);
			attributefile->release();
		}
		closedir(directoryRef);
	return self;
}
//---------------------------------------------------------------------------
_di_NSString MPMediaItemPropertyTitle() {
	return NSSTR("title");
}
示例#9
0
NSString*
	NSMutableString::description()
{
	return NSSTR(ref->m_sString.c_str());
}
示例#10
0
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include <Foundation/NSException.h>
NSString * const NSGenericException=NSSTR("NSGenericException");
NSString * const NSInvalidArgumentException=NSSTR("NSInvalidArgumentException");
NSString * const NSRangeException=NSSTR("NSRangeException");

NSString * const NSInternalInconsistencyException=NSSTR("NSInternalInconsistencyException");
NSString * const NSMallocException=NSSTR("NSMallocException");

NSString * const NSParseErrorException=NSSTR("NSParseErrorException");
NSString * const NSInconsistentArchiveException=NSSTR("NSInconsistentArchiveException");
NSString*
	NSException::name()
{
	return self->_name;
}
NSString*
	NSException::reason()
示例#11
0
_di_NSString MPMediaItemPropertyMediaType() {
	return NSSTR("mediaType");
}
示例#12
0
_di_NSString MPMediaItemPropertyComposer() {
	return NSSTR("composer");
}
示例#13
0
_di_NSString MPMediaItemPropertyArtwork() {
	return NSSTR("artwork");
}
示例#14
0
_di_NSString MPMediaItemPropertyPlaybackDuration() {
	return NSSTR("playbackDuration");
}
示例#15
0
_di_NSString MPMediaItemPropertyArtist() {
	return NSSTR("artist");
}
示例#16
0
_di_NSString MPMediaItemPropertyAlbumTitle(){
	return TNSString::Wrap(TNSString::Alloc()->initWithString(NSSTR("albumTitle")));
//	return NSSTR("albumTitle");
}
示例#17
0
_di_NSString MPMediaItemPropertyGenre() {
	return NSSTR("genre");
}
示例#18
0
_di_NSString MPMediaItemPropertyPodcastTitle() {
	return NSSTR("podcastTitle");
}
示例#19
0
_di_NSString MPMediaPlaylistPropertyName() {
	return NSSTR("name");
}