コード例 #1
0
static sqInt
makeDirEntryNamesizecreateDatemodDateisDirfileSizeposixPermissionsisSymlink(char *entryName, sqInt entryNameSize, sqInt createDate, sqInt modifiedDate, sqInt dirFlag, squeakFileOffsetType  fileSize, sqInt posixPermissions, sqInt symlinkFlag)
{
	// FilePlugin>>#makeDirEntryName:size:createDate:modDate:isDir:fileSize:posixPermissions:isSymlink:
    sqInt createDateOop;
    sqInt fileSizeOop;
    sqInt i;
    sqInt modDateOop;
    sqInt nameString;
    sqInt posixPermissionsOop;
    sqInt results;
    char *stringPtr;


	/* allocate storage for results, remapping newly allocated
	   oops in case GC happens during allocation */

	pushRemappableOop(instantiateClassindexableSize(classArray(), 7));
	pushRemappableOop(instantiateClassindexableSize(classString(), entryNameSize));
	pushRemappableOop(positive32BitIntegerFor(createDate));
	pushRemappableOop(positive32BitIntegerFor(modifiedDate));
	pushRemappableOop(positive64BitIntegerFor(fileSize));
	pushRemappableOop(positive32BitIntegerFor(posixPermissions));
	posixPermissionsOop = popRemappableOop();
	fileSizeOop = popRemappableOop();
	modDateOop = popRemappableOop();
	createDateOop = popRemappableOop();
	nameString = popRemappableOop();

	/* copy name into Smalltalk string */

results = popRemappableOop();
	stringPtr = firstIndexableField(nameString);
	for (i = 0; i < entryNameSize; i += 1) {
stringPtr[i] = (entryName[i]);
	}
	storePointerofObjectwithValue(0, results, nameString);
	storePointerofObjectwithValue(1, results, createDateOop);
	storePointerofObjectwithValue(2, results, modDateOop);
	if (dirFlag) {
storePointerofObjectwithValue(3, results, trueObject());
	}
	else {
storePointerofObjectwithValue(3, results, falseObject());
	}
	storePointerofObjectwithValue(4, results, fileSizeOop);
	storePointerofObjectwithValue(5, results, posixPermissionsOop);
	if (symlinkFlag) {
storePointerofObjectwithValue(6, results, trueObject());
	}
	else {
storePointerofObjectwithValue(6, results, falseObject());
	}
	return results;
}
コード例 #2
0
ファイル: GdbARMPlugin.c プロジェクト: johnnyzz/pharo-vm
	/* InterpreterPlugin>>#positiveMachineIntegerFor: */
