⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mrmtypes.c

📁 安装DDD之前
💻 C
📖 第 1 页 / 共 2 页
字号:
    ColorTable *this = (ColorTable *)malloc(sizeof(ColorTable));    this->theExpression.type = MrmRtypeColorTable;    this->ColorVector = NULL;    this->theExpression.value = (long)this->ColorVector;    this->theExpression.Emit = (PFI)ColorTableEmit;    return this;}voidColorTableAppend(ColorTable *this, char *Representation, Color *color){    ColorElement **i;    for (i = &this->ColorVector; *i != NULL; i = &((*i)->Next));    *i = ColorElementNew(Representation, color);}voidColorTableEmit(ColorTable *this){    ColorElement **j;    int size = 0;    fputc(this->theExpression.type, outFile);    for (j = &this->ColorVector; *j != NULL; j = &((*j)->Next))    {	size++;    }    fwrite(&size, sizeof(size), 1, outFile);    for (j = &this->ColorVector; *j != NULL; j = &((*j)->Next))    {	ColorElementEmit(*j);    };}Char8Vector *Char8VectorNew(void){    Char8Vector *this = (Char8Vector *)malloc(sizeof(Char8Vector));    this->theExpression.type = MrmRtypeChar8Vector;    this->CharVector = NULL;    this->theExpression.value = (long)&this->CharVector;    this->theExpression.Emit = (PFI)Char8VectorEmit;    return this;}static Char8Element *Char8ElementNew(char *s){    Char8Element *this = (Char8Element *)malloc(sizeof(Char8Element));    this->Next = NULL;    if (strlen(s) > 255)	/* FIX ME */    {	__MrmExit(LOC, "String too long\n");    }    strcpy(this->lvalue, s);    return this;}voidChar8VectorAppend(Char8Vector *this, char *s){    Char8Element **j;    for (j = &this->CharVector; *j != NULL; j = &((*j)->Next));    *j = Char8ElementNew(s);}voidChar8VectorEmit(Char8Vector *this){    Char8Element **j;    fputc(this->theExpression.type, outFile);    for (j = &this->CharVector; *j != NULL; j = &((*j)->Next))    {	fputs((*j)->lvalue, outFile);	fputc('"', outFile);    };    fputc(0, outFile);}BooleanM *BooleanMNew(Bool i){    BooleanM *this = (BooleanM *)malloc(sizeof(BooleanM));    this->theExpression.value = i;    this->theExpression.type = MrmRtypeBoolean;    this->theExpression.Emit = (PFI)BooleanMEmit;    return this;}voidBooleanMEmit(BooleanM *this){    fputc(this->theExpression.type, outFile);    fwrite(&this->theExpression.value, sizeof(long), 1, outFile);}Integer *IntegerNew(int i){    Integer *this = (Integer *)malloc(sizeof(Integer));    this->theExpression.value = (long)i;    this->theExpression.type = MrmRtypeInteger;    this->theExpression.Emit = (PFI)IntegerEmit;    return this;}voidIntegerEmit(Integer *this){    fputc(this->theExpression.type, outFile);    fwrite(&this->theExpression.value, sizeof(long), 1, outFile);}#if 0static intIntegerGetEvalValue(Integer *this){    return ((int)this->theExpression.value);}#endifAddrName *AddrNameNew(char *s){    AddrName *this = (AddrName *)malloc(sizeof(AddrName));    strcpy(this->lvalue, s);    this->theExpression.value = (long)this->lvalue;    this->theExpression.type = MrmRtypeAddrName;    this->theExpression.Emit = (PFI)AddrNameEmit;    return this;}voidAddrNameEmit(AddrName *this){    fputc(this->theExpression.type, outFile);    fputs((char *)this->theExpression.value, outFile);    fputc(0, outFile);}static CStringElement *CStringElementNew(char *s, char *fs,		  int IsAddress, int IsSeparator){    CStringElement *this = (CStringElement *) malloc(sizeof(CStringElement));    this->Next = NULL;    this->theFontSet = fs;    this->IsAddress = IsAddress;    this->IsSeparator = IsSeparator;    strcpy(this->lvalue, s);    return this;}static voidCStringElementEmit(CStringElement * this){    fputs((char *)this->lvalue, outFile);    fputc(0, outFile);    if (this->theFontSet)    {	fputs((char *)this->theFontSet, outFile);    }    fputc(0, outFile);    fputc(this->IsAddress, outFile);    fputc(this->IsSeparator, outFile);}CString *CStringNew(char *s, char *fs, char IsAddress, char IsSeparator){    CString *this = (CString *)malloc(sizeof(CString));    this->StringVector = CStringElementNew(s, fs, IsAddress, IsSeparator);    this->theExpression.type = MrmRtypeCString;    this->theExpression.value = (long)this->StringVector;    this->theExpression.Emit = (PFI)CStringEmit;    return this;}CString *CStringNew1(AddrName *add){    return CStringNew((char *)add->theExpression.value, NULL, 1, 0);}CString *CStringAdd(CString *this, CString *s){    CStringElement **j;    for (j = &this->StringVector; *j != NULL; j = &((*j)->Next));    *j = s->StringVector;    return this;}voidCStringEmit(CString *this){    CStringElement **j;    fputc(this->theExpression.type, outFile);    for (j = &this->StringVector; *j != NULL; j = &((*j)->Next))    {	CStringElementEmit(*j);    };    fputc(0, outFile);}Char8 *Char8New1(char *s, FontSet * fs){    Char8 *this = Char8New(s);    this->theFontSet = fs;    return this;}Char8 *Char8New(char *s){    Char8 *this = (Char8 *)malloc(sizeof(Char8));    char *q = s;    char *q1 = s;    while (*q)    {	if ('\\' == *q)	{	    q++;	    switch (*q)	    {	    case 'a':		*q1++ = '\a';		break;	    case 'n':		*q1++ = '\n';		break;	    case 'r':		*q1++ = '\r';		break;	    case 't':		*q1++ = '\t';		break;	    case '\\':		*q1++ = '\\';		break;	    default:		*q1++ = *q;		break;	    }	    q++;	}	else	{	    *q1++ = *q++;	}    }    *q1 = '\0';    this->theExpression.type = MrmRtypeChar8;    strcpy(this->lvalue, s);    this->theExpression.value = (long)this->lvalue;    this->theExpression.Emit = (PFI)Char8Emit;    this->theFontSet = NULL;    return this;}voidChar8Emit(Char8 *this){    fputc(this->theExpression.type, outFile);    fputs((char *)this->theExpression.value, outFile);    fputc(0, outFile);    if (this->theFontSet)    {	fputs((char *)this->theFontSet->fontset.name, outFile);    }    fputc(0, outFile);}PixmapImage *PixmapImageNew(char *ColorMap, Char8Vector *pixmap){    char *current = NULL, *source = NULL;    Char8Element **i;    PixmapImage *this = (PixmapImage *)malloc(sizeof(PixmapImage));    this->theExpression.type = MrmRtypePixmapImage;    this->thePixmap.height = 0;    this->theData = NULL;    if (ColorMap)    {	this->theColorMap = __MrmStore(ColorMap);    }    else    {	this->theColorMap = NULL;    }    this->thePixmap.width = strlen(pixmap->CharVector->lvalue);    for (i = &pixmap->CharVector; *i != NULL; i = &((*i)->Next))    {	this->thePixmap.height += 1;    }    current = this->theData =	(char *)malloc(this->thePixmap.height * this->thePixmap.width);    for (i = &pixmap->CharVector; *i != NULL; i = &((*i)->Next))    {	source = (*i)->lvalue;	if (NULL == source)	{	    __MrmExit(LOC, "Source?\n");	}	while (*source)	{	    *current++ = *source++;	}    }    this->thePixmap.data = this->theData;    this->theExpression.value = (long)&this->thePixmap;    this->theExpression.Emit = (PFI)PixmapImageEmit;    return this;}voidPixmapImageEmit(PixmapImage *this){    fputc(this->theExpression.type, outFile);    fwrite((char *)this->theExpression.value, 1, sizeof(int) * 2, outFile);    if (this->theColorMap)    {	fputs(this->theColorMap, outFile);    }    fputc(0, outFile);    fwrite(this->thePixmap.data, 1,	   this->thePixmap.width * this->thePixmap.height, outFile);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -