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

📄 dvbuild.c

📁 DataDraw is an ultra-fast persistent database for high performance programs written in C. It s so fa
💻 C
字号:
/* * Copyright (C) 2006 Bill Cox * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License  * along with this program; if not, write to the Free Software  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA *//*--------------------------------------------------------------------------------------------------  Constructors--------------------------------------------------------------------------------------------------*/#include "dv.h"/*--------------------------------------------------------------------------------------------------  Add a new directory to the module path.--------------------------------------------------------------------------------------------------*/dvModpath dvModpathCreate(    utSym sym){    dvModpath modpath = dvModpathAlloc();    dvModpathSetSym(modpath, sym);    dvRootAppendModpath(dvTheRoot, modpath);    return modpath;}/*--------------------------------------------------------------------------------------------------  Build a new module object.--------------------------------------------------------------------------------------------------*/dvModule dvModuleCreate(    utSym sym,    utSym prefix){    dvModule module = dvModuleAlloc();    utSym lowerPrefix;    dvModuleSetSym(module, sym);    if(prefix == utSymNull) {        prefix = sym;    }    lowerPrefix = utSymCreate(utStringToLowerCase(utSymGetName(prefix)));    dvModuleSetPrefixSym(module, lowerPrefix);    dvRootAppendModule(dvTheRoot, module);    return module;}/*--------------------------------------------------------------------------------------------------  Build a new enum object.--------------------------------------------------------------------------------------------------*/dvEnum dvEnumCreate(    dvModule module,    utSym sym,    utSym prefix){    dvEnum theEnum = dvEnumAlloc();    if(prefix == utSymNull) {        prefix = utSymCreate("");    }    dvEnumSetSym(theEnum, sym);    dvEnumSetPrefixSym(theEnum, prefix);    dvModuleAppendEnum(module, theEnum);    return theEnum;}/*--------------------------------------------------------------------------------------------------  Build a new entry object.--------------------------------------------------------------------------------------------------*/dvEntry dvEntryCreate(    dvEnum owningEnum,    utSym sym,    uint32 value){    dvEntry entry = dvEntryAlloc();    dvEntrySetSym(entry, sym);    dvEntrySetValue(entry, value);    dvEnumAppendEntry(owningEnum, entry);    return entry;}/*--------------------------------------------------------------------------------------------------  Build a new typedef object.--------------------------------------------------------------------------------------------------*/dvTypedef dvTypedefCreate(    dvModule module,    utSym sym){    dvTypedef theTypedef = dvTypedefAlloc();    dvTypedefSetSym(theTypedef, sym);    dvModuleAppendTypedef(module, theTypedef);    return theTypedef;}/*--------------------------------------------------------------------------------------------------  Create a new schema, an object for organizing classes into logical groups.--------------------------------------------------------------------------------------------------*/dvSchema dvSchemaCreate(    dvModule module,    utSym sym){    dvSchema schema = dvSchemaAlloc();    dvSchemaSetSym(schema, sym);    dvModuleAppendSchema(module, schema);    return schema;}/*--------------------------------------------------------------------------------------------------  Create a new class.--------------------------------------------------------------------------------------------------*/dvClass dvClassCreate(    dvModule module,    dvSchema schema,    utSym sym,    dvClass baseClass){    dvClass theClass = dvModuleFindClass(module, sym);    if(theClass == dvClassNull) {        theClass = dvClassAlloc();        dvClassSetSym(theClass, sym);        dvModuleAppendClass(module, theClass);        dvClassSetReferenceSize(theClass, 32);        dvClassSetMemoryStyle(theClass, MEM_FREE_LIST);    }    if(schema != dvSchemaNull && dvClassGetSchema(theClass) == dvSchemaNull) {        dvSchemaAppendClass(schema, theClass);    }    if(baseClass != dvClassNull && dvClassGetBaseClass(theClass) == dvClassNull) {        dvClassAppendDerivedClass(baseClass, theClass);    }    return theClass;}/*--------------------------------------------------------------------------------------------------  Create a new property.--------------------------------------------------------------------------------------------------*/dvProperty dvPropertyCreate(    dvClass owningClass,    dvUnion owningUnion,    dvPropertyType type,    utSym sym){    dvProperty property = dvClassFindProperty(owningClass, sym);    if(property != dvPropertyNull) {        utWarning("Property %s already exists on class %s", utSymGetName(sym),            dvClassGetName(owningClass));        if(dvPropertyGetClass(property) != owningClass ||                dvPropertyGetUnion(property) != owningUnion ||                dvPropertyGetType(property) != type) {            utExit("Property %s defined differently the second time", utSymGetName(sym));        }        return property;    }    property = dvPropertyAlloc();    dvPropertySetType(property, type);    dvPropertySetSym(property, sym);    dvClassAppendProperty(owningClass, property);    if(owningUnion != dvUnionNull) {        dvUnionAppendProperty(owningUnion, property);    }    return property;}/*--------------------------------------------------------------------------------------------------  Create a new union.--------------------------------------------------------------------------------------------------*/dvUnion dvUnionCreate(    dvClass owningClass,    utSym propertySym,    uint16 unionNumber){    dvUnion theUnion = dvUnionAlloc();    dvClassAppendUnion(owningClass, theUnion);    dvUnionSetPropertySym(theUnion, propertySym);    dvUnionSetNumber(theUnion, unionNumber);    return theUnion;}/*--------------------------------------------------------------------------------------------------  Create a new relationship.--------------------------------------------------------------------------------------------------*/dvRelationship dvRelationshipCreate(    dvClass parent,    dvClass child,    dvRelationshipType type,    utSym parentLabel,    utSym childLabel){    dvRelationship relationship = dvRelationshipAlloc();    if(parentLabel == utSymNull) {        parentLabel = utSymCreate("");    }    if(childLabel == utSymNull) {        childLabel = utSymCreate("");    }    dvRelationshipSetType(relationship, type);    dvRelationshipSetParentLabelSym(relationship, parentLabel);    dvRelationshipSetChildLabelSym(relationship, childLabel);    dvRelationshipSetAccessParent(relationship, true);    dvRelationshipSetAccessChild(relationship, true);    dvClassAppendChildRelationship(parent, relationship);    dvClassAppendParentRelationship(child, relationship);    return relationship;}/*--------------------------------------------------------------------------------------------------  Create a new link.--------------------------------------------------------------------------------------------------*/dvLink dvLinkCreate(    dvModule importModule,    dvModule exportModule){    dvLink link = dvLinkAlloc();    dvModuleAppendImportLink(importModule, link);    dvModuleAppendExportLink(exportModule, link);    return link;}

⌨️ 快捷键说明

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