static sqInt
positiveMachineIntegerFor(usqIntptr_t value)
{
	return (BytesPerWord == 8
		? positive64BitIntegerFor(value)
		: positive32BitIntegerFor(value));
}
コード例 #3
0
primitiveSoundPlaySamples(void)
{
	// SoundPlugin>>#primitiveSoundPlaySamples
	unsigned *buf;
	sqInt frameCount;
	sqInt framesPlayed;
	sqInt startIndex;
	sqInt _return_value;

	frameCount = stackIntegerValue(2);
	success(isWords(stackValue(1)));
	buf = ((unsigned *) (firstIndexableField(stackValue(1))));
	startIndex = stackIntegerValue(0);
	if (failed()) {
		return null;
	}
	success((startIndex >= 1)
	 && (((startIndex + frameCount) - 1) <= (slotSizeOf(((sqInt)(long)(buf) - BaseHeaderSize)))));
	if (!(failed())) {
		framesPlayed = snd_PlaySamplesFromAtLength(frameCount, (void *)buf, startIndex - 1);
		success(framesPlayed >= 0);
	}
	_return_value = positive32BitIntegerFor(framesPlayed);
	if (failed()) {
		return null;
	}
	popthenPush(4, _return_value);
	return null;
}
コード例 #4
0
primitiveDLSym(void)
{
    void *addr;
    sqInt i;
    char *name;
    sqInt nameObj;
    char *namePtr;
    sqInt sz;

	nameObj = stackValue(0);
	if (!(isBytes(nameObj))) {
		return primitiveFailFor(PrimErrBadArgument);
	}
	sz = byteSizeOf(nameObj);
	name = malloc(sz + 1);
	namePtr = firstIndexableField(nameObj);
	for (i = 0; i < sz; i += 1) {
		name[i] = (namePtr[i]);
	}
	name[sz] = 0;
	addr = dlsym(RTLD_SELF,name);
	free(name);
	return methodReturnValue((addr == 0
		? nilObject()
		: (/* begin positiveMachineIntegerFor: */
			(BytesPerWord == 8
					? positive64BitIntegerFor(((usqIntptr_t)addr))
					: positive32BitIntegerFor(((usqIntptr_t)addr))))));
}
コード例 #5
0
primitiveSoundInsertSamples(void)
{
	// SoundPlugin>>#primitiveSoundInsertSamples
	unsigned *buf;
	sqInt frameCount;
	sqInt framesPlayed;
	sqInt leadTime;
	sqInt _return_value;

	frameCount = stackIntegerValue(2);
	success(isWords(stackValue(1)));
	buf = ((unsigned *) (firstIndexableField(stackValue(1))));
	leadTime = stackIntegerValue(0);
	if (failed()) {
		return null;
	}
	success(frameCount <= (slotSizeOf(((sqInt)(long)(buf) - BaseHeaderSize))));
	if (!(failed())) {
		framesPlayed = snd_InsertSamplesFromLeadTime(frameCount, (void *)buf, leadTime);
		success(framesPlayed >= 0);
	}
	_return_value = positive32BitIntegerFor(framesPlayed);
	if (failed()) {
		return null;
	}
	popthenPush(4, _return_value);
	return null;
}
コード例 #6
0
/*
  primitivePluginRequestUrlStream: url with: semaIndex
  Request a URL from the browser. Signal semaIndex
  when the result of the request can be queried.
  Returns a handle used in subsequent calls to plugin
  stream functions.
  Note: A request id is the index into requests[].
*/
int display_primitivePluginRequestURLStream()
{
    sqStreamRequest *req;
    int id, url, length, semaIndex;

    if (!inBrowser) return primitiveFail();

    DPRINT("VM: primitivePluginRequestURLStream()\n");

    for (id=0; id<MAX_REQUESTS; id++) {
        if (!requests[id]) break;
    }
    if (id >= MAX_REQUESTS) return primitiveFail();

    semaIndex= stackIntegerValue(0);
    url= stackObjectValue(1);
    if (failed()) return 0;

    if (!isBytes(url)) return primitiveFail();

    req= calloc(1, sizeof(sqStreamRequest));
    if (!req) return primitiveFail();
    req->localName= NULL;
    req->semaIndex= semaIndex;
    req->state= -1;
    requests[id]= req;

    length= byteSizeOf(url);
    browserGetURLRequest(id, firstIndexableField(url), length, NULL, 0);
    pop(3);
    push(positive32BitIntegerFor(id));
    DPRINT("VM:   request id: %i\n", id);
    return 1;
}
コード例 #7
0
ファイル: GdbARMPlugin.c プロジェクト: johnnyzz/pharo-vm
primitiveNewCPU(void)
{
	void *cpu;

	cpu = newCPU();
	if (cpu == 0) {
		primitiveFail();
		return null;
	}
	popthenPush(1, (BytesPerWord == 8
		? positive64BitIntegerFor(((usqIntptr_t) cpu))
		: positive32BitIntegerFor(((usqIntptr_t) cpu))));
	if (failed()) {
		return null;
	}
	return null;
}
コード例 #8
0
primitiveSoundPlaySilence(void)
{
	// SoundPlugin>>#primitiveSoundPlaySilence
	sqInt framesPlayed;
	sqInt _return_value;


	/* -1 if sound output not started */

framesPlayed = snd_PlaySilence();
	success(framesPlayed >= 0);
	_return_value = positive32BitIntegerFor(framesPlayed);
	if (failed()) {
		return null;
	}
	popthenPush(1, _return_value);
	return null;
}
コード例 #9
0
primitiveSoundAvailableSpace(void)
{
	// SoundPlugin>>#primitiveSoundAvailableSpace
	sqInt frames;
	sqInt _return_value;


	/* -1 if sound output not started */

frames = snd_AvailableSpace();
	success(frames >= 0);
	_return_value = positive32BitIntegerFor(frames);
	if (failed()) {
		return null;
	}
	popthenPush(1, _return_value);
	return null;
}
コード例 #10
0
primitiveReadJoystick(void)
{
	sqInt index;
	sqInt _return_value;

	index = stackIntegerValue(0);
	if (failed()) {
		return null;
	}
	if (failed()) {
		return null;
	}
	_return_value = positive32BitIntegerFor((joystickRead(index)));
	if (failed()) {
		return null;
	}
	popthenPush(2, _return_value);
	return null;
}
コード例 #11
0
/*
  primitivePluginPostURL: url target: target data: data semaIndex: semaIndex
  Post data to a URL into the given target.
*/
int display_primitivePluginPostURL()
{
    sqStreamRequest *req;
    int url, urlLength;
    int target, targetLength;
    int data, dataLength;
    int id, semaIndex;

    if (!browserWindow) return primitiveFail();
    for (id=0; id<MAX_REQUESTS; id++) {
        if (!requests[id]) break;
    }

    if (id >= MAX_REQUESTS) return primitiveFail();

    semaIndex= stackIntegerValue(0);
    data= stackObjectValue(1);
    target= stackObjectValue(2);
    url= stackObjectValue(3);

    if (failed()) return 0;
    if (target == nilObject()) target= 0;
    if (!isBytes(url) || !isBytes(data) || !(!target || isBytes(target))) return primitiveFail();

    urlLength= byteSizeOf(url);
    targetLength= target ? byteSizeOf(target) : 0;
    dataLength= byteSizeOf(data);

    req= calloc(1, sizeof(sqStreamRequest));
    if(!req) return primitiveFail();
    req->localName= NULL;
    req->semaIndex= semaIndex;
    req->state= -1;
    requests[id]= req;

    browserPostURLRequest(id, firstIndexableField(url), urlLength,
                          target ? firstIndexableField(target) : NULL, targetLength,
                          firstIndexableField(data), dataLength);
    pop(4);
    push(positive32BitIntegerFor(id));
    return 1;
}
コード例 #12
0
primitiveTextureGetColorMasks(void)
{
	// B3DAcceleratorPlugin>>#primitiveTextureGetColorMasks
    sqInt array;
    sqInt arrayOop;
    sqInt handle;
    sqInt i;
    int masks[4];
    sqInt renderer;
    sqInt result;

	if (!((methodArgumentCount()) == 3)) {
		return primitiveFail();
	}
	array = stackObjectValue(0);
	handle = stackIntegerValue(1);
	renderer = stackIntegerValue(2);
	if (failed()) {
		return null;
	}
	if (!((fetchClassOf(array)) == (classArray()))) {
		return primitiveFail();
	}
	if (!((slotSizeOf(array)) == 4)) {
		return primitiveFail();
	}
	result = b3dxTextureColorMasks(renderer, handle, masks);
	if (!result) {
return primitiveFail();
	}
	arrayOop = array;
	for (i = 0; i <= 3; i += 1) {
pushRemappableOop(arrayOop);
		result = positive32BitIntegerFor(masks[i]);
		arrayOop = popRemappableOop();
		storePointerofObjectwithValue(i, arrayOop, result);
	}
	return pop(3);
}
コード例 #13
0
primitiveSoundRecordSamples(void)
{
	// SoundPlugin>>#primitiveSoundRecordSamples
	unsigned *buf;
	sqInt bufLen;
	char*bufPtr;
	sqInt bufSizeInBytes;
	sqInt byteOffset;
	sqInt samplesRecorded;
	sqInt startWordIndex;
	sqInt _return_value;

	success(isWords(stackValue(1)));
	buf = ((unsigned *) (firstIndexableField(stackValue(1))));
	startWordIndex = stackIntegerValue(0);
	if (failed()) {
		return null;
	}
	if (!(failed())) {
		bufSizeInBytes = (slotSizeOf(((sqInt)(long)(buf) - BaseHeaderSize))) * 4;
		success((startWordIndex >= 1)
		 && (((startWordIndex - 1) * 2) < bufSizeInBytes));
	}
	if (!(failed())) {
		byteOffset = (startWordIndex - 1) * 2;
		bufPtr = (((char*) buf)) + byteOffset;
		bufLen = bufSizeInBytes - byteOffset;
		samplesRecorded = snd_RecordSamplesIntoAtLength(bufPtr, 0, bufLen);
	}
	_return_value = positive32BitIntegerFor(samplesRecorded);
	if (failed()) {
		return null;
	}
	popthenPush(3, _return_value);
	return null;
}
コード例 #14
0
primitiveExecutableModulesAndOffsets(void)
{
    const struct mach_header *h;
    const struct mach_header_64 *h64;
    sqInt i;
    const char *name;
    char *nameObjData;
    sqInt nimages;
    sqInt resultObj;
    const struct section *s;
    const struct section_64 *s64;
    usqIntptr_t size;
    usqIntptr_t slide;
    usqIntptr_t start;
    sqInt valueObj;

	
#  if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4

	/* _dyld_present was deprecated in 10.5 */
	if (!(_dyld_present())) {
		return primitiveFail();
	}

#  endif /* MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 */

	nimages = _dyld_image_count();
	resultObj = instantiateClassindexableSize(classArray(), nimages * 4);
	if (resultObj == 0) {
		return primitiveFail();
	}
	pushRemappableOop(resultObj);
	for (i = 0; i < nimages; i += 1) {

		/* impossible start & size */
		start = (size = -1);
		name = _dyld_get_image_name(i);
		slide = _dyld_get_image_vmaddr_slide(i);
		
#    if __x86_64__
		h64 = (const struct mach_header_64 *)_dyld_get_image_header(i);
		if (!(h64 == null)) {
			s64 = getsectbynamefromheader_64(h64,SEG_TEXT,SECT_TEXT);
			if (!(s64 == null)) {
				start = s64->addr;
				size = s64->size;
			}
		}

#    else /* __x86_64__ */
		h = _dyld_get_image_header(i);
		if (!(h == null)) {
			s = getsectbynamefromheader(h,SEG_TEXT,SECT_TEXT);
			if (!(s == null)) {
				start = s->addr;
				size = s->size;
			}
		}

#    endif /* __x86_64__ */

		valueObj = instantiateClassindexableSize(classString(), strlen(name));
		if (failed()) {
			popRemappableOop();
			return primitiveFail();
		}
		storePointerofObjectwithValue(i * 4, topRemappableOop(), valueObj);
		nameObjData = arrayValueOf(valueObj);
		memcpy(nameObjData, name, strlen(name));
		valueObj = (BytesPerWord == 8
			? signed64BitIntegerFor(slide)
			: signed32BitIntegerFor(slide));
		if (failed()) {
			popRemappableOop();
			return primitiveFail();
		}
		storePointerofObjectwithValue((i * 4) + 1, topRemappableOop(), valueObj);
		/* begin positiveMachineIntegerFor: */
		valueObj = (BytesPerWord == 8
			? positive64BitIntegerFor(start)
			: positive32BitIntegerFor(start));
		if (failed()) {
			popRemappableOop();
			return primitiveFail();
		}
		storePointerofObjectwithValue((i * 4) + 2, topRemappableOop(), valueObj);
		/* begin positiveMachineIntegerFor: */
		valueObj = (BytesPerWord == 8
			? positive64BitIntegerFor(size)
			: positive32BitIntegerFor(size));
		if (failed()) {
			popRemappableOop();
			return primitiveFail();
		}
		storePointerofObjectwithValue((i * 4) + 3, topRemappableOop(), valueObj);
	}
	resultObj = popRemappableOop();
	return popthenPush(1, resultObj);
}