예제 #1
0
파일: utf7.c 프로젝트: mloar/charset
static void read_utf7(charset_spec const *charset, long int input_chr,
                      charset_state *state,
                      void (*emit)(void *ctx, long int output), void *emitctx)
{
    long int hw;

    UNUSEDARG(charset);

    /*
     * state->s0 is used to handle the conversion of the UTF-7
     * transport format into a stream of halfwords. Its layout is:
     *
     *  - In normal ASCII mode, it is zero.
     *
     * 	- Otherwise, it holds a leading 1 followed by all the bits
     * 	  so far accumulated in base64 digits.
     *
     * 	- Special case: when we have only just seen the initial `+'
     * 	  which enters base64 mode, it is set to 2 rather than 1
     * 	  (this is an otherwise unused value since base64 always
     * 	  accumulates an even number of bits at a time), so that
     * 	  the special sequence `+-' can be made to encode `+'
     * 	  easily.
     *
     * state->s1 is used to handle the conversion of those
     * halfwords into Unicode values. It contains a high surrogate
     * value if we've just seen one, and 0 otherwise.
     */

    if (!state->s0) {
        if (input_chr == '+')
            state->s0 = 2;
        else
            emit(emitctx, input_chr);
        return;
    } else {
        if (!SET_B(input_chr)) {
            /*
             * base64 mode ends here. Emit the character we have,
             * unless it's a minus in which case we should swallow
             * it.
             */
            if (input_chr != '-')
                emit(emitctx, input_chr);
            else if (state->s0 == 2)
                emit(emitctx, '+');    /* special case */
            state->s0 = 0;
            return;
        }

        /*
         * Now we have a base64 character, so add it to our state,
         * first correcting the special case value of s0.
         */
        if (state->s0 == 2)
            state->s0 = 1;
        state->s0 = (state->s0 << 6) | base64_value(input_chr);
    }

    /*
     * If we don't have a whole halfword at this point, bale out.
     */
    if (!(state->s0 & 0xFFFF0000))
        return;

    /*
     * Otherwise, extract the halfword. There are three
     * possibilities for where the top set bit might be.
     */
    if (state->s0 & 0x00100000) {
        hw = (state->s0 >> 4) & 0xFFFF;
        state->s0 = (state->s0 & 0xF) | 0x10;
    } else if (state->s0 & 0x00040000) {
static void evaluate_dynamical_model(AMOContext_Context submodel_ctx)
{
   /* Local common sub-expressions. */
   ZERO_SIZE_ARRAY(cs);
   ZERO_SIZE_ARRAY(is);
   ZERO_SIZE_ARRAY(bs);
   ZERO_SIZE_ARRAY(rs);
   ZERO_SIZE_ARRAY(ss);
   
   /* Evaluating toplevel systems. */
   SET_B(0, FALSE) /* idb__ */;
   SET_B(1, FALSE) /* idb___0 */;
   SET_R(
      16,
      IF(
         GT_TRIGGER(1),
         R(14) /* ifield */ *
         (
            R(14) /* ifield */ *
            (
               5.8160000000000001e-001 * R(14) /* ifield */ +
               - 2.9315000000000002e+000
            ) +
            4.6432000000000002e+000
         ),
         0.0000000000000000e+000
      )
   )
      /* k */;
   SET_R(0, R(16) /* k */ * (1.0471975511999999e-001 * R(17) /* speed */))
      /* BEMF */;
   SET_R(
      4,
      IF(
         BNOT(GE_TRIGGER(0)),
         (- 1.0000000000000000e+000 * R(6) /* Rarm1 */ + R(5) /* Rarm0 */) *
         (
            TIME *
            (
               - 1.0000000000000000e+000 *
               RIPOW(R(18) /* tswitchoff */, - 1)
            ) +
            1.0000000000000000e+000
         ) +
         R(6) /* Rarm1 */,
         R(6) /* Rarm1 */
      )
   )
      /* Rarm */;
   SET_R(
      13,
      RIPOW(R(4) /* Rarm */, - 1) *
      (
         - 1.0000000000000000e+000 * R(0) /* BEMF */ +
         1.4000000000000000e+002
      )
   )
      /* iarm */;
   SET_R(12, R(14) /* ifield */ + R(13) /* iarm */) /* i */;
   SET_R(2, 1.4000000000000000e+002 * R(12) /* i */) /* Pe */;
   SET_R(8, R(13) /* iarm */ * R(16) /* k */) /* Tem */;
   SET_R(
      3, R(8) /* Tem */ * (1.0471975511999999e-001 * R(17) /* speed */)
   )
      /* Pem */;
   SET_R(
      10,
      RIPOW(R(1) /* Lfield */, - 1) *
      (
         R(7) /* Rfield */ *
         (- 1.0000000000000000e+000 * R(14) /* ifield */) +
         1.4000000000000000e+002
      )
   )
      /* der(ifield) */;
   SET_R(
      11,
      9.5492965854826952e+000 *
      (
         R(9) /* cvisc */ * (- 1.0000000000000000e+000 * R(17) /* speed */) +
         R(8) /* Tem */
      )
   )
      /* der(speed) */;
   SET_R(19, 1.4000000000000000e+002) /* u */;
   
   return;
}
void CEmTubeSplashViewContainer::Draw(const TRect& /*aRect*/) const
	{

    CWindowGc& gc = SystemGc();

    gc.SetClippingRect( Rect() );

	gc.SetBrushColor( KRgbWhite );
    gc.Clear( Rect() );

	TRect rect = Rect();
	TInt x, y;

	x = (rect.Width() / 2) - (KBitmapSize / 2);
	y = (rect.Height() / 2) - (KBitmapSize / 2);

	TInt s_width = iBitmap->ScanLineLength(iBitmap->SizeInPixels().iWidth, EColor16MU ) / 4;
	TInt s_height = iBitmap->SizeInPixels().iHeight;

	TInt d_width = iTmpBitmap->ScanLineLength(iTmpBitmap->SizeInPixels().iWidth, EColor16MU ) / 4;
//	TInt d_height = iTmpBitmap->SizeInPixels().iHeight;

	iBitmap->LockHeap(ETrue);
	iTmpBitmap->LockHeap(ETrue);

	TUint32* src = (TUint32*) iBitmap->DataAddress();
	TUint32* dst = (TUint32*) iTmpBitmap->DataAddress();

#define GET_R( rgb ) ((rgb >> 16) & 0xff)
#define GET_G( rgb ) ((rgb >> 8) & 0xff)
#define GET_B( rgb ) (rgb & 0xff)

#define SET_R( r ) ((r & 0xff) << 16 )
#define SET_G( g ) ((g & 0xff) << 8 )
#define SET_B( b ) ( b & 0xff)

	TUint32 alpha = iAlpha * 255;
	TUint32 alpha1 = (KAlphaMax - iAlpha);
	for (TInt i = 0; i < s_height; i++)
    	{
    	TUint32* d = dst;
    	TUint32* s = src;
        for (TInt j = 0; j < s_width; j++)
	        {
			TUint32 rgb = *s++;

			TUint32 r = ((GET_R( rgb ) * alpha1) + alpha) >> 8;
			TUint32 g = ((GET_G( rgb ) * alpha1) + alpha) >> 8;
			TUint32 b = ((GET_B( rgb ) * alpha1) + alpha) >> 8;

			rgb = SET_R( r ) + SET_G( g ) + SET_B( b );
			*d++ = rgb;
	        }
        dst += d_width;
        src += s_width;
		}

	iBitmap->UnlockHeap(ETrue);
	iTmpBitmap->UnlockHeap(ETrue);

	gc.BitBlt( TPoint( x, y ), iTmpBitmap);
    gc.CancelClippingRect();
	}
static void evaluate_initial_model(AMOContext_Context submodel_ctx)
{
   /* Local common sub-expressions. */
   ZERO_SIZE_ARRAY(cs);
   ZERO_SIZE_ARRAY(is);
   ZERO_SIZE_ARRAY(bs);
   ZERO_SIZE_ARRAY(rs);
   ZERO_SIZE_ARRAY(ss);
   
   /* Evaluating toplevel systems. */
   SET_B(0, TIME >= 2.5000000000000000e+000) /* idb__ */;
   SET_B(1, R(14) /* ifield */ > 0.0000000000000000e+000) /* idb___0 */;
   SET_R(
      16,
      IF(
         B(1) /* idb___0 */,
         R(14) /* ifield */ *
         (
            R(14) /* ifield */ *
            (
               5.8160000000000001e-001 * R(14) /* ifield */ +
               - 2.9315000000000002e+000
            ) +
            4.6432000000000002e+000
         ),
         0.0000000000000000e+000
      )
   )
      /* k */;
   SET_R(0, R(16) /* k */ * (1.0471975511999999e-001 * R(17) /* speed */))
      /* BEMF */;
   SET_R(1, 1.0000000000000001e-001) /* Lfield */;
   SET_R(
      4,
      IF(
         BNOT(B(0) /* idb__ */),
         3.6000000000000001e+000 *
         (
            TIME *
            (
               - 1.0000000000000000e+000 *
               RIPOW(2.5000000000000000e+000, - 1)
            ) +
            1.0000000000000000e+000
         ) +
         4.0000000000000002e-001,
         4.0000000000000002e-001
      )
   )
      /* Rarm */;
   SET_R(
      13,
      RIPOW(R(4) /* Rarm */, - 1) *
      (
         - 1.0000000000000000e+000 * R(0) /* BEMF */ +
         1.4000000000000000e+002
      )
   )
      /* iarm */;
   SET_R(12, R(14) /* ifield */ + R(13) /* iarm */) /* i */;
   SET_R(2, 1.4000000000000000e+002 * R(12) /* i */) /* Pe */;
   SET_R(8, R(13) /* iarm */ * R(16) /* k */) /* Tem */;
   SET_R(
      3, R(8) /* Tem */ * (1.0471975511999999e-001 * R(17) /* speed */)
   )
      /* Pem */;
   SET_R(5, 4.0000000000000000e+000) /* Rarm0 */;
   SET_R(6, 4.0000000000000002e-001) /* Rarm1 */;
   SET_R(7, 2.7500000000000000e+002) /* Rfield */;
   SET_R(9, 1.7000000000000001e-002) /* cvisc */;
   SET_R(
      10,
      RIPOW(1.0000000000000001e-001, - 1) *
      (
         - 2.7500000000000000e+002 * R(14) /* ifield */ +
         1.4000000000000000e+002
      )
   )
      /* der(ifield) */;
   SET_R(
      11,
      9.5492965854826952e+000 *
      (- 1.7000000000000001e-002 * R(17) /* speed */ + R(8) /* Tem */)
   )
      /* der(speed) */;
   SET_R(15, 5.9999999999999998e-001) /* inertia */;
   SET_R(18, 2.5000000000000000e+000) /* tswitchoff */;
   SET_R(19, 1.4000000000000000e+002) /* u */;
   
   return;
}