Example #1
0
static BOOL setSegsBuffers(scicos_block * block, int maxNumberOfPoints)
{
    int iFigureUID;
    int iAxeUID;
    int iSegsUID;

    int i;
    int nclk = block->nipar - 6;
    BOOL result = TRUE;

    int color;

    iFigureUID = getFigure(block);
    iAxeUID = getAxe(iFigureUID, block);
    for (i = 0; i < nclk; i++)
    {
        iSegsUID = getSegs(iAxeUID, block, i);
        result = setGraphicObjectProperty(iSegsUID, __GO_NUMBER_ARROWS__, &maxNumberOfPoints, jni_int, 1);

        /*
         * Update color due to bug #9902
         * http://bugzilla.scilab.org/show_bug.cgi?id=9902
         */
        color = block->ipar[2 + i];
        if (color > 0)
        {
            setGraphicObjectProperty(iSegsUID, __GO_SEGS_COLORS__, &color, jni_int_vector, 1);
        }
    }

    return result;
}
Example #2
0
static int getAxe(int iFigureUID, scicos_block * block)
{
    int iAxe;
    int i;

    int nclk = block->nipar - 6;
    sco_data *sco = getScoData(block);

    // assert the sco is not NULL
    if (sco == NULL)
    {
        return 0;
    }

    // fast path for an existing object
    if (sco->scope.cachedAxeUID)
    {
        return sco->scope.cachedAxeUID;
    }

    iAxe = findChildWithKindAt(iFigureUID, __GO_AXES__, 0);

    /*
     * Allocate if necessary
     */
    if (iAxe == 0)
    {
        cloneAxesModel(iFigureUID);
        iAxe = findChildWithKindAt(iFigureUID, __GO_AXES__, 0);
    }

    /*
     * Setup on first access
     */
    if (iAxe != 0)
    {
        // allocate the segs through the getter
        for (i = 0; i < nclk; i++)
        {
            getSegs(iAxe, block, i);
        }
    }
    else
    {
        return 0;
    }

    /*
     * then cache with a local storage
     */
    sco->scope.cachedAxeUID = iAxe;
    return sco->scope.cachedAxeUID;
}
Example #3
0
static BOOL pushData(scicos_block * block, int input)
{
    int iFigureUID;
    int iAxeUID;
    int iSegsUID;

    int dataLen;
    double *base;
    double *direction;
    sco_data *sco;

    BOOL result;

    iFigureUID = getFigure(block);
    iAxeUID = getAxe(iFigureUID, block);
    iSegsUID = getSegs(iAxeUID, block, input);

    sco = getScoData(block);
    if (sco == NULL)
    {
        return FALSE;
    }

    // select the right input and row
    base = sco->internal.data[2 * input];
    direction = sco->internal.data[2 * input + 1];

    dataLen = 3 * sco->internal.maxNumberOfPoints[input];

    result = setGraphicObjectProperty(iSegsUID, __GO_BASE__, base, jni_double_vector, dataLen);
    if (result == FALSE)
    {
        return result;
    }
    result = setGraphicObjectProperty(iSegsUID, __GO_DIRECTION__, direction, jni_double_vector, dataLen);

    return result;
}
Example #4
0
int openElf(elf_t *dst, const char *path)
{
	int res;

	if (dst == NULL || path == NULL)
		return EINVAL;

	dst->path = path;

	dst->fp = fopen(path, "rb");
	if (dst->fp == NULL) {
		perror(path);
		return errno;
	}

	if (fread(&dst->ehdr, sizeof(dst->ehdr), 1, dst->fp) <= 0) {
		if (feof(dst->fp)) {
			fprintf(stderr, "%s: Unexpected EOF\n", path);
			errno = EILSEQ;
		} else
			perror(path);

		fclose(dst->fp);
		return errno;
	}

	dst->orgShnum = dst->ehdr.e_shnum;

	dst->scns = getScns(dst->fp, path, &dst->ehdr);
	if (dst->scns == NULL) {
		fclose(dst->fp);
		return errno;
	}

	dst->strtab = dst->scns + dst->ehdr.e_shstrndx;
	res = loadScn(dst->fp, dst->strtab, path);
	if (res) {
		free(dst->scns);
		fclose(dst->fp);
		return res;
	}

	dst->symtab = findScnByType(dst->scns, dst->ehdr.e_shnum,
		SHT_SYMTAB, path);
	if (dst->symtab == NULL) {
		free(dst->scns);
		free(dst->strtab->content);
		fclose(dst->fp);
		return errno;
	}

	res = loadScn(dst->fp, dst->symtab,
		(void *)((uintptr_t)dst->strtab->content + dst->symtab->shdr.sh_name));
	if (res) {
		free(dst->scns);
		free(dst->strtab->content);
		fclose(dst->fp);
		return res;
	}

	res = getSceScns(&dst->sceScns, dst->scns, dst->ehdr.e_shnum,
		dst->strtab->content, path);
	if (res) {
		free(dst->scns);
		free(dst->strtab->content);
		free(dst->symtab->content);
		fclose(dst->fp);
		return res;
	}

	dst->segs = getSegs(dst->fp, path, &dst->ehdr,
		dst->scns, &dst->rela, dst->sceScns.relMark);
	if (dst->segs == NULL) {
		free(dst->scns);
		free(dst->strtab->content);
		free(dst->symtab->content);
		fclose(dst->fp);
		return errno;
	}

	return 0;
}