Example #1
0
/*===========================================================================
  R5RS : 6.3 Other data types : 6.3.1 Booleans
===========================================================================*/
SCM_EXPORT ScmObj
scm_p_not(ScmObj obj)
{
    DECLARE_FUNCTION("not", procedure_fixed_1);

    return MAKE_BOOL(FALSEP(obj));
}
Example #2
0
/* Bitwise Operations */
SCM_EXPORT ScmObj
scm_p_srfi60_logand(ScmObj left, ScmObj right, enum ScmReductionState *state)
{
    DECLARE_FUNCTION("logand", reduction_operator);

    BITWISE_OPERATION_BODY(&, left, right, -1);
}
Example #3
0
SCM_EXPORT ScmObj
scm_p_booleanp(ScmObj obj)
{
    DECLARE_FUNCTION("boolean?", procedure_fixed_1);

    return MAKE_BOOL(EQ(obj, SCM_FALSE) || EQ(obj, SCM_TRUE));
}
Example #4
0
/* The name 'error?' should be reserved for SRFI-35 */
SCM_EXPORT ScmObj
scm_p_error_objectp(ScmObj obj)
{
    DECLARE_FUNCTION("%%error-object?", procedure_fixed_1);

    return MAKE_BOOL(CONSP(obj) && EQ(CAR(obj), l_err_obj_tag));
}
Example #5
0
/*=======================================
  R5RS : 6.4 Control Features
=======================================*/
SCM_EXPORT ScmObj
scm_p_procedurep(ScmObj obj)
{
    DECLARE_FUNCTION("procedure?", procedure_fixed_1);

    return MAKE_BOOL(PROCEDUREP(obj));
}
Example #6
0
/*===========================================================================
  R5RS : 6.1 Equivalence predicates
===========================================================================*/
SCM_EXPORT ScmObj
scm_p_eqp(ScmObj obj1, ScmObj obj2)
{
    DECLARE_FUNCTION("eq?", procedure_fixed_2);

    return MAKE_BOOL(EQ(obj1, obj2));
}
Example #7
0
/* R6RS (R5.91RS) compatible */
SCM_EXPORT ScmObj
scm_p_least_fixnum(void)
{
    DECLARE_FUNCTION("least-fixnum", procedure_fixed_0);

    return MAKE_INT(SCM_INT_MIN);
}
Example #8
0
/* R6RS (R5.91RS) compatible */
SCM_EXPORT ScmObj
scm_p_greatest_fixnum(void)
{
    DECLARE_FUNCTION("greatest-fixnum", procedure_fixed_0);

    return MAKE_INT(SCM_INT_MAX);
}
Example #9
0
/* R6RS (R5.91RS) compatible */
SCM_EXPORT ScmObj
scm_p_fixnum_width(void)
{
    DECLARE_FUNCTION("fixnum-width", procedure_fixed_0);

    return MAKE_INT(SCM_INT_BITS);
}
Example #10
0
/*===========================================================================
  R5RS : 6.4 Control features
===========================================================================*/
SCM_EXPORT ScmObj
scm_p_force(ScmObj promise)
{
    ScmObj proc, result;
    DECLARE_FUNCTION("force", procedure_fixed_1);

    ENSURE_CONS(promise);

    proc = CDR(promise);
    ENSURE_PROCEDURE(proc);

    if (PROMISE_FORCEDP(promise))
        return CAR(promise);

    /* R5RS:
     *   Rationale: A promise may refer to its own value, as in the last
     *   example above. Forcing such a promise may cause the promise to be
     *   forced a second time before the value of the first force has been
     *   computed. This complicates the definition of `make-promise'. */
    result = scm_call(proc, SCM_NULL);
    if (PROMISE_FORCEDP(promise))
        return CAR(promise);
    SET_CAR(promise, result);
    return result;
}
Example #11
0
/*===========================================================================
  R5RS : 6.3 Other data types : 6.3.3 Symbols
===========================================================================*/
SCM_EXPORT ScmObj
scm_p_symbolp(ScmObj obj)
{
    DECLARE_FUNCTION("symbol?", procedure_fixed_1);

    return MAKE_BOOL(SYMBOLP(obj));
}
Example #12
0
SCM_EXPORT ScmObj
scm_p_sscm_version(void)
{
    DECLARE_FUNCTION("sscm-version", procedure_fixed_0);

    /* PACKAGE_VERSION may be overridden by a master package such as uim. */
    return CONST_STRING(SSCM_VERSION_STRING);
}
Example #13
0
/*
 * TODO: replace original specification with a SRFI standard or other de facto
 * standard
 */
