Exemplo n.º 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);
}
Exemplo n.º 2
0
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);
}
Exemplo n.º 3
0
newtRef NsSPrintObject(newtRefArg rcvr, newtRefArg r)
{
    newtRefVar	str;

    str = NSSTR("");

	NcStrCat(str, r);

    return str;
}
Exemplo n.º 4
0
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;
}
Exemplo n.º 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;
}
Exemplo n.º 6
0
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;
}
Exemplo n.º 7
0
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;
}
Exemplo n.º 8
0
//---------------------------------------------------------------------------
_di_NSString MPMediaItemPropertyTitle() {
	return NSSTR("title");
}
Exemplo n.º 9
0
NSString*
	NSMutableString::description()
{
	return NSSTR(ref->m_sString.c_str());
}
Exemplo n.º 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()
Exemplo n.º 11
0
_di_NSString MPMediaItemPropertyMediaType() {
	return NSSTR("mediaType");
}
Exemplo n.º 12
0
_di_NSString MPMediaItemPropertyComposer() {
	return NSSTR("composer");
}
Exemplo n.º 13
0
_di_NSString MPMediaItemPropertyArtwork() {
	return NSSTR("artwork");
}
Exemplo n.º 14
0
_di_NSString MPMediaItemPropertyPlaybackDuration() {
	return NSSTR("playbackDuration");
}
Exemplo n.º 15
0
_di_NSString MPMediaItemPropertyArtist() {
	return NSSTR("artist");
}
Exemplo n.º 16
0
_di_NSString MPMediaItemPropertyAlbumTitle(){
	return TNSString::Wrap(TNSString::Alloc()->initWithString(NSSTR("albumTitle")));
//	return NSSTR("albumTitle");
}
Exemplo n.º 17
0
_di_NSString MPMediaItemPropertyGenre() {
	return NSSTR("genre");
}
Exemplo n.º 18
0
_di_NSString MPMediaItemPropertyPodcastTitle() {
	return NSSTR("podcastTitle");
}
Exemplo n.º 19
0
_di_NSString MPMediaPlaylistPropertyName() {
	return NSSTR("name");
}