コード例 #1
0
ファイル: ioptutil.c プロジェクト: NoSuchProcess/OrangeC
BRIGGS_SET *briggsAllocs(int size)
{
    BRIGGS_SET *p = sAlloc(sizeof(BRIGGS_SET));
    p-> indexes = sAlloc(sizeof(*p->indexes) * size);
    p->data = sAlloc(sizeof(*p->data) * size);
    p->size = size ;
    return p;
}
コード例 #2
0
static LRESULT WINAPI 
sDurationMsgProc (
		HWND	hwnd, 
		UINT	msg, 
		WPARAM	wParam, 
		LPARAM	lParam) 
{
	DCWndData* pDC = Duration_GetPtr(hwnd);

    if (pDC == NULL) {
        if (msg == WM_NCCREATE) 
		{
			pDC = (DCWndData*)sAlloc (sizeof(DCWndData));
			if (pDC == NULL) return 0L;
			Duration_SetPtr (hwnd, pDC);
        }
        else 
        	return DefWindowProc (hwnd, msg, wParam, lParam);
    }
	
    if (msg == WM_NCDESTROY) 
	{
		sFree (pDC);
        pDC = NULL;
        Duration_SetPtr (hwnd, NULL);
    }

	switch (msg) {

	case WM_CREATE :
	{
		LPCREATESTRUCT	lpcs		= (LPCREATESTRUCT)lParam;

		pDC->hwnd		= hwnd;
		pDC->hwndParent = lpcs->hwndParent;
		pDC->iID		= (INT)(lpcs->hMenu); 
		pDC->dwStyle	= lpcs->style & ES_READONLY;
		pDC->hFont		= GetStockObject (DEFAULT_GUI_FONT);

		pDC->iFocused		= -1;
		pDC->iPrevFocused	= 0;
		pDC->bFirstKey		= TRUE;
		pDC->iHeight		= lpcs->cy;

		pDC->iRangeLo[DAYS]		= 0;
		pDC->iRangeLo[HOURS]	= 0;
		pDC->iRangeLo[MINS]		= 0;

		pDC->iRangeHi[DAYS]		= 99;
		pDC->iRangeHi[HOURS]	= 23;
		pDC->iRangeHi[MINS]		= 59;

		pDC->ulDuration			= 0;
		pDC->ulMinDuration		= 0;
		pDC->ulMaxDuration		= 8553600 + 82800 + 3540; // 99d + 23h + 59m

		lstrcpy (&pDC->szText[DAYS][0], "d, ");
		lstrcpy (&pDC->szText[HOURS][0], "h, ");
		lstrcpy (&pDC->szText[MINS][0], "m");

		// create the up/down control
		pDC->hwndUpDown = CreateWindowEx (0L, UPDOWN_CLASS, "",
			WS_CHILD|WS_VISIBLE|pDC->dwStyle,
			0, 0, 0, 0, hwnd, NULL, 0, NULL);

		// create edit controls
		// days
		pDC->hwndEdit[DAYS] = CreateWindowEx (0L, "EDIT", "",
			WS_CHILD|WS_TABSTOP|WS_VISIBLE|ES_NUMBER|ES_RIGHT|pDC->dwStyle, 
			0, 0, 0, 0, hwnd, (HMENU)IDC_EDITDAYS, 0, NULL);
		SendMessage (pDC->hwndEdit[DAYS], 
						WM_SETFONT, (WPARAM)pDC->hFont, FALSE);
		SendMessage (pDC->hwndEdit[DAYS], 
						EM_SETLIMITTEXT, 2, 0);
		pDC->wpOrigEditProc[DAYS] = 
						(WNDPROC) SetWindowLong (pDC->hwndEdit[DAYS],
								GWL_WNDPROC, (LONG)sEditDaysProc); 

		pDC->hwndText[DAYS] = CreateWindowEx (0L, "EDIT", "",
			WS_CHILD|WS_VISIBLE|ES_LEFT|pDC->dwStyle, 
			0, 0, 0, 0, hwnd, (HMENU)IDC_TEXTDAYS, 0, NULL);
		SendMessage (pDC->hwndText[DAYS], 
						WM_SETFONT, (WPARAM)pDC->hFont, FALSE);
		pDC->wpOrigTextProc[DAYS] = 
						(WNDPROC) SetWindowLong (pDC->hwndText[DAYS],
								GWL_WNDPROC, (LONG)sText0Proc); 

		// hours
		pDC->hwndEdit[HOURS] = CreateWindowEx (0L, "EDIT", "",
			WS_CHILD|WS_TABSTOP|WS_VISIBLE|ES_NUMBER|ES_RIGHT|pDC->dwStyle, 
			0, 0, 0, 0, hwnd, (HMENU)IDC_EDITHOURS, 0, NULL);
		SendMessage (pDC->hwndEdit[HOURS], 
						WM_SETFONT, (WPARAM)pDC->hFont, FALSE);
		SendMessage (pDC->hwndEdit[HOURS], 
						EM_SETLIMITTEXT, 2, 0);
		pDC->wpOrigEditProc[HOURS] = 
						(WNDPROC) SetWindowLong (pDC->hwndEdit[HOURS],
								GWL_WNDPROC, (LONG)sEditHoursProc); 

		pDC->hwndText[HOURS] = CreateWindowEx (0L, "EDIT", "",
			WS_CHILD|WS_VISIBLE|ES_LEFT|pDC->dwStyle, 
			0, 0, 0, 0, hwnd, (HMENU)IDC_TEXTHOURS, 0, NULL);
		SendMessage (pDC->hwndText[HOURS], 
						WM_SETFONT, (WPARAM)pDC->hFont, FALSE);
		pDC->wpOrigTextProc[HOURS] = 
						(WNDPROC) SetWindowLong (pDC->hwndText[HOURS],
								GWL_WNDPROC, (LONG)sText1Proc); 

		// minutes
		pDC->hwndEdit[MINS] = CreateWindowEx (0L, "EDIT", "",
			WS_CHILD|WS_TABSTOP|WS_VISIBLE|ES_NUMBER|ES_RIGHT|pDC->dwStyle, 
			0, 0, 0, 0, hwnd, (HMENU)IDC_EDITMINS, 0, NULL);
		SendMessage (pDC->hwndEdit[MINS], 
						WM_SETFONT, (WPARAM)pDC->hFont, FALSE);
		SendMessage (pDC->hwndEdit[MINS], 
						EM_SETLIMITTEXT, 2, 0);
		pDC->wpOrigEditProc[MINS] = 
						(WNDPROC) SetWindowLong (pDC->hwndEdit[MINS],
								GWL_WNDPROC, (LONG)sEditMinsProc); 

		pDC->hwndText[MINS] = CreateWindowEx (0L, "EDIT", "",
			WS_CHILD|WS_VISIBLE|ES_LEFT|pDC->dwStyle, 
			0, 0, 0, 0, hwnd, (HMENU)IDC_TEXTMINS, 0, NULL);
		SendMessage (pDC->hwndText[MINS], 
						WM_SETFONT, (WPARAM)pDC->hFont, FALSE);
		pDC->wpOrigTextProc[MINS] = 
						(WNDPROC) SetWindowLong (pDC->hwndText[MINS],
								GWL_WNDPROC, (LONG)sText2Proc); 

		sSetControls (hwnd, pDC);

		break;
	}

	case WM_GETDLGCODE :
		return DLGC_WANTMESSAGE;
		
	case WM_NOTIFY :
	{
		LPNMHDR	pnmhdr = (LPNMHDR)lParam;

		if (pnmhdr->hwndFrom == pDC->hwndUpDown)
		{
			LPNMUPDOWN pnmud = (LPNMUPDOWN)lParam;
			sScrollUnit (pDC, -1*pnmud->iDelta);
		}
		break;
	}

	case WM_PAINT :
		// paint background, if necessary
		if (pDC->dwStyle & (WS_DISABLED | ES_READONLY))
		{
			PAINTSTRUCT	ps;
			HDC			hdc;
			RECT		rc;

			hdc = BeginPaint (hwnd, &ps);
			GetClientRect (hwnd, &rc);
			FillRect (hdc, &rc, (HBRUSH)(COLOR_3DFACE+1));
			EndPaint (hwnd, &ps);
		}
		break;

	case WM_SETFOCUS :
		SetFocus (pDC->hwndEdit[pDC->iPrevFocused]);
		break;

	case WM_DESTROY :
		SetWindowLong (pDC->hwndText[DAYS], 
							GWL_WNDPROC, (LONG)pDC->wpOrigTextProc[DAYS]); 
		SetWindowLong (pDC->hwndText[HOURS], 
							GWL_WNDPROC, (LONG)pDC->wpOrigTextProc[HOURS]); 
		SetWindowLong (pDC->hwndText[MINS],
							GWL_WNDPROC, (LONG)pDC->wpOrigTextProc[MINS]);
		
		DestroyWindow (pDC->hwndText[DAYS]);
		DestroyWindow (pDC->hwndText[HOURS]);
		DestroyWindow (pDC->hwndText[MINS]);

		SetWindowLong (pDC->hwndEdit[DAYS], 
							GWL_WNDPROC, (LONG)pDC->wpOrigEditProc[DAYS]); 
		SetWindowLong (pDC->hwndEdit[HOURS], 
							GWL_WNDPROC, (LONG)pDC->wpOrigEditProc[HOURS]); 
		SetWindowLong (pDC->hwndEdit[MINS], 
							GWL_WNDPROC, (LONG)pDC->wpOrigEditProc[MINS]); 
		
		DestroyWindow (pDC->hwndEdit[DAYS]);
		DestroyWindow (pDC->hwndEdit[HOURS]);
		DestroyWindow (pDC->hwndEdit[MINS]);

		DestroyWindow (pDC->hwndUpDown);
		break;

	case EM_SETREADONLY :
		if (wParam)
			pDC->dwStyle |= ES_READONLY;
		else
			pDC->dwStyle &= ~ES_READONLY;

		SendMessage (pDC->hwndText[DAYS], msg, wParam, lParam);
		SendMessage (pDC->hwndText[HOURS], msg, wParam, lParam);
		SendMessage (pDC->hwndText[MINS], msg, wParam, lParam);

		SendMessage (pDC->hwndEdit[DAYS], msg, wParam, lParam);
		SendMessage (pDC->hwndEdit[HOURS], msg, wParam, lParam);
		SendMessage (pDC->hwndEdit[MINS], msg, wParam, lParam);

		InvalidateRect (hwnd, NULL, TRUE);
		break;

	case WM_HELP :
	{
		LPHELPINFO lphi = (LPHELPINFO)lParam;

		lphi->iCtrlId = pDC->iID;
		lphi->hItemHandle = pDC->hwnd;
		break;
	}

	case WM_ENABLE :
		if (wParam)
		{
			pDC->dwStyle &= ~WS_DISABLED;
			EnableWindow (pDC->hwndUpDown, TRUE);
		}
		else
		{
			pDC->dwStyle |= WS_DISABLED;
			EnableWindow (pDC->hwndUpDown, FALSE);
		}

		SendMessage (pDC->hwndText[DAYS], msg, wParam, lParam);
		SendMessage (pDC->hwndText[HOURS], msg, wParam, lParam);
		SendMessage (pDC->hwndText[MINS], msg, wParam, lParam);

		SendMessage (pDC->hwndEdit[DAYS], msg, wParam, lParam);
		SendMessage (pDC->hwndEdit[HOURS], msg, wParam, lParam);
		SendMessage (pDC->hwndEdit[MINS], msg, wParam, lParam);

		InvalidateRect (hwnd, NULL, TRUE);
		return 0;

	case PGP_DCM_SETDURATION :
		pDC->ulDuration = lParam;
		sDisplayDuration (pDC);
		break;

	case PGP_DCM_GETDURATION :
		*(PULONG)lParam = pDC->ulDuration;
		break;

	case PGP_DCM_SETMINDURATION :
		pDC->ulMinDuration = (ULONG)lParam;
		break;

	case PGP_DCM_SETMAXDURATION :
		pDC->ulMaxDuration = (ULONG)lParam;
		break;

	case PGP_DCM_SETTEXT :
		lstrcpyn (&pDC->szText[wParam][0], (LPSTR)lParam, MAXTEXTLEN);
		sSetControls (hwnd, pDC);
		InvalidateRect (hwnd, NULL, TRUE);
		break;
	} 
	return (DefWindowProc (hwnd, msg, wParam, lParam));
}
コード例 #3
0
ファイル: ioptutil.c プロジェクト: NoSuchProcess/OrangeC
BITARRAY *sallocbit(int size)
{
    BITARRAY *rv = sAlloc(sizeof(BITARRAY) - 1 + (size + (BITINTBITS-1))/BITINTBITS * sizeof(BITINT));
    rv->count = size;
    return rv;
}
コード例 #4
0
ファイル: ilive.c プロジェクト: jossk/OrangeC
static void liveOut()
{
    BITINT inWorkList[8192];
    unsigned short *workList = sAlloc((blockCount + 1) * sizeof(unsigned short));
    int i;
    int head = 0, tail = 0;
    int tempDWords = (tempCount + BITINTBITS-1)/BITINTBITS;
    memset(inWorkList, 0, (blockCount + BITINTBITS-1)/BITINTBITS * sizeof(BITINT));
    workList[head++] = exitBlock;
    setbit(inWorkList, exitBlock);
    while (tail != head)
    {
        unsigned n = workList[tail++];
        BLOCKLIST *bl = blockArray[n]->pred;
        while (bl)
        {
            BITINT *b;
            BITINT r;
            n = bl->block->blocknum;
            b = inWorkList + (n/BITINTBITS);
            r = 1 << (n % BITINTBITS);
            if (!(*b & r))
            {
                *b |= r;
                workList[head++] = n;
            }
            bl = bl->next;
        }
    }
    tail = 0;
    while (head != tail)
    {
        BOOL changed = FALSE;
        unsigned n = workList[tail];
        BLOCK *b = blockArray[n];
        BLOCKLIST *bl = b->succ;
        int j;
        BITINT *gen, *kills, *live, *outb;
        if (++tail == blockCount + 1)
            tail = 0;
        clearbit(inWorkList, n);
        memset(b->liveOut, 0 , tempDWords * sizeof(BITINT));
        while (bl)
        {
            live = bl->block->liveIn;
            outb = b->liveOut;
            for (j=0; j < tempDWords; j++, live++, outb++)
            {
                if (*live)
                    *outb |= *live;
            }
            bl = bl->next;
        }
        live = b->liveIn;
        gen = b->liveGen;
        kills = b->liveKills;
        outb = b->liveOut;
        for (j=0; j < tempDWords; j++, gen++,kills++,live++, outb++)
        {
            BITINT c = *gen | (*outb & ~*kills);
            if (changed)
                *live = c;
            else if (c != *live)
            {
                *live = c;
                changed = TRUE;
            }
        }
        if (changed)
        {
            bl = b->pred;
            while (bl)
            {
                BITINT *b;
                BITINT r;
                n = bl->block->blocknum;
                b = inWorkList + (n/BITINTBITS);
                r = 1 << (n % BITINTBITS);
                if (!(*b & r))
                {
                    *b |= r;
                    workList[head] = n;
                    if (++head == blockCount + 1)
                        head = 0;
                }
                bl = bl->next;
            }
        }
    }
    /* in the ICD file display live variables at the end of each block */
    if (cparams.prm_icdfile)
    {
        for (i = 0; i < blockCount; i++)
        {
            if (blockArray[i])
            {
                QUAD *t = blockArray[i]->tail->fwd;
                /* this doesn't follow the normal handling rules
                 * so we remove and insert it by hand
                 */
                if (t && t->dc.opcode == i_blockend)
                {
                    t->back->fwd = t->fwd;
                    if (t->fwd)
                        t->fwd->back = t->back;
                }
                    
                if (blockArray[i]->liveOut)
                {
                    QUAD *q = Alloc(sizeof(QUAD));
                    t = blockArray[i]->tail;
                    q->dc.opcode = i_blockend;
                    q->dc.v.data = blockArray[i]->liveOut;
                    q->block = blockArray[i];
                    q->fwd = t->fwd;
                    q->back = t;
                    if (t->fwd)
                        t->fwd->back = q;
                    t->fwd = q;
                }
            }
        }
    }
}