SCM_EXPORT ScmObj
scm_p_providedp(ScmObj feature)
{
    DECLARE_FUNCTION("provided?", procedure_fixed_1);

    ENSURE_STRING(feature);

    return MAKE_BOOL(scm_providedp(feature));
}
Example #14
0
SCM_EXPORT ScmObj
scm_p_pair_mutablep(ScmObj kons)
{
    DECLARE_FUNCTION("%%pair-mutable?", procedure_fixed_1);

    ENSURE_CONS(kons);

    return MAKE_BOOL(SCM_CONS_MUTABLEP(kons));
}
Example #15
0
SCM_EXPORT ScmObj
scm_p_backtrace(void)
{
    DECLARE_FUNCTION("%%backtrace", procedure_fixed_0);

    scm_show_backtrace(scm_trace_stack());

    return SCM_UNDEF;
}
Example #16
0
SCM_EXPORT ScmObj
scm_p_srfi60_lognot(ScmObj n)
{
    DECLARE_FUNCTION("lognot", procedure_fixed_1);

    ENSURE_INT(n);

    return MAKE_INT(~SCM_INT_VALUE(n));
}
Example #17
0
SCM_EXPORT ScmObj
scm_p_current_environment(ScmEvalState *eval_state)
{
    DECLARE_FUNCTION("%%current-environment", procedure_fixed_tailrec_0);

    eval_state->ret_type = SCM_VALTYPE_AS_IS;

    return eval_state->env;
}
Example #18
0
SCM_EXPORT ScmObj
scm_p_string2symbol(ScmObj str)
{
    DECLARE_FUNCTION("string->symbol", procedure_fixed_1);

    ENSURE_STRING(str);

    return scm_intern(SCM_STRING_STR(str));
}
Example #19
0
SCM_EXPORT ScmObj
scm_p_symbol2string(ScmObj sym)
{
    DECLARE_FUNCTION("symbol->string", procedure_fixed_1);

    ENSURE_SYMBOL(sym);

    return CONST_STRING(SCM_SYMBOL_NAME(sym));
}
Example #20
0
SCM_EXPORT ScmObj
scm_p_srfi60_logtest(ScmObj j, ScmObj k)
{
    DECLARE_FUNCTION("logtest", procedure_fixed_2);

    ENSURE_INT(j);
    ENSURE_INT(k);

    return MAKE_BOOL(SCM_INT_VALUE(j) & SCM_INT_VALUE(k));
}
Example #21
0
/*===========================================================================
  R5RS : 4.2 Derived expression types : 4.2.5 Delayed evaluation
===========================================================================*/
SCM_EXPORT ScmObj
scm_s_delay(ScmObj exp, ScmObj env)
{
    ScmObj proc;
    DECLARE_FUNCTION("delay", syntax_fixed_1);

    proc = scm_s_lambda(SCM_NULL, LIST_1(exp), env);

    /* (result . proc) */
    return CONS(l_tag_unforced, proc);
}
Example #22
0
/*
 * TODO: replace original specification with a SRFI standard or other de facto
 * standard
 */
