12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829 |
- /*
- * CDE - Common Desktop Environment
- *
- * Copyright (c) 1993-2012, The Open Group. All rights reserved.
- *
- * These libraries and programs are free software; you can
- * redistribute them and/or modify them under the terms of the GNU
- * Lesser General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * These libraries and programs are distributed in the hope that
- * they will be useful, but WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with these librararies and programs; if not, write
- * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301 USA
- */
- /*
- * @OSF_COPYRIGHT@
- * COPYRIGHT NOTICE
- * Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
- * ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
- * the full copyright text.
- */
- /*
- * HISTORY
- */
- #ifdef REV_INFO
- #ifndef lint
- static char rcsid[] = "$XConsortium: wmlresolve.c /main/9 1995/08/29 11:11:05 drk $"
- #endif
- #endif
- /*
- * (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
- /*
- * This module contains all routines which perform semantic analysis of
- * the parsed WML specification. It is responsible for building all
- * ordered structures which can be directly translated into literal
- * code values for the various .h files. It is responsible for performing
- * inheritance of resources for all classes.
- *
- * Input:
- * the ordered list of syntactic objects in wml_synobj_ptr
- *
- * Output:
- *
- */
- #include "wml.h"
- #if defined(__STDC__)
- #include <stdlib.h>
- #endif
- #include <stdio.h>
- /*
- * Routines used only in this module
- */
- void wmlResolveGenerateSymK ();
- void wmlResolveValidateClass ();
- void wmlResolvePrintReport ();
- void wmlResolveSymKDataType ();
- void wmlResolveSymKChild ();
- void wmlResolveSymKEnumVal ();
- void wmlResolveSymKEnumSet ();
- void wmlResolveSymKReason ();
- void wmlResolveSymKArgument ();
- void wmlResolveSymKRelated ();
- void wmlResolveSymKClass ();
- void wmlResolveSymKCtrlList ();
- void wmlResolveSymKCharSet ();
- void wmlResolveClassInherit ();
- void wmlResolveClearRefPointers ();
- void wmlResolveInitRefObj ();
- void wmlResolveInitChildRefObj ();
- void wmlResolvePrintClass ();
- void wmlResolvePrintClassArgs ();
- void wmlResolvePrintClassReasons ();
- ObjectPtr wmlResolveFindObject ();
- void wmlIssueReferenceError ();
- void wmlIssueIllegalReferenceError ();
- void wmlIssueError ();
- /*
- * The control routine for semantic analysis. It calls the various phases.
- */
- void wmlResolveDescriptors ()
- {
- /*
- * Perform the code assignment pass. This results in assignment of sym_k_...
- * codes to all entities. Also, all objects and cross-linking are validated.
- */
- wmlResolveGenerateSymK ();
- printf ("\nInitial validation and reference resolution complete");
- /*
- * Perform class inheritance and validation
- */
- wmlResolveValidateClass ();
- printf ("\nClass validation and inheritance complete");
- /*
- * Print a report
- */
- if ( wml_err_count > 0 ) return;
- wmlResolvePrintReport ();
- }
- /*
- * Routine to linearize and assign sym_k... literals for objects. Simply
- * a dispatching routine.
- */
- void wmlResolveGenerateSymK ()
- {
- /*
- * Process the datatype objects
- */
- wmlResolveSymKDataType ();
- /*
- * Process the enumeration value and enumeration sets
- */
- wmlResolveSymKEnumVal ();
- wmlResolveSymKEnumSet ();
- /*
- * Process the resources, producing argument and reason vectors.
- */
- wmlResolveSymKReason ();
- wmlResolveSymKArgument ();
- /*
- * Bind related arguments
- */
- wmlResolveSymKRelated ();
- /*
- * Process the class definitions
- */
- wmlResolveSymKClass ();
- /*
- * Process the controls list definitions
- */
- wmlResolveSymKCtrlList ();
- /*
- * Process the charset objects
- */
- wmlResolveSymKCharSet ();
- /* Process the child definitions. */
- wmlResolveSymKChild();
- }
- /*
- * Routine to linearize data types
- *
- * - Generate the wml_obj_datatype... vector of resolved data type objects,
- * ordered lexicographically.
- * Do name processing, and acquire links to any other objects named in
- * the syntactic descriptor.
- */
- void wmlResolveSymKDataType ()
- {
- WmlSynDataTypeDefPtr cursyn; /* current syntactic object */
- WmlDataTypeDefPtr newobj; /* new resolved object */
- int ndx; /* loop index */
- /*
- * Initialize the object vector. Then process the syntactic vector,
- * processing each datatype object encountered (the vector is ordered).
- * create and append a resolved object for each one encountered. This
- * will be ordered as well.
- */
- wmlInitHList (wml_obj_datatype_ptr, 50, TRUE);
- for ( ndx=0 ; ndx<wml_synobj_ptr->cnt ; ndx++ )
- {
- cursyn = (WmlSynDataTypeDefPtr) wml_synobj_ptr->hvec[ndx].objptr;
- if ( cursyn->validation != WmlDataTypeDefValid ) continue;
- /*
- * Create and initialize new object. Append to resolved object vector.
- */
- newobj = (WmlDataTypeDefPtr) malloc (sizeof(WmlDataTypeDef));
- newobj->syndef = cursyn;
- cursyn->rslvdef = newobj;
- if ( cursyn->int_lit != NULL )
- newobj->tkname = cursyn->int_lit;
- else
- newobj->tkname = cursyn->name;
- wmlInsertInHList (wml_obj_datatype_ptr, newobj->tkname, (ObjectPtr)newobj);
- /*
- * Validate any object references in the syntactic object
- */
- }
- }
- /*
- * Routine to linearize children
- *
- * - Generate the wml_obj_child... vector of resolved child objects,
- * ordered lexicographically. Assign sym_k_... values while doing so.
- * Link child to its class.
- */
- void wmlResolveSymKChild ()
- {
- WmlSynChildDefPtr cursyn; /* current syntactic object */
- WmlChildDefPtr newobj; /* new resolved object */
- int code; /* assigned sym_k code value */
- int ndx; /* loop index */
- /*
- * Initialize the object vector. Then process the syntactic vector,
- * processing each child object encountered (the vector is ordered).
- * create and append a resolved object for each one encountered. This
- * will be ordered as well.
- */
- wmlInitHList (wml_obj_child_ptr, 50, TRUE);
- for ( ndx=0 ; ndx<wml_synobj_ptr->cnt ; ndx++ )
- {
- cursyn = (WmlSynChildDefPtr) wml_synobj_ptr->hvec[ndx].objptr;
- if ( cursyn->validation != WmlChildDefValid ) continue;
- /*
- * Create and initialize new object. Append to resolved object vector.
- */
- newobj = (WmlChildDefPtr) malloc (sizeof(WmlChildDef));
- newobj->syndef = cursyn;
- cursyn->rslvdef = newobj;
- newobj->tkname = cursyn->name;
- wmlInsertInHList (wml_obj_child_ptr, newobj->tkname, (ObjectPtr)newobj);
- /* Link class to the resolved object. */
- if (cursyn->class != NULL)
- newobj->class = (WmlClassDefPtr)
- wmlResolveFindObject(cursyn->class, WmlClassDefValid, cursyn->name);
- }
- /*
- * All objects are in the vector. The order is the code order, so
- * process it again and assign codes to each object
- */
- code = 1;
- for ( ndx=0 ; ndx<wml_obj_child_ptr->cnt ; ndx++ )
- {
- newobj = (WmlChildDefPtr) wml_obj_child_ptr->hvec[ndx].objptr;
- newobj->sym_code = code;
- code += 1;
- }
- }
- /*
- * Routine to linearize and assign sym_k values to enumeration values
- *
- * - Generate the wml_obj_datatype... vector of resolved data type objects,
- * ordered lexicographically. No sym_k_... values are needed for
- * enumeration values, so don't assign any.
- */
- void wmlResolveSymKEnumVal ()
- {
- WmlSynEnumSetDefPtr cures; /* current enumeration set */
- WmlSynEnumSetValDefPtr curesv; /* current enum set value */
- WmlSynEnumValueDefPtr cursyn; /* current syntactic object */
- WmlEnumValueDefPtr newobj; /* new resolved object */
- int ndx; /* loop index */
- int code; /* sym_k_... code */
- /*
- * Perform defaulting. Process all the enumeration sets, and define a
- * syntactic object for every enumeration value named in an enumeration set
- * which has no syntactic entry. If there is an error in a name, then
- * this error won't be detected until we attempt to compile the output .h files.
- */
- for ( ndx=0 ; ndx<wml_synobj_ptr->cnt ; ndx++ )
- {
- cures = (WmlSynEnumSetDefPtr) wml_synobj_ptr->hvec[ndx].objptr;
- if ( cures->validation != WmlEnumSetDefValid ) continue;
- for (curesv=cures->values ; curesv!=NULL ; curesv=curesv->next)
- if ( wmlFindInHList(wml_synobj_ptr,curesv->name) < 0 )
- wmlCreateEnumValue (curesv->name);
- }
- /*
- * Initialize the object vector. Then process the syntactic vector,
- * processing each enumeration value object encountered (the vector is ordered).
- * create and append a resolved object for each one encountered. This
- * will be ordered as well.
- */
- wmlInitHList (wml_obj_enumval_ptr, 50, TRUE);
- for ( ndx=0 ; ndx<wml_synobj_ptr->cnt ; ndx++ )
- {
- cursyn = (WmlSynEnumValueDefPtr) wml_synobj_ptr->hvec[ndx].objptr;
- if ( cursyn->validation != WmlEnumValueDefValid ) continue;
- /*
- * Create and initialize new object. Append to resolved object vector.
- */
- newobj = (WmlEnumValueDefPtr) malloc (sizeof(WmlEnumValueDef));
- newobj->syndef = cursyn;
- cursyn->rslvdef = newobj;
- wmlInsertInHList (wml_obj_enumval_ptr, cursyn->name, (ObjectPtr)newobj);
- }
- /*
- * All objects are in the vector. That order is the code order, so
- * process it again and assign codes to each object
- */
- code = 1;
- for ( ndx=0 ; ndx<wml_obj_enumval_ptr->cnt ; ndx++ )
- {
- newobj = (WmlEnumValueDefPtr) wml_obj_enumval_ptr->hvec[ndx].objptr;
- newobj->sym_code = code;
- code += 1;
- }
- }
- /*
- * Routine to linearize and assign sym_k values to enumeration sets
- *
- * - Generate the wml_obj_datatype... vector of resolved data type objects,
- * ordered lexicographically. No sym_k_... values are needed for
- * enumeration values, so don't assign any.
- */
- void wmlResolveSymKEnumSet ()
- {
- WmlSynEnumSetDefPtr cursyn; /* current syntactic object */
- WmlEnumSetDefPtr newobj; /* new resolved object */
- int ndx; /* loop index */
- int code; /* sym_k_... code */
- WmlSynEnumSetValDefPtr esvelm; /* current syntactic list element */
- WmlEnumValueDefPtr evobj; /* current enumeration value */
- WmlEnumSetValDefPtr esvobj; /* current list element */
- /*
- * Initialize the object vector. Then process the syntactic vector,
- * processing each enumeration set object encountered (the vector is ordered).
- * create and append a resolved object for each one encountered. This
- * will be ordered as well.
- */
- wmlInitHList (wml_obj_enumset_ptr, 20, TRUE);
- for ( ndx=0 ; ndx<wml_synobj_ptr->cnt ; ndx++ )
- {
- cursyn = (WmlSynEnumSetDefPtr) wml_synobj_ptr->hvec[ndx].objptr;
- if ( cursyn->validation != WmlEnumSetDefValid ) continue;
- /*
- * Create and initialize new object. Append to resolved object vector.
- */
- newobj = (WmlEnumSetDefPtr) malloc (sizeof(WmlEnumSetDef));
- newobj->syndef = cursyn;
- cursyn->rslvdef = newobj;
- newobj->tkname = cursyn->name;
- newobj->dtype_def = (WmlDataTypeDefPtr)
- wmlResolveFindObject (cursyn->datatype,
- WmlDataTypeDefValid,
- cursyn->name);
- wmlInsertInHList (wml_obj_enumset_ptr, newobj->tkname, (ObjectPtr)newobj);
- }
- /*
- * All objects are in the vector. That order is the code order, so
- * process it again and assign codes to each object. Simultaneously construct
- * a vector of resolved enumeration values, and count them.
- */
- code = 1;
- for ( ndx=0 ; ndx<wml_obj_enumset_ptr->cnt ; ndx++ )
- {
- newobj = (WmlEnumSetDefPtr) wml_obj_enumset_ptr->hvec[ndx].objptr;
- newobj->sym_code = code;
- code += 1;
- /*
- * Validate and construct a resolved enumeration value list
- */
- cursyn = newobj->syndef;
- newobj->values_cnt = 0;
- newobj->values = NULL;
- for ( esvelm=cursyn->values ; esvelm!=NULL ; esvelm=esvelm->next )
- {
- evobj = (WmlEnumValueDefPtr)
- wmlResolveFindObject (esvelm->name,
- WmlEnumValueDefValid,
- cursyn->name);
- if ( evobj == NULL ) continue;
- esvobj = (WmlEnumSetValDefPtr) malloc (sizeof(WmlEnumSetValDef));
- esvobj->value = evobj;
- esvobj->next = newobj->values;
- newobj->values = esvobj;
- newobj->values_cnt += 1;
- }
- }
- }
- /*
- * Routine to linearize and assign sym_k values to reasons.
- *
- * - Generate the wml_obj_reason... vector of resolved reason objects,
- * ordered lexicographically. Assign a sym_k_... value as this is done.
- * Do name processing, and acquire links to any other objects named in
- * the syntactic descriptor.
- */
- void wmlResolveSymKReason ()
- {
- WmlSynResourceDefPtr cursyn; /* current syntactic object */
- WmlResourceDefPtr newobj; /* new resolved object */
- int ndx; /* loop index */
- int code; /* assigned sym_k code value */
- char errmsg[300];
- /*
- * Initialize the object vector. Then process the syntactic vector,
- * processing each reason resource object encountered (the vector is ordered).
- * create and append a resolved object for each one encountered. This
- * will be ordered as well.
- */
- wmlInitHList (wml_obj_reason_ptr, 100, TRUE);
- for ( ndx=0 ; ndx<wml_synobj_ptr->cnt ; ndx++ )
- {
- cursyn = (WmlSynResourceDefPtr) wml_synobj_ptr->hvec[ndx].objptr;
- if ( cursyn->validation != WmlResourceDefValid ) continue;
- if ( cursyn->type != WmlResourceTypeReason ) continue;
- newobj = (WmlResourceDefPtr) malloc (sizeof(WmlResourceDef));
- /*
- * Create and initialize new object. Append to resolved object vector.
- */
- newobj->syndef = cursyn;
- cursyn->rslvdef = newobj;
- if ( cursyn->int_lit != NULL )
- newobj->tkname = cursyn->int_lit;
- else
- newobj->tkname = cursyn->name;
- newobj->dtype_def = NULL;
- newobj->enumset_def = NULL;
- newobj->related_code = 0;
- wmlInsertInHList (wml_obj_reason_ptr, newobj->tkname, (ObjectPtr)newobj);
- /*
- * Validate any object references in the syntactic object
- * Reason can't bind to some objects.
- */
- if ( cursyn->datatype != NULL )
- wmlIssueIllegalReferenceError (cursyn->name, "DataType");
- }
- /*
- * All objects are in the vector. That order is the code order, so
- * process it again and assign codes to each object
- */
- code = 1;
- for ( ndx=0 ; ndx<wml_obj_reason_ptr->cnt ; ndx++ )
- {
- newobj = (WmlResourceDefPtr) wml_obj_reason_ptr->hvec[ndx].objptr;
- newobj->sym_code = code;
- code += 1;
- }
- }
- /*
- * Routine to linearize and assign sym_k values to arguments.
- *
- * - Generate the wml_obj_arg... vector of resovled reason objects,
- * ordered lexicographically. Assign a sym_k_... values while doing so.
- * validate the data type for each argument, and link it to its data type
- * object.
- * Do name processing, and acquire links to any other objects named in
- * the syntactic descriptor.
- */
- void wmlResolveSymKArgument ()
- {
- WmlSynResourceDefPtr cursyn; /* current syntactic object */
- WmlResourceDefPtr newobj; /* new resolved object */
- int ndx; /* loop index */
- int code; /* assigned sym_k code value */
- char errmsg[300];
- /*
- * Initialize the object vector. Then process the syntactic vector,
- * processing each reason resource object encountered (the vector is ordered).
- * create and append a resolved object for each one encountered. This
- * will be ordered as well.
- */
- wmlInitHList (wml_obj_arg_ptr, 500, TRUE);
- for ( ndx=0 ; ndx<wml_synobj_ptr->cnt ; ndx++ )
- {
- cursyn = (WmlSynResourceDefPtr) wml_synobj_ptr->hvec[ndx].objptr;
- if ( cursyn->validation != WmlResourceDefValid ) continue;
- if ( cursyn->type == WmlResourceTypeReason ) continue;
- newobj = (WmlResourceDefPtr) malloc (sizeof(WmlResourceDef));
- /*
- * Create and initialize new object. Append to resolved object vector.
- */
- newobj->syndef = cursyn;
- cursyn->rslvdef = newobj;
- if ( cursyn->int_lit != NULL )
- newobj->tkname = cursyn->int_lit;
- else
- newobj->tkname = cursyn->name;
- newobj->related_code = 0;
- newobj->enumset_def = NULL;
- wmlInsertInHList (wml_obj_arg_ptr, newobj->tkname, (ObjectPtr)newobj);
- /*
- * Validate any object references in the syntactic object
- */
- newobj->dtype_def = (WmlDataTypeDefPtr)
- wmlResolveFindObject (cursyn->datatype,
- WmlDataTypeDefValid,
- cursyn->name);
- if ( cursyn->enumset != NULL )
- newobj->enumset_def = (WmlEnumSetDefPtr)
- wmlResolveFindObject (cursyn->enumset,
- WmlEnumSetDefValid,
- cursyn->name);
- }
- /*
- * All objects are in the vector. The order is the code order, so
- * process it again and assign codes to each object
- */
- code = 1;
- for ( ndx=0 ; ndx<wml_obj_arg_ptr->cnt ; ndx++ )
- {
- newobj = (WmlResourceDefPtr) wml_obj_arg_ptr->hvec[ndx].objptr;
- newobj->sym_code = code;
- code += 1;
- }
- }
- /*
- * Routine to resolve related argument references.
- *
- * Search the argument vector for any argument with its related
- * argument set. Find the related argument, and bind the relation.
- * The binding only goes one way.
- */
- void wmlResolveSymKRelated ()
- {
- WmlResourceDefPtr srcobj; /* object with related reference */
- WmlResourceDefPtr dstobj; /* other object in binding */
- WmlSynResourceDefPtr srcsynobj; /* source syntactic object */
- int ndx; /* loop index */
- /*
- * Scan all arguments for related argument bindings.
- */
- for ( ndx=0 ; ndx<wml_obj_arg_ptr->cnt ; ndx++ )
- {
- srcobj = (WmlResourceDefPtr) wml_obj_arg_ptr->hvec[ndx].objptr;
- srcsynobj = srcobj->syndef;
- if ( srcsynobj->related != NULL )
- {
- dstobj = (WmlResourceDefPtr)
- wmlResolveFindObject (srcsynobj->related,
- WmlResourceDefValid,
- srcsynobj->name);
- if ( dstobj != NULL )
- srcobj->related_code = dstobj->sym_code;
- }
- }
- }
-
- /*
- * Routine to linearize and assign sym_k values to classes
- *
- * There are two linearizations of classes:
- * - all classes in wml_obj_allclass...
- * - all widgets and gadgets in wml_obj_class...
- * Create and linearize all class objects into these vectors. Assign sym_k
- * codes. Link all subclasses to their superclasses. Perform name processing
- * and link to any other named object.
- *
- * Resources are not inherited and linked at this time.
- */
- void wmlResolveSymKClass ()
- {
- WmlSynClassDefPtr cursyn; /* current syntactic object */
- WmlClassDefPtr newobj; /* new resolved object */
- int ndx; /* loop index */
- int code; /* assigned sym_k code value */
- char errmsg[300];
- /*
- * Initialize the object vectors. Then process the syntactic vector,
- * processing each class object encountered (the vector is ordered).
- * create and append a resolved object for each one encountered. This
- * will be ordered as well.
- */
- wmlInitHList (wml_obj_allclass_ptr, 200, TRUE);
- wmlInitHList (wml_obj_class_ptr, 200, TRUE);
- for ( ndx=0 ; ndx<wml_synobj_ptr->cnt ; ndx++ )
- {
- cursyn = (WmlSynClassDefPtr) wml_synobj_ptr->hvec[ndx].objptr;
- if ( cursyn->validation != WmlClassDefValid ) continue;
- /*
- * Create and initialize new object. Append to resolved object vector.
- */
- newobj = (WmlClassDefPtr) malloc (sizeof(WmlClassDef));
- newobj->syndef = cursyn;
- cursyn->rslvdef = newobj;
- newobj->superclass = NULL;
- newobj->parentclass = NULL;
- if ( cursyn->int_lit != NULL )
- newobj->tkname = cursyn->int_lit;
- else
- newobj->tkname = cursyn->name;
- newobj->inherit_done = FALSE;
- newobj->arguments = NULL;
- newobj->reasons = NULL;
- newobj->controls = NULL;
- newobj->children = NULL;
- newobj->variant = NULL;
- newobj->nondialog = NULL;
- newobj->ctrlmapto = NULL;
- switch ( cursyn->type )
- {
- case WmlClassTypeMetaclass:
- wmlInsertInHList
- (wml_obj_allclass_ptr, newobj->tkname, (ObjectPtr)newobj);
- break;
- case WmlClassTypeGadget:
- case WmlClassTypeWidget:
- wmlInsertInHList
- (wml_obj_allclass_ptr, newobj->tkname, (ObjectPtr)newobj);
- wmlInsertInHList
- (wml_obj_class_ptr, newobj->tkname, (ObjectPtr)newobj);
- break;
- }
- /*
- * Require a convenience function name
- */
- if ( cursyn->type != WmlClassTypeMetaclass )
- if ( cursyn->convfunc == NULL )
- {
- sprintf (errmsg, "Class %s does not have a convenience function",
- cursyn->name);
- wmlIssueError (errmsg);
- }
- /*
- * Validate any object references in the syntactic object
- */
- if ( cursyn->ctrlmapto != NULL )
- newobj->ctrlmapto = (WmlResourceDefPtr)
- wmlResolveFindObject (cursyn->ctrlmapto,
- WmlResourceDefValid,
- cursyn->name);
- }
- /*
- * All objects are in the vector. That order is the code order, so
- * process it again and assign codes to each object
- */
- code = 1;
- for ( ndx=0 ; ndx<wml_obj_class_ptr->cnt ; ndx++ )
- {
- newobj = (WmlClassDefPtr) wml_obj_class_ptr->hvec[ndx].objptr;
- newobj->sym_code = code;
- code += 1;
- }
- }
- /*
- * Routine to validate controls lists
- *
- * Construct and linearize resolved controls lists. The linearized list
- * is used to resolve references.
- */
- void wmlResolveSymKCtrlList ()
- {
- WmlSynCtrlListDefPtr cursyn; /* current syntactic object */
- WmlCtrlListDefPtr newobj; /* new resolved object */
- WmlSynClassCtrlDefPtr refptr; /* current controls reference */
- WmlClassCtrlDefPtr ctrlobj; /* resolved control reference */
- WmlClassDefPtr classobj; /* the controlled class */
- int ndx; /* loop index */
- /*
- * Process each control list. Construct a resolved control list for each
- */
- wmlInitHList (wml_obj_ctrlist_ptr, 20, TRUE);
- for ( ndx=0 ; ndx<wml_synobj_ptr->cnt ; ndx++ )
- {
- cursyn = (WmlSynCtrlListDefPtr) wml_synobj_ptr->hvec[ndx].objptr;
- if ( cursyn->validation != WmlCtrlListDefValid ) continue;
- /*
- * Create and initialize new object. Append to resolved object vector.
- */
- newobj = (WmlCtrlListDefPtr) malloc (sizeof(WmlCtrlListDef));
- newobj->syndef = cursyn;
- cursyn->rslvdef = newobj;
- newobj->controls = NULL;
- wmlInsertInHList (wml_obj_ctrlist_ptr, cursyn->name, (ObjectPtr)newobj);
- /*
- * Validate and construct a resolved controls reference list.
- */
- for ( refptr=cursyn->controls ; refptr!=NULL ; refptr=refptr->next )
- {
- classobj = (WmlClassDefPtr)
- wmlResolveFindObject (refptr->name,
- WmlClassDefValid,
- cursyn->name);
- if ( classobj == NULL ) continue;
- ctrlobj = (WmlClassCtrlDefPtr) malloc (sizeof(WmlClassCtrlDef));
- ctrlobj->next = newobj->controls;
- newobj->controls = ctrlobj;
- ctrlobj->ctrl = classobj;
- }
- }
- }
- /*
- * Routine to linearize and assign sym_k values to character sets
- *
- * - Generate the wml_obj_charset... vector of resolved data type objects,
- * ordered lexicographically. Assign a sym_k... value as this is done.
- * Do name processing, and acquire links to any other objects named in
- * the syntactic descriptor.
- */
- void wmlResolveSymKCharSet ()
- {
- WmlSynCharSetDefPtr cursyn; /* current syntactic object */
- WmlCharSetDefPtr newobj; /* new resolved object */
- int ndx; /* loop index */
- int code; /* assigned sym_k code value */
- char errmsg[300];
- /*
- * Initialize the object vector. Then process the syntactic vector,
- * processing each charset object encountered (the vector is ordered).
- * create and append a resolved object for each one encountered. This
- * will be ordered as well.
- */
- wmlInitHList (wml_obj_charset_ptr, 50, TRUE);
- for ( ndx=0 ; ndx<wml_synobj_ptr->cnt ; ndx++ )
- {
- cursyn = (WmlSynCharSetDefPtr) wml_synobj_ptr->hvec[ndx].objptr;
- if ( cursyn->validation != WmlCharSetDefValid ) continue;
- /*
- * Create and initialize new object. Append to resolved object vector.
- */
- newobj = (WmlCharSetDefPtr) malloc (sizeof(WmlCharSetDef));
- newobj->syndef = cursyn;
- cursyn->rslvdef = newobj;
- if ( cursyn->int_lit != NULL )
- newobj->tkname = cursyn->int_lit;
- else
- newobj->tkname = cursyn->name;
- wmlInsertInHList (wml_obj_charset_ptr, newobj->tkname, (ObjectPtr)newobj);
- /*
- * Parsing direction defaults to writing direction if unspecified
- */
- if ( cursyn->parsedirection == WmlAttributeUnspecified )
- cursyn->parsedirection = cursyn->direction;
- /*
- * Require StandardsName attribute for character set
- */
- if ( cursyn->xms_name == NULL )
- {
- sprintf (errmsg, "CharacterSet %s does not have a StandardsName",
- cursyn->name);
- wmlIssueError (errmsg);
- }
- }
- /*
- * All objects are in the vector. That order is the code order, so
- * process it again and assign codes to each object. We start at code
- * 2 since 1 is reserved for sym_k_userdefined_charset
- */
- code = 2;
- for ( ndx=0 ; ndx<wml_obj_charset_ptr->cnt ; ndx++ )
- {
- newobj = (WmlCharSetDefPtr) wml_obj_charset_ptr->hvec[ndx].objptr;
- newobj->sym_code = code;
- code += 1;
- }
- }
- /*
- * Routine to perform class inheritance and validation.
- *
- * This routine has two major phases:
- * - Complete resolution of class references, and expand out
- * controls list.
- * - Perform inheritance of resources, partitioning them into
- * into arguments and reasons. When complete, the class has
- * a list of all its resources, including copies from a
- * superclass and possibly a parentclass.
- * Excluded resources remain in the list, and are simply marked.
- */
- void wmlResolveValidateClass ()
- {
- int ndx; /* loop index */
- int max; /* maximum code value */
- WmlClassDefPtr clsobj; /* current class object */
- WmlSynClassDefPtr synobj; /* syntactic class object */
- WmlClassDefPtr superobj; /* superclass */
- WmlClassDefPtr parentobj; /* parentclass */
- WmlClassDefPtr widgobj; /* gadget's widget class */
- WmlSynClassCtrlDefPtr refptr; /* current controls reference */
- WmlClassCtrlDefPtr ctrlobj; /* resolved control reference */
- int refndx; /* index in vector */
- WmlClassDefPtr refcls; /* referenced class object */
- WmlCtrlListDefPtr reflist; /* controls list object */
- WmlClassCtrlDefPtr listelem; /* control reference in list */
- char errmsg[300];
- /*
- * Acquire the superclass pointer for each widget and gadget class
- */
- for ( ndx=0 ; ndx<wml_obj_allclass_ptr->cnt ; ndx++ )
- {
- clsobj = (WmlClassDefPtr) wml_obj_allclass_ptr->hvec[ndx].objptr;
- synobj = clsobj->syndef;
- if ( synobj->superclass != NULL )
- {
- superobj = (WmlClassDefPtr)
- wmlResolveFindObject (synobj->superclass,
- WmlClassDefValid,
- synobj->name);
- if ( superobj == NULL ) continue;
- clsobj->superclass = superobj;
- }
- }
- /*
- * Acquire the parentclass pointer (if one exists),
- * for each widget and gadget class
- */
- for ( ndx=0 ; ndx<wml_obj_allclass_ptr->cnt ; ndx++ )
- {
- clsobj = (WmlClassDefPtr) wml_obj_allclass_ptr->hvec[ndx].objptr;
- synobj = clsobj->syndef;
- if ( synobj->parentclass != NULL )
- {
- parentobj = (WmlClassDefPtr)
- wmlResolveFindObject (synobj->parentclass,
- WmlClassDefValid,
- synobj->name);
- if ( parentobj == NULL ) continue;
- clsobj->parentclass = parentobj;
- }
- }
- /*
- * Link each gadget class with its widget class (both ways).
- * Link any class with a non-dialog version to the non-dialog class.
- */
- for ( ndx=0 ; ndx<wml_obj_class_ptr->cnt ; ndx++ )
- {
- clsobj = (WmlClassDefPtr) wml_obj_class_ptr->hvec[ndx].objptr;
- synobj = clsobj->syndef;
- if ( synobj->type == WmlClassTypeGadget )
- {
- if ( synobj->widgetclass == NULL )
- {
- sprintf (errmsg, "Gadget class %s has no widgetclass reference",
- synobj->name);
- wmlIssueError (errmsg);
- }
- else
- {
- widgobj = (WmlClassDefPtr)
- wmlResolveFindObject
- (synobj->widgetclass,
- WmlClassDefValid,
- synobj->name);
- if ( widgobj != NULL )
- {
- clsobj->variant = widgobj;
- widgobj->variant = clsobj;
- }
- }
- }
- if ( synobj->dialog == TRUE )
- {
- clsobj->nondialog = clsobj->superclass;
- while ( clsobj->nondialog->syndef->dialog == TRUE )
- clsobj->nondialog = clsobj->nondialog->superclass;
- }
- else
- if ( clsobj->superclass != NULL )
- {
- synobj->dialog = clsobj->superclass->syndef->dialog;
- clsobj->nondialog = clsobj->superclass->nondialog;
- }
- }
- /*
- * Construct the list of resolved controls. Control lists are expanded
- * in place.
- */
- for ( ndx=0 ; ndx<wml_obj_class_ptr->cnt ; ndx++ )
- {
- clsobj = (WmlClassDefPtr) wml_obj_class_ptr->hvec[ndx].objptr;
- synobj = clsobj->syndef;
- for ( refptr=synobj->controls ; refptr!= NULL ; refptr=refptr->next )
- {
- refndx = wmlFindInHList (wml_obj_class_ptr, refptr->name);
- if ( refndx >= 0 )
- {
- refcls = (WmlClassDefPtr) wml_obj_class_ptr->hvec[refndx].objptr;
- ctrlobj = (WmlClassCtrlDefPtr) malloc (sizeof(WmlClassCtrlDef));
- ctrlobj->next = clsobj->controls;
- clsobj->controls = ctrlobj;
- ctrlobj->ctrl = refcls;
- continue;
- }
- refndx = wmlFindInHList (wml_obj_ctrlist_ptr, refptr->name);
- if ( refndx >= 0 )
- {
- reflist = (WmlCtrlListDefPtr)
- wml_obj_ctrlist_ptr->hvec[refndx].objptr;
- for ( listelem=reflist->controls ;
- listelem!=NULL ;
- listelem=listelem->next)
- {
- ctrlobj = (WmlClassCtrlDefPtr)
- malloc (sizeof(WmlClassCtrlDef));
- ctrlobj->next = clsobj->controls;
- clsobj->controls = ctrlobj;
- ctrlobj->ctrl = listelem->ctrl;
- }
- continue;
- }
- wmlIssueReferenceError (synobj->name, refptr->name);
- continue;
- }
- }
- /*
- * Perform resource inheritance for each class. This constructs the
- * arguments and reasons reference vectors.
- */
- for ( ndx=0 ; ndx<wml_obj_allclass_ptr->cnt ; ndx++ )
- {
- clsobj = (WmlClassDefPtr) wml_obj_allclass_ptr->hvec[ndx].objptr;
- wmlResolveClassInherit (clsobj);
- }
- }
- /*
- * Routine to perform resource inheritance for a class.
- *
- * This routine constructs the argument and reason resource and child reference
- * vectors for a class. It first ensures the superclass (if any) has
- * been inited. It then makes a copy of the superclass lists. It repeats this
- * procedure for the parentclass (if any.) Finally, it
- * merges in the resources from the syntactic object. It uses the
- * resolved resource or child object to point to the matching reference object
- * in the list being created as an aid to search doing overrides. This also
- * detects whether a resource or child is already in the list (if so, it is
- * assumed to be inherited).
- */
- void wmlResolveClassInherit (clsobj)
- WmlClassDefPtr clsobj;
- {
- WmlClassDefPtr superobj; /* superclass object */
- WmlClassDefPtr parentobj; /* parentclass object */
- int ndx; /* loop index */
- WmlResourceDefPtr resobj; /* current resource object */
- WmlClassResDefPtr refobj; /* current resource reference */
- WmlClassResDefPtr srcref; /* source of copy */
- WmlChildDefPtr childobj; /* current child object */
- WmlClassChildDefPtr crefobj; /* current child reference */
- WmlClassChildDefPtr csrcref; /* child source of copy */
- WmlSynClassDefPtr synobj; /* this class' syntactic object */
- WmlSynClassResDefPtr refptr; /* syntactic resource reference */
- WmlSynClassChildDefPtr crefptr; /* syntactic child reference */
- /*
- * Done if inheritance previously performed. Ensure the superclass is
- * done.
- */
- if ( clsobj == NULL ) return;
- if ( clsobj->inherit_done ) return;
- superobj = clsobj->superclass;
- wmlResolveClassInherit (superobj);
- parentobj = clsobj->parentclass;
- wmlResolveClassInherit (parentobj);
- synobj = clsobj->syndef;
- /*
- * Clear the active reference pointer in the resolved resource objects.
- */
- wmlResolveClearRefPointers ();
- /*
- * Copy the superclass resources, setting the reference pointer as we go.
- */
- if ( superobj != NULL )
- {
- for ( srcref=superobj->arguments ; srcref!=NULL ; srcref=srcref->next )
- {
- refobj = (WmlClassResDefPtr) malloc (sizeof(WmlClassResDef));
- refobj->next = clsobj->arguments;
- clsobj->arguments = refobj;
- wmlResolveInitRefObj (refobj, srcref);
- }
- for ( srcref=superobj->reasons ; srcref!=NULL ; srcref=srcref->next )
- {
- refobj = (WmlClassResDefPtr) malloc (sizeof(WmlClassResDef));
- refobj->next = clsobj->reasons;
- clsobj->reasons = refobj;
- wmlResolveInitRefObj (refobj, srcref);
- }
- for (csrcref = superobj->children ; csrcref!=NULL ; csrcref=csrcref->next)
- {
- crefobj = (WmlClassChildDefPtr) malloc (sizeof(WmlClassChildDef));
- crefobj->next = clsobj->children;
- clsobj->children = crefobj;
- wmlResolveInitChildRefObj (crefobj, csrcref);
- }
- }
- /*
- * Copy the parentclass resources, setting the reference pointer as we go.
- */
- if ( parentobj != NULL )
- {
- for ( srcref=parentobj->arguments ; srcref!=NULL ; srcref=srcref->next )
- {
- if (srcref->act_resource->ref_ptr == NULL)
- {
- refobj = (WmlClassResDefPtr) malloc (sizeof(WmlClassResDef));
- refobj->next = clsobj->arguments;
- clsobj->arguments = refobj;
- wmlResolveInitRefObj (refobj, srcref);
- }
- }
- for ( srcref=parentobj->reasons ; srcref!=NULL ; srcref=srcref->next )
- {
- if (srcref->act_resource->ref_ptr == NULL)
- {
- refobj = (WmlClassResDefPtr) malloc (sizeof(WmlClassResDef));
- refobj->next = clsobj->reasons;
- clsobj->reasons = refobj;
- wmlResolveInitRefObj (refobj, srcref);
- }
- }
- for (csrcref = parentobj->children ; csrcref!=NULL ; csrcref=csrcref->next)
- {
- if (csrcref->act_child->ref_ptr == NULL)
- {
- crefobj = (WmlClassChildDefPtr) malloc (sizeof(WmlClassChildDef));
- crefobj->next = clsobj->children;
- clsobj->children = crefobj;
- wmlResolveInitChildRefObj (crefobj, csrcref);
- }
- }
- }
- /*
- * Process the resources belonging to this class. They may either be
- * new resources, or override ones already in the list. Partition them
- * into arguments and reasons.
- */
- for ( refptr=synobj->resources ; refptr!=NULL ; refptr=refptr->next )
- {
- resobj = (WmlResourceDefPtr) wmlResolveFindObject (refptr->name,
- WmlResourceDefValid,
- synobj->name);
- if ( resobj == NULL ) continue;
- /*
- * Acquire the resolved resource object, and the resource reference.
- * New references are linked in to the proper list, and have their
- * defaults set.
- */
- if ( resobj->ref_ptr != NULL )
- refobj = resobj->ref_ptr;
- else
- {
- refobj = (WmlClassResDefPtr) malloc (sizeof(WmlClassResDef));
- refobj->act_resource = resobj;
- resobj->ref_ptr = refobj;
- refobj->over_dtype = NULL;
- refobj->dflt = NULL;
- refobj->exclude = WmlAttributeUnspecified;
- if ( resobj->syndef->type == WmlResourceTypeReason )
- {
- refobj->next = clsobj->reasons;
- clsobj->reasons = refobj;
- }
- else
- {
- refobj->next = clsobj->arguments;
- clsobj->arguments = refobj;
- }
- }
- /*
- * Override any values in the reference which are explicit in the
- * syntactic reference.
- */
- if ( refptr->type != NULL )
- refobj->over_dtype = (WmlDataTypeDefPtr)
- wmlResolveFindObject (refptr->type,
- WmlDataTypeDefValid,
- synobj->name);
- if ( refptr->dflt != NULL )
- refobj->dflt = refptr->dflt;
- if ( refptr->exclude != WmlAttributeUnspecified )
- refobj->exclude = refptr->exclude;
- }
- /*
- * Process the children belonging to this class.
- */
- for ( crefptr = synobj->children ; crefptr!=NULL ; crefptr = crefptr->next )
- {
- childobj = (WmlChildDefPtr) wmlResolveFindObject (crefptr->name,
- WmlChildDefValid,
- synobj->name);
- if ( childobj == NULL ) continue;
- /*
- * Acquire the resolved child object, and the child reference.
- * New references are linked in to the proper list, and have their
- * defaults set.
- */
- if ( childobj->ref_ptr != NULL )
- crefobj = childobj->ref_ptr;
- else
- {
- crefobj = (WmlClassChildDefPtr) malloc (sizeof(WmlClassChildDef));
- crefobj->act_child = childobj;
- childobj->ref_ptr = crefobj;
- crefobj->next = clsobj->children;
- clsobj->children = crefobj;
- }
- }
- /*
- * inheritance complete
- */
- clsobj->inherit_done = TRUE;
- }
- /*
- * Routine to copy a resource reference
- */
- void wmlResolveInitRefObj (dstobj, srcobj)
- WmlClassResDefPtr dstobj;
- WmlClassResDefPtr srcobj;
- {
- WmlResourceDefPtr resobj;
- resobj = srcobj->act_resource;
- dstobj->act_resource = resobj;
- resobj->ref_ptr = dstobj;
- dstobj->over_dtype = srcobj->over_dtype;
- dstobj->dflt = srcobj->dflt;
- dstobj->exclude = srcobj->exclude;
- }
- /*
- * Routine to copy a child reference
- */
- void wmlResolveInitChildRefObj (dstobj, srcobj)
- WmlClassChildDefPtr dstobj;
- WmlClassChildDefPtr srcobj;
- {
- WmlChildDefPtr childobj;
- childobj = srcobj->act_child;
- dstobj->act_child = childobj;
- childobj->ref_ptr = dstobj;
- }
- /*
- * Routine to print a report in a file.
- *
- * This routine dumps the developed database into the file 'wml.report'
- */
- void wmlResolvePrintReport ()
- {
- FILE *outfil; /* output file */
- int ndx; /* loop index */
- WmlClassDefPtr clsobj; /* current class */
- /*
- * Open the output file.
- */
- outfil = fopen ( "wml.report", "w");
- if ( outfil == NULL )
- {
- printf ("\nCouldn't open wml.report");
- return;
- }
- /*
- * Go through all classes. Print basic information, then dump their
- * resources. The main purpose of this report is to show the actual
- * resources and controls for the class.
- */
- for ( ndx=0 ; ndx<wml_obj_allclass_ptr->cnt ; ndx++ )
- {
- clsobj = (WmlClassDefPtr) wml_obj_allclass_ptr->hvec[ndx].objptr;
- wmlMarkReferencePointers (clsobj);
- wmlResolvePrintClass (outfil, clsobj);
- }
- /*
- * close the output file
- */
- fprintf (outfil, "\n\n");
- printf ("\nCreated report file wml.report");
- fclose (outfil);
- }
- /*
- * Print the information for a class
- */
- void wmlResolvePrintClass (outfil, clsobj)
- FILE *outfil;
- WmlClassDefPtr clsobj;
- {
- int ndx; /* loop index */
- WmlSynClassDefPtr synobj; /* syntactic object */
- WmlClassCtrlDefPtr ctrlref; /* controls reference */
- WmlClassDefPtr ctrlobj; /* current class in control */
- synobj = clsobj->syndef;
- fprintf (outfil, "\n\n\nClass %s:", synobj->name);
- switch ( synobj->type )
- {
- case WmlClassTypeMetaclass:
- fprintf (outfil, "\n Type: Metaclass\t");
- if ( synobj->superclass != NULL )
- fprintf (outfil, "Superclass: %s\t", synobj->superclass);
- if ( synobj->parentclass != NULL )
- fprintf (outfil, "Parentclass: %s\t", synobj->parentclass);
- break;
- case WmlClassTypeWidget:
- fprintf (outfil, "\n Type: Widget\t");
- if ( synobj->superclass != NULL )
- fprintf (outfil, "Superclass: %s\t", synobj->superclass);
- if ( synobj->parentclass != NULL )
- fprintf (outfil, "Parentclass: %s\t", synobj->parentclass);
- if ( clsobj->variant != NULL )
- fprintf (outfil, "\n Associated gadget class: %s\t",
- clsobj->variant->syndef->name);
- if ( synobj->convfunc != NULL )
- fprintf (outfil, "Convenience function: %s", synobj->convfunc);
- break;
- case WmlClassTypeGadget:
- fprintf (outfil, "\n Type: Gadget\t");
- if ( synobj->superclass != NULL )
- fprintf (outfil, "Superclass: %s\t", synobj->superclass);
- if ( synobj->parentclass != NULL )
- fprintf (outfil, "Parentclass: %s\t", synobj->parentclass);
- if ( clsobj->variant != NULL )
- fprintf (outfil, "\n Associated widget class: %s\t",
- clsobj->variant->syndef->name);
- if ( synobj->convfunc != NULL )
- fprintf (outfil, "Convenience function: %s", synobj->convfunc);
- break;
- }
- /*
- * Print associated non-dialog class
- */
- if ( clsobj->nondialog != NULL )
- fprintf (outfil, "\n DialogClass: True\tNon-dialog ancestor: %s\t",
- clsobj->nondialog->syndef->name);
- /*
- * Print the arguments valid in the class. First the new resources for the
- * class are printed, then each ancestor's contribution is printed. This
- * is intended to match the way resources are printed in the toolkit manual,
- * so that checking is as easy as possible.
- */
- fprintf (outfil, "\n Arguments:");
- wmlResolvePrintClassArgs (outfil, clsobj);
- /*
- * Print the reasons valid in the class
- */
- fprintf (outfil, "\n Reasons:");
- wmlResolvePrintClassReasons (outfil, clsobj);
- /*
- * Print the controls valid in the class
- */
- fprintf (outfil, "\n Controls:");
- for ( ndx=0 ; ndx<wml_obj_class_ptr->cnt ; ndx++ )
- {
- ctrlobj = (WmlClassDefPtr) wml_obj_class_ptr->hvec[ndx].objptr;
- if ( ctrlobj->ref_ptr == NULL ) continue;
- fprintf (outfil, "\n %s", ctrlobj->syndef->name);
- }
- }
- /*
- * Routine to print the arguments for a class
- *
- * This routine prints out the currently marked arguments which are
- * present in this class. Each argument which is printed is remarked
- * so that it won't be printed again. This routine first prints the
- * superclass arguments, so that the printing order becomes the top-down
- * inheritance order.
- */
- void wmlResolvePrintClassArgs (outfil, clsobj)
- FILE *outfil;
- WmlClassDefPtr clsobj;
- {
- int prthdr = TRUE; /* print header line */
- int ndx; /* loop index */
- WmlSynClassDefPtr synobj; /* syntactic object */
- WmlClassResDefPtr resref; /* resource reference */
- int constr = FALSE; /* check for constraints */
- WmlResourceDefPtr resobj; /* current resource */
- WmlSynResourceDefPtr synres; /* syntactic resource object */
- /*
- * Print the superclass arguments
- */
- if ( clsobj->superclass != NULL )
- wmlResolvePrintClassArgs (outfil, clsobj->superclass);
- /*
- * Print the parentclass arguments
- */
- if ( clsobj->parentclass != NULL )
- wmlResolvePrintClassArgs (outfil, clsobj->parentclass);
- /*
- * Print the arguments for this class. Unmark the reference so it won't
- * be printed again.
- */
- synobj = clsobj->syndef;
- for ( ndx=0 ; ndx<wml_obj_arg_ptr->cnt ; ndx++ )
- {
- resobj = (WmlResourceDefPtr) wml_obj_arg_ptr->hvec[ndx].objptr;
- resref = resobj->ref_ptr;
- if ( resref == NULL ) continue;
- if ( wmlResolveResIsMember(resobj,clsobj->arguments) == NULL ) continue;
- synres = resobj->syndef;
- switch ( synres->type )
- {
- case WmlResourceTypeArgument:
- case WmlResourceTypeSubResource:
- break;
- case WmlResourceTypeConstraint:
- constr = TRUE;
- break;
- default:
- continue;
- break;
- }
- if ( prthdr )
- {
- fprintf (outfil, "\n %s argument set:", synobj->name);
- prthdr = FALSE;
- }
-
- fprintf (outfil, "\n %s", synres->name);
- fprintf (outfil, "\n\tType = %s", resobj->dtype_def->syndef->name);
- if ( strcmp(synres->name,synres->resliteral) != 0 )
- fprintf (outfil, "\tResourceLiteral = %s", synres->resliteral);
- switch ( resref->exclude )
- {
- case WmlAttributeTrue:
- fprintf (outfil, "\n\tExclude = True;");
- break;
- case WmlAttributeFalse:
- fprintf (outfil, "\n\tExclude = False;");
- break;
- }
- if ( resref->dflt != NULL )
- fprintf (outfil, "\n\tDefault = \"%s\"", resref->dflt);
- else
- if ( synres->dflt != NULL )
- fprintf (outfil, "\n\tDefault = \"%s\"", synres->dflt);
- resobj->ref_ptr = NULL;
- }
- /*
- * Print the constraints valid in the class
- */
- if ( constr )
- {
- prthdr = TRUE;
- for ( ndx=0 ; ndx<wml_obj_arg_ptr->cnt ; ndx++ )
- {
- resobj = (WmlResourceDefPtr) wml_obj_arg_ptr->hvec[ndx].objptr;
- resref = resobj->ref_ptr;
- if ( resref == NULL ) continue;
- if ( wmlResolveResIsMember(resobj,clsobj->arguments) == NULL ) continue;
- synres = resobj->syndef;
- switch ( synres->type )
- {
- case WmlResourceTypeConstraint:
- break;
- default:
- continue;
- break;
- }
- if ( prthdr )
- {
- fprintf (outfil, "\n %s constraint set:", synobj->name);
- prthdr = FALSE;
- }
- fprintf (outfil, "\n %s", synres->name);
- if ( strcmp(synres->name,synres->resliteral) != 0 )
- fprintf (outfil, "\tResourceLiteral = %s", synres->resliteral);
- switch ( resref->exclude )
- {
- case WmlAttributeTrue:
- fprintf (outfil, "\n\tExclude = True;");
- break;
- case WmlAttributeFalse:
- fprintf (outfil, "\n\tExclude = False;");
- break;
- }
- if ( resref->dflt != NULL )
- fprintf (outfil, "\n\tDefault = \"%s\"", resref->dflt);
- else
- if ( synres->dflt != NULL )
- fprintf (outfil, "\n\tDefault = \"%s\"", synres->dflt);
- resobj->ref_ptr = NULL;
- }
- }
- }
- /*
- * Routine to print reasons in a class.
- *
- * Like printing arguments, only reasons instead.
- */
- void wmlResolvePrintClassReasons (outfil, clsobj)
- FILE *outfil;
- WmlClassDefPtr clsobj;
- {
- int prthdr = TRUE; /* print header flag */
- int ndx; /* loop index */
- WmlSynClassDefPtr synobj; /* syntactic object */
- WmlClassResDefPtr resref; /* resource reference */
- WmlResourceDefPtr resobj; /* current resource */
- WmlSynResourceDefPtr synres; /* syntactic resource object */
- /*
- * Print the superclass reasons
- */
- if ( clsobj->superclass != NULL )
- wmlResolvePrintClassReasons (outfil, clsobj->superclass);
- /*
- * Print the parentclass reasons
- */
- if ( clsobj->parentclass != NULL )
- wmlResolvePrintClassReasons (outfil, clsobj->parentclass);
- /*
- * Print the reasons for this class. Unmark the reference so it won't
- * be printed again.
- */
- synobj = clsobj->syndef;
- for ( ndx=0 ; ndx<wml_obj_reason_ptr->cnt ; ndx++ )
- {
- resobj = (WmlResourceDefPtr) wml_obj_reason_ptr->hvec[ndx].objptr;
- resref = resobj->ref_ptr;
- if ( resref == NULL ) continue;
- if ( wmlResolveResIsMember(resobj,clsobj->reasons) == NULL ) continue;
- synres = resobj->syndef;
- if ( prthdr )
- {
- fprintf (outfil, "\n %s reason set:", synobj->name);
- prthdr = FALSE;
- }
- fprintf (outfil, "\n %s", synres->name);
- if ( strcmp(synres->name,synres->resliteral) != 0 )
- fprintf (outfil, "\tResourceLiteral = %s", synres->resliteral);
- switch ( resref->exclude )
- {
- case WmlAttributeTrue:
- fprintf (outfil, "\n\tExclude = True;");
- break;
- case WmlAttributeFalse:
- fprintf (outfil, "\n\tExclude = False;");
- break;
- }
- resobj->ref_ptr = NULL;
- }
- }
- /*
- * Routine to mark reference pointers for a class
- *
- * This routine clears all reference pointers, then marks the class and
- * resource objects to flag those contained in the current class. This
- * allows processing of the widget and resource vectors in order to produce
- * bit masks or reports.
- */
- void wmlMarkReferencePointers (clsobj)
- WmlClassDefPtr clsobj;
- {
- int ndx; /* loop index */
- WmlClassDefPtr mrkcls; /* class object to mark */
- WmlResourceDefPtr mrkres; /* resource object to mark */
- WmlClassResDefPtr resref; /* resource reference */
- WmlClassCtrlDefPtr ctrlref; /* controls reference */
- /*
- * Clear the reference pointers. Then go through the arguments, reasons,
- * and controls lists, and mark the referenced classes.
- */
- wmlResolveClearRefPointers ();
- for ( resref=clsobj->arguments ; resref!= NULL ; resref=resref->next )
- resref->act_resource->ref_ptr = resref;
- for ( resref=clsobj->reasons ; resref!= NULL ; resref=resref->next )
- resref->act_resource->ref_ptr = resref;
- for ( ctrlref=clsobj->controls ; ctrlref!=NULL ; ctrlref=ctrlref->next )
- ctrlref->ctrl->ref_ptr = ctrlref;
- }
- /*
- * Routine to clear reference pointers
- */
- void wmlResolveClearRefPointers ()
- {
- int ndx; /* loop index */
- WmlClassDefPtr mrkcls; /* class object to mark */
- WmlResourceDefPtr mrkres; /* resource object to mark */
- WmlChildDefPtr mrkcld; /* child object to mark */
- for ( ndx=0 ; ndx<wml_obj_allclass_ptr->cnt ; ndx++ )
- {
- mrkcls = (WmlClassDefPtr) wml_obj_allclass_ptr->hvec[ndx].objptr;
- mrkcls->ref_ptr = NULL;
- }
- for ( ndx=0 ; ndx<wml_obj_reason_ptr->cnt ; ndx++ )
- {
- mrkres = (WmlResourceDefPtr) wml_obj_reason_ptr->hvec[ndx].objptr;
- mrkres->ref_ptr = NULL;
- }
- for ( ndx=0 ; ndx<wml_obj_arg_ptr->cnt ; ndx++ )
- {
- mrkres = (WmlResourceDefPtr) wml_obj_arg_ptr->hvec[ndx].objptr;
- mrkres->ref_ptr = NULL;
- }
- for ( ndx=0 ; ndx<wml_obj_child_ptr->cnt ; ndx++ )
- {
- mrkcld = (WmlChildDefPtr) wml_obj_child_ptr->hvec[ndx].objptr;
- mrkcld->ref_ptr = NULL;
- }
- }
- /*
- * Routine to find an object for binding. The name is always looked
- * in the syntactic object list, since all references made by the
- * user are in that list (resolved objects may be entered under
- * an internal literal, and not be found). This routine always attempts to
- * return a resolved object (which depends on object type). It also guarantees
- * that the object it finds matches the given type.
- *
- * name the object to be found
- * type type the object should match
- * requester requester name, for error messages
- *
- * Returns: pointer to the object found
- */
- ObjectPtr wmlResolveFindObject (name, type, requester)
- char *name;
- int type;
- char *requester;
- {
- int objndx; /* the object index in the list */
- WmlSynDefPtr synobj; /* syntactic object */
- char errmsg[300];
- objndx = wmlFindInHList (wml_synobj_ptr, name);
- if ( objndx < 0 )
- {
- wmlIssueReferenceError (requester, name);
- return NULL;
- }
- synobj = (WmlSynDefPtr) wml_synobj_ptr ->hvec[objndx].objptr;
- if ( synobj->validation != type )
- {
- sprintf (errmsg,
- "Object %s references object %s\n\tin a context where a different type of object is required",
- requester, name);
- wmlIssueError (errmsg);
- return NULL;
- }
- switch ( synobj->validation )
- {
- case WmlClassDefValid:
- case WmlResourceDefValid:
- case WmlDataTypeDefValid:
- case WmlCtrlListDefValid:
- case WmlEnumSetDefValid:
- case WmlEnumValueDefValid:
- case WmlChildDefValid:
- return (ObjectPtr) synobj->rslvdef;
- break;
- default:
- return (ObjectPtr) synobj;
- }
- }
- /*
- * Report an object reference error
- *
- * srcname the object making the reference
- * badname the missing object
- */
- void wmlIssueReferenceError (srcname, badname)
- char *srcname;
- char *badname;
- {
- printf ("\nObject %s references undefined object %s", srcname, badname);
- wml_err_count += 1;
- }
- /*
- * Report an attempt to make a reference which is not supported.
- */
- void wmlIssueIllegalReferenceError (srcname, badname)
- char *srcname;
- char *badname;
- {
- printf ("\nObject %s cannot reference a %s object", srcname, badname);
- wml_err_count += 1;
- }
- /*
- * Report an error string.
- */
- void wmlIssueError (errstg)
- char *errstg;
- {
- printf ("\n%s", errstg);
- wml_err_count += 1;
- }
|