SCM_EXPORT ScmObj
scm_p_provide(ScmObj feature)
{
    DECLARE_FUNCTION("provide", procedure_fixed_1);

    ENSURE_STRING(feature);

    scm_provide(feature);

    return SCM_TRUE;
}
Example #23
0
SCM_EXPORT ScmObj
scm_p_prealloc_heaps(ScmObj n)
{
    DECLARE_FUNCTION("%%prealloc-heaps", procedure_fixed_1);

    ENSURE_INT(n);
    if (SCM_INT_VALUE(n) < 0)
        ERR_OBJ("non-negative number required but got", n);

    scm_prealloc_heaps((size_t)SCM_INT_VALUE(n));

    return n;
}
Example #24
0
SCM_EXPORT ScmObj
scm_p_current_char_codec(void)
{
    const char *encoding;
    DECLARE_FUNCTION("%%current-char-codec", procedure_fixed_0);

#if SCM_USE_MULTIBYTE_CHAR
    encoding = SCM_CHARCODEC_ENCODING(scm_current_char_codec);
#else
    encoding = "ISO-8859-1";
#endif

    return CONST_STRING(encoding);
}
// the main method where all calculations are done
void SmartMeshMorphDeformer::Update(Actor* actor, Node* node, const double timeDelta)
{
	DECLARE_FUNCTION(Update)

	// get the deform data and number of vertices to deform
	MeshExpressionPart::DeformData* deformData = mMeshExpressionPart->mDeformDatas[ mDeformDataNr ];
	const int numDeformVerts = deformData->mNumVerts;

	// this mesh deformer can't work on this mesh, because the deformdata number of vertices is bigger than the 
	// number of vertices inside this mesh!
	// and that would make it crash, which isn't what we want
	if (numDeformVerts > mMesh->GetNumVertices())
		return;

	// get the weight value and convert it to a range based weight value
	const float weight = mMeshExpressionPart->CalcRangedWeight( mMeshExpressionPart->GetWeight() );

	// nothing to do when the weight is too small
	bool nearZero = InRange<float>(weight, -Math::EPSILON, Math::EPSILON);

	// we are near zero, and the previous frame as well, so we can return
	if (nearZero && mLastNearZero)
		return;

	// update the flag
	if (nearZero)
		mLastNearZero = true;
	else
		mLastNearZero = false;	// we moved away from zero influence

	// some vars we need
	Vector3*	positions		= mMesh->GetPositions();
	Vector3*	normals			= mMesh->GetNormals();
	int*		vertexNumbers	= deformData->mVertexNumbers;

	Compressed16BitVector3*	deltas		 = deformData->mDeltas;
	Compressed8BitVector3*	deltaNormals = deformData->mDeltaNormals;
	const float				minValue	 = deformData->mMinValue;
	const float				maxValue	 = deformData->mMaxValue;

	// process all touched vertices
	int v;
	int vtxNr;
	for (v=0; v<numDeformVerts; v++)
	{
		vtxNr = vertexNumbers[v];
		positions[vtxNr] += deltas[v].ToVector3(minValue, maxValue) * weight;
		normals  [vtxNr] += deltaNormals[v].ToVector3(-1.0f, 1.0f) * weight;
	}
}
Example #26
0
SCM_EXPORT ScmObj
scm_p_inspect_error(ScmObj err_obj)
{
    ScmObj rest;
#if SCM_USE_BACKTRACE
    ScmObj trace_stack;
#endif
    DECLARE_FUNCTION("%%inspect-error", procedure_fixed_1);

    if (ERROBJP(err_obj)) {
        rest = err_obj;
        MUST_POP_ARG(rest);
        MUST_POP_ARG(rest);
        MUST_POP_ARG(rest);
#if SCM_USE_BACKTRACE
        trace_stack = MUST_POP_ARG(rest);
#else
        MUST_POP_ARG(rest);
#endif
        ASSERT_NO_MORE_ARG(rest);
    } else {
#if SCM_USE_BACKTRACE
        trace_stack = scm_trace_stack();
#else
        scm_trace_stack();
#endif
    }

    if (scm_debug_categories() & SCM_DBG_ERRMSG) {
        scm_port_puts(scm_err, SCM_ERR_HEADER);
        if (ERROBJP(err_obj)) {
#if SCM_USE_SRFI38
            scm_display_errobj_ss(scm_err, err_obj);
#else
            scm_display(scm_err, err_obj);
#endif
        } else {
            scm_port_puts(scm_err, ERRMSG_UNHANDLED_EXCEPTION ": ");
            SCM_WRITE_SS(scm_err, err_obj);
        }
        scm_port_newline(scm_err);
    }

#if SCM_USE_BACKTRACE
    if (scm_debug_categories() & SCM_DBG_BACKTRACE)
        scm_show_backtrace(trace_stack);
#endif

    return SCM_UNDEF;
}
Example #27
0
SCM_EXPORT ScmObj
scm_p_srfi60_bitwise_if(ScmObj mask, ScmObj n0, ScmObj n1)
{
    scm_int_t result, c_mask;
    DECLARE_FUNCTION("bitwise-if", procedure_fixed_3);

    ENSURE_INT(mask);
    ENSURE_INT(n0);
    ENSURE_INT(n1);

    c_mask = SCM_INT_VALUE(mask);
    result = (c_mask & SCM_INT_VALUE(n0)) | (~c_mask & SCM_INT_VALUE(n1));

    return MAKE_INT(result);
}
Example #28
0
SCM_EXPORT ScmObj
scm_p_map(ScmObj proc, ScmObj args)
{
    DECLARE_FUNCTION("map", procedure_variadic_1);

    if (NULLP(args))
        ERR("wrong number of arguments");

    /* fast path for single arg case */
    if (NULLP(CDR(args)))
        return scm_map_single_arg(proc, CAR(args));

    /* multiple args case */
    return scm_map_multiple_args(proc, args, scm_false);
}
Example #29
0
/*
 * Dotted list length is returned as follows:
 *
 * list            SRFI-1 dotted length    length* result
 * 'term                    0                    -1
 * '(1 . term)              1                    -2
 * '(1 2 . term)            2                    -3
 * '(1 2 3 . term)          3                    -4
 */
SCM_EXPORT ScmObj
scm_p_lengthstar(ScmObj lst)
{
    scm_int_t len;
    DECLARE_FUNCTION("length*", procedure_fixed_1);

    len = scm_length(lst);
    if (!SCM_LISTLEN_PROPERP(len)) { /* make fast path for proper list */
        if (SCM_LISTLEN_DOTTEDP(len))
            len = -SCM_LISTLEN_DOTTED(len) - 1;
        else if (SCM_LISTLEN_CIRCULARP(len))
            return SCM_FALSE;
    }

    return MAKE_INT(len);
}
Example #30
0
SCM_EXPORT ScmObj
scm_p_eqvp(ScmObj obj1, ScmObj obj2)
{
#if SCM_HAS_EQVP

#define scm_p_eqvp error_eqvp_recursed__ /* Safety measure. */
    return EQVP(obj1, obj2);
#undef scm_p_eqvp

#else  /* don't have inlined EQVP() */

#if (!(SCM_HAS_IMMEDIATE_NUMBER_ONLY && SCM_HAS_IMMEDIATE_CHAR_ONLY))
    enum ScmObjType type;
#endif
    DECLARE_FUNCTION("eqv?", procedure_fixed_2);

    if (EQ(obj1, obj2))
        return SCM_TRUE;

#if (!(SCM_HAS_IMMEDIATE_NUMBER_ONLY && SCM_HAS_IMMEDIATE_CHAR_ONLY))
    type = SCM_TYPE(obj1);

    /* different type */
    if (type != SCM_TYPE(obj2))
        return SCM_FALSE;

    /* same type */
    switch (type) {
#if (SCM_USE_INT && !SCM_HAS_IMMEDIATE_INT_ONLY)
    case ScmInt:
        return MAKE_BOOL(SCM_INT_VALUE(obj1) == SCM_INT_VALUE(obj2));
#endif

#if (SCM_USE_CHAR && !SCM_HAS_IMMEDIATE_CHAR_ONLY)
    case ScmChar:
        return MAKE_BOOL(SCM_CHAR_VALUE(obj1) == SCM_CHAR_VALUE(obj2));
#endif

    default:
        break;
    }
#endif /* (!(SCM_HAS_IMMEDIATE_NUMBER_ONLY && SCM_HAS_IMMEDIATE_CHAR_ONLY)) */

    return SCM_FALSE;

#endif /* don't have inlined EQVP() */
}