Initial import of the CDE 2.1.30 sources from the Open Group.

This commit is contained in:
Peter Howkins
2012-03-10 18:21:40 +00:00
commit 83b6996daa
18978 changed files with 3945623 additions and 0 deletions

View File

@@ -0,0 +1,161 @@
XCOMM $XConsortium: Imakefile /main/13 1996/10/09 14:03:09 drk $
XCOMM
XCOMM RESTRICTED CONFIDENTIAL INFORMATION:
XCOMM
XCOMM The information in this document is subject to special
XCOMM restrictions in a confidential disclosure agreement between
XCOMM HP, IBM, Sun, USL, SCO, Fujitsu and Univel. Do not distribute this
XCOMM document outside HP, IBM, Sun, USL, SCO, Fujitsu, or Univel without
XCOMM Sun's specific written approval. This document and all copies
XCOMM and derivative works thereof must be returned or destroyed at
XCOMM Sun's request.
XCOMM
XCOMM (c) Copyright 1996 Digital Equipment Corporation.
XCOMM (c) Copyright 1996 Hewlett-Packard Company.
XCOMM (c) Copyright 1996 International Business Machines Corp.
XCOMM (c) Copyright 1993,1996 Sun Microsystems, Inc.
XCOMM (c) Copyright 1996 Novell, Inc.
XCOMM (c) Copyright 1996 FUJITSU LIMITED.
XCOMM (c) Copyright 1996 Hitachi.
#include "../ab.tmpl"
#include "../ab.rules"
INCLUDES = -I. -I$(ABINCLUDES)
DEFINES =
SOURCES.h.shipped =
SOURCES.h.shared = \
abmf.h
SOURCES.h.unshared = \
abmfP.h \
argsP.h \
cdefsP.h \
connectP.h \
create_declsP.h \
dtb_utils.h \
ui_header_fileP.h \
instancesP.h \
lib_func_stringsP.h \
make_fileP.h \
merge_cP.h \
motifdefsP.h \
msg_cvt.h \
msg_file.h \
msg_fileP.h \
obj_namesP.h \
parse_cP.h \
proj_c_fileP.h \
proj_header_fileP.h \
resource_fileP.h \
stubs_c_fileP.h \
ui_c_fileP.h \
ui_header_fileP.h \
utils_c_fileP.h \
utils_header_fileP.h \
utilsP.h \
write_cP.h \
write_codeP.h
SOURCES.msg = \
dtcodegen.msg \
../libAButil/libAButil.msg \
../libABobjXm/libABobjXm.msg \
../libABil/libABil.msg
SRCS = abmf.c args.c \
cdefs.c connect.c \
create_decls.c dtb_utils.c \
generate_code.c instances.c \
lib_func_strings.c make_file.c \
merge_c.c motifdefs.c \
msg_cvt.c msg_file.c \
obj_names.c parse_c.c \
proj_c_file.c proj_header_file.c \
resource_file.c stubs_c_file.c \
ui_c_file.c ui_header_file.c \
utils.c utils_c_file.c \
utils_header_file.c write_c.c \
write_code.c
OBJS = abmf.o args.o \
cdefs.o connect.o \
create_decls.o dtb_utils.o \
generate_code.o instances.o \
lib_func_strings.o make_file.o \
merge_c.o motifdefs.o \
msg_cvt.o msg_file.o \
obj_names.o parse_c.o \
proj_c_file.o proj_header_file.o \
resource_file.o stubs_c_file.o \
ui_c_file.o ui_header_file.o \
utils.o utils_c_file.o \
utils_header_file.o write_c.o \
write_code.o
SYS_LIBRARIES = -lm $(ICONVSYSLIB) $(DYNLIBSYSLIB) $(REGEXSYSLIB)
#ifdef AlphaArchitecture
CCOPTIONS = -std1
#endif
#ifdef RsArchitecture
CCOPTIONS = -qnoro
#endif
#ifdef SunArchitecture
WAITTARGET = .WAIT
#endif /* SunArchitecture */
PROGRAMS = dtcodegen
LINTLIBS = $(XINPUTLIB) $(DTHELPLIB) $(DTSVCLIB) $(XMLIB) $(XTOOLLIB) $(XLIB)
/* DEPLIBS contains the list of library depencies for a client.
* LOCAL_LIBRARIES contains the list of libraries on the link line.
* Generally, the dependency form of a library has DEP as a prefix.
* e.g. put $(XLIB) in LOCAL_LIBRARIES and $(DEPXLIB) in DEPLIBS.
* NOTE: if DEPLIBS is not set here, it is by default null and there
* are no library dependencies for clients.
* You cannot put -Llibpath into DEPLIBS. You must put actual
* paths to the library.
*/
DEPLIBS = ../libABil/libABil.a ../libABobjXm/libABobjXm.a \
../libABobj/libABobj.a ../libAButil/libAButil.a \
$(DEPDTTERMLIB) $(DEPDTHELPLIB) $(DEPDTWIDGETLIB) \
$(DEPDTSVCLIB) $(DEPTTLIB) $(DEPXMLIB) \
$(DEPXTOOLLIB) $(DEPXLIB)
LOCAL_LIBRARIES = ../libABil/libABil.a ../libABobjXm/libABobjXm.a \
../libABobj/libABobj.a ../libAButil/libAButil.a \
$(DTTERMLIB) $(DTHELPLIB) $(DTWIDGETLIB) \
$(DTSVCLIB) $(TTLIB) $(XMLIB) $(XTOOLLIB) $(XLIB)
ComplexProgramTarget(dtcodegen)
AbMessageCatalogTarget(dtcodegen)
LinkFileList(shared_includes,$(SOURCES.h.shared),../include/ab_private,../../abmf)
includes:: shared_includes $(WAITTARGET)
SRCS2 = ab_func_strings.c
OBJS2 = ab_func_strings.o
DEPLIBS2 = ../libAButil/libAButil.a
ComplexProgramTarget_2(ab_func_strings,$(DEPLIBS2),$(SYS_LIBRARIES))
XCOMM
XCOMM Test harnesses and drivers
XCOMM
test_parse_main.o: parse_c.c
$(CC) $(CFLAGS) -DMAIN -c -o test_parse_main.o parse_c.c
test_parse: test_parse_main.o ../libAButil/libAButil.a
$(CC) $(CFLAGS) -o test_parse test_parse_main.o ../libAButil/libAButil.a
test_merge_main.o: merge_c.c
$(CC) $(CFLAGS) -DMAIN -c -o test_merge_main.o merge_c.c
test_merge: test_merge_main.o parse_c.o ../libAButil/libAButil.a
$(LINKCC) $(CFLAGS) $(LDOPTIONS) -o test_merge test_merge_main.o parse_c.o ../libAButil/libAButil.a

View File

@@ -0,0 +1,7 @@
text : .text%obj_verify : ../libABobj/libABobj.a(obj_utils.o);
text : .text%istr_dup : ../libAButil/libAButil.a(istr.o);
text : .text%objxm_file_to_pixmap : ../libABobjXm/libABobjXm.a(objxm_util.o);
text : .text%obj_set_name : ../libABobj/libABobj.a(obj_fields.o);
text : .text%AByyparse : ../libABil/libABil.a(bil_parse.o);
text : .text%bilP_load_att_hoffset : ../libABil/libABil.a(bil_loadatt.o);
text : .text%istr_P188530Ppriv_destroy : ../libAButil/libAButil.a(istr.o);

View File

@@ -0,0 +1,307 @@
XCOMM $XConsortium: README.src /main/3 1996/04/23 20:03:43 drk $
Executable: abmf
Description: Motif/CDE code-generator
Revision: dunn: 7 June, 1994
-------------------------------------------------------
-------------------------------------------------------
Module Prefix Description
------ ------ -----------------------
Motif-codegen abmf_
INTRODUCTION
This document has been written primarily to give an overview of how the
code generator (dtcodegen) for the application builder is implemented.
Its primary thrust is to provide information on how to add support for
new widgets and object types in the code generator.
SYNOPSIS
A few basic principle drive the code generator, and understanding them
should make working on dtcodegen much easier. These principles are explained
in more detail later on, but I'll give a brief synopsis here.
All code generation is driven by the GenCodeInfo data type. A parameter
of this type gets passed in to many functions in the code generator and
is used to modify the way code is generated. This structure holds data that
has a rather wide affect, such as what resources to put in the code file, what
resources to put in the resource file, what form of internationalization is
being used, and whether or not a function is currently being written. If
a function is being written, this data type determines what type of function
is being generated, what the parameters to the function are, what object
is being created by the function, and the like. Be sure to keep this
data up-to-date at all times, especially if you are generating functions
other than library functions.
abmfP_write_create_widgets_for_comp_obj() is guaranteed to be called
for every composite object being written. This is the first place to
look when implementing a new object type. Modifications to handle the
new object type should be put in this function or in
abmfP_write_create_widgets_for_one_obj().
Always use abmfP_parent() to get the parent of a widget. Some objects are
ignored because they are only used by the front end, and abmfP_parent()
will skip past them.
Use abmfP_get_c_name() to get the C identifier for an object. This takes
a GenCodeInfo, and will automatically give back instance pointers or
global references, as needed.
A struct obj is an object that defines a C struct. In other words, a
C struct is written for each window in the project, so each window is
a struct obj. Substruct objs define substructures (e.g., menus).
instances.c should contain ALL widget-creation code. Do not put code
to write widget creation anywhere else, because it becomes very difficult
to track down problems.
args.c should contain ALL resource-handling code. This model supports
"classes" of resources that allow some resources to be written out in
one way, and others at a different time. If all else fails, args.c functions
exist to write out individual resource values.
"dump" vs. "write" vs. "spew": The identifiers in dtcodegen that deal
with output files, and resource files in particular, use these three
terms. Data is "dumped" to a resource file, "written" to the C code file,
and "spewed" data can go to either place, depending upon context. For
instance a spewed resource will go to either the resource or code file,
depending on the user's options. The "spew" functions should be used
most often, because they handle a lot of details.
abio_printf(), abio_puts(), abio_indent(), abio_outdent() and related
functions should be used to write out C code. STRINGS PASSED TO THESE
FUNCTIONS SHOULD *NOT* CONTAIN NEWLINES, EXCEPT AT THE BEGINNING OR
END OF THE STRING TO BE PRINTED.
GenCodeInfo STRUCT
Here's the structure:
typedef struct
{
/* write arg = write to C file
* dump arg = dump to resource file
*/
File code_file; /* C code */
File resource_file; /* dumped resources */
BOOL prototype_funcs; /* write prototypes? */
BOOL dump_resources_i18n; /* dump i18n res's */
BOOL dump_resources_all; /* dump all res's */
ABMF_I18N_METHOD i18n_method; /* intl'zation method */
BOOL writing_func; /* currently writing a func? */
GenFuncInfoRec cur_func; /* func currently being generated */
} GenCodeInfoRec, *GenCodeInfo;
The GenFuncInfoRec is too large to be included here, but this data type
determines nearly all aspects of how the code is to be written. It is
passed in to many functions in dtcodegen, which modify their operations
based on the data stored therein.
The data that is used most frequently are the fields code_file and
resource_file, which hold the open streams for the current code and resource
files, respectively.
WIDGET CREATION
All widget creation should occur in the file instances.c. It's most useful
public functions are:
abmfP_write_create_widgets_for_comp_obj()
abmfP_write_create_widgets_for_one_obj()
abmfP_write_add_callback()
abmfP_write_create_widgets_for_comp_obj() writes all widgets necessary
for a composite object, and may or may not call
abmfP_write_create_widgets_for_one_obj(). It is guaranteed that
abmfP_write_widgets_for_comp_obj() will be called for the root node of
every salient ui object in the project. This is the best place to add
a new "type" of object.
instances.c has a number of private functions to help with widget creation.
The most easily used are write_create_widget_by_xt_va_create(), and
write_create_widget_by_non_va_conv_func(). These handle creating the
widgets and setting their resources. You can also call
write_comp_create_all_subobjs, which handles the general-purpose case.
The functions that handle composite objects should start with write_comp_,
and those that handle only one object should have names that start with
write_obj_.
LOCAL VARIABLES FOR OBJECT-CREATION FUNCTIONS
All local variables for object-creation functions are written by the
function abmfP_write_create_proc_decls() in create_decls.c. Defined
local variables are carefully kept track of in the GenCodeInfo struct,
so it can be easily determined whether a particular variable exists
in the current function, and whether or not it has a valid value. This
also removes the possibility of defining the same variable twice.
Xt RESOURCES
All Xt resources are handled in the file args.c. The functions in this
file will return the number of resources of a particular "class" an object
has, and will write them to the appropriate file, as well as providing
other information about the resources.
The argument "classes" are defined as follows:
ABMF_ARGCLASS_UNDEF
ABMF_ARGCLASS_NONE
ABMF_ARGCLASS_TYPED
ABMF_ARGCLASS_WIDGET_REF
ABMF_ARGCLASS_OTHER
ABMF_ARGCLASS_ALL /* composite class */
ABMF_ARGCLASS_ALL_BUT_WIDGET_REF /* composite class */
abmfP_get_num_code_file_args_of_classes()
abmfP_get_num_res_file_args_of_classes()
abmfP_get_args_of_classes()
The functions that write arguments and argument lists also take
an argument class parameter. They also take a parameter that determines
the style of argument output. They format type and functions are:
ABMF_ARGFMT_ARRAY
ABMF_ARGFMT_VA_LIST
abmfP_obj_spew_args()
abmfP_write_arg_val()
A few utility functions exist to help with writing argument lists:
abmfP_xt_va_list_open() /* indent() */
abmfP_xt_va_list_open_setvalues() /*writes XtVaSetValues(widget,\n"*/
abmfP_xt_va_list_close() /* NULL);\n, outdent() */
Here are more resource (argument) utility functions:
abmfP_arg_is_dumped() /* dupmed to resource file */
abfmP_arg_is_written() /* written to code file */
abmfP_arg_is_i18n() /* i18n-related */
abmfP_get_res_type(arg, res); /* gets AB_ARG_TYPE for resource */
"LIBRARY" FUNCTIONS
"Library" functions are those general-purpose functions that are put
in the user's application. An example is the dtb_create_greyed_pixmap()
function.
LibFuncRec is the data type that is used to define a library function,
and contains the function's declaration (prototype) and definition.
More needs to be written on this, but I don't have time, right now...
GENERATED STRUCTURES
Generated data types consist primarily of structures that define
the user-interface elements of the project. A "struct obj" is an object
that has a structure defined to represent it that is used for a global
variable. A "substruct obj" has a structure defined for it that exists
only inside another structure. For instance, a window is a struct obj and
has a global structure and variable created to define it. A menu is
a substruct obj because the structure defined for it is only used inside
of other structures.
abmfP_obj_has_field() /* a field exists for obj */
abmfP_obj_has_struct_field() /* a struct field exists for obj */
abmfP_obj_has_substruct_field() /* a substructe field exists for obj */
abmfP_obj_is_struct_obj() /* obj is root of struct */
abmfP_obj_is_substruct_obj() /* obj is root of substructure */
OBJECT/IDENTIFIER NAMES
There are several types of "names" for an object. One is the "C" identifier,
which is a reference to a C variable. This variable can be accessed via
a local instance pointer, or through the global variable. It is also
necessary to be able to get the name of the structure type an object is
in and also the name of the widget that the object causes to be generated.
The functions that don't specify a scope (e.g., abmfP_get_c_name(), vs.
abmfP_get_c_global_name()) determine the best scope from the GenCodeInfo
data and should be used whenever possible.
- These get the name of the variable for this object
abmfP_get_c_name() - "appropriate" name, given genCodeInfO
abmfP_get_c_name_global() - global variable name
abmfp_get_c_name_in_inst() - relative to instance->
abmfP_get_c_name_in_subinst() - relative to instance->substruct.
- These get the name of the widget for this object
abmfP_get_widget_name()
abmfP_get_widgt_global_name()
- These get the name of the structure variable this obj belongs to,
- or the type name of the structure.
abmfP_get_c_struct_ptr_type_name()
abmfP_get_c_struct_global_name()
abmfP_get_c_struct_name()
OUTPUTTING C CODE
abio_printf() and related functions should be used to actually write
out anything to the C (code) file. Strings to these functions should
never contain a newline, except at the beginning or end of the string
to be printed. These functions look for newlines in order to automatically
indent their output.
abio_indent() and abio_outdent() should be used to change the indent
level in the output C file. By doing this, called functions can automatically
indent properly, regardless of context.
Several functions can be used to declare and write C functions. The _decl()
functions write the function prototypes, and the _begin() functions write
the beginning of the function, including the name, parameters and opening
curly brace. Some of them take variable argument lists, which allow
arbitrary parameters to be written into the declarations or functions.
These also handle keeping the GenCodeInfo data up-to-date. Some of these
functions are:
abmfP_write_c_block_begin()
abmfP_write_c_block_end()
abmfP_write_c_comment()
abmfP_write_c_include()
abmfP_write_c_func_decl()
abmfP_write_c_func_begin()
abmfP_write_c_func_end()
abmfP_write_xm_callback_decl()
abmfP_write_xm_callback_begin()
abmfP_write_xm_callback_end()
GENERAL UTILITIES
abmfP_parent() gets the parent of an object, and should always be used
to get object parents. This is because some objects are ignored completely
when generating code, and this function will skip those objects.
ObjWClassIs(), ObjWClassIsLabel(), ObjWClassIsShell(), ... These functions
return BOOL and check the class_name of the object directly.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,63 @@
/*
* $XConsortium: abmf.h /main/3 1995/11/06 18:01:36 rswiston $
*
* @(#)abmf.h 1.3 15 Jul 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* abmf.h - public entry points to the code generator
*/
#ifndef _ABMF_ABMF_H_
#define _ABMF_ABMF_H_
#include <ab_private/obj.h>
typedef enum
{
ABMF_I18N_UNDEF= 0,
ABMF_I18N_NONE, /* no i18n */
ABMF_I18N_XPG4_API, /* generated code conforms to
* XPG4 API
*/
ABMF_I18N_METHOD_NUM_VALUES /* must be last */
} ABMF_I18N_METHOD;
typedef enum
{
ABMF_CGEN_UNDEF,
ABMF_CGEN_ALL,
ABMF_CGEN_BY_DATE,
ABMF_CGEN_BY_DATE_AND_CONTENTS,
ABMF_CGEN_RESTRICTION_NUM_VALUES /* must be last */
} ABMF_CGEN_RESTRICTION;
/*
* "dumped" resources are written to a resource file, rather than a C file
*/
int abmf_generate_code(
ABObj project,
ABMF_CGEN_RESTRICTION restriction,
BOOL merge_files,
ABMF_I18N_METHOD i18nMethod,
BOOL prototype_functions,
AB_ARG_CLASS_FLAGS dumped_resources
);
#endif /* _ABMF_ABMF_H_ */

View File

@@ -0,0 +1,168 @@
/*
* $XConsortium: abmfP.h /main/3 1995/11/06 18:01:49 rswiston $
*
* @(#)abmfP.h 3.36 30 Apr 1995 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* abmfP.h - declarations common to all abmf files
*/
#ifndef _ABMF_ABMFP_H_
#define _ABMF_ABMFP_H_
#include <assert.h> /* assert() */
#include <stdio.h> /* FILE*, BUFSIZ */
#include <sys/param.h> /* MAXPATHLEN, ... */
#include <nl_types.h>
#include <X11/Intrinsic.h>
#include <ab_private/obj.h>
#include <ab_private/trav.h>
#include <ab_private/strlist.h>
#include "abmf.h"
/*
* Constants
*/
#define STD_BUF_SIZE (BUFSIZ)
#define MAX_PATH_SIZE (MAXPATHLEN+1)
#define MAX_NAME_SIZE (MAX_PATH_SIZE)
#define CGenFlagsNone ((CGenFlags)0x0000)
#define CGenFlagCompFieldsUnique ((CGenFlags)0x0001)
#define CGenFlagSubstructObjValid ((CGenFlags)0x0002)
#define CGenFlagStructObjValid ((CGenFlags)0x0004)
#define CGenFlagIsStructObjValid ((CGenFlags)0x0008)
#define CGenFlagIsStructObj ((CGenFlags)0x0010)
#define CGenFlagIsSubstructObjValid ((CGenFlags)0x0020)
#define CGenFlagIsSubstructObj ((CGenFlags)0x0040)
#define CGenFlagWriteDefToProjFile ((CGenFlags)0x0080)
#define CGenFlagIsDuplicateDef ((CGenFlags)0x0100)
#define CGenFlagLoadMe ((CGenFlags)0x0200)
#define CGenFlagIsReferenced ((CGenFlags)0x0400)
#define CGenFlagTreatAsAppShell ((CGenFlags)0x0800)
/* specify what type of cgen data is attached to obj */
#define CGenFlagDataIsModule ((CGenFlags)0x2000)
#define CGenFlagDataIsObj ((CGenFlags)0x4000)
#define CGenFlagDataIsProj ((CGenFlags)0x8000)
typedef FILE *File; /* convenience */
/*
typedef struct
{
ISTRING field_name;
ABObj struct_obj;
ABObj substruct_obj;
} CGenObjDataRec, *CGenObjData;
*/
/* Proj info */
typedef struct
{
StringList callbacks;
CGenAnyData children_data;
BOOL has_ui_obj;
BOOL has_terminal;
BOOL has_help;
ISTRING exe_name;
} CGenProjDataRec, *CGenProjData;
/* Module info */
typedef struct
{
StringList callbacks;
CGenAnyData children_data;
} CGenModuleDataRec, *CGenModuleData;
typedef struct CGEN_ANY_DATA_REC /* name must match obj.h! */
{
ISTRING field_name;
ABObj struct_obj;
ABObj substruct_obj;
int num_auto_callbacks;
union
{
CGenProjData proj;
CGenModuleData module;
} info;
} CGenAnyDataRec;
typedef CGenAnyDataRec CGenDataRec;
typedef CGenAnyData CGenData;
#define return_if_err(_return_code, _return_value) \
if ((_return_code) < 0) \
{ \
return_value= (_return_value); \
goto epilogue; \
}
#define return_code(_return_code) \
{return_value= (_return_code); goto epilogue;}
#define mfobj_flags(obj) ((obj)->cgen_flags)
#define mfobj_set_flags(obj, _flags) \
((obj)->cgen_flags |= ((CGenFlags)(_flags)))
#define mfobj_clear_flags(obj, _flags) \
(mfobj_flags(obj) &= ~((CGenFlags)(_flags)))
#define mfobj_has_flags(obj, _flags) \
((mfobj_flags(obj) & ((CGenFlags)(_flags))) != 0)
/*
* Get the various types of data from the object
*/
#define mfobj_has_data(obj) \
((obj)->cgen_data != NULL)
#define mfobj_data(obj) \
(obj->cgen_data)
#define mfobj_set_proj_data(_obj,_data) \
( mfobj_set_flags(_obj, CGenFlagDataIsProj), \
((int)(mfobj_data(_obj)->info.proj = (_data))) \
)
#define mfobj_get_proj_data(obj) \
(mfobj_has_flags(obj, CGenFlagDataIsProj)? \
(mfobj_data(obj)->info.proj) \
: \
((CGenProjData)NULL) \
)
#define mfobj_set_module_data(_obj,_data) \
( mfobj_set_flags(_obj, CGenFlagDataIsModule), \
((int)(mfobj_data(_obj)->info.module = (_data))) \
)
#define mfobj_get_module_data(obj) \
(mfobj_has_flags(obj, CGenFlagDataIsModule)? \
(mfobj_data(obj)->info.module) \
: \
((CGenModuleData)NULL) \
)
/* Internationalization defines and references */
extern nl_catd Dtb_project_catd;
#endif /* _ABMF_ABMFP_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,169 @@
/*
* $XConsortium: argsP.h /main/3 1995/11/06 18:02:44 rswiston $
*
* @(#)argsP.h 1.15 01 May 1995 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* argsP.h - deal with argument lists
*
* Nomenclature
* ------------
*
* "written" args are written into the C code
* "dumped" arg is dumped into a resource file
*
*/
#ifndef _ABMF_ARGSP_H_
#define _ABMF_ARGSP_H_
#include "write_codeP.h"
typedef enum
{
ABMF_ARGFMT_UNDEF = 0,
ABMF_ARGFMT_ARRAY,
ABMF_ARGFMT_VA_LIST,
ABMF_ARG_LIST_FORMAT_NUM_VALUES /* must be last */
} ABMF_ARG_LIST_FORMAT;
/*
* Argument "classes"
*/
typedef unsigned char ABMF_ARG_CLASS;
#define ABMF_ARGCLASS_UNDEF ABMF_ARGCLASS_NONE
#define ABMF_ARGCLASS_NONE ((ABMF_ARG_CLASS)0x00)
#define ABMF_ARGCLASS_SENSITIVITY ((ABMF_ARG_CLASS)0x01)
#define ABMF_ARGCLASS_TYPED ((ABMF_ARG_CLASS)0x02)
#define ABMF_ARGCLASS_WIDGET_REF ((ABMF_ARG_CLASS)0x04)
#define ABMF_ARGCLASS_OTHER ((ABMF_ARG_CLASS)0x08)
#define ABMF_ARGCLASS_ALL ((ABMF_ARG_CLASS)0xff)
#define ABMF_ARGCLASS_ALL_BUT_WIDGET_REF \
(ABMF_ARGCLASS_ALL & ~ABMF_ARGCLASS_WIDGET_REF)
int abmfP_args_init(void); /* call first! */
int abmfP_xt_va_list_open(GenCodeInfo);
int abmfP_xt_va_list_open_setvalues(GenCodeInfo, ABObj obj);
int abmfP_xt_va_list_close(GenCodeInfo);
BOOL abmfP_arg_is_sensitivity(STRING argName);
BOOL abmfP_arg_is_typed(STRING argName);
BOOL abmfP_arg_is_widget_ref(STRING argName);
BOOL abmfP_arg_is_callback(STRING argName);
int abmfP_get_num_args(ABObj obj);
int abmfP_get_num_code_file_args(GenCodeInfo genCodeInfo, ABObj obj);
int abmfP_get_num_res_file_args(GenCodeInfo genCodeInfo, ABObj obj);
int abmfP_write_arg_val(
GenCodeInfo genCodeInfo,
BOOL dumpResource, /* put in res. file format */
STRING argName,
void *argValue,
ABObj obj /* obj the arg belongs to */
);
/*
* Count args of specific classes (typed, widget-reference, ...)
*/
int abmfP_get_num_args_of_classes(
ABObj obj,
ABMF_ARG_CLASS classes
);
int abmfP_comp_get_num_args_of_classes(
ABObj obj,
ABMF_ARG_CLASS classes
);
int abmfP_get_num_code_file_args_of_classes(
GenCodeInfo genCodeInfo,
ABObj obj,
ABMF_ARG_CLASS classes
);
int abmfP_comp_get_num_code_file_args_of_classes(
GenCodeInfo genCodeInfo,
ABObj obj,
ABMF_ARG_CLASS classes
);
int abmfP_get_num_res_file_args_of_classes(
GenCodeInfo genCodeInfo,
ABObj obj,
ABMF_ARG_CLASS classes
);
int abmfP_comp_get_num_res_file_args_of_classes(
GenCodeInfo genCodeInfo,
ABObj obj,
ABMF_ARG_CLASS classes
);
BOOL abmfP_arg_is_spewed( /* saved out, or ignored completely? */
GenCodeInfo genCodeInfo,
STRING argName,
ABObj obj
);
BOOL abmfP_arg_is_dumped( /* should arg be dumped to resource file? */
GenCodeInfo genCodeInfo,
STRING argName,
ABObj obj
);
BOOL abmfP_arg_is_written( /* should arg be written to the C file? */
GenCodeInfo genCodeInfo,
STRING argName,
ABObj obj
);
int abmfP_obj_spew_args(
GenCodeInfo genCodeInfo,
ABObj obj,
ABMF_ARG_CLASS argClassesToSpew,
ABMF_ARG_LIST_FORMAT argFormat
);
AB_ARG_TYPE abmfP_get_res_type(
STRING res_xmname,
ABObj obj /* may be NULL */
);
/*****************************************************************
** **
** INLINE IMPLEMENTATION **
** **
*****************************************************************/
#define abmfP_get_num_args(obj) \
(abmfP_get_num_args_of_classes(obj, ABMF_ARGCLASS_ALL))
#define abmfP_get_num_code_file_args(obj) \
(abmfP_get_num_code_file_args_of_classes(obj, ABMF_ARGCLASS_ALL))
#define abmfP_get_num_res_file_args(obj) \
(abmfP_get_num_res_file_args_of_classes(obj, ABMF_ARGCLASS_ALL))
#endif /* _ABMF_ARGSP_H_ */

View File

@@ -0,0 +1,65 @@
/*
* $XConsortium: cdefs.c /main/3 1995/11/06 18:02:58 rswiston $
*
* @(#)cdefs.c 1.11 17 Nov 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* cdefs.c - general C defines, for spitting out code
*/
#include "cdefsP.h"
/*************************************************************************
** **
** Constants (#define and const) **
** **
**************************************************************************/
/*************************************************************************
** **
** Private Functions (C declarations and macros) **
** **
**************************************************************************/
/*************************************************************************
** **
** Data **
** **
**************************************************************************/
/*************************************************************************
** **
** Function Definitions **
** **
**************************************************************************/
STRING abmfP_comment_begin= "/*\n";
STRING abmfP_comment_continue= " * ";
STRING abmfP_comment_end= " */\n";
STRING abmfP_call_data_var_name = "callData";
STRING abmfP_client_data_var_name = "clientData";
STRING abmfP_instance_ptr_var_name= "instance";
STRING abmfP_parent_param_name= "parent";
STRING abmfP_toplevel_var_name= "toplevel";
STRING abmfP_widget_var_name = "widget";
STRING abmfP_tt_msg_var_name = "msg";
STRING abmfP_ss_session_file_var_name = "session_file";
STRING abmfP_argv_var_name = "argv";
STRING abmfP_argc_var_name = "argc";

View File

@@ -0,0 +1,46 @@
/*
* $XConsortium: cdefsP.h /main/3 1995/11/06 18:03:13 rswiston $
*
* @(#)cdefsP.h 1.11 17 Nov 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* cdefs.h - string constants, defines, et cetera for writing C code
*/
#ifndef _ABMF_CDEFS_H_
#define _ABMF_CDEFS_H_
#include "write_codeP.h"
extern STRING abmfP_comment_begin;
extern STRING abmfP_comment_continue;
extern STRING abmfP_comment_end;
extern STRING abmfP_call_data_var_name;
extern STRING abmfP_client_data_var_name;
extern STRING abmfP_counter_var_name;
extern STRING abmfP_instance_ptr_var_name;
extern STRING abmfP_parent_param_name;
extern STRING abmfP_toplevel_var_name;
extern STRING abmfP_widget_var_name;
extern STRING abmfP_tt_msg_var_name;
extern STRING abmfP_ss_session_file_var_name;
extern STRING abmfP_argv_var_name;
extern STRING abmfP_argc_var_name;
#endif /* _ABMF_CDEFS_H_ */

View File

@@ -0,0 +1,262 @@
/*
* $XConsortium: connect.c /main/3 1995/11/06 18:03:27 rswiston $
*
* @(#)connect.c 3.25 13 Feb 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special restrictions in a
* confidential disclosure agreement between HP, IBM, Sun, USL, SCO and
* Univel. Do not distribute this document outside HP, IBM, Sun, USL, SCO,
* or Univel without Sun's specific written approval. This document and all
* copies and derivative works thereof must be returned or destroyed at Sun's
* request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* connect.c - Handles connections stuff
*/
#include <stdio.h>
#include <string.h>
#include <ab_private/trav.h>
#include "ui_header_fileP.h" /* abmfP_comp_get_widget_specific_includes */
#include "obj_namesP.h"
#include "connectP.h"
#define APP_PREFIX_LEN 4
#define APP_PREFIX "_app"
static int abmfP_set_action_names_for_obj(ABObj rootObj);
STRING
abmfP_get_action_name(ABObj action)
{
static char name[256];
STRING parent_name = (STRING) NULL;
ABObj from = NULL, parent = NULL;
STRING tmpName = NULL;
*name = 0;
from = obj_get_from(action);
if (action->info.action.auto_named && (from != NULL))
{
/* If the source object is the project,
* then this is an "Application" connection.
* This probably won't happen because right
* now "Application" connections can only be
* of type AB_FUNC_USER_DEF (which means auto-
* named is FALSE).
*/
if (obj_is_project(from))
{
parent = obj_get_project(action);
parent_name = (STRING) util_malloc(
strlen(obj_get_name(parent))
+ APP_PREFIX_LEN + 1);
strcpy(parent_name, obj_get_name(parent));
strcat(parent_name, APP_PREFIX);
}
else
{
parent = obj_get_module(from);
parent_name = obj_get_name(parent);
}
if (!util_strempty(parent_name) &&
!util_strempty(obj_get_name(from)))
{
sprintf(name, "%s_%s%s",
parent_name,
obj_get_name(from),
obj_get_func_name_suffix(action));
}
if (obj_is_project(from))
{
util_free(parent_name);
}
}
else
{
if ((tmpName = obj_get_func_name(action)) != NULL)
{
sprintf(name, "%s", tmpName);
}
}
return (name[0] == 0 ? NULL : name);
}
/*
*
*/
int
abmfP_tree_set_action_names(ABObj rootObj)
{
int return_value = 0;
AB_TRAVERSAL moduleTrav;
ABObj module = NULL;
if (!obj_is_project(rootObj))
{
return_value = abmfP_set_action_names_for_obj(rootObj);
}
else
{
/* for efficiency, we'll only visit those modules that are
* going to be written
*/
abmfP_set_action_names_for_obj(rootObj); /* project 1st */
for (trav_open(&moduleTrav, rootObj, AB_TRAV_MODULES);
(module = trav_next(&moduleTrav)) != NULL; )
{
if (obj_get_write_me(module))
{
abmfP_set_action_names_for_obj(module); /* each module */
}
}
trav_close(&moduleTrav);
}
return return_value;
}
static int
abmfP_set_action_names_for_obj(ABObj rootObj)
{
int return_value = 0;
int actionNum = -1;
AB_TRAVERSAL actionTrav;
ABObj action = NULL;
ABObj fromObj = NULL;
char buf[256];
if (mfobj_data(rootObj) == NULL)
{
return -1;
}
for (trav_open(&actionTrav, rootObj, AB_TRAV_ACTIONS_FOR_OBJ);
(action = trav_next(&actionTrav)) != NULL;)
{
if ( (obj_get_func_type(action) != AB_FUNC_USER_DEF)
&& ((fromObj = obj_get_from(action)) != NULL) )
{
action->info.action.auto_named = TRUE;
actionNum = mfobj_data(fromObj)->num_auto_callbacks + 1;
mfobj_data(fromObj)->num_auto_callbacks = actionNum;
sprintf(buf, "_CB%d", actionNum);
obj_set_func_name_suffix(action, buf);
}
}
trav_close(&actionTrav);
return return_value;
}
int
abmfP_get_connect_includes(StringList includeFiles, ABObj projOrModule)
{
AB_TRAVERSAL trav;
BOOL actionIsCrossModule = FALSE;
ABObj project = obj_get_project(projOrModule);
ABObj action = NULL;
ABObj toObj = NULL;
ABObj compRoot = NULL;
ABObj toModule = NULL;
ABObj win_parent = NULL;
ABObj popup_win = NULL;
char headerFilename[MAXPATHLEN+1];
*headerFilename = 0;
strlist_set_is_unique(includeFiles, TRUE);
assert(project != NULL);
if (project == NULL)
{
return NULL;
}
for (trav_open(&trav, projOrModule, AB_TRAV_ACTIONS_FOR_OBJ);
(action = trav_next(&trav)) != NULL; )
{
actionIsCrossModule = obj_is_cross_module(action);
toObj = obj_get_to(action);
if (toObj == NULL)
{
continue;
}
toModule = obj_get_module(toObj);
if (actionIsCrossModule)
{
sprintf(headerFilename, "\"%s\"",
abmfP_get_ui_header_file_name(toModule));
strlist_add_str(includeFiles, headerFilename, NULL);
}
/*
* Check to see if the popup's window parent is in another module
*/
compRoot = obj_get_root(toObj);
popup_win = NULL;
if (obj_is_popup_win(compRoot))
{
popup_win = compRoot;
}
if (popup_win == NULL)
{
popup_win = obj_get_parent_of_type(compRoot, AB_TYPE_DIALOG);
}
if (popup_win == NULL)
{
popup_win = obj_get_parent_of_type(compRoot, AB_TYPE_BASE_WINDOW);
}
if (popup_win != NULL)
{
win_parent= obj_get_win_parent(popup_win);
if (win_parent != NULL)
{
toModule = obj_get_module(win_parent);
if (toModule != NULL)
{
sprintf(headerFilename, "\"%s\"",
abmfP_get_ui_header_file_name(toModule));
strlist_add_str(includeFiles, headerFilename, NULL);
}
}
}
/*
* For some actions, we need widget-specific convenience
* functions and resource strings that exist in the header files.
*/
if (obj_get_func_type(action) == AB_FUNC_BUILTIN)
{
switch (obj_get_func_builtin(action))
{
case AB_STDACT_SET_LABEL:
case AB_STDACT_SET_TEXT:
case AB_STDACT_SET_VALUE:
abmfP_comp_get_widget_specific_includes(
includeFiles, obj_get_root(toObj));
break;
}
}
}
trav_close(&trav);
return 0;
}

View File

@@ -0,0 +1,34 @@
/*
* $XConsortium: connectP.h /main/3 1995/11/06 18:03:43 rswiston $
*
* @(#)connectP.h 3.14 07 Mar 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* connect.h - abmf connections
*/
#ifndef _ABMF_CONNECTION_H_
#define _ABMF_CONNECTION_H_
#include <ab_private/obj.h>
#include "utilsP.h"
int abmfP_set_auto_func_names(ABObj root);
int abmfP_tree_set_action_names(ABObj tree);
int abmfP_get_connect_includes(StringList includeFiles, ABObj projOrModule);
#endif /* _ABMF_CONNECTION_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,32 @@
/*
* $XConsortium: create_declsP.h /main/3 1995/11/06 18:04:11 rswiston $
*
* %W% %G% cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* create_declsP.h - write create/init function declarations
*/
#ifndef _ABMF_CREATE_DECLSP_H_
#define _ABMF_CREATE_DECLSP_H_
#include "write_codeP.h"
int abmfP_write_create_proc_decls(GenCodeInfo genCodeInfo);
#endif /* _ABMF_CREATE_DECLSP_H_ */

View File

@@ -0,0 +1,340 @@
/*
* $XConsortium: dtb_utils.c /main/3 1995/11/06 18:04:26 rswiston $
*
* @(#)dtb_utils.c 1.1 20 Sep 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* dtb_utils.c - partial set of dtb_utils functions
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <ab_private/util.h>
#include "dtb_utils.h"
/*
* Map Xt/Xm symbols to symbols we have defined
*/
#define String STRING
#define Boolean BOOL
#define False FALSE
#define True TRUE
#define min(a,b) util_min(a,b)
/*************************************************************************
** **
** Constants (#define and const) **
** **
**************************************************************************/
/*************************************************************************
** **
** Private Functions (C declarations and macros) **
** **
**************************************************************************/
/*
* Private functions used for finding paths
*/
static int determine_exe_dir(char *argv0, char *buf, int bufSize);
static int determine_exe_dir_from_argv(char *argv0, char *buf, int bufSize);
static int determine_exe_dir_from_path (char *argv0, char *buf, int bufSize);
static Boolean path_is_executable(char *path, uid_t euid, gid_t egid);
/*************************************************************************
** **
** Data **
** **
**************************************************************************/
/*
* Directory where the binary for this process whate loaded from
*/
static char *dtb_exe_dir = (char *)NULL;
/*************************************************************************
** **
** Function Definitions **
** **
**************************************************************************/
void
dtb_save_command(char *argv0)
{
char exe_dir[MAXPATHLEN+1];
/*
* Save the path to the executable
*/
if (determine_exe_dir(argv0, exe_dir, MAXPATHLEN+1) >= 0)
{
dtb_exe_dir = (char *)malloc(strlen(exe_dir)+1);
if (dtb_exe_dir != NULL)
{
strcpy(dtb_exe_dir, exe_dir);
}
}
}
/*
* Returns the directory that the executable for this process was loaded
* from.
*/
String
dtb_get_exe_dir(void)
{
return dtb_exe_dir;
}
/*
* Determines the directory the executable for this process was loaded from.
*/
static int
determine_exe_dir(char *argv0, char *buf, int bufSize)
{
Boolean foundDir= False;
if ((buf == NULL) || (bufSize < 1))
{
return -1;
}
if (determine_exe_dir_from_argv(argv0, buf, bufSize) >= 0)
{
foundDir = True;
}
if (!foundDir)
{
if (determine_exe_dir_from_path(argv0, buf, bufSize) >= 0)
{
foundDir = True;
}
}
/*
* Convert relative path to absolute, so that directory changes will
* not affect us.
*/
if (foundDir && (buf[0] != '/'))
{
char cwd[MAXPATHLEN+1];
char *env_pwd = NULL;
char *path_prefix = NULL;
char abs_exe_dir[MAXPATHLEN+1];
if (getcwd(cwd, MAXPATHLEN+1) != NULL)
{
path_prefix = cwd;
}
else
{
env_pwd = getenv("PWD");
if (env_pwd != NULL)
{
path_prefix = env_pwd;
}
}
if (path_prefix != NULL)
{
strcpy(abs_exe_dir, path_prefix);
if (strcmp(buf, ".") != 0)
{
strcat(abs_exe_dir, "/");
strcat(abs_exe_dir, buf);
}
strcpy(buf, abs_exe_dir);
}
}
return foundDir? 0:-1;
}
/*
* Looks for absolute path in arv[0].
*/
static int
determine_exe_dir_from_argv(char *argv0, char *buf, int bufSize)
{
int i= 0;
Boolean foundit= False;
for (i= strlen(argv0)-1; (i >= 0) && (argv0[i] != '/'); --i)
{
}
if (i >= 0)
{
int maxStringSize= min(i, bufSize);
strncpy(buf, argv0, maxStringSize);
buf[min(maxStringSize, bufSize-1)]= 0;
foundit = True;
}
return foundit? 0:-1;
}
/*
* Assumes: bufSize > 0
*/
static int
determine_exe_dir_from_path (char *argv0, char *buf, int bufSize)
{
Boolean foundDir= False;
Boolean moreDirs= True;
char *szExeName= argv0;
int iExeNameLen= strlen(szExeName);
char *szTemp= NULL;
char szPathVar[MAXPATHLEN+1];
int iPathVarLen= 0;
char szCurrentPath[MAXPATHLEN+1];
int iCurrentPathLen= 0;
int iCurrentPathStart= 0;
int i = 0;
uid_t euid= geteuid();
uid_t egid= getegid();
szTemp= getenv("PATH");
if (szTemp == NULL)
{
moreDirs= False;
}
else
{
strncpy(szPathVar, szTemp, MAXPATHLEN);
szPathVar[MAXPATHLEN]= 0;
iPathVarLen= strlen(szPathVar);
}
while ((!foundDir) && (moreDirs))
{
/* find the current directory name */
for (i= iCurrentPathStart; (i < iPathVarLen) && (szPathVar[i] != ':');
)
{
++i;
}
iCurrentPathLen= i - iCurrentPathStart;
if ((iCurrentPathLen + iExeNameLen + 2) > MAXPATHLEN)
{
iCurrentPathLen= MAXPATHLEN - (iExeNameLen + 2);
}
/* create a possible path to the executable */
strncpy(szCurrentPath, &szPathVar[iCurrentPathStart], iCurrentPathLen);
szCurrentPath[iCurrentPathLen]= 0;
strcat(szCurrentPath, "/");
strcat(szCurrentPath, szExeName);
/* see if the executable exists (and we can execute it) */
if (path_is_executable(szCurrentPath, euid, egid))
{
foundDir= True;
}
/* skip past the current directory name */
if (!foundDir)
{
iCurrentPathStart+= iCurrentPathLen;
while ( (iCurrentPathStart < iPathVarLen)
&& (szPathVar[iCurrentPathStart] != ':') )
{
++iCurrentPathStart; /* find : */
}
if (iCurrentPathStart < iPathVarLen)
{
++iCurrentPathStart; /* skip : */
}
if (iCurrentPathStart >= iPathVarLen)
{
moreDirs= False;
}
}
} /* while !foundDir */
if (foundDir)
{
szCurrentPath[iCurrentPathLen]= 0;
strncpy(buf, szCurrentPath, bufSize);
buf[bufSize-1]= 0;
}
return foundDir? 0:-1;
}
/*
* returns False is path does not exist or is not executable
*/
static Boolean
path_is_executable(char *path, uid_t euid, gid_t egid)
{
Boolean bExecutable= False;
struct stat sStat;
if (stat(path, &sStat) == 0)
{
Boolean bDetermined= False;
if (!bDetermined)
{
if (!S_ISREG(sStat.st_mode))
{
/* not a regular file */
bDetermined= True;
bExecutable= False;
}
}
if (!bDetermined)
{
if ( (euid == 0)
&& ( ((sStat.st_mode & S_IXOTH) != 0)
|| ((sStat.st_mode & S_IXGRP) != 0)
|| ((sStat.st_mode & S_IXUSR) != 0) )
)
{
bDetermined= True;
bExecutable= True;
}
}
if (!bDetermined)
{
if ( (((sStat.st_mode & S_IXOTH) != 0) )
|| (((sStat.st_mode & S_IXGRP) != 0) && (sStat.st_gid == egid))
|| (((sStat.st_mode & S_IXUSR) != 0) && (sStat.st_gid == euid))
)
{
bDetermined= True;
bExecutable= True;
}
}
} /* if stat */
return bExecutable;
}

View File

@@ -0,0 +1,34 @@
/*
* $XConsortium: dtb_utils.h /main/3 1995/11/06 18:04:40 rswiston $
*
* @(#)dtb_utils.h 1.1 20 Sep 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* dtb_utils.h - partial set of dtb_utils.h functions
*/
#ifndef _ABMF_DTB_UTILS_H_
#define _ABMF_DTB_UTILS_H_
#include <ab/util_types.h>
void dtb_save_command(char *argv0);
STRING dtb_get_exe_dir(void);
#endif /* _ABMF_DTB_UTILS_H_ */

View File

@@ -0,0 +1,904 @@
.\" $XConsortium: dtcodegen.man /main/2 1995/07/17 10:50:10 drk $
.\" *************************************************************************
.\" ** (c) Copyright 1993, 1994 Hewlett-Packard Company
.\" ** (c) Copyright 1993, 1994 International Business Machines Corp.
.\" ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
.\" ** (c) Copyright 1993, 1994 Novell, Inc.
.\" *************************************************************************
.\"--- The above copyrights must appear at the top of each man page.
.\"---
.\"--- ******** THIS IS THE SECTION 1 MAN PAGE TEMPLATE/STYLE GUIDE *******
.\"---
.\"--- Naming conventions:
.\"--- The title of the page name starts with dt (except ToolTalk and Motif).
.\"--- The section number is 1 or 1m if appropriate (except ToolTalk and Motif).
.\"--- The Sample Implementation man page file is the complete title
.\"--- without truncation or abbreviation, plus the .1 or .1m extension.
.\"--- The common source (X/Open and Sample Implementation) man page file name
.\"--- is the complete title without truncation or abbreviation, plus the
.\"--- .1xo extension.
.\"--- As the man pages are converted to the common source, the .1 files are
.\"--- replaced by .1xo files, and the .1 files are generated at build time.
.\"---
.\"---
.\"--- Substitute the appropriate text for items beginning and ending with `_'
.\"--- (for example, _title_ and _name_). \-option_ items begin with
.\"--- `\-' (minus) and end with `_'. Do not delete the `\-' characters.
.\"--- Be sure to use upper or lower case as indicated for each item.
.\"---
.\"---
.\"--- GUI documentation:
.\"--- The graphical user interfaces (menus, dialogs, etc.) are not
.\"--- documentated in section 1 man pages. A reference to the appropriate
.\"--- on-line help volume is included instead.
.\"---
.\"---
.\"--- Use Cde whenever you want CDE. The scripts will then pick up the
.\"--- correct trademark name for the X/Open version and use CDE for the man
.\"--- page.
.\"---
.\"--- Always spell out standard input, output, and error.
.\"---
.\"--- Never use "print" unless you are describing literal printing
.\"--- operations; use "write to standard output [error]."
.\"---
.\"--- Be careful not to say "character" when you mean "byte."
.\"---
.\"--- Never change the case of a symbol such as a function name. If it
.\"--- starts lowercase, you cannot start a sentence with it.
.\"---
.\"--- Do not use the second person form of address or imperatives when
.\"--- referring to the reader or application.
.\"---
.\"--- Avoid passive voice.
.\"---
.\"--- Call utilities utilities, not commands.
.\"---
.\"--- *******
.\"--- *** Question for Hal *** The CDE specs distinguish between utilities
.\"--- (no GUI) and clients (GUI). Should both of these be referred to
.\"--- as utilities for X/Open?
.\"--- *******
.\"---
.\"--- Utilities appear in italics.
.\"--- Use the following macro with a second argument for the section number.
.\"--- For example: .Cm tt_session 1
.\"--- There is no section number for same page usage.
.\"--- If no information is appropriate under a heading, say None or Not used.
.\"---
.\"--- Variable list example:
.\"--- .VL 12
.\"--- .LI foo
.\"--- text text text
.\"--- .LI averylongtagneedsabreak
.\"--- .br
.\"--- text text text
.\"--- .Lc R_OK
.\"--- text text text
.\"--- .LE
.\"---
.\"--- Bulleted list example:
.\"--- .VL 3
.\"--- .LI \(bu
.\"--- text text text
.\"--- .LI \(bu
.\"--- text text text
.\"--- .LE
.\"---
.\"--- Environment variables example:
.\"--- Use italics and all uppercase. Do not prefix with a $ in regular text,
.\"--- (only shell script examples)
.\"--- .I SHELL
.\"--- .IR LC_MESSAGES
.\"--- .LI \f2LANG\fP [.VL list version]
.\"---
.\"--- Pathnames example:
.\"--- Use bold font
.\"--- .B /etc/passwd
.\"--- .BR \&.profile [note the \& to protect leading dot]
.\"--- .LI \f3/tmp\fP
.\"---
.\"--- Utility options in SYNOPSIS example:
.\"--- .SH SYNOPSIS
.\"--- .yS
.\"--- ttsession
.\"--- [\-hNpsStv]
.\"--- [\-E|\-X]
.\"--- [\-a\ \f2level\fP]
.\"--- [\-d\ \f2display\fP]
.\"--- [\-c\ [\f2command\fP]]
.\"--- .yE
.\"---
.\"--- Utility options in TEXT example (bold for X/Open; use \- for minus):
.\"--- .B \-x
.\"--- .BR \-y ;
.\"--- .BI \-f " makefile" [note space]
.\"--- \f3\(mif\ \fPmakefile\fP [version of previous if you're breaking
.\"--- across two lines]
.\"--- .LI \f3\-a\0\f2level\f1 [.VL version; note usage of \0 as an internal
.\"--- space and the return to font 1]
.\"---
.\"---
.\"---
.\"--- *** Typographical Conventions
.\"---
.\"--- Use the following to denote different fonts: italic = \f2, bold = \f3
.\"--- regular font = \f1. These are used in the common source and are
.\"--- translated by the sed scripts into the appropriate font needed for X/Open
.\"--- or the SI.
.\"---
.\"--- Bold font is used for options and commands, filenames, keywords and
.\"--- typenames. It is also used to identify brackets surrounding optional
.\"--- items in syntax, [ ].
.\"---
.\"--- Italic strings are used for emphasis or to identify the first instance
.\"--- of a word requiring definition. Italic also denotes: variable names,
.\"--- which are also shown in capitals; commands or utilities; external
.\"--- variables; X Window System widgets; functions - all these are shown as
.\"--- follows: \f2name\fP(), name without parentheses are either external
.\"--- variables or function family names.
.\"---
.\"--- Regular font is used for the names of constants and literals.
.\"---
.\"--- The notation <file.h> indicates a header file.
.\"---
.\"--- Names surrounded by braces, for example, {ARG_MAX}, represent symbolic
.\"--- limits or configuration values that may be declared in appropriate
.\"--- headers by means of the C #define construct.
.\"---
.\"--- Ellipses, . . . , are used to show that additional arguments are
.\"--- optional.
.\"---
.\"--- Syntax and code examples are shown in fixed-width font. Brackets
.\"--- shown in this font, [ ], are part of the syntax and do not indicate
.\"--- optional items.
.\"---
.\"--- Variables within syntax statements are shown in italic fixed-width font.
.\"---
.\"--- ***Headings for Section 1 man pages
.\"---
.\"--- Use the headings in the list below for Section 1 man pages in the order
.\"--- listed. Use only these listed main headings. List each heading even
.\"--- if no information is appropriate; if no information is appropriate, say
.\"--- "None" or "Not used."
.\"---
.\"--- Headings use uppercase and are marked with the .SH macro.
.\"--- If the heading is more than one word, you must put the entire heading
.\"--- between quotes.
.\"---
.\"--- You may use headings other than those in the list when
.\"--- they help you organize the page; headings other than those in the list
.\"--- are subordinate to the listed main headings. Place subordinate
.\"--- headings under the appropriate main heading.
.\"--- Use the .HU macro for subordinate headings.
.\"---
.\"--- There should be only one utility per man page.
.\"---
.\"--- REQUIRED Headings for Section 1 man pages:
.\"--- NAME, SYNOPSIS, DESCRIPTION, OPTIONS, OPERANDS, RESOURCES,
.\"--- CAPABILITIES, STDIN, "INPUT FILES", "ENVIRONMENT VARIABLES",
.\"--- "ASYNCHRONOUS EVENTS", STDOUT, STDERR, "OUTPUT FILES",
.\"--- "EXTENDED DESCRIPTION", "EXIT STATUS", "CONSEQUENCES OF ERRORS",
.\"--- "APPLICATION USAGE", EXAMPLES, "SEE ALSO"
.\"---
.\"--- -------------------------------------------------------------------------
.\"--- .TH Macro
.\"--- The .TH macro specifies information that applies to the man page as
.\"--- a whole.
.\"--- _title_ is the name of the man page. This should correspond to the
.\"--- first word under the NAME heading. _#_ specifies the manual section in
.\"--- which the page appears, where # is the number of the section.
.\"---
.\"--- .TH _title _#_
.TH dtcodegen 1
.\"---
.\"----------------------------------------------------------------------------
.\"--- NAME
.\"--- Give the name of the entry and briefly state its purpose.
.\"--- This section is used by cross-referencing programs. Hence, do not
.\"--- use any font changes or troff escape sequences in this section.
.\"--- After the name, use one space, a backslash minus \-, and then another space
.\"-- before the summary.
.\"--- Do not start the summary sentence with a capital letter or use
.\"--- any punctuation at the end.
.\"--- The summary line must be on one line (it can wrap). The reason for this
.\"--- is that some man page implementations build an index of man page values
.\"--- by reading through and getting the single line that follows the .SH NAME
.\"--- line. The line doesn't have to fit on a terminal screen, but there
.\"--- can be only one physical new line on the line.
.\"--- Make the summary a simple declarative sentence.
.\"---
.\"--- NAME example:
.\"---
.\"--- ttsession \- the ToolTalk message server
.\"--- or:
.\"--- dtgather \- gather application files for presentation by the Application Manager
.\"---
.SH Name
dtcodegen \- generate code from a Cde Application Builder project or module file
.\"---
.\"----------------------------------------------------------------------------
.\"--- SYNOPSIS
.\"--- This section summarizes the syntax of the calling sequence for the
.\"--- utility, including options, option-arguments and operands.
.\"---
.\"--- Begin the synopsis with the .yS macro and end the synopsis with the
.\"--- .yE macro.
.\"---
.\"--- Use backslash minus \- for minus.
.\"---
.\"--- List single letters first in a group.
.\"---
.\"--- Code as in the following example; the conversion scripts do the rest.
.\"---
.\"--- Utility options in SYNOPSIS example:
.\"---
.\"--- .SH SYNOPSIS
.\"--- .yS
.\"--- ttsession
.\"--- [\-hNpsStv]
.\"--- [\-E|\-X]
.\"--- [\-a\ \f2level\fP]
.\"--- [\-d\ \f2display\fP]
.\"--- [\-c\ [\f2command\fP]]
.\"--- .yE
.\"---
.\"--- Utility options in TEXT example (bold for X/Open; use \- for minus):
.\"--- .B \-x
.\"--- .BR \-y ;
.\"--- .BI \-f " makefile" [note space]
.\"--- \f3\(mif\ \fPmakefile\fP [version of previous if you're breaking
.\"--- across two lines]
.\"--- .LI \f3\-a\0\f2level\f1 [.VL version; note usage of \0 as an internal
.\"--- space and the return to font 1]
.\"---
.SH SYNOPSIS
.yS
dtcodegen
[\-s|\-silent]
[\-v|\-verbose]
[\-p|\-project]
[\-np|\-noproject]
[\-nomerge]
[\-merge]
[\-help]
[-main]
[-showall]
[-changed]
[filename]
.yE
.\"---
.\"----------------------------------------------------------------------------
.\"--- DESCRIPTION
.\"--- This section describes the actions of the utility. If the utility
.\"--- has a very complex set of subcommands or its own procedural language,
.\"--- an EXTENDED DESCRIPTION heading is provided. Most explanations of
.\"--- optional functionality are omitted here, as they are usually explained
.\"--- under the OPTIONS heading.
.\"--- When specific functions are cited, the underlying operating system
.\"--- provides equivalent functionality and all side effects associated
.\"--- with successful execution of the function. The treatment of erors and
.\"--- intermediate results from the individual functions cited are generally
.\"--- not specified by this document. See the utility's EXIT STATUS and
.\"--- CONSEQUENCES OF ERRORS section for all actions associated with errors
.\"--- encountered with by the utility.
.\"---
.\"--- When writing, use active voice, never use 2nd person, and make it
.\"--- clear who or what the requirements are placed on.
.\"---
.\"--- DESCRIPTION example:
.\"---
.\"--- Do not say: When you are done with this
.\"--- implementation object, it should be freed. (Who frees
.\"--- it, the programmer or the implementation?)
.\"--- Do use active voice and say: When you are done with this implementation
.\"--- object, you must free it. Or: When you are done with this
.\"--- implementation object, the implementation will free it.
.\"---
.\"--- Make the utility the grammatical subject
.\"--- of the first sentence; use a present tense verb to describe the utility;
.\"--- note that whenever you use the utility name, use the
.\"--- .Fn request and put it on a single line.
.\"--- .Fn gets the correct font and puts in the trailing
.\"--- "( )" with the correct spacing.
.\"---
.\"--- DESCRIPTION example:
.\"---
.\"--- The
.\"--- .Fn tt_session
.\"--- utility is the ToolTalk message server.
.\"---
.SH DESCRIPTION
The
.Cm dtcodegen
utility reads Builder Interface Language (BIL) files created by the
Cde Application Builder, a user interface and application development tool,
and produces C, Motif and Cde source code for the user interface and
application elements defined.
The BIL files supplied can be individual module files (*.bil) or a
project file (*.bip) that contains references to one or more module files.
.\"---
.\"----------------------------------------------------------------------------
.\"--- OPTIONS
.\"--- This section describes the utility options and option-arguments, and how
.\"--- they modify the actions of the utility.
.\"--- Default behavior: When this section is listed as "None", it means that
.\"--- the implementation need not support any options.
.\"---
.\"--- OPTIONS example:
.\"---
.\"--- .SH OPTIONS
.\"--- need something here as an example
.\"---
.SH OPTIONS
.TP
.B \-s [\-silent]
Instructs
.Cm dtcodegen
to work silently, producing no output except error messages while generating
source code.
.TP
.B \-v [\-verbose]
Instructs
.Cm dtcodegen
to be more verbose in providing progress and status messages
during the generation of source code.
.TP
.B \-p [\-project] myproj
Specifies that
.B dtcodegen
should generate code for the project
.IR myproj ,
(which is expected to be defined in the file
.IR myproj.bip .
.TP
.B \-merge
Instructs
.Cm dtcodegen
to merge generated stubs files with previous versions,
perpetuating changes made or custom edits done to the previous stubs file.
By default
.Cm
dtcodegen
performs as if this option had been specified.
.TP
.B \-nomerge
Prohibits
.B dtcodegen
from merging existing and new _stubs.c files.
Using this option overrides the default merging behavior.
.TP
.B \-help
Print out a help message explaining all
.B dtcodegen
options.
.TP
.B \-main
Instructs
.Cm dtcodegen
to only produce the project files associated with the application's
main routine.
.TP
.B \-changed
Instructs
.Cm dtcodegen
to only generate source code for those modules that have changed since
the last time it was run.
.TP
.B \-noproject
Will cause the
.I project.bip
project file to be ignored and default project settings to be used instead.
This is useful in producing an application from one or a few module files (e.g.,
for testing) as an alternative to generating the entire project.
.TP
.B -showall
Indicates that the generated application should show (map) all application
windows (e.g. main windows and dialogs) at startup, ignoring whether they are
set to be initially visibile or not.
If no project is specified on the command line
.Cm dtcodegen
will perform as if this option had been specified.
(In such cases it can be turned off by using the -noshowall option).
.TP
.B -noshowall
Indicates that the generated application should show at startup (map) only those
windows (e.g. main windows and dialogs) whose initially-visible attribute is
true.
If a project is specified on the command line either by using
the -project option or by specifying a
.I project.bip
file as an operand,
.Cm dtcodegen
will perform as if this option had been specified.
(In such cases it can be turned off by using the -showall option).
.\"---
.\"----------------------------------------------------------------------------
.\"--- OPERANDS
.\"--- This section describes the utility operands, and how they affect the
.\"--- actions of the utility.
.\"--- Default behavior: When this section is listed as "None", it means that
.\"--- the implementation need not support any operands.
.\"---
.\"--- OPERANDS example:
.\"---
.\"--- .SH OPERANDS
.\"--- need some sort of example here
.\"---
.SH OPERANDS
The
.Cm dtcodegen
utility accepts one or more filename operands as a way of specifying which
project and modules should be processed.
It is not necessary to specify the .bip or .bil extension for any file, as
.Cm dtcodegen
uses a sequence of search algorithms in the current directory to determine
what files should be read in order to satisfy the specified command line.
.P
If no filename operands are given,
.Cm dtcodegen
searches the current directory for a project file (*.bip).
If one is found, it will be used as if it had been specified on
the command line.
If more than one is found, the first one encountered will be used.
.P
If one or more filename operands are specified,
.Cm dtcodegen
checks to see if any of them are project files in the current working
directory, and will use it.
If none of the filename operands are project files, then the directory is
searched for a project file.
This search is similar to the no-operand case, but is modified to look
for a project file that contain modules corresponding to other filename
operands provided on the
.Cm dtcodegen
command line.
.P
Filename operands other than the project file are taken to be module
names.
.P
See the EXAMPLES section for more on the interpretation of filename operands
and how the search features of
.Cm dtcodegen
may be used.
.\"---
.\"----------------------------------------------------------------------------
.\"--- RESOURCES
.\"--- This section, which has no corresponding section in the X/Open CAE
.\"--- Specification, Commands and Utilities, Issue 4, lists the X Window
.\"--- System resources that affect the utility operation.
.\"---
.\"--- RESOURCES example:
.\"---
.\"--- .SH RESOURCES
.\"--- need some sort of example here.
.\"---
.SH RESOURCES
None.
The
.Cm dtcodegen
utility is not a X windows application, neither requires nor establishes
a connection to an X server, and therefore has no associated
X Window System Resources.
.\"----------------------------------------------------------------------------
.\"--- CAPABILITIES
.\"--- TBD
.\"---
.\"---
.\"----------------------------------------------------------------------------
.\"--- STDIN
.\"--- This section describes the standard input of the utility. This section
.\"--- is frequently a reference to the following section, as many utilties
.\"--- treat standard input and input files in the same manner. Unless
.\"--- otherwise stated, all restrictions described under the INPUT FILES
.\"--- heading apply to this section as well.
.\"--- Default behavior: When this section is listed as "Not used", it means
.\"--- that the standard input will not be read when the utility is used as
.\"--- described by this document.
.\"---
.\"---STDIN example:
.\"---
.\"--- .SH STDIN
.\"--- need some example here
.\"---
.SH STDIN
Not used.
.\"---
.\"----------------------------------------------------------------------------
.\"--- "INPUT FILES"
.\"--- This section describes the files, other than the standard input, used
.\"--- as input by the utility. It includes files named as operands
.\"--- and option-arguments as well as other files that are referred to, such
.\"--- as startup and initialization files, databases, etc. Commonly-used
.\"--- files are generally described in one place and cross-referenced by other
.\"--- utilities.
.\"--- Default Behavior: When this section is listed as "None", it means that
.\"--- no input files are required to be supplied when the utility is used as d
.\"--- described om this document.
.\"---
.\"--- INPUT FILES example:
.\"---
.\"--- "INPUT FILES"
.\"--- need an example here
.\"---
.SH "INPUT FILES"
Files processed by the
.Cm dtcodegen
utility are required to be in the BIL format defined for the Cde Application
Builder.
.\"----------------------------------------------------------------------------
.\"--- "ENVIRONMENT VARIABLES"
.\"--- This section lists what variables affect the utility's execution.
.\"--- Default Behavior: When this section is listed as "None", it means that the
.\"--- behavior of the utility is not directly affected by environment variables
.\"--- described by this document when the utility is used as described in this
.\"--- document.
.\"---
.\"--- ENVIRONMENT VARIABLES example:
.\"---
.\"--- .SH "ENVIRONMENT VARIABLES"
.\"--- need example here
.\"---
.SH "ENVIRONMENT VARIABLES"
None.
.\"---
.\"----------------------------------------------------------------------------
.\"--- "ASYNCHRONOUS EVENTS"
.\"--- This section lists how the utility reacts to such events as signals
.\"--- and what signals are caught.
.\"---
.\"--- ASYNCHRONOUS EVENTS example:
.\"---
.\"--- .SH "ASYNCHRONOUS EVENTS"
.\"--- The
.\"--- .Cm ttsession
.\"--- utility reacts to two signals.
.\"--- If it receives the
.\"--- .Cn SIGUSR1
.\"--- signal, it toggles trace mode on or off (see the
.\"--- .B \-t
.\"--- option).
.\"--- If it receives the
.\"--- .Cn SIGUSR2
.\"--- signal, it rereads the types file.
.\"--- The
.\"---.Cm ttsession
.\"--- utility takes the standard action for all other signals.
.\"---
.SH "ASYNCHRONOUS EVENTS"
The
.Cm dtcodegen
utility takes the standard action for all signals.
.\"---
.\"----------------------------------------------------------------------------
.\"--- "STDOUT"
.\"--- This section describes the standard output of the utility.
.\"--- Default Behavior: When this section is listed as "Not Used", it means
.\"--- that the standard output will not be written when the utility is used as
.\"--- described in this document.
.\"---
.\"--- STDOUT example:
.\"---
.\"--- .SH STDOUT
.\"--- When the
.\"--- .B \-v
.\"--- option is used,
.\"--- .Cm ttsession
.\"--- writes the version number in an unspecified format.
.\"--- When
.\"--- .B \-p
.\"--- is used,
.\"--- .Cm ttsession
.\"--- writes the name of a new process tree session.
.\"---
.SH STDOUT
Not used.
.\"---
.\"----------------------------------------------------------------------------
.\"--- STDERR
.\"--- This section describes the standard error output of the utility.
.\"--- Only those messages that are purposely sent by the utility are
.\"--- described.
.\"--- Default Behavior: When this section is listed as "Used only for dagnostic
.\"--- messages", it means that, unless otherwise stated, the diagnostic messages
.\"--- are sent to the standard error only when the exit status is non-zero
.\"--- and the utility is used as described by this document.
.\"--- When this section is listed as "Not used", it means that the standard
.\"--- output will not be written when the utility is used as
.\"--- described in this document.
.\"---
.\"--- STDERR example:
.\"---
.\"--- .SH STDERR
.\"--- need example here
.\"---
.SH STDERR
Used only for diagnostic messages.
.\"---
.\"----------------------------------------------------------------------------
.\"--- "OUTPUT FILES"
.\"--- This section describes the files created or modified by the utility.
.\"--- Default Behavior: When this section is listed as "None", it means that no
.\"--- files are created or modified as a consequence of direct action on the
.\"--- part of the utility when the utility is used as described by this
.\"--- document. However, the utility may create or modify system files, such
.\"--- as log files, that are outside the utility's normal execution environment.
.\"---
.\"--- OUTPUT FILES example:
.\"---
.\"--- .SH "OUTPUT FILES"
.\"--- need example
.\"---
.SH "OUTPUT FILES"
The
.Cm dtcodegen
utility produces the following files:
.TP
.I modname_ui.c
The primary source code file for module
.IR modname ,
containing C code to create the objects in the module and
establish connections for those objects.
.TP
.I modname_ui.h
Contains declarations and C externs for module
.IR modname .
.TP
.I modname_stubs.c
Contains callback functions for the element handlers specific to
module
.BR modname .
Additional application code should be added to this file, as its contents
are merged across runs of
.IR dtcodegen .
.TP
.I project.c
If
.Cm dtcodegen
is generating code for a project, this file will contain
the main() plus any callback functions that are common
across modules.
.TP
.I project.h
If
.Cm dtcodegen
is generating code for a project, this file will contain
declarations for any callback functions and C externs
that are common across interfaces.
.TP
.I .dtcodegen.log
This file is produced by the
.Cm dtcodegen
utility as a record of per-module code generation and the date/time of
each module was processed.
This data is required to provide support for the
.B -changed
option as part of determining which files need to be regenerated and
which ones do not.
.\"---
.\"----------------------------------------------------------------------------
.\"--- "EXTENDED DESCRIPTION"
.\"--- This section provides a place for describing the actions of very complicated
.\"--- utilities, such as text editors or language processors, which typically
.\"--- have elaborate command languages.
.\"--- Default behavior: When this section is listed as "None", no further
.\"--- description is necessary.
.\"---
.\"--- EXTENDED DESCRIPTION example:
.\"---
.\"--- .SH "EXTENDED DESCRIPTION"
.\"--- need example
.\"---
.SH "EXTENDED DESCRIPTION"
None.
.\"---
.\"----------------------------------------------------------------------------
.\"--- "EXIT STATUS"
.\"--- This section describes the values the utility returns to the calling
.\"--- program, or shell, and the conditions that cause these
.\"--- values to be returned. Usually, utilities return zero for successful
.\"--- completion and values greater than zero for various error conditions.
.\"--- If specific numeric values are listed in this section, the system
.\"--- uses those values for the errors described. In some cases, status
.\"--- values are listed more loosely, such as ">0". A portable application
.\"--- cannot rely on any specific value in the range shown and must be
.\"--- prepared to receive any value in the range. For example,
.\"--- a utility may list zero as a successful return, 1 as a failure for a
.\"--- specific reason, and >1 as "an error occurred". In this case,
.\"--- unspecified conditions may cause a 2 or 3, or other value, to be
.\"--- returned. A portable application should be written
.\"--- so that it tests for successful exit status values (zero in this case),
.\"--- rather than relying on the single specific error value listed
.\"--- in this document. In that way, it will have maximum portability,
.\"--- even on implementations with extensions. Unspecified error
.\"--- conditions may be represented by specific values not listed
.\"--- in this document.
.\"---
.\"--- EXIT STATUS example:
.\"---
.\"--- .SH "EXIT STATUS"
.\"--- When the
.\"--- .B \-c
.\"--- child process exits,
.\"--- .Cm ttsession
.\"--- exits with the status of the exited child.
.\"--- Otherwise, the following exit values are returned:
.\"--- .VL 4
.\"--- .LI 0
.\"--- Normal termination.
.\"--- Without the
.\"--- .B \-c
.\"--- or
.\"--- .B \-S
.\"--- options, a zero exit status means
.\"--- .Cm ttsession
.\"--- has successfully forked an instance of itself that has begun
.\"--- serving the session.
.\"--- .LI 1
.\"--- Abnormal termination.
.\"--- The
.\"--- .Cm ttsession
.\"--- utility was given invalid command line options, was interrupted by
.\"--- .Cn SIGINT ,
.\"--- or encountered some internal error.
.\"--- .LI 2
.\"--- Collision.
.\"--- Another
.\"--- .Cm ttsession
.\"--- was found to be serving the session already.
.\"--- .LE
.\"---
.SH "EXIT STATUS"
The following exit values are returned:
.VL 4
.LI 0
Normal termination.
.LI 1
Abnormal termination.
The
.Cm dtcodegen
utility was given invalid command line options, detected an error
in the format or content of the input file, failed to generate output,
was only asked to generate its usage message,
or determined that it was not necessary to generate any output given
the timestamps on the input file and the associated files in the target
directories.
.LE
.\"---
.\"----------------------------------------------------------------------------
.\"--- "CONSEQUENCES OF ERRORS"
.\"--- This section describes the effects on the environment, files systems, and
.\"--- so on, when error conditions occur. It does not describe error messages
.\"--- produced or exit status values used.
.\"--- When a utility encounters an error condition, several actions are possible,
.\"--- depending on the severity of the error and the state of the utility.
.\"--- Included in the possible actions of various utilities are: deletion of
.\"--- temporary intermediate work files; deletion of incomplete files; validity
.\"--- checking of the file system or directory.
.\"--- Default behavior: When this section is listed as "Default", it means that
.\"--- any changes to the environment are unspecified.
.\"---
.\"--- CONSEQUENCES OF ERRORS example:
.\"---
.\"--- .SH "CONSEQUENCES OF ERRORS"
.\"--- need example here.
.\"---
.SH "CONSEQUENCES OF ERRORS"
Because code generation involves the sequential production of a set
of application files, errors that cause the
.Cm dtcodegen
utility to prematurely exit might also result in some module or
project source files having been generated while others were
not.
Attempts to build the application from this mix of new and old
generated code may not succeed.
.\"---
.\"----------------------------------------------------------------------------
.\"--- "APPLICATION USAGE"
.\"--- This section gives advice to the application programmer or user about the
.\"--- way the utility should be used.
.\"---
.SH "APPLICATION USAGE"
Typically the
.Cm dtcodegen
utility is used indirectly through the
Cde Application Builder's Code Generator dialog.
This allows application code to be generated while the user is working
with the Application Builder rather than through a separate interface or
shell command line.
The Code Generator dialog provides a graphical user interface for
.Cm dtcodegen
that makes it easy to generate code, build the resulting application
and then excute it.
.P
In some cases, however, it may be desirable to use the
.Cm dtcodegen
utility directly.
A common example of this usage is to employ the
code generator from within an application Makefile to produce
a portion of the application code from pre-existing project or module
files.
.\"---
.\"----------------------------------------------------------------------------
.\"--- EXAMPLES
.\"--- This section gives one or more examples of usage, where appropriate.
.\"---
.SH EXAMPLES
.TP
.B "dtcodegen -p myproject"
This runs the code generator on the application defined by the
project file
.BR "myproject.bip" .
.TP
.B "dtcodegen myproject.bip modulename
Runs the code generator for the project
.B myproject.bip
but only generates code for the module
.BR modulename.bil .
.TP
.B "dtcodegen -silent mymodule"
The
.Cm dtcodegen
utility will search the current working directory for a project file that
references the module
.B mymodule
and then silently generate code for just that module.
.TP
.TP
.B "dtcodegen name1 name2"
If the project file
.B name1.bip
exists, it is used and code will be generated for module
.BR name2.bil .
Otherwise both
.B name1
and
.B name2
are taken as the name of modules, the current working directory is
searched for a project file that references both modules, and code
for those two modules is generated.
.TP
.B "dtcodegen"
This runs the code generator, which will search the current working
directory for a project file to be processed, and will generate all code
associated with that project.
.TP
.B "dtcodegen -main -p myproject"
This command will generate just the files associated with the main routine
for the project
.BR myproject ,
namely
.B myproject.c
and
.BR myproject.h .
.TP
.B "dtcodegen -changed"
This command searches the current working directory for a project file and,
if one is found, generates code for only those modules that have changed
since the code generator was last run.
.TP
.B "dtcodegen -changed -p myproject module1 module2 module3
This command will generate, for project
.BR myproject.bip ,
code only for those modules among the set
.BR module1 ,
.BR module2 ,
and
.B module3
that have changed since the last time the code generator was run.
.\"---
.\"----------------------------------------------------------------------------
.\"--- "SEE ALSO"
.\"--- This section lists related entries
.\"---
.\"--- for example:
.\"---
.\"--- .SH "SEE ALSO"
.\"--- .Hd <header_file.h> 5, if needed
.\"--- .Fn utility_name section number,
.\"--- .Fn utility_name section number,
.\"--- .Fn utility_name section number.
.\"---
.SH "SEE ALSO"
.Cm dtbuilder 1
.Cm BIL 4

View File

@@ -0,0 +1,94 @@
$ $XConsortium: dtcodegen.msg /main/3 1995/11/06 18:04:54 rswiston $
$ ========================================================================
$ = Message source text file for 'dtcodgen', the App Builder code generator
$ = @(#)dtcodegen.msg 1.2 13 Sep 1994 dtappbuilder/src/abmf
$ ========================================================================
$quote "
$set 1
1 "No project file that references module(s) - using defaults\n"
2 "No files specified, and no project file found\n"
3 "Reading project %s.\n"
4 "%s: exiting due to error loading project.\n"
5 "%s: Nothing to do!\n"
6 "Missing project name for -p option"
7 "%s: Illegal option \"%s\"\n\n"
8 "Only one project file may be specified."
9 "ignoring -noproject (-np) because project file was specified: %s\n"
10 "Unexpected project in file %s. Aborting\n"
11 "Module %s not found in file %s. Aborting\n"
12 "Usage: %s [options] [project-file] [module-file [module-file] ...]\n\n"
13 "Code is generated for each module specified on the command line, or for\n"
14 "all modules in the project, if no modules are specified. If no project\n"
15 "file is specified, a project file containing the specified module(s) is\n"
16 "searched for in the current directory.\n\n"
17 "Files with extension .bip are assumend to be BIL project files, files with\n"
18 ".bix extenstion are assumed to be encapsulated BIL files, and files\n"
19 "with a .bil extension are assumed to be BIL module files.\n"
20 "Options (* = default, + = default with no project file):\n"
21 " -help (-h) Print out this help message\n"
22 " -main Write file containing main()\n"
23 " -changed Only generate files that have changed\n"
24 "* -merge Merge generated _stubs.c files with previous version\n"
25 " -nomerge Don't merge existing and new stubs file\n"
26 " -nomerge Don't merge existing and new stubs file\n"
27 " -noproject (-np) Use default project settings, ignore project file\n"
28 "+ -showall Application shows (maps) all windows at startup\n"
29 "* -noshowall Application shows (maps) only initially-visible windows\n"
30 " -silent (-s) Silent mode, no messages written\n"
31 " -verbose (-v) Verbose mode, detailed progress messages\n\n"
32 "Couldn't open '.'"
33 "%s: Please specify project file (e.g."
34 ")\n"
35 "%s: More than one project contains specified module(s)\n"
36 "Could not allocate cgen data\n"
37 "Added in the following piece of code at line %d:\n"
38 "%s: main() is missing from the stubs file.\n"
39 " Refer to the %s file for the new main() function.\n"
40 "The main() is missing from the old stubs file.\n"
41 " The following main() is NOT added to the new stubs file:\n"
42 "No changes were made to the stubs file since the last run of %s.\n"
43 "=== END ===\n"
44 "cannot open old file: ran out of memory\n"
45 "cannot open new file: ran out of memory\n"
46 "cannot open temporary output file\n"
47 "cannot open log file\n"
48 "%s: cannot parse %s beyond line %d\n"
49 "%s: the original content of %s is retained\n"
50 "Changed an object initialization at line %d:\n"
51 "Added in an object initialization at line %d:\n"
52 "writing"
53 "** Aborting due to errors **\n"
54 "%s: module filename must contain only letters\n"
55 "and digits. %s will generate C variables based\n"
56 "on the module filename. Please rename %s\n"
57 "%s: writing resources for %s into %s\n"
58 "generating %s because of changes in modules\n"
59 "%s: Skipping user-defined %s\n"
60 "Could not determine OS type of this machine\n"
61 "Skipping user-defined %s\n"
62 "linking %s => %s\n"
63 "Could not remove %s\n"
64 "Could not create link to %s\n"
65 "%s: %s\n"
66 "%s: backing up %s to %s\n"
67 "%s %s\n"
68 "skipping (no changes) %s\n"
69 "skipping (up-to-date) %s\n"
70 "skipping due to errors %s\n"
71 "saving previous %s to %s\n"
72 "Unable to generate %s. File merge failed due to syntax error.\n"
73 "unknown group type"
74 "Ignoring unsupported WHEN - obj:<unnamed> when:%s\n"
75 "Ignoring unsupported WHEN - obj:%s when:%s\n"
76 "Unknown action name, %s"
77 "Unknown action type, %d"
78 "unknown function type for action from object, %s"
79 "%s#%d: looking for '%s', found '%s'. Expression begins on line %d\n"
80 "%s#%d: '%s' without '%s'\n"
81 "%s: '%s' matching line %d not found!\n"
82 "%s#%d: nested comments not allowed\n"
83 "calloc: out of memory"
84 "malloc: out of memory"
85 "realloc: out of memory"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,182 @@
/*
* $XConsortium: instancesP.h /main/3 1995/11/06 18:06:09 rswiston $
*
* @(#)instancesP.h 3.33 02 May 1995
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
#ifndef _ABMF_INSTANCESP_H_
#define _ABMF_INSTANCESP_H_
#include "write_codeP.h"
#include "motifdefsP.h"
STRING abmfP_get_widget_parent_name(GenCodeInfo genCodeInfo, ABObj obj);
int abmfP_write_create_widgets_for_comp_obj(
GenCodeInfo genCodeInfo,
ABObj obj
);
int abmfP_write_create_widgets_for_one_obj(
GenCodeInfo genCodeInfo,
ABObj obj
);
int abmfP_write_add_callbacks_and_actions(
GenCodeInfo genCodeInfo,
ABObj obj
);
int abmfP_write_add_callback(
GenCodeInfo genCodeInfo,
STRING resource,
STRING func_name,
ABObj src,
ABObj dest);
int abmfP_write_add_callback_with_string(
GenCodeInfo genCodeInfo,
STRING resource,
STRING func_name,
ABObj src,
STRING client_data);
int abmfP_write_help_indirect_callback(
GenCodeInfo genCodeInfo,
ABObj src_obj,
ABObj help_obj);
int write_widget_creation_proc(
GenCodeInfo genCodeInfo,
ABObj obj
);
#define ObjWClassIs(obj, motif_class) \
(util_streq(obj_get_class_name(obj), istr_string(motif_class)))
#define ObjWClassIsApplicationShell(obj) \
(ObjWClassIs((obj), abmfP_applicationShell))
#define ObjWClassIsArrowButton(obj) \
(ObjWClassIs((obj), abmfP_xmArrowButton))
#define ObjWClassIsBulletinBoard(obj) \
(ObjWClassIs((obj), abmfP_xmBulletinBoard))
#define ObjWClassIsCommand(obj) \
(ObjWClassIs((obj), abmfP_xmCommand))
#define ObjWClassIsComposite(obj) \
(ObjWClassIs((obj), abmfP_xtComposite))
#define ObjWClassIsConstraint(obj) \
(ObjWClassIs((obj), abmfP_xtConstraint))
#define ObjWClassIsDialogShell(obj) \
(ObjWClassIs((obj), abmfP_xmDialogShell))
#define ObjWClassIsDrawingArea(obj) \
(ObjWClassIs((obj), abmfP_xmDrawingArea))
#define ObjWClassIsFileSelectionBox(obj) \
(ObjWClassIs((obj), abmfP_xmFileSelectionBox))
#define ObjWClassIsForm(obj) \
(ObjWClassIs((obj), abmfP_xmForm))
#define ObjWClassIsFrame(obj) \
(ObjWClassIs((obj), abmfP_xmFrame))
#define ObjWClassIsLabel(obj) \
(ObjWClassIs((obj), abmfP_xmLabel))
#define ObjWClassIsList(obj) \
(ObjWClassIs((obj), abmfP_xmList))
#define ObjWClassIsMainWindow(obj) \
(ObjWClassIs((obj), abmfP_xmMainWindow))
#define ObjWClassIsManager(obj) \
(ObjWClassIs((obj), abmfP_xmManager))
#define ObjWClassIsMenuShell(obj) \
(ObjWClassIs((obj), abmfP_xmMenuShell))
#define ObjWClassIsMessageBox(obj) \
(ObjWClassIs((obj), abmfP_xmMessageBox))
#define ObjWClassIsOverrideShell(obj) \
(ObjWClassIs((obj), abmfP_xtOverrideShell))
#define ObjWClassIsPanedWindow(obj) \
(ObjWClassIs((obj), abmfP_xmPanedWindow))
#define ObjWClassIsPopupMenu(obj) \
( (ObjWClassIs((obj), abmfP_abPopupMenu)) \
|| (ObjWClassIs((obj), abmfP_abPopupMenu2)) )
#define ObjWClassIsPrimitive(obj) \
(ObjWClassIs((obj), abmfP_xmPrimitive))
#define ObjWClassIsPulldownMenu(obj) \
( (ObjWClassIs((obj), abmfP_abPulldownMenu)) \
|| (ObjWClassIs((obj), abmfP_abPulldownMenu2)) )
#define ObjWClassIsPushButton(obj) \
(ObjWClassIs((obj), abmfP_xmPushButton))
#define ObjWClassIsRowColumn(obj) \
(ObjWClassIs((obj), abmfP_xmRowColumn))
#define ObjWClassIsScrolledWindow(obj) \
(ObjWClassIs((obj), abmfP_xmScrolledWindow))
#define ObjWClassIsSelectionBox(obj) \
(ObjWClassIs((obj), abmfP_xmSelectionBox))
#define ObjWClassIsShell(obj) \
(ObjWClassIs((obj), abmfP_xtShell))
#define ObjWClassIsTextField(obj) \
(ObjWClassIs((obj), abmfP_xmTextField))
#define ObjWClassIsText(obj) \
(ObjWClassIs((obj), abmfP_xmText))
#define ObjWClassIsTopLevelShell(obj) \
(ObjWClassIs((obj), abmfP_topLevelShell))
#define ObjWClassIsTransientShell(obj) \
(ObjWClassIs((obj), abmfP_xtTransientShell))
#define ObjWClassIsVendorShell(obj) \
(ObjWClassIs((obj), abmfP_xtVendorShell))
#define ObjWClassIsWMShell(obj) \
(ObjWClassIs((obj), abmfP_xtWMShell))
#define ObjWClassIsBaseWinShell(obj) \
(ObjWClassIsApplicationShell(obj))
/*
* Complex checks
*/
BOOL ObjWClassIsCompositeSubclass(ABObj obj);
BOOL ObjWClassIsManagerSubclass(ABObj obj);
BOOL ObjWClassIsShellSubclass(ABObj obj);
#endif /*_ABMF_INSTANCESP_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,137 @@
/*
* $XConsortium: lib_func_stringsP.h /main/3 1995/11/06 18:07:17 rswiston $
*
* @(#)lib_func_stringsP.h 1.25 08 May 1995 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* lib_lib_stringsP.h - library functions in the form of character strings
*/
#ifndef _ABMF_LIB_FUNC_STRINGSP_H_
#define _ABMF_LIB_FUNC_STRINGSP_H_
#include <ab_private/AB.h>
#include <ab/util_types.h>
typedef struct
{
STRING name; /* name */
STRING proto; /* prototype */
STRING def; /* actual code */
} LibFuncRec, *LibFunc;
extern LibFunc abmfP_lib_cvt_file_to_pixmap;
extern LibFunc abmfP_lib_create_greyed_pixmap;
extern LibFunc abmfP_lib_set_label_pixmaps;
extern LibFunc abmfP_lib_file_has_extension;
extern LibFunc abmfP_lib_cvt_filebase_to_pixmap;
extern LibFunc abmfP_lib_cvt_image_file_to_pixmap;
extern LibFunc abmfP_lib_set_label_from_image_file;
extern LibFunc abmfP_lib_set_label_from_bitmap_data;
extern LibFunc abmfP_lib_set_label_from_xpm_data;
extern LibFunc abmfP_lib_cvt_resource_from_string;
extern LibFunc abmfP_lib_save_toplevel_widget;
extern LibFunc abmfP_lib_get_toplevel_widget;
extern LibFunc abmfP_lib_remove_sash_focus;
extern LibFunc abmfP_lib_save_command;
extern LibFunc abmfP_lib_get_command;
extern LibFunc abmfP_lib_help_dispatch;
extern LibFunc abmfP_lib_help_back_hdlr;
extern LibFunc abmfP_lib_more_help_dispatch;
extern LibFunc abmfP_lib_do_onitem_help;
extern LibFunc abmfP_lib_show_help_volume_info;
extern LibFunc abmfP_lib_session_save;
extern LibFunc abmfP_lib_get_client_session_saveCB;
extern LibFunc abmfP_lib_set_client_session_saveCB;
extern LibFunc abmfP_lib_session_restore;
extern LibFunc abmfP_lib_set_client_session_restoreCB;
extern LibFunc abmfP_lib_get_client_session_restoreCB;
extern LibFunc abmfP_lib_create_message_dlg;
extern LibFunc abmfP_lib_destroyCB;
extern LibFunc abmfP_lib_MessageBoxGetActionButton;
extern LibFunc abmfP_lib_show_message;
extern LibFunc abmfP_lib_show_modal_message;
extern LibFunc abmfP_lib_modal_dlgCB;
extern LibFunc abmfP_lib_children_center;
extern LibFunc abmfP_lib_children_uncenter;
extern LibFunc abmfP_lib_center;
extern LibFunc abmfP_lib_uncenter;
extern LibFunc abmfP_lib_center_widget;
extern LibFunc abmfP_lib_uncenter_widget;
extern LibFunc abmfP_lib_centering_handler;
extern LibFunc abmfP_lib_get_label_widget;
extern LibFunc abmfP_lib_get_offset_from_ancestor;
extern LibFunc abmfP_lib_get_label_width;
extern LibFunc abmfP_lib_get_widest_label;
extern LibFunc abmfP_lib_get_widest_value;
extern LibFunc abmfP_lib_get_widget_rect;
extern LibFunc abmfP_lib_get_greatest_size;
extern LibFunc abmfP_lib_get_group_cell_size;
extern LibFunc abmfP_lib_get_group_row_col;
extern LibFunc abmfP_lib_get_group_child;
extern LibFunc abmfP_lib_children_align;
extern LibFunc abmfP_lib_align_children;
extern LibFunc abmfP_lib_align_handler;
extern LibFunc abmfP_lib_expose_handler;
extern LibFunc abmfP_lib_free_group_info;
extern LibFunc abmfP_lib_align_rows;
extern LibFunc abmfP_lib_align_cols;
extern LibFunc abmfP_lib_align_left;
extern LibFunc abmfP_lib_align_right;
extern LibFunc abmfP_lib_align_labels;
extern LibFunc abmfP_lib_align_vcenter;
extern LibFunc abmfP_lib_align_top;
extern LibFunc abmfP_lib_align_bottom;
extern LibFunc abmfP_lib_align_hcenter;
extern LibFunc abmfP_lib_get_exe_dir;
extern LibFunc abmfP_lib_determine_exe_dir;
extern LibFunc abmfP_lib_determine_exe_dir_from_argv;
extern LibFunc abmfP_lib_determine_exe_dir_from_path;
extern LibFunc abmfP_lib_path_is_executable;
extern LibFunc abmfP_lib_set_tt_msg_quitCB;
extern LibFunc abmfP_lib_get_tt_msg_quitCB;
extern LibFunc abmfP_lib_tt_msg_quit;
extern LibFunc abmfP_lib_set_tt_msg_do_commandCB;
extern LibFunc abmfP_lib_get_tt_msg_do_commandCB;
extern LibFunc abmfP_lib_tt_msg_do_command;
extern LibFunc abmfP_lib_set_tt_msg_get_statusCB;
extern LibFunc abmfP_lib_get_tt_msg_get_statusCB;
extern LibFunc abmfP_lib_tt_msg_get_status;
extern LibFunc abmfP_lib_set_tt_msg_pause_resumeCB;
extern LibFunc abmfP_lib_get_tt_msg_pause_resumeCB;
extern LibFunc abmfP_lib_tt_msg_pause_resume;
extern LibFunc abmfP_lib_tt_contractCB;
extern LibFunc abmfP_lib_tt_close;
extern LibFunc abmfP_lib_call_help_callback;
extern LibFunc abmfP_lib_popup_menu_register;
extern LibFunc abmfP_lib_popup_menu;
extern LibFunc abmfP_lib_popup_menu_destroyCB;
extern LibFunc abmfP_lib_drag_site_register;
extern LibFunc abmfP_lib_drop_site_register;
extern LibFunc abmfP_lib_drag_terminate;
extern LibFunc abmfP_lib_drag_button1_motion_handler;
extern LibFunc abmfP_lib_drag_start;
extern LibFunc abmfP_lib_drag_convertCB;
extern LibFunc abmfP_lib_drag_to_rootCB;
extern LibFunc abmfP_lib_drag_finishCB;
extern LibFunc abmfP_lib_default_dragCB;
extern LibFunc abmfP_lib_default_dropCB;
extern LibFunc abmfP_lib_drop_animateCB;
extern LibFunc abmfP_lib_drop_transferCB;
#endif /* _ABMF_LIB_FUNC_STRINGSP_H_ */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,29 @@
/*
* $XConsortium: make_fileP.h /main/3 1995/11/06 18:08:34 rswiston $
*
* @(#)make_fileP.h 3.13 24 Mar 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
#include "write_codeP.h"
int abmfP_write_make_file(
GenCodeInfo genCodeInfo,
ABObj project,
AB_OS_TYPE osType,
BOOL useSourceBrowser
);

View File

@@ -0,0 +1,501 @@
/*
* $XConsortium: merge_c.c /main/4 1996/10/02 13:38:19 drk $
*
* @(#)merge_c.c 1.9 27 Mar 1995 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* merge_c.c - merge C source files with "magic" comments
*/
#include <assert.h>
#include "parse_cP.h"
#include "merge_cP.h"
/*************************************************************************
** **
** Constants (#define and const) **
** **
**************************************************************************/
/*************************************************************************
** **
** Private Functions (C declarations and macros) **
** **
**************************************************************************/
static int merge_files_by_segment(
File oldFile,
CSegArray oldSegs,
STRING oldFileName,
File newFile,
CSegArray newSegs,
STRING newFileName,
File *mergedFileOutPtr,
File *deltaFileOutPtr
);
static int match_all_segments(CSegArray newSegs, CSegArray oldSegs);
static CSeg match_segment(
CSeg oldSeg,
CSegArray oldSegArray,
CSegArray newSegArray
);
/*************************************************************************
** **
** Data **
** **
**************************************************************************/
/*************************************************************************
** **
** Function Definitions **
** **
**************************************************************************/
int
abmfP_merge_c_files(
File oldFile,
STRING oldFileName,
File newFile,
STRING newFileName,
File *mergedFileOutPtr,
File *deltaFileOutPtr
)
{
int return_value = 0;
int rc = 0; /* return code */
CSegArray newSegs = NULL;
CSegArray oldSegs = NULL;
File mergedFile = NULL;
File deltaFile = NULL;
/*
if (debugging())
{
long off = 0;
FILE *fp = NULL;
int c = 0;
if (oldFile != NULL)
{
fp = util_fopen_locked("merge-old", "w");
assert(fp != NULL);
off = ftell(oldFile);
while ((c = fgetc(oldFile)) != EOF)
{
fputc(c, fp);
}
util_fclose(fp);
fseek(oldFile, off, SEEK_SET);
}
if (newFile != NULL)
{
fp = util_fopen_locked("merge-new", "w");
assert(fp != NULL);
off = ftell(newFile);
while ((c = fgetc(newFile)) != EOF)
{
fputc(c, fp);
}
util_fclose(fp);
fseek(newFile, off, SEEK_SET);
}
}
*/
if (oldFile != NULL)
{
rc = abmfP_parse_c_file(oldFile, &oldSegs);
return_if_err(rc,rc);
}
if (newFile != NULL)
{
rc = abmfP_parse_c_file(newFile, &newSegs);
return_if_err(rc,rc);
}
rc = merge_files_by_segment(
oldFile, oldSegs, oldFileName,
newFile, newSegs, newFileName,
&mergedFile,
&deltaFile);
if (rc < 0)
{
return_value = rc;
}
else
{
*mergedFileOutPtr = mergedFile;
if (deltaFileOutPtr != NULL)
{
*deltaFileOutPtr = deltaFile;
}
}
epilogue:
cseg_array_destroy(oldSegs);
cseg_array_destroy(newSegs);
return return_value;
}
/*
* Merges segments in C files
*
* Assumes: all segments and user segments are sorted by beginning offset.
*/
static int
merge_files_by_segment(
File oldFile,
CSegArray oldSegs,
STRING oldFileName,
File newFile,
CSegArray newSegs,
STRING newFileName,
File *mergedFileOutPtr,
File *deltaFileOutPtr
)
{
int return_value = 0;
int numSegsChanged = 0;
int c = 0;
long oldFileOffset = 0;
long nextModOffset = 0;
long nextDeltaOffset = 0;
File mergedFile = NULL;
File deltaFile = NULL;
CUserSeg oldUserSeg = NULL;
CUserSeg newUserSeg = NULL;
*mergedFileOutPtr = NULL;
*deltaFileOutPtr = NULL;
numSegsChanged = match_all_segments(oldSegs, newSegs);
if (numSegsChanged < 1)
{
return 0;
}
mergedFile = tmpfile();
if (deltaFileOutPtr != NULL)
{
deltaFile = tmpfile();
}
rewind(oldFile);
oldFileOffset = 0;
oldUserSeg = oldSegs->firstUserSeg;
while ((oldUserSeg != NULL) && (oldUserSeg->clientData == NULL))
{
oldUserSeg = oldUserSeg->next;
}
assert(oldUserSeg != NULL); /* at least one change exists */
nextModOffset = oldUserSeg->offset;
while ((c = fgetc(oldFile)) != EOF)
{
++oldFileOffset;
if (oldFileOffset == (nextModOffset+1))
{
newUserSeg = ((CUserSeg)(oldUserSeg->clientData));
if ( (deltaFile != NULL)
&& (!util_streq(oldUserSeg->text, newUserSeg->text)) )
{
fprintf(deltaFile,
"\n========================================\n");
fprintf(deltaFile,
"----- FROM (old file, line %ld) -----\n"
"%s",
oldUserSeg->line, oldUserSeg->text);
fprintf(deltaFile,
"----- TO (new file, line %ld) -----\n"
"%s",
newUserSeg->line, newUserSeg->text);
fprintf(deltaFile,
"-----\n");
}
fputs(newUserSeg->text, mergedFile);
oldFileOffset = oldUserSeg->offset + oldUserSeg->length;
fseek(oldFile, oldFileOffset, SEEK_SET);
oldUserSeg = oldUserSeg->next;
while ((oldUserSeg != NULL) && (oldUserSeg->clientData == NULL))
{
oldUserSeg = oldUserSeg->next;
}
nextModOffset = (oldUserSeg == NULL? -1:oldUserSeg->offset);
}
else
{
fputc(c, mergedFile);
}
}
(*mergedFileOutPtr) = mergedFile;
(*deltaFileOutPtr) = deltaFile;
return return_value;
}
/*
* Sets clientData to point to corresponding segments and user segments, IFF
* the segments have changed.
*
* Returns the # of user segments that have actually changed.
*/
static int
match_all_segments(CSegArray oldSegs, CSegArray newSegs)
{
CSeg oldSeg = NULL;
CSeg newSeg = NULL;
BOOL segChanged = FALSE;
int userSegChangeCount = 0;
int userSegCount = 0;
int i = 0;
for (i = 0; i < oldSegs->numSegs; ++i)
{
oldSeg = &(oldSegs->segs[i]);
newSeg = match_segment(oldSeg, oldSegs, newSegs);
oldSeg->clientData = NULL;
segChanged = FALSE;
if (newSeg != NULL)
{
for (userSegCount = 0;
(userSegCount < oldSeg->userSegs.numSegs)
&& (userSegCount < newSeg->userSegs.numSegs);
++userSegCount)
{
if (!util_streq(oldSeg->userSegs.segs[userSegCount].text,
newSeg->userSegs.segs[userSegCount].text))
{
segChanged = TRUE;
++userSegChangeCount;
oldSeg->userSegs.segs[userSegCount].clientData =
&(newSeg->userSegs.segs[userSegCount]);
}
#ifdef BOGUS /* (debugging stuff) */
printf("[%s] %ld -> %ld\n",
oldSeg->userSegs.segs[userSegCount].clientData == NULL?
" ":"X",
oldSeg->userSegs.segs[userSegCount].line,
newSeg->userSegs.segs[userSegCount].line);
#endif /* BOGUS */
}
}
if (segChanged)
{
oldSeg->clientData = (void *)newSeg;
}
} /* for i */
return userSegChangeCount;
}
static CSeg
match_segment(
CSeg oldSeg,
CSegArray oldSegArray,
CSegArray newSegArray
)
{
CSeg newSeg = NULL;
int oldSegIndex = -1;
int oldSegNum = -1;
int newSegIndex = -1;
int newSegNum = 0;
int i = 0;
oldSegIndex = -1;
if (oldSeg->type == CSEG_GLOBAL)
{
/*
* Global segments are unnamed - find number of segment
*/
oldSegNum = -1;
for (i = 0; i < oldSegArray->numSegs; ++i)
{
if (oldSegArray->segs[i].type == CSEG_GLOBAL)
{
++oldSegNum;
}
if (&(oldSegArray->segs[i]) == oldSeg)
{
break;
}
}
oldSegIndex = i;
/* these asserts check to see if seg is in array at all */
assert(oldSegNum >= 0);
assert((oldSegIndex >= 0) && (oldSegIndex < oldSegArray->numSegs));
/*
* Find matching segment in new array
*/
newSegNum = -1;
for (i = 0; i < newSegArray->numSegs; ++i)
{
if (newSegArray->segs[i].type == CSEG_GLOBAL)
{
++newSegNum;
}
if (oldSegNum == newSegNum)
{
break;
}
}
if (newSegNum != oldSegNum)
{
goto epilogue;
}
newSegIndex = i;
newSeg = &(newSegArray->segs[newSegIndex]);
}
else
{
/* Not global - find segment by name */
for (i = 0; i < newSegArray->numSegs; ++i)
{
if (util_streq(oldSeg->name, newSegArray->segs[i].name))
{
newSeg = &(newSegArray->segs[i]);
break;
}
}
}
epilogue:
return newSeg;
}
#ifdef MAIN
int
main (int argc, char *argv[])
{
int rc = 0; /* return code */
STRING newFileName = NULL;
File newFile = NULL;
STRING oldFileName = NULL;
File oldFile = NULL;
File mergedFile = NULL;
File deltaFile = NULL;
int c = 0;
util_init(&argc, &argv);
if (argc != 3)
{
fprintf(stderr, "Usage: %s <old-file> <new-file>\n", argv[0]);
exit(1);
}
oldFileName = argv[1];
newFileName = argv[2];
/*
* Open the files
*/
oldFile = util_fopen_locked(oldFileName, "r");
if (oldFile == NULL)
{
perror(oldFileName);
exit(1);
}
newFile = util_fopen_locked(newFileName, "r");
if (newFile == NULL)
{
perror(newFileName);
exit(1);
}
/*
* Merge 'em!
*/
rc = abmfP_merge_c_files(
oldFile, oldFileName,
newFile, newFileName,
&mergedFile,
&deltaFile);
if ((rc >= 0) && (mergedFile == NULL))
{
printf("No changes found.\n");
}
if (deltaFile != NULL)
{
char name[1024];
File f = NULL;
sprintf(name, "%s.delta", oldFileName);
printf("writing %s\n", name);
unlink(name);
f = util_fopen_locked(name, "w");
if (f == NULL)
{
perror(name);
exit(1);
}
rewind(deltaFile);
while ((c = fgetc(deltaFile)) != EOF)
{
fputc(c, f);
}
util_fclose(deltaFile);
util_fclose(f);
}
if (mergedFile != NULL)
{
char name[1024];
File f = NULL;
sprintf(name, "%s.merge", oldFileName);
printf("writing %s\n", name);
unlink(name);
f = util_fopen_locked(name, "w");
if (f == NULL)
{
perror(name);
exit(1);
}
rewind(mergedFile);
while ((c = fgetc(mergedFile)) != EOF)
{
fputc(c, f);
}
util_fclose(mergedFile);
util_fclose(f);
}
util_fclose(oldFile);
util_fclose(newFile);
exit(0);
return 0;
}
#endif /* MAIN */

View File

@@ -0,0 +1,40 @@
/*
* $XConsortium: merge_cP.h /main/3 1995/11/06 18:09:04 rswiston $
*
* @(#)merge_cP.h 1.2 01 Sep 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* merge_cP.h - Merge C files, using magic comments
*/
#ifndef _ABMF_MERGE_CP_H_
#define _ABMF_MERGE_CP_H_
#include "abmfP.h"
extern int abmfP_merge_c_files(
File oldFile,
STRING oldFileName,
File newFile,
STRING newFileName,
File *mergedFileOut,
File *deltaFileOut
);
#endif /* _ABMF_MERGE_CP_H_ */

View File

@@ -0,0 +1,219 @@
/*
* $XConsortium: motifdefs.c /main/3 1995/11/06 18:09:19 rswiston $
*
* @(#)motifdefs.c 1.13 02 May 1995 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* motifdefs.c
*/
#include "motifdefsP.h"
#include <ab_private/objxm.h>
/*************************************************************************
** **
** Constants (#define and const) **
** **
**************************************************************************/
/*************************************************************************
** **
** Private Functions (C declarations and macros) **
** **
**************************************************************************/
/*************************************************************************
** **
** Data **
** **
**************************************************************************/
/*************************************************************************
** **
** Function Definitions **
** **
**************************************************************************/
/*
* Widget class names
*/
ISTRING abmfP_abPopupMenu = NULL;
ISTRING abmfP_abPopupMenu2 = NULL;
ISTRING abmfP_abPulldownMenu = NULL;
ISTRING abmfP_abPulldownMenu2 = NULL;
ISTRING abmfP_dtComboBox = NULL;
ISTRING abmfP_dtEditor = NULL;
ISTRING abmfP_dtHelpDialog = NULL;
ISTRING abmfP_dtHelpQuickDialog = NULL;
ISTRING abmfP_dtMenuButton = NULL;
ISTRING abmfP_dtSpinBox = NULL;
ISTRING abmfP_dtTerm = NULL;
ISTRING abmfP_dtTermPrim = NULL;
ISTRING abmfP_xmArrowButton = NULL;
ISTRING abmfP_xmBulletinBoard = NULL;
ISTRING abmfP_xmCascadeButton = NULL;
ISTRING abmfP_xmCommand = NULL;
ISTRING abmfP_xmDialogShell = NULL;
ISTRING abmfP_xmDragOverShell = NULL;
ISTRING abmfP_xmDrawingArea = NULL;
ISTRING abmfP_xmDrawnButton = NULL;
ISTRING abmfP_xmFileSelectionBox = NULL;
ISTRING abmfP_xmForm = NULL;
ISTRING abmfP_xmFrame = NULL;
ISTRING abmfP_xmLabel = NULL;
ISTRING abmfP_xmList = NULL;
ISTRING abmfP_xmMainWindow = NULL;
ISTRING abmfP_xmManager = NULL;
ISTRING abmfP_xmMenuShell = NULL;
ISTRING abmfP_xmMessageBox = NULL;
ISTRING abmfP_xmPanedWindow = NULL;
ISTRING abmfP_xmPrimitive = NULL;
ISTRING abmfP_xmPushButton = NULL;
ISTRING abmfP_xmRowColumn = NULL;
ISTRING abmfP_xmSash = NULL;
ISTRING abmfP_xmScale = NULL;
ISTRING abmfP_xmScrollbar = NULL;
ISTRING abmfP_xmScrolledWindow = NULL;
ISTRING abmfP_xmSelectionBox = NULL;
ISTRING abmfP_xmSeparator = NULL;
ISTRING abmfP_xmTearOffButton = NULL;
ISTRING abmfP_xmText = NULL;
ISTRING abmfP_xmTextField = NULL;
ISTRING abmfP_xmToggleButton = NULL;
ISTRING abmfP_xtApplicationShell = NULL;
ISTRING abmfP_xtComposite = NULL;
ISTRING abmfP_xtConstraint = NULL;
ISTRING abmfP_xtCore = NULL;
ISTRING abmfP_xtOverrideShell = NULL;
ISTRING abmfP_xtShell = NULL;
ISTRING abmfP_xtTopLevelShell = NULL;
ISTRING abmfP_xtTransientShell = NULL;
ISTRING abmfP_xtVendorShell = NULL;
ISTRING abmfP_xtWMShell = NULL;
/* backwards compatibitility (inconsistent names) */
ISTRING abmfP_applicationShell = NULL;
ISTRING abmfP_topLevelShell = NULL;
ISTRING abmfP_xmComboBox = NULL;
ISTRING abmfP_xmMenuButton = NULL;
ISTRING abmfP_xmSpinBox = NULL;
ISTRING abmfP_xmTerm = NULL;
ISTRING abmfP_xmTermPrim = NULL;
/*
* Resources
*/
ISTRING abmfP_XmNheight = NULL;
ISTRING abmfP_XmNlabelString = NULL;
ISTRING abmfP_XmNset = NULL;
int
abmfP_motifdefs_init(void)
{
static BOOL inited= FALSE;
if (inited)
{
return 0;
}
inited= TRUE;
/*
* Widget class names. The _<widget> string variables are declared as part
* of libABobjXm.
*
* abPulldownMenu, and abPulldownMenu2 are equivalent. It's a minor bug
* that we have two.
*/
abmfP_abPopupMenu = istr_const("xmPopupMenuWidgetClass");
abmfP_abPopupMenu2 = istr_const("xmPopupMenuPseudoClass");
abmfP_abPulldownMenu = istr_const("xmPulldownMenuWidgetClass");
abmfP_abPulldownMenu2 = istr_const("xmPulldownMenuPseudoClass");
abmfP_dtComboBox = istr_const(_dtComboBox);
abmfP_dtEditor = istr_const("dtEditorWidgetClass");
abmfP_dtHelpDialog = istr_const("dtHelpDialogWidgetClass");
abmfP_dtHelpQuickDialog = istr_const("dtHelpQuickDialogWidgetClass");
abmfP_dtMenuButton = istr_const(_dtMenuButton);
abmfP_dtSpinBox = istr_const(_dtSpinBox);
abmfP_dtTerm = istr_const(_dtTerm);
abmfP_dtTermPrim = istr_const("dtTermPrimitiveWidgetClass");
abmfP_xmArrowButton = istr_const(_xmArrowButton);
abmfP_xmBulletinBoard = istr_const(_xmBulletinBoard);
abmfP_xmCascadeButton = istr_const(_xmCascadeButton);
abmfP_xmCommand = istr_const(_xmCommand);
abmfP_xmDialogShell = istr_const(_xmDialogShell);
abmfP_xmDragOverShell = istr_const("xmDragOverShellWidgetClass");
abmfP_xmDrawingArea = istr_const(_xmDrawingArea);
abmfP_xmDrawnButton = istr_const(_xmDrawnButton);
abmfP_xmFileSelectionBox = istr_const(_xmFileSelectionBox);
abmfP_xmForm = istr_const(_xmForm);
abmfP_xmFrame = istr_const(_xmFrame);
abmfP_xmLabel = istr_const(_xmLabel);
abmfP_xmList = istr_const(_xmList);
abmfP_xmMainWindow = istr_const(_xmMainWindow);
abmfP_xmManager = istr_const(_xmManager);
abmfP_xmMenuShell = istr_const(_xmMenuShell);
abmfP_xmMessageBox = istr_const(_xmMessageBox);
abmfP_xmPanedWindow = istr_const(_xmPanedWindow);
abmfP_xmPrimitive = istr_const(_xmPrimitive);
abmfP_xmPushButton = istr_const(_xmPushButton);
abmfP_xmRowColumn = istr_const(_xmRowColumn);
abmfP_xmSash = istr_const("xmSashWidgetClass");
abmfP_xmScale = istr_const(_xmScale);
abmfP_xmScrollbar = istr_const(_xmScrollBar);
abmfP_xmScrolledWindow = istr_const(_xmScrolledWindow);
abmfP_xmSelectionBox = istr_const(_xmSelectionBox);
abmfP_xmSeparator = istr_const(_xmSeparator);
abmfP_xmTearOffButton = istr_const("xmTearOffButtonWidgetClass");
abmfP_xmText = istr_const(_xmText);
abmfP_xmTextField = istr_const(_xmTextField);
abmfP_xmToggleButton = istr_const(_xmToggleButton);
abmfP_xtApplicationShell = istr_const("applicationShellWidgetClass");
abmfP_xtComposite = istr_const("compositeWidgetClass");
abmfP_xtConstraint = istr_const("constraintWidgetClass");
abmfP_xtCore = istr_const("coreWidgetClass");
abmfP_xtOverrideShell = istr_const("overrideShellWidgetClass");
abmfP_xtShell = istr_const("shellWidgetClass");
abmfP_xtTopLevelShell = istr_const("topLevelShellWidgetClass");
abmfP_xtTransientShell = istr_const("transientShellWidgetClass");
abmfP_xtVendorShell = istr_const("vendorShellWidgetClass");
abmfP_xtWMShell = istr_const("wmShellWidgetClass");
/* backwards compatibitility (inconsistent names) */
abmfP_applicationShell = istr_dup(abmfP_xtApplicationShell);
abmfP_topLevelShell = istr_dup(abmfP_xtTopLevelShell);
abmfP_xmComboBox = istr_dup(abmfP_dtComboBox);
abmfP_xmMenuButton = istr_dup(abmfP_dtMenuButton);
abmfP_xmSpinBox = istr_dup(abmfP_dtSpinBox);
abmfP_xmTerm = istr_dup(abmfP_dtTerm);
abmfP_xmTermPrim = istr_dup(abmfP_dtTermPrim);
/*
* Resources
*/
abmfP_XmNheight = istr_const("XmNheight");
abmfP_XmNlabelString = istr_const("XmNlabelString");
abmfP_XmNset = istr_const("XmNset");
return 0;
}

View File

@@ -0,0 +1,102 @@
/*
* $XConsortium: motifdefsP.h /main/3 1995/11/06 18:09:33 rswiston $
*
* @(#)motifdefsP.h 3.49 02 May 1995 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
#ifndef _ABMF_MOTIFDEFSP_H__
#define _ABMF_MOTIFDEFSP_H__
#include <ab_private/istr.h>
/*
* Widget class names
*/
extern ISTRING abmfP_abPopupMenu; /* pseudo class */
extern ISTRING abmfP_abPopupMenu2; /* same as above */
extern ISTRING abmfP_abPulldownMenu; /* pseudo class */
extern ISTRING abmfP_abPulldownMenu2; /* same as above */
extern ISTRING abmfP_dtComboBox;
extern ISTRING abmfP_dtEditor;
extern ISTRING abmfP_dtHelpDialog;
extern ISTRING abmfP_dtHelpQuickDialog;
extern ISTRING abmfP_dtMenuButton;
extern ISTRING abmfP_dtSpinBox;
extern ISTRING abmfP_dtTerm;
extern ISTRING abmfP_dtTermPrim;
extern ISTRING abmfP_xmArrowButton;
extern ISTRING abmfP_xmBulletinBoard;
extern ISTRING abmfP_xmCascadeButton;
extern ISTRING abmfP_xmCommand;
extern ISTRING abmfP_xmDialogShell;
extern ISTRING abmfP_xmDragOverShell;
extern ISTRING abmfP_xmDrawingArea;
extern ISTRING abmfP_xmDrawnButton;
extern ISTRING abmfP_xmFileSelectionBox;
extern ISTRING abmfP_xmForm;
extern ISTRING abmfP_xmFrame;
extern ISTRING abmfP_xmLabel;
extern ISTRING abmfP_xmList;
extern ISTRING abmfP_xmMainWindow;
extern ISTRING abmfP_xmManager;
extern ISTRING abmfP_xmMenuShell;
extern ISTRING abmfP_xmMessageBox;
extern ISTRING abmfP_xmPanedWindow;
extern ISTRING abmfP_xmPrimitive;
extern ISTRING abmfP_xmPushButton;
extern ISTRING abmfP_xmRowColumn;
extern ISTRING abmfP_xmSash;
extern ISTRING abmfP_xmScale;
extern ISTRING abmfP_xmScrollbar;
extern ISTRING abmfP_xmScrolledWindow;
extern ISTRING abmfP_xmSelectionBox;
extern ISTRING abmfP_xmSeparator;
extern ISTRING abmfP_xmTearOffButton;
extern ISTRING abmfP_xmText;
extern ISTRING abmfP_xmTextField;
extern ISTRING abmfP_xmToggleButton;
extern ISTRING abmfP_xtApplicationShell;
extern ISTRING abmfP_xtComposite;
extern ISTRING abmfP_xtConstraint;
extern ISTRING abmfP_xtCore;
extern ISTRING abmfP_xtOverrideShell;
extern ISTRING abmfP_xtShell;
extern ISTRING abmfP_xtTopLevelShell;
extern ISTRING abmfP_xtTransientShell;
extern ISTRING abmfP_xtVendorShell;
extern ISTRING abmfP_xtWMShell;
/* backwards compatibitility (these have inconsistent names) */
extern ISTRING abmfP_applicationShell;
extern ISTRING abmfP_topLevelShell;
extern ISTRING abmfP_xmComboBox;
extern ISTRING abmfP_xmMenuButton;
extern ISTRING abmfP_xmSpinBox;
extern ISTRING abmfP_xmTerm;
extern ISTRING abmfP_xmTermPrim;
/*
* Resources
*/
extern ISTRING abmfP_XmNheight;
extern ISTRING abmfP_XmNlabelString;
extern ISTRING abmfP_XmNset;
int abmfP_motifdefs_init(void); /* call this first!!! */
#endif /* _ABMF_MOTIFDEFSP_H__ */

View File

@@ -0,0 +1,153 @@
/*
* $XConsortium: msg_cvt.c /main/3 1995/11/06 18:09:48 rswiston $
*
* @(#)msg_cvt.c 1.1 15 Jul 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special restrictions in a
* confidential disclosure agreement between HP, IBM, Sun, USL, SCO and
* Univel. Do not distribute this document outside HP, IBM, Sun, USL, SCO,
* or Univel without Sun's specific written approval. This document and all
* copies and derivative works thereof must be returned or destroyed at Sun's
* request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* msg_cvt.c - Handles [re]generation of message source file
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <ab_private/obj.h>
#include "write_codeP.h"
#include "msg_file.h"
#include "msg_cvt.h"
static MsgSet get_cached_msg_set(
MsgFile msg_file,
ABObj obj
);
extern BOOL
abmfP_initialize_msg_file(
GenCodeInfo genCodeInfo,
ABObj project
)
{
BOOL ret_val = (BOOL)FALSE;
char msg_file_name[BUFSIZ];
MsgFile msg_file;
if (project == NULL)
goto cret;
if (genCodeInfo->msg_file_obj != NULL)
{
ret_val = TRUE;
goto cret;
}
/*
* Make path name of message src file
*/
sprintf(msg_file_name, "%s%s", obj_get_name(project), ".msg");
if ((msg_file = MsgFile_create(obj_get_name(project), msg_file_name))
!= NULL)
{
genCodeInfo->msg_src_file_name = strdup(msg_file_name);
genCodeInfo->msg_file_obj = msg_file;
ret_val = (BOOL)TRUE;
}
cret:
return(ret_val);
}
extern char *
abmfP_catgets_prefix_str(
GenCodeInfo genCodeInfo,
ABObj obj,
char *msg_string
)
{
static char str_catg[BUFSIZ];
char *ret_val = msg_string;
MsgSet msg_set;
int msg_num;
if ((msg_set = get_cached_msg_set(genCodeInfo->msg_file_obj, obj))== NULL)
goto cret;
if ((msg_num = MsgSet_sure_find_msg(msg_set, msg_string)) <= 0)
goto cret;
MsgSet_set_msg_is_referenced(msg_set, msg_num, TRUE);
sprintf(str_catg, "catgets(Dtb_project_catd, %d, %d, ",
MsgSet_get_number(msg_set),
msg_num);
ret_val = str_catg;
cret:
return(ret_val);
}
static MsgSet
get_cached_msg_set(
MsgFile msg_file,
ABObj obj
)
{
static ABObj prev_obj = (ABObj)NULL;
static MsgSet prev_msg_set = (MsgSet)NULL;
MsgSet msg_set;
if (obj == prev_obj)
msg_set = prev_msg_set;
else if (obj_is_project(obj))
{
char *project_name = obj_get_name(obj);
char proj_suffixed_name[BUFSIZ];
strcpy(proj_suffixed_name, project_name);
strcat(proj_suffixed_name, "_project");
msg_set = MsgFile_sure_find_msg_set(msg_file, proj_suffixed_name);
prev_msg_set = msg_set;
}
else
{
static ABObj prev_module = (ABObj)NULL;
ABObj module;
char *module_name;
module = obj_get_module(obj);
if (module == prev_module)
msg_set = prev_msg_set;
else
{
prev_module = module;
module_name = obj_get_name(module);
msg_set = MsgFile_sure_find_msg_set(msg_file, module_name);
prev_msg_set = msg_set;
}
}
return(msg_set);
}

View File

@@ -0,0 +1,41 @@
/*
* $XConsortium: msg_cvt.h /main/3 1995/11/06 18:10:03 rswiston $
*
* @(#)msg_cvt.h 1.1 15 Jul 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
#ifndef _ABMF_MSG_CVT_H_
#define _ABMF_MSG_CVT_H_
/*
* msg_cvt.h - API for message [re]generation
*/
#include <ab/util_types.h>
#include "write_codeP.h"
#include "msg_file.h"
extern BOOL abmfP_initialize_msg_file(
GenCodeInfo genCodeInfo,
ABObj project
);
extern char * abmfP_catgets_prefix_str(
GenCodeInfo genCodeInfo,
ABObj obj,
char *msg_string
);
#endif /* !_ABMF_MSG_CVT_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,63 @@
/*
* $XConsortium: msg_file.h /main/3 1995/11/06 18:10:36 rswiston $
*
* @(#)msg_file.h 1.1 15 Jul 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
#ifndef _ABMF_MSG_FILE_H_
#define _ABMF_MSG_FILE_H_
/*
* msg_file.h - ADT interface for message source file [re]generation.
*/
#include <ab/util_types.h>
#include <ab_private/obj.h>
/* A message set */
typedef struct _MsgSetRec *MsgSet;
/* MsgSet Methods */
MsgSet MsgSet_create(int set_number, char *name);
int MsgSet_destroy(MsgSet that);
int MsgSet_get_number(MsgSet that);
int MsgSet_just_find_msg(MsgSet that, char *string);
int MsgSet_sure_find_msg(MsgSet that, char *string);
int MsgSet_set_msg_is_referenced(
MsgSet that,
int msg_num,
BOOL msg_is_referenced
);
int MsgSet_set_allow_msg_delete(MsgSet that, BOOL allow_delete);
BOOL MsgSet_get_allow_msg_delete(MsgSet that);
int MsgSet_set_is_referenced(MsgSet that, BOOL set_is_referenced);
BOOL MsgSet_is_referenced(MsgSet that);
/* Memory representation of a message source file */
typedef struct _MsgFileRec *MsgFile;
/* MsgFile Methods */
MsgFile MsgFile_create(char *project_name, char *msg_src_filename);
int MsgFile_destroy(MsgFile that);
int MsgFile_save(MsgFile that, FILE **msgFileOut);
MsgSet MsgFile_just_find_msg_set(MsgFile that, char *module_name);
MsgSet MsgFile_sure_find_msg_set(MsgFile that, char *module_name);
/* adds one, if not already there */
MsgSet MsgFile_obj_sure_find_msg_set(MsgFile that, ABObj obj);
#endif /* !_ABMF_MSG_FILE_H_ */

View File

@@ -0,0 +1,64 @@
/*
* $XConsortium: msg_fileP.h /main/3 1995/11/06 18:10:51 rswiston $
*
* @(#)msg_fileP.h 1.5 12 Oct 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
#ifndef _ABMF_MSG_FILEP_H_
#define _ABMF_MSG_FILEP_H_
/*
* msg_fileP.h - ADT implementation declrn for message file [re]generation.
*/
#include "msg_file.h"
#define DTB_GEN_MSG_SET_PREFIX "DTBMS_"
/* INTERNAL: A message */
typedef struct _MsgRec {
BOOL is_referenced;
int msg_number;
ISTRING msg_string; /* message string */
ISTRING msg_comment; /* comment after the message: i18n guide */
} MsgRec, *Msg;
/* EXPORT: A message set */
typedef struct _MsgSetRec {
int set_number;
char *set_name;
BOOL allow_msg_delete;
BOOL is_generated; /* false <-> msgs are NULL; everything
stored as set comment */
BOOL is_referenced;
char *set_comment; /* comment after $set stmt: i18n guide */
Msg *msgs;
int num_msgs;
int alloced_slots;
} MsgSetRec;
/* EXPORT: Memory representation of a message file */
typedef struct _MsgFileRec {
FILE *fp; /* pointer to file which was loaded */
char *file_comment; /* comment before first $set stmt */
MsgSet *msg_sets; /* in order read from msg_file */
int num_msg_sets;
int alloced_slots;
} MsgFileRec;
#endif /* !_ABMF_MSG_FILEP_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,100 @@
/*
* $XConsortium: obj_namesP.h /main/3 1995/11/06 18:11:24 rswiston $
*
* @(#)obj_namesP.h 1.21 01 May 1995 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* obj_namesP.h - C/Widget/other names for objects
*/
#ifndef _ABMF_OBJ_NAMES__H_
#define _ABMF_OBJ_NAMESP_H_
#include "write_codeP.h"
/*
* Objects
*/
/*
* abmfP_get_c_name is *real* smart. It determines the name
* based on the state of code generation. Use it a lot!
*/
STRING abmfP_get_action_name(ABObj action);
STRING abmfP_get_c_array_of_selected_bools_name(ABObj obj);
STRING abmfP_get_c_array_of_widgets_name(ABObj obj);
STRING abmfP_get_c_array_of_names_name(ABObj obj);
STRING abmfP_get_c_array_of_strings_name(ABObj obj);
STRING abmfP_get_c_array_of_mnemonics_name(ABObj obj);
STRING abmfP_get_c_array_of_xmstrings_name(ABObj obj);
STRING abmfP_get_c_name(GenCodeInfo genCodeInfo, ABObj obj);
STRING abmfP_get_c_name_global(ABObj obj);
STRING abmfP_get_c_name_in_inst(ABObj obj);
STRING abmfP_get_c_name_in_subinst(ABObj obj);
STRING abmfP_get_c_field_name(ABObj obj);
/*
* Structs
*/
STRING abmfP_get_c_struct_type_name(ABObj obj);
STRING abmfP_get_c_struct_ptr_type_name(ABObj obj);
STRING abmfP_get_c_struct_global_name(ABObj obj);
STRING abmfP_get_c_struct_name(GenCodeInfo, ABObj obj);
STRING abmfP_get_c_struct_ptr_name(GenCodeInfo, ABObj obj);
/*
* Substructs
*/
STRING abmfP_get_c_substruct_global_name(ABObj);
STRING abmfP_get_c_substruct_field_name(ABObj obj);
STRING abmfP_get_c_substruct_type_name(ABObj obj);
STRING abmfP_get_c_substruct_ptr_type_name(ABObj obj);
STRING abmfP_get_c_substruct_name(GenCodeInfo, ABObj obj);
/*
* Procedures
*/
STRING abmfP_get_clear_proc_name(ABObj obj);
STRING abmfP_get_msg_clear_proc_name(ABObj module);
STRING abmfP_get_create_proc_name(ABObj obj);
STRING abmfP_get_init_proc_name(ABObj obj);
/*
* Files
*/
STRING abmfP_get_project_c_file_name(ABObj obj);
STRING abmfP_get_project_header_file_name(ABObj obj);
STRING abmfP_get_utils_c_file_name(ABObj obj);
STRING abmfP_get_utils_header_file_name(ABObj obj);
STRING abmfP_get_stubs_c_file_name(ABObj obj);
STRING abmfP_get_ui_c_file_name(ABObj obj);
STRING abmfP_get_ui_header_file_name(ABObj obj);
STRING abmfP_get_exe_file_name(ABObj obj);
/*
* Widgets
*/
STRING abmfP_get_app_class_name(ABObj obj);
STRING abmfP_get_widget_name(ABObj obj);
STRING abmfP_get_widget_name_for_res_file(ABObj obj);
/*
* Miscellaneous
*/
STRING abmfP_get_control_imm_parent_name(ABObj obj);
STRING abmfP_get_c_app_root_win_name(ABObj obj);
#endif /* _ABMF_OBJ_NAMESP_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,97 @@
/*
* $XConsortium: parse_cP.h /main/3 1995/11/06 18:11:57 rswiston $
*
* @(#)parse_cP.h 1.5 13 Sep 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* parse_cP.h
*
* Parses a C file into "segments" to help determine what changes the
* user has made.
*/
#ifndef _ABMF_PARSE_CP_H_
#define _ABMF_PARSE_CP_H_
#include "abmfP.h"
#define MAX_USER_SEGS_PER_CSEG 10
typedef enum
{
CSEG_UNDEF = 0,
CSEG_AGGREGATE_TYPE,
CSEG_AGGREGATE_VAR,
CSEG_COMMENT,
CSEG_FUNC,
CSEG_GLOBAL,
CSEG_TYPE_NUM_VALUES /* must be last */
} CSEG_TYPE;
typedef struct C_USER_SEG_REC
{
long line;
long offset;
long length;
STRING text;
struct C_USER_SEG_REC *next; /* next userseg, bypasses segments */
void *clientData;
} CUserSegRec, *CUserSeg;
typedef struct /* this struct tag is here as a test */ C_USER_SEGS_REG
{
int numSegs;
CUserSegRec segs[MAX_USER_SEGS_PER_CSEG];
} CUserSegsRec, *CUserSegs;
typedef struct
{
CSEG_TYPE type;
STRING name; /* type or func name */
long offset;
long length;
/* these fields may be NULL */
STRING text; /* actual text from file */
STRING declaration;
int numUserSegs;
CUserSegsRec userSegs;
void *clientData; /* client controls this */
} CSegRec, *CSeg;
typedef struct
{
int numSegs;
CSeg segs;
CUserSeg firstUserSeg;
} CSegArrayRec, *CSegArray;
int abmfP_parse_c_file(FILE *c_file, CSegArray *segmentsOut);
CSegArray cseg_array_create(void);
int cseg_array_destroy(CSegArray);
/*
* Private symbols
*/
#define cseg_array_destroy(array) (cseg_arrayP_destroy_impl(&(array)))
int cseg_arrayP_destroy_impl(CSegArray *);
#endif /* _ABMF_PARSE_CP_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,37 @@
/*
* $XConsortium: proj_c_fileP.h /main/3 1995/11/06 18:12:33 rswiston $
*
* %W% %G% cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* proj_c_file.h - writes project.c file
*/
#ifndef _ABMF_PROJ_C_FILEP_H_
#define _ABMF_PROJ_C_FILEP_H_
#include "write_codeP.h"
int abmfP_write_project_c_file(
GenCodeInfo genCodeInfo,
STRING codeFileName,
BOOL prepareForMerge,
ABObj project
);
#endif /* _ABMF_PROJ_C_FILEP_H_ */

View File

@@ -0,0 +1,281 @@
/*
* $XConsortium: proj_header_file.c /main/3 1995/11/06 18:12:47 rswiston $
*
* @(#)proj_header_file.c 3.64 23 Nov 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* Create a file containing the main() for the given project. This
* file is generated when -P or -m flag is used.
*/
#include <sys/param.h>
#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
#include <ab/util_types.h>
#include <ab_private/abio.h>
#include "abmfP.h"
#include "cdefsP.h"
#include "ui_header_fileP.h"
#include "instancesP.h"
#include "motifdefsP.h"
#include "utilsP.h"
#include "obj_namesP.h"
#include "write_cP.h"
/*
* Local functions
*/
static int write_includes(GenCodeInfo genCodeInfo);
static int write_connection_decls(GenCodeInfo genCodeInfo, ABObj module);
static int write_callback_decls(GenCodeInfo genCodeInfo, ABObj module);
static int write_user_or_auto_decls(
GenCodeInfo genCodeInfo,
ABObj project,
BOOL auto_named
);
static int write_app_resource_struct(GenCodeInfo genCodeInfo, ABObj project);
static int write_app_resource_var_extern(GenCodeInfo genCodeInfo, ABObj project);
static int write_i18n_declarations(GenCodeInfo genCodeInfo, ABObj project);
/*
* Main header file includes for i18n: may not be same as main C file
*/
static char *I18n_Includes[] =
{
"<nl_types.h>",
NULL,
};
/*
* Write the project.h file.
*/
int
abmfP_write_project_header_file(
GenCodeInfo genCodeInfo,
ABObj project,
STRING codeFileName
)
{
File codeFile = genCodeInfo->code_file;
char projectName[1024];
/*
* Write file header.
*/
abmfP_write_user_header_seg(genCodeInfo);
abio_puts(codeFile, nlstr);
sprintf(projectName, "project %s", obj_get_name(project));
abmfP_write_file_header(
genCodeInfo,
codeFileName,
TRUE,
projectName,
util_get_program_name(),
ABMF_MODIFY_USER_SEGS,
" * Contains: object data structures and callback declarations"
);
write_includes(genCodeInfo);
/*
* Write declarations for i18n.
* These are needed only if i18n is enabled.
*/
if (genCodeInfo->i18n_method == ABMF_I18N_XPG4_API)
write_i18n_declarations(genCodeInfo, project);
write_app_resource_struct(genCodeInfo, project);
write_connection_decls(genCodeInfo, project);
write_callback_decls(genCodeInfo, project);
write_app_resource_var_extern(genCodeInfo, project);
abmfP_write_user_long_seg(genCodeInfo,
"Add types, macros, and externs here");
abmfP_write_file_footer(genCodeInfo, codeFileName, TRUE);
return OK;
}
static int
write_includes(GenCodeInfo genCodeInfo)
{
abmfP_write_c_system_include(genCodeInfo, "stdlib.h");
abmfP_write_c_system_include(genCodeInfo, "X11/Intrinsic.h");
return 0;
}
/*
* Traverse object list and write out callback decls, for those
* connections with the proper value of auto_named.
*/
static int
write_user_or_auto_decls(
GenCodeInfo genCodeInfo,
ABObj project,
BOOL auto_named)
{
AB_TRAVERSAL trav;
ABObj action = NULL;
AB_ACTION_INFO *actinfo = NULL;
STRING func_name = NULL;
for (trav_open(&trav, project, AB_TRAV_ACTIONS);
(action = trav_next(&trav)) != NULL;)
{
/* If action is not a cross-module connection AND it
* is not a shared connection, continue.
*/
if ( !obj_is_cross_module(action) &&
( mfobj_has_flags(action, CGenFlagIsDuplicateDef) ||
(!mfobj_has_flags(action, CGenFlagWriteDefToProjFile))
)
)
{
continue;
}
actinfo = &(action->info.action);
func_name = abmfP_get_action_name(action);
if (!util_xor(actinfo->auto_named, auto_named))
{
abmfP_write_action_func_decl(genCodeInfo, action);
abio_puts(genCodeInfo->code_file, nlstr);
}
}
trav_close(&trav);
return 0;
}
/*
* Traverse object list and write out connection decls. (Functions
* that have been automatically generated and named)
*/
static int
write_connection_decls(GenCodeInfo genCodeInfo, ABObj project)
{
return write_user_or_auto_decls(genCodeInfo, project, TRUE);
}
/*
* Traverse object list and write out callback decls. (Functions that
* have been named by the user)
*/
static int
write_callback_decls(GenCodeInfo genCodeInfo, ABObj project)
{
return write_user_or_auto_decls(genCodeInfo, project, FALSE);
}
static int
write_app_resource_struct(
GenCodeInfo genCodeInfo,
ABObj project
)
{
File codeFile;
if (!genCodeInfo || !project)
return (0);
codeFile = genCodeInfo->code_file;
abio_puts(codeFile,"\n");
abmfP_write_c_comment(genCodeInfo,
FALSE, "Structure to store values for Application Resources");
abio_puts(codeFile,"typedef struct {\n");
abio_indent(codeFile);
abio_puts(codeFile,"char *session_file;\n");
abio_puts(codeFile,"\n");
abmfP_write_user_struct_fields_seg(genCodeInfo);
abio_outdent(codeFile);
abio_puts(codeFile, "} DtbAppResourceRec;\n");
abio_puts(codeFile,"\n");
return (0);
}
static int
write_app_resource_var_extern(
GenCodeInfo genCodeInfo,
ABObj project
)
{
File codeFile;
if (!genCodeInfo || !project)
return (0);
codeFile = genCodeInfo->code_file;
abio_puts(codeFile,"\n");
abio_puts(codeFile,"extern DtbAppResourceRec\tdtb_app_resource_rec;\n");
abio_puts(codeFile,"\n");
return (0);
}
static int
write_i18n_declarations(
GenCodeInfo genCodeInfo,
ABObj project
)
{
File codeFile;
STRING *p = NULL;
int ret_val = 0;
if (genCodeInfo == NULL)
goto cret;
codeFile = genCodeInfo->code_file;
/*
* Write out the include directives
*/
for (p = I18n_Includes; *p; p++)
{
abio_printf(codeFile, "#include %s\n", *p);
}
/*
* Write out the macro for the name of the catalog
*/
abio_printf(codeFile, "#define DTB_PROJECT_CATALOG\t\"%s\"\n",
obj_get_name(project));
abio_puts(codeFile,
"/* Handle for standard message catalog for the project */\n");
abio_puts(codeFile, "extern nl_catd\tDtb_project_catd;\n");
cret:
return(ret_val);
}

View File

@@ -0,0 +1,26 @@
/*
* $XConsortium: proj_header_fileP.h /main/3 1995/11/06 18:13:03 rswiston $
*
* @(#)proj_header_fileP.h 3.11 23 Feb 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
int abmfP_write_project_header_file(
GenCodeInfo genCodeInfo,
ABObj project,
STRING codeFileName
);

View File

@@ -0,0 +1,776 @@
/*
* $XConsortium: resource_file.c /main/3 1995/11/06 18:13:17 rswiston $
*
* @(#)resource_file.c 1.12 04 May 1995 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special restrictions in a
* confidential disclosure agreement between HP, IBM, Sun, USL, SCO and
* Univel. Do not distribute this document outside HP, IBM, Sun, USL, SCO,
* or Univel without Sun's specific written approval. This document and all
* copies and derivative works thereof must be returned or destroyed at Sun's
* request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* resource_file.c
*/
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
#include <ab_private/util_err.h>
#include <ab_private/abio.h>
#include "abmfP.h"
#include "utilsP.h"
#include "resource_fileP.h"
/*************************************************************************
** **
** Constants (#define and const) **
** **
**************************************************************************/
#define MAX_USER_SEGS 2
typedef struct
{
long offset;
long len;
} UserSegRec, *UserSeg;
typedef struct
{
UserSegRec segs[MAX_USER_SEGS];
int numSegs;
} UserSegsRec, *UserSegs;
typedef struct
{
ISTRING fileName;
File file;
BOOL isIntermediate;
} ResFileInfoRec, *ResFileInfo;
static ResFileInfoRec resFile;
static STRING userSegStartString = "DTB_USER_RES_START";
static STRING userSegEndString = "DTB_USER_RES_END";
/*************************************************************************
** **
** Private Functions (C declarations and macros) **
** **
**************************************************************************/
static int write_header(
File file,
STRING fileName,
ABObj project,
BOOL isIntermediateFile
);
static int write_footer(
File file,
BOOL isIntermediateFile
);
static int abmfP_res_file_append_intermediate_files(
File appResFile,
ABObj project
);
static int append_intermediate_res_file(
File toFile,
File intFile
);
static STRING get_name_for_comment(ABObj obj, STRING buf, int bufSize);
static int find_user_segs(File file, UserSegs segs);
static int find_user_seg(File file, UserSeg segs);
static long find_user_seg_begin(File file);
static long find_user_seg_end(File file);
/*************************************************************************
** **
** Data **
** **
**************************************************************************/
/*************************************************************************
** **
** Function Definitions **
** **
**************************************************************************/
/*
* <0 = error
* 0 = file written and complete
* 1 = file written, but is incomplete.
*/
int
abmfP_write_app_res_file(
File file,
ABObj project,
STRING resFileName
)
{
int return_value = 0;
int rc = 0;
assert(obj_is_project(project));
assert(resFile.file = file);
rc = abmfP_res_file_append_intermediate_files(file, project);
write_footer(file, resFile.isIntermediate);
return_value = rc;
return rc;
}
/*
* If the resource file exists, the file is backed up and copied. References
* to modules that will be rewritten are deleted.
*/
File
abmfP_res_file_open(
STRING filePath,
STRING fileDescName,
ABObj obj,
BOOL isIntermediateFile
)
{
File fp = NULL;
if (filePath != NULL)
{
if ((fp = util_fopen_locked(filePath, "w")) == NULL)
{
goto epilogue;
}
}
else
{
if ((fp = tmpfile()) == NULL)
{
goto epilogue;
}
}
write_header(fp, fileDescName, obj, isIntermediateFile);
epilogue:
if (fp != NULL)
{
resFile.fileName = istr_create(filePath);
resFile.file = fp;
resFile.isIntermediate = isIntermediateFile;
}
return fp;
}
int
abmfP_res_file_close_impl(File *pfile)
{
#define closeFile (*pfile)
if (closeFile != NULL)
{
assert(resFile.file == closeFile);
util_fclose(closeFile);
}
/* reset resFile */
istr_destroy(resFile.fileName);
memset((void *)&resFile, 0, sizeof(ResFileInfoRec));
closeFile = NULL;
return 0;
#undef closeFile
}
int
abmfP_res_file_merge(
File vanillaFile,
File modifiedFile,
File *mergedFileOut
)
{
int return_value = 0;
int rc = 0;
long userSegOff = 0;
File mergedFile = NULL;
int iChar = 0;
int iLastChar = 0;
int i = 0;
UserSegsRec vanillaUserSegs;
UserSegsRec modifiedUserSegs;
long vanillaOffset = 0;
int curSegIndex = 0;
UserSeg curVanillaSeg = NULL;
UserSeg curModifiedSeg = NULL;
long modifiedOffset = 0;
*mergedFileOut = NULL;
rc = find_user_segs(vanillaFile, &vanillaUserSegs);
return_if_err(rc,rc);
rc = find_user_segs(modifiedFile, &modifiedUserSegs);
return_if_err(rc,rc);
/*
* Copy the "vanilla" file to the merged file
*/
if ((mergedFile = tmpfile()) == NULL)
{
return ERR_INTERNAL;
}
rewind(vanillaFile);
vanillaOffset = -1;
curSegIndex = 0;
curVanillaSeg = &(vanillaUserSegs.segs[curSegIndex]);
curModifiedSeg = &(modifiedUserSegs.segs[curSegIndex]);
while ((iChar = fgetc(vanillaFile)) != EOF)
{
++vanillaOffset;
if ( (curVanillaSeg != NULL)
&& (vanillaOffset >= curVanillaSeg->offset) )
{
/*
* We just hit a segment - replace with modified segment
*/
modifiedOffset = curModifiedSeg->offset;
fseek(modifiedFile, modifiedOffset, SEEK_SET);
for (i = 0; i < curModifiedSeg->len; ++i)
{
iChar = fgetc(modifiedFile);
assert(iChar != EOF);
fputc(iChar, mergedFile);
}
fseek(vanillaFile,
curVanillaSeg->offset + curVanillaSeg->len, SEEK_SET);
vanillaOffset = ftell(vanillaFile)-1;
if (++curSegIndex < 2)
{
curVanillaSeg = &(vanillaUserSegs.segs[curSegIndex]);
curModifiedSeg = &(modifiedUserSegs.segs[curSegIndex]);
}
else
{
curVanillaSeg = NULL;
curModifiedSeg = NULL;
}
}
else
{
/* not in a segment */
fputc(iChar, mergedFile);
}
}
/*
* End-of-file segment may have gotten skipped
*/
if (curModifiedSeg != NULL)
{
fseek(modifiedFile, curModifiedSeg->offset, SEEK_SET);
for (i = 0; i < curModifiedSeg->len; ++i)
{
iChar = fgetc(modifiedFile);
assert(iChar != EOF);
fputc(iChar, mergedFile);
}
}
epilogue:
*mergedFileOut = mergedFile; mergedFile = NULL;
return return_value;
}
static int
find_user_segs(File file, UserSegs segs)
{
int return_value = 0;
int rc = 0;
rewind(file);
memset(segs, 0, sizeof(UserSegsRec));
while ( (segs->numSegs < MAX_USER_SEGS)
&& ((rc = find_user_seg(file, &(segs->segs[segs->numSegs]))) >= 0) )
{
++(segs->numSegs);
}
if ((rc < 0) && (rc != ERR_EOF))
{
return_code(rc);
}
if (segs->numSegs != 2)
{
util_printf_err(
"There are %d DTB_USER segments in the file (there should be two)\n",
segs->numSegs);
return_value = ERR_INTERNAL;
}
epilogue:
return return_value;
}
static int
find_user_seg(File file, UserSeg seg)
{
long userSegStart = -1;
long userSegEnd = -1;
if ((userSegStart = find_user_seg_begin(file)) < 0)
{
return (int)userSegStart;
}
if ((userSegEnd = find_user_seg_end(file)) < 0)
{
if (userSegEnd == ERR_EOF)
{
/* segment goes to EOF */
struct stat fileInfo;
if (fstat(fileno(file), &fileInfo) == 0)
{
userSegEnd = ((long)fileInfo.st_size) - 1;
userSegEnd = util_max(userSegEnd,0);
}
}
else
{
return (int)userSegEnd;
}
}
seg->offset = userSegStart;
seg->len = userSegEnd - userSegStart + 1;
return 0;
}
static long
find_user_seg_begin(File modifiedResFile)
{
long userSegOff = -1;
char lineBuf[256];
int lineOff = 0;
char magicLine[256];
int magicLineLen = 0;
int iChar = 0;
int iLastChar = 0;
*lineBuf = 0;
*magicLine = 0;
sprintf(magicLine, "! %s", userSegStartString);
magicLineLen = strlen(magicLine);
while ( (userSegOff < 0)
&& ((iChar = fgetc(modifiedResFile)) != EOF) )
{
if (iChar == '\n')
{
lineOff = 0;
}
else if (lineOff < magicLineLen)
{
lineBuf[lineOff++] = iChar;
if (lineOff == magicLineLen)
{
lineBuf[lineOff] = 0;
if (util_streq(lineBuf, magicLine))
{
/* look for end of comment section */
while ((iChar = fgetc(modifiedResFile)) != EOF)
{
if (iChar == '\n')
{
userSegOff = ftell(modifiedResFile);
break;
}
iLastChar = iChar;
}
lineOff = 0;
}
}
}
iLastChar = iChar;
}
/*
* See if the user segment is longer than 0 bytes
*/
if (userSegOff < 0)
{
if (iChar == EOF)
{
userSegOff = ERR_EOF;
}
}
else if (userSegOff >= 0)
return userSegOff;
}
static long
find_user_seg_end(File file)
{
long userSegEndOff = -1;
char lineBuf[256];
int lineOff = 0;
char magicLine[256];
int magicLineLen = 0;
long lastNewlineOff = 0;
int iChar = 0;
*lineBuf = 0;
*magicLine = 0;
sprintf(magicLine, "! %s", userSegEndString);
magicLineLen = strlen(magicLine);
lastNewlineOff = ftell(file) - 1;
while ((iChar = fgetc(file)) != EOF)
{
if (iChar == '\n')
{
lastNewlineOff = ftell(file)-1;
lineOff = 0;
}
else if (lineOff <= magicLineLen)
{
lineBuf[lineOff++] = iChar;
if (lineOff == magicLineLen)
{
lineBuf[lineOff] = 0;
if (util_streq(lineBuf, magicLine))
{
userSegEndOff = lastNewlineOff;
goto epilogue;
}
}
}
}
epilogue:
if ((userSegEndOff < 0) && (iChar == EOF))
{
userSegEndOff = ERR_EOF;
}
return userSegEndOff;
}
STRING
abmfP_get_intermediate_res_file_name(
ABObj obj,
char *fileNameOut,
int nameMax
)
{
ABObj resFileObj = NULL;
nameMax = nameMax; /* avoid warning */
if ((resFileObj = obj_get_module(obj)) == NULL)
{
resFileObj = obj_get_project(obj);
}
assert(resFileObj != NULL);
strcpy(fileNameOut, obj_get_name(resFileObj));
if (obj_is_project(resFileObj))
{
strcat(fileNameOut, ".pres");
}
else
{
strcat(fileNameOut, ".res");
}
return fileNameOut;
}
STRING
abmfP_get_app_res_file_name(
ABObj obj,
char *fileNameOut,
int nameMax
)
{
ABObj project = obj_get_project(obj);
STRING fileName = NULL;
strcpy(fileNameOut, obj_get_name(obj));
fileName = abmfP_capitalize_first_char(fileNameOut);
if (fileName != fileNameOut)
{
util_strncpy(fileNameOut, fileName, nameMax);
}
return fileNameOut;
}
/*************************************************************************
** **
** PRIVATE FUNCTIONS **
** **
*************************************************************************/
static int
write_header(File file, STRING fileName, ABObj obj, BOOL isIntermediateFile)
{
char buf[MAXPATHLEN+1];
assert(obj_is_project(obj) || obj_is_module(obj));
if (!isIntermediateFile)
{
abio_printf(file,
"! %s - vvv Add file header below vvv\n"
"! %s - ^^^ Add file header above ^^^\n"
"\n",
userSegStartString,
userSegEndString);
}
abio_printf(file,
"! File: %s\n"
"!\n",
fileName);
if (isIntermediateFile)
{
abio_printf(file,
"! Intermediate resource file for %s\n",
get_name_for_comment(obj, buf, MAXPATHLEN));
abio_puts(file,
"!\n"
"! ** DO NOT EDIT BY HAND. ALL MODIFICATIONS WILL BE LOST!\n");
}
else
{
assert(obj_is_project(obj));
abio_printf(file,
"! Resource file for application %s\n", obj_get_name(obj));
abio_printf(file,
"! This file was generated by %s, from project %s\n",
util_get_program_name(), obj_get_name(obj));
abio_printf(file,
"!\n"
"! Any text may be added between the %s\n"
"! and %s comments. Descriptive comments are\n"
"! provided only as an aid.\n"
"!\n"
"! ** EDIT ONLY WITHIN SECTIONS MARKED WITH DTB_USER_ COMMENTS. **\n"
"! ** ALL OTHER MODIFICATIONS WILL BE OVERWRITTEN. DO NOT MODIFY OR **\n"
"! ** DELETE THE GENERATED COMMENTS! **\n"
"!\n",
userSegStartString, userSegEndString);
}
/*
* MUST END HEADER WITH \n\n, FOR APP RESOURCE FILE GENERATION TO WORK!!
*/
abio_puts(file,nlstr);
return 0;
}
static int
write_footer(File file, BOOL isIntermediate)
{
if (isIntermediate)
{
/* intermediate files have no footer */
return 0;
}
abio_printf(file,
"\n"
"\n"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
"!\n"
"! The remainder of this file (following this comment) may be modified.\n"
"! Add new resources or override values defined above.\n"
"!\n"
"! %s\n",
userSegStartString);
return 0;
}
/*
* < 0 = error
* 0 = file built completely, all intermediate files found
* 1 = file built, but may be incomplete
*
* We always write out the individual comments in the output file, showing
* where the individual modules go. This is so that modules with no
* resources will create a file identical to modules that have not had
* a resource file generated, yet. This way, we can tell if the module that
* is currently being generated actually affects the resource file by
* seeing if the app resource file changes.
*
* It also makes it obvious to whoever looks at the app resource file
* if resources for a particular module exist.
*/
static int
abmfP_res_file_append_intermediate_files(
File appResFile,
ABObj project
)
{
int return_value = 0;
char partResFileName[MAX_PATH_SIZE];
File partResFile = NULL;
AB_TRAVERSAL trav;
ABObj module = NULL;
BOOL allFilesFound = TRUE;
char nameBuf[MAXPATHLEN];
*partResFileName = 0;
/*
* Get the project resources
*/
abmfP_get_intermediate_res_file_name(
project, partResFileName, MAX_PATH_SIZE);
partResFile = util_fopen_locked(partResFileName, "r");
/* always put comment in, whether file exists, or not */
abio_printf(appResFile, "\n! Resource list for %s\n!\n",
get_name_for_comment(project, nameBuf, MAXPATHLEN));
if (partResFile == NULL)
{
allFilesFound = FALSE;
}
else
{
append_intermediate_res_file(appResFile, partResFile);
}
util_fclose(partResFile);
/*
* Get the module res files
*/
for (trav_open(&trav, project, AB_TRAV_MODULES);
(module = trav_next(&trav)) != NULL; )
{
abmfP_get_intermediate_res_file_name(
module, partResFileName, MAX_PATH_SIZE);
partResFile = util_fopen_locked(partResFileName, "r");
/* always put comment in, whether file exists, or not */
abio_printf(appResFile, "\n! Resource list for %s\n!\n",
get_name_for_comment(module, nameBuf, MAXPATHLEN));
if (partResFile == NULL)
{
allFilesFound = FALSE;
}
else
{
append_intermediate_res_file(appResFile, partResFile);
}
util_fclose(partResFile);
}
trav_close(&trav);
if ((return_value >= 0) && (!allFilesFound))
{
return_value = 1;
}
return return_value;
}
static int
append_intermediate_res_file(
File toFile,
File intFile
)
{
int return_value = 0;
int iChar = 0;
int iLastChar = 0;
/*
* Skip file header (the header will always be terminated by one or
* more empty lines.
*/
while ((iChar = getc(intFile)) != EOF)
{
if ((iLastChar == '\n') && (iChar == '\n'))
{
break;
}
iLastChar = iChar;
}
while ((iChar = getc(intFile)) != EOF)
{
if (iChar != '\n')
{
ungetc(iChar, intFile);
break;
}
}
/*
* Copy the rest of the file
*/
while ((iChar = getc(intFile)) != EOF)
{
fputc(iChar, toFile);
}
return return_value;
}
static STRING
get_name_for_comment(ABObj obj, STRING buf, int bufSize)
{
assert(bufSize >= util_strlen(obj_get_name(obj)) + 20);
assert(obj_is_project(obj) || obj_is_module(obj));
assert(obj_get_name(obj) != NULL);
strcpy(buf, "AppBuilder ");
if (obj_is_project(obj))
{
strcat(buf, "project ");
}
else if (obj_is_module(obj))
{
strcat(buf, "module ");
}
strcat(buf, obj_get_name(obj));
return buf;
}

View File

@@ -0,0 +1,75 @@
/*
* $XConsortium: resource_fileP.h /main/3 1995/11/06 18:13:33 rswiston $
*
* @(#)resource_fileP.h 1.6 19 Oct 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* resource_fileP.h - functions dealing with Xt Resource files
*/
#ifndef _ABMF_RESOURCE_FILEP_H_
#define _ABMF_RESOURCE_FILEP_H_
#include "abmfP.h"
File abmfP_res_file_open(
STRING resFilePath, /* file to open */
STRING resFileName, /* name to appear in header */
ABObj obj,
BOOL isIntermediateFile
);
int abmfP_res_file_close(
File resFile
);
int abmfP_write_app_res_file(
File resFile,
ABObj project,
STRING resFileName
);
int abmfP_res_file_merge(
File vanillaFile,
File modifiedResFileName,
File *mergedFileOut
);
STRING abmfP_get_intermediate_res_file_name(
ABObj obj,
char *fileNameOut,
int nameMax
);
STRING abmfP_get_app_res_file_name(
ABObj obj,
char *fileNameOut,
int nameMax
);
/*************************************************************************
** **
** Inline implementation **
** **
*************************************************************************/
#define abmfP_res_file_close(file) (abmfP_res_file_close_impl(&(file)))
int abmfP_res_file_close_impl(File*);
#endif /* _ABMF_RESOURCE_FILEP_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,43 @@
/*
* $XConsortium: stubs_c_fileP.h /main/3 1995/11/06 18:14:15 rswiston $
*
* @(#)stubs_c_fileP.h 3.14 20 Sep 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
#ifndef _ABMF_STUBS_C_FILEP_H_
#define _ABMF_STUBS_C_FILEP_H_
#include "write_codeP.h"
int abmfP_write_stubs_c_file(
GenCodeInfo genCodeInfo,
STRING codeFileName,
ABObj module
);
int abmfP_write_action_function(
GenCodeInfo genCodeInfo,
ABObj action
);
int abmfP_write_builtin_action(
GenCodeInfo genCodeInfo,
ABObj action,
BOOL setUpVars
);
#endif /* _ABMF_STUBS_C_FILEP_H_ */

View File

@@ -0,0 +1,80 @@
/*
* $XConsortium: template.c /main/3 1995/11/06 18:14:30 rswiston $
*
* %W% %G% cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* template.c - template c file.
*/
#include "template.h"
/*************************************************************************
** **
** Constants (#define and const) **
** **
**************************************************************************/
#define FOO_DEFINES "here"
const char *foo_consts = "also here";
/*************************************************************************
** **
** Private Functions (C declarations and macros) **
** **
**************************************************************************/
#define foo_macro(x) ((x) + 1)
static int foo_me(
int foo_int,
char *foo_char
);
/*************************************************************************
** **
** Data **
** **
**************************************************************************/
/* static int foo_private= 0; */
/*************************************************************************
** **
** Function Definitions **
** **
**************************************************************************/
/* int
foo_func(
char *foo_char
)
{
} */
/* static int
foo_me(
int foo_int,
char *foo_char
)
{
} */

View File

@@ -0,0 +1,29 @@
/*
* $XConsortium: template.h /main/3 1995/11/06 18:14:44 rswiston $
*
* %W% %G% cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* template.h - template header file
*/
#ifndef _ABMF_TEMPLATE_H_
#define _ABMF_TEMPLATE_H_
#endif /* _ABMF_TEMPLATE_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,33 @@
/*
* $XConsortium: ui_c_fileP.h /main/3 1995/11/06 18:15:26 rswiston $
*
* %W% %G% cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
#ifndef _ABMF_UI_C_FILEP_H_
#define _ABMF_UI_C_FILEP_H_
#include <ab_private/obj.h>
#include "write_codeP.h"
int abmfP_write_ui_c_file(
GenCodeInfo cGenInfo,
STRING codeFileName,
ABObj module
);
#endif /* _ABMF_UI_C_FILEP_H_ */

View File

@@ -0,0 +1,909 @@
/*
* $XConsortium: ui_header_file.c /main/3 1995/11/06 18:15:39 rswiston $
*
* @(#)ui_header_file.c 3.51 15 Feb 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special restrictions in a
* confidential disclosure agreement between HP, IBM, Sun, USL, SCO and
* Univel. Do not distribute this document outside HP, IBM, Sun, USL, SCO,
* or Univel without Sun's specific written approval. This document and all
* copies and derivative works thereof must be returned or destroyed at Sun's
* request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* Creates a Motif application header file containing standard include files,
* widget specific include files, decls of User Interface Objects
* (Widgets) decls of User Create Procedures, decls of
* connection routines, and decls of callback routines.
*
* This file should be included in the application in order for it to reference
* the user module objects, create procs, and callback routines.
*/
#include <sys/param.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ab/util_types.h>
#include <ab_private/abio.h>
#include "abmfP.h"
#include "cdefsP.h"
#include "motifdefsP.h"
#include "obj_namesP.h"
#include "utilsP.h"
#include "instancesP.h"
#include "connectP.h"
#include "write_cP.h"
#include "lib_func_stringsP.h"
#include "ui_header_fileP.h"
typedef struct
{
STRING include_file; /* file to include */
} IncludeFileRec, *IncludeFile;
/*
* Widget Class to Widget Specific includes mapping
*/
typedef struct
{
ISTRING class_name;
IncludeFile include;
} IncludeForClassRec, *IncludeForClass;
/*
* One entry for each include file, so that multiple classes including the
* same file (e.g., sliders and gauges, control areas and settings) don't
* cause the file to be included twice.
*/
static IncludeFileRec incStandardLib = {"<stdlib.h>"};
static IncludeFileRec incArrowButton = {"<Xm/ArrowB.h>"};
static IncludeFileRec incBulletinBoard = {"<Xm/BulletinB.h>"};
static IncludeFileRec incCascadeButton = {"<Xm/CascadeB.h>"};
static IncludeFileRec incComboBox= {"<Dt/ComboBox.h>"};
static IncludeFileRec incDialogShell = {"<Xm/DialogS.h>"};
static IncludeFileRec incDrawingArea = {"<Xm/DrawingA.h>"};
static IncludeFileRec incDrawnButton = {"<Xm/DrawnB.h>"};
static IncludeFileRec incodeFileChooser = {"<Xm/FileSB.h>"};
static IncludeFileRec incForm = {"<Xm/Form.h>"};
static IncludeFileRec incFrame = {"<Xm/Frame.h>"};
static IncludeFileRec incIntrinsic= {"<X11/Intrinsic.h>"};
static IncludeFileRec incLabel = {"<Xm/Label.h>"};
static IncludeFileRec incList = {"<Xm/List.h>"};
static IncludeFileRec incMainWindow = {"<Xm/MainW.h>"};
static IncludeFileRec incMenuShell = {"<Xm/MenuShell.h>"};
static IncludeFileRec incMenuButton = {"<Dt/MenuButton.h>"};
static IncludeFileRec incMwmUtil = {"<Xm/MwmUtil.h>"};
static IncludeFileRec incPanedWindow = {"<Xm/PanedW.h>"};
static IncludeFileRec incPushButton = {"<Xm/PushB.h>"};
static IncludeFileRec incRowColumn = {"<Xm/RowColumn.h>"};
static IncludeFileRec incScale = {"<Xm/Scale.h>"};
static IncludeFileRec incScrollbar = {"<Xm/ScrollBar.h>"};
static IncludeFileRec incScrolledWindow = {"<Xm/ScrolledW.h>"};
static IncludeFileRec incSeparator = {"<Xm/Separator.h>"};
static IncludeFileRec incShell = {"<X11/Shell.h>"};
static IncludeFileRec incSpinBox= {"<Dt/SpinBox.h>"};
static IncludeFileRec incStringDefs = {"<X11/StringDefs.h>"};
static IncludeFileRec incTerm = {"<Dt/Term.h>"};
static IncludeFileRec incTermPrim = {"<Dt/TermPrim.h>"};
static IncludeFileRec incText = {"<Xm/Text.h>"};
static IncludeFileRec incTextField = {"<Xm/TextF.h>"};
static IncludeFileRec incToggleButton = {"<Xm/ToggleB.h>"};
static IncludeFileRec incXm = {"<Xm/Xm.h>"};
static IncludeFileRec incDtbUtils = {"\"dtb_utils.h\""};
/*
* Note - more than one table entry may exist for a given class!
*/
static IncludeForClass class_includes = NULL;
/*
* Initialization file includes.
*/
static IncludeFileRec *std_includes[] =
{
&incStandardLib,
&incIntrinsic,
&incDtbUtils,
NULL,
};
int
abmfP_ui_header_file_init(void)
{
#define add_inc(in_entry, in_class_name, in_include) \
(in_entry)->class_name= istr_dup(in_class_name); \
(in_entry)->include= (in_include); \
++(in_entry);
int class_includes_size = 22;
IncludeForClass include = NULL;
/*
* class_includes
*/
class_includes_size = 35;
class_includes = (IncludeForClass) abmfP_malloc(
class_includes_size * sizeof(IncludeForClassRec));
include = class_includes;
/* Make sure ISTRINGS exist for these, so string lists of */
/* header file names don't actually allocate any memory */
istr_const(incStandardLib.include_file);
istr_const(incArrowButton.include_file);
istr_const(incBulletinBoard.include_file);
istr_const(incCascadeButton.include_file);
istr_const(incComboBox.include_file);
istr_const(incDialogShell.include_file);
istr_const(incDrawingArea.include_file);
istr_const(incDrawnButton.include_file);
istr_const(incodeFileChooser.include_file);
istr_const(incForm.include_file);
istr_const(incFrame.include_file);
istr_const(incIntrinsic.include_file);
istr_const(incLabel.include_file);
istr_const(incList.include_file);
istr_const(incMainWindow.include_file);
istr_const(incMenuShell.include_file);
istr_const(incMenuButton.include_file);
istr_const(incMwmUtil.include_file);
istr_const(incPanedWindow.include_file);
istr_const(incPushButton.include_file);
istr_const(incRowColumn.include_file);
istr_const(incScale.include_file);
istr_const(incScrolledWindow.include_file);
istr_const(incSeparator.include_file);
istr_const(incShell.include_file);
istr_const(incSpinBox.include_file);
istr_const(incStringDefs.include_file);
istr_const(incTerm.include_file);
istr_const(incTermPrim.include_file);
istr_const(incText.include_file);
istr_const(incTextField.include_file);
istr_const(incToggleButton.include_file);
istr_const(incXm.include_file);
/* build the class<->include_file relationships */
add_inc(include, abmfP_topLevelShell, &incShell);
add_inc(include, abmfP_applicationShell, &incShell);
add_inc(include, abmfP_xmArrowButton, &incArrowButton);
add_inc(include, abmfP_xmBulletinBoard, &incBulletinBoard);
add_inc(include, abmfP_xmCascadeButton, &incCascadeButton);
add_inc(include, abmfP_xmComboBox, &incComboBox);
add_inc(include, abmfP_xmDialogShell, &incDialogShell);
add_inc(include, abmfP_xmDrawingArea, &incDrawingArea);
add_inc(include, abmfP_xmDrawnButton, &incDrawnButton);
add_inc(include, abmfP_xmFileSelectionBox, &incodeFileChooser);
add_inc(include, abmfP_xmForm, &incForm);
add_inc(include, abmfP_xmFrame, &incFrame);
add_inc(include, abmfP_xmLabel, &incLabel);
add_inc(include, abmfP_xmList, &incList);
add_inc(include, abmfP_xmMainWindow, &incMainWindow);
add_inc(include, abmfP_xmMenuShell, &incMenuShell);
add_inc(include, abmfP_xmMenuShell, &incRowColumn);
add_inc(include, abmfP_xmMenuButton, &incMenuButton);
add_inc(include, abmfP_xmPanedWindow, &incPanedWindow);
add_inc(include, abmfP_xmPushButton, &incPushButton);
add_inc(include, abmfP_xmRowColumn, &incRowColumn);
add_inc(include, abmfP_xmScale, &incScale);
add_inc(include, abmfP_xmScrolledWindow, &incScrolledWindow);
add_inc(include, abmfP_xmScrolledWindow, &incList);
add_inc(include, abmfP_xmSeparator, &incSeparator);
add_inc(include, abmfP_xmSpinBox, &incSpinBox);
add_inc(include, abmfP_xmTerm, &incTerm);
add_inc(include, abmfP_xmTermPrim, &incTermPrim);
add_inc(include, abmfP_xmText, &incText);
add_inc(include, abmfP_xmTextField, &incTextField);
add_inc(include, abmfP_xmToggleButton, &incToggleButton);
add_inc(include, NULL, NULL);
assert((include - class_includes) <= class_includes_size);
return 0;
#undef add_inc
}
static int write_struct_def(GenCodeInfo genCodeInfo, ABObj structObj);
static int write_substruct_def(GenCodeInfo genCodeInfo, ABObj structObj);
int
abmfP_comp_get_widget_specific_includes(StringList includesList, ABObj obj)
{
int return_value = 0;
int rc = 0; /* return code */
AB_TRAVERSAL trav;
ABObj subobj = NULL;
for (trav_open(&trav, obj, AB_TRAV_COMP_SUBOBJS);
(subobj = trav_next(&trav)) != NULL; )
{
rc = abmfP_obj_get_widget_specific_includes(includesList, subobj);
return_if_err(rc,rc);
}
trav_close(&trav);
epilogue:
return return_value;
}
/*
* Puts all the necessary header files for the object in the string
* list. Normally, the string list should be made to be unique
* (via strlist_set_is_unique() before calling this function, in order
* to avoid duplicates in the list.
*/
int
abmfP_obj_get_widget_specific_includes(StringList includesList, ABObj obj)
{
int return_value = 0;
int num_includes = 0;
BOOL objHasScrollbar = FALSE;
register IncludeForClass include = class_includes;
/*
* Get optional widget parts
*/
if (obj_has_scrollbar(obj))
{
strlist_add_str(includesList, incScrollbar.include_file, NULL);
}
if (obj_is_base_win(obj) && !obj_get_resizable(obj))
{
strlist_add_str(includesList, incMwmUtil.include_file, NULL);
}
/*
* Save all the includes for this class
*/
if (obj_get_class_name(obj) != NULL)
{
for (include = class_includes; include->class_name != NULL;
((include->class_name != NULL) ? ++include : include))
{
if (util_streq(obj_get_class_name(obj),
istr_string(include->class_name)))
{
/* this include file is needed */
strlist_add_str(includesList,
include->include->include_file, NULL);
}
} /* for include */
} /* class_name != NULL */
if (return_value >= 0)
{
return_value = num_includes;
}
return return_value;
}
/*
* Traverse object list and write out needed widget specific includes.
* REMIND: move SOMEwhere..
*/
int
abmfP_tree_write_widget_specific_includes(File codeFile, ABObj module)
{
int return_value = 0;
int num_includes = 0;
AB_TRAVERSAL trav;
ABObj obj = NULL;
StringListRec includesRec;
StringList includes = &includesRec;
strlist_construct(&includesRec);
strlist_set_is_unique(includes, TRUE);
/*
* Get standard includes
*/
strlist_add_str(includes, incStandardLib.include_file, NULL);
strlist_add_str(includes, incIntrinsic.include_file, NULL);
/*
* Get the list of includes we need
*/
for (trav_open(&trav, module, AB_TRAV_UI);
(obj = trav_next(&trav)) != NULL;)
{
abmfP_obj_get_widget_specific_includes(includes, obj);
}
trav_close(&trav);
/*
* Write 'em out!
*/
num_includes = strlist_get_num_strs(includes);
if (num_includes > 0)
{
int i = 0;
STRING include = NULL;
abio_puts(codeFile, "\n");
for (i= 0; i < num_includes; ++i)
{
include = strlist_get_str(includes, i, NULL);
abio_printf(codeFile, "#include %s\n", include);
}
}
strlist_destruct(&includesRec);
if (return_value >= 0)
{
return_value = num_includes;
}
return return_value;
}
/*
* writes one structure definition
*/
static int
write_struct_def(GenCodeInfo genCodeInfo, ABObj structObj)
{
File codeFile= genCodeInfo->code_file;
AB_TRAVERSAL salientTrav;
AB_TRAVERSAL uiTrav;
ABObj item = NULL;
ABObj fieldObj= NULL;
ABObj salientObj = NULL;
STRING typeName = NULL;
STRING fieldName = NULL;
int numFields = 0;
int thisFieldNum = 0;
BOOL objHasItems = FALSE;
BOOL lastNumFields = 0;
BOOL separateObj = TRUE;
BOOL lastSeparateObj = FALSE;
char commentBuf[1024] = "";
int fieldsWritten = 0;
/* Don't want the message structure written out to the
* _ui.h file. It belongs in the dtb_utils.h file.
*/
if (obj_is_message(structObj))
return 0;
/*
* Write out all the substructure data types
*/
for (trav_open(&uiTrav, structObj, AB_TRAV_UI|AB_TRAV_MOD_PARENTS_FIRST);
(fieldObj = trav_next(&uiTrav)) != NULL; )
{
/* ref objs do not have their own type (they take the menu's type */
if ( abmfP_obj_is_substruct_obj(fieldObj)
&& (!obj_is_ref(fieldObj)) )
{
write_substruct_def(genCodeInfo, fieldObj);
}
}
trav_close(&uiTrav);
abio_printf(codeFile, "typedef struct\n{\n");
abio_indent(codeFile);
abio_printf(codeFile, "Boolean\tinitialized;\n");
for (trav_open(&salientTrav,
structObj, AB_TRAV_UI|AB_TRAV_MOD_PARENTS_FIRST);
(salientObj= trav_next(&salientTrav)) != NULL;
lastNumFields = numFields, lastSeparateObj = separateObj)
{
if (! (obj_is_salient(salientObj) || obj_is_menu_ref(salientObj)) )
{
continue;
}
item = obj_get_item(salientObj, 0);
objHasItems = ((item != NULL) &&
!obj_is_list_item(item) &&
!obj_is_combo_box_item(item) &&
!obj_is_spin_box_item(item));
numFields = obj_get_num_comp_subobjs(salientObj) + (objHasItems? 1:0);
thisFieldNum = -1;
separateObj = (numFields > 1);
if (separateObj || lastSeparateObj)
{
abio_puts(codeFile, "\n");
}
/*
* Handle composite subobjects
*/
for (trav_open(&uiTrav, salientObj,
AB_TRAV_COMP_SUBOBJS|AB_TRAV_MOD_PARENTS_FIRST);
(fieldObj = trav_next(&uiTrav)) != NULL; ++thisFieldNum)
{
typeName = NULL;
fieldName = NULL;
if ( abmfP_obj_has_struct_field(fieldObj)
&& (!obj_was_written(fieldObj)) )
{
typeName = abmfP_str_widget;
fieldName = abmfP_get_c_field_name(fieldObj);
}
if ((typeName != NULL) && (fieldName != NULL))
{
++thisFieldNum;
++fieldsWritten;
obj_set_was_written(fieldObj, TRUE);
if (obj_is_menu_ref(fieldObj))
{
/* be sure we don't write the items, since they're */
/* in the substructure */
abmfP_obj_set_items_written(fieldObj, TRUE);
}
abio_printf(codeFile, "%s\t%s;",
typeName, fieldName);
if (separateObj && (thisFieldNum == 0))
{
STRING userObjName = NULL;
if (obj_is_ref(salientObj))
{
userObjName =
obj_get_name(obj_get_actual_obj(salientObj));
}
else
{
userObjName = obj_get_name(salientObj);
}
abio_puts(codeFile, "\t");
sprintf(commentBuf, "object \"%s\"",
util_strsafe(userObjName));
abmfP_write_c_comment(genCodeInfo, TRUE, commentBuf);
}
else
{
abio_puts(codeFile, nlstr);
}
}
}
trav_close(&uiTrav);
/*
* Handle items for this object
*/
if (objHasItems)
{
char msg[256];
++fieldsWritten;
abio_printf(codeFile, "%s\t%s;\n",
abmfP_get_c_substruct_type_name(salientObj),
abmfP_get_c_substruct_field_name(salientObj));
abmfP_obj_set_items_written(salientObj, TRUE);
}
}
trav_close(&salientTrav);
abio_outdent(codeFile);
abio_printf(codeFile, "} %s, *%s;\n",
abmfP_get_c_struct_type_name(structObj),
abmfP_get_c_struct_ptr_type_name(structObj));
return 0;
}
static int
write_substruct_def(GenCodeInfo genCodeInfo, ABObj structObj)
{
File codeFile = genCodeInfo->code_file;
ABObj fieldObj = NULL;
AB_TRAVERSAL trav;
abio_printf(codeFile, "typedef struct {\n");
abio_indent(codeFile);
for (trav_open(&trav, structObj, AB_TRAV_ITEMS_FOR_OBJ);
(fieldObj = trav_next(&trav)) != NULL; )
{
if (abmfP_obj_has_substruct_field(fieldObj))
{
obj_set_was_written(fieldObj, TRUE);
abio_printf(codeFile, "%s\t%s;\n",
abmfP_str_widget,
abmfP_get_c_field_name(fieldObj));
}
}
trav_close(&trav);
abio_outdent(codeFile);
abio_printf(codeFile, "} %s, *%s;\n",
abmfP_get_c_substruct_type_name(structObj),
abmfP_get_c_substruct_ptr_type_name(structObj));
return 0;
}
/*
* write the definitions of the structures that hold the widgets
*/
static int
write_all_struct_defs(GenCodeInfo genCodeInfo, ABObj module)
{
AB_TRAVERSAL trav;
ABObj structObj= NULL;
ABObj menuObj;
int numWritten = 0;
/*
* Menu creation procs are shared by all menu references
* in the module, so we write their substructure definitions
* first.
*
* We then mark all the menu refs and their items as written,
* so they do not get put into each data structure.
*/
abmfP_write_c_comment(genCodeInfo, FALSE, "Shared data structures");
for (trav_open(&trav, module, AB_TRAV_MENUS);
(menuObj = trav_next(&trav)) != NULL; )
{
/* refs use the type that they reference */
if ((!obj_is_ref(menuObj)) && (abmfP_obj_is_substruct_obj(menuObj)))
{
++numWritten;
write_substruct_def(genCodeInfo, menuObj);
}
}
trav_close(&trav);
if (numWritten > 0)
{
abio_puts(genCodeInfo->code_file, nlstr);
}
/*
* Write all structures
*/
for (trav_open(&trav, module, AB_TRAV_UI | AB_TRAV_MOD_PARENTS_FIRST);
(structObj= trav_next(&trav)) != NULL; )
{
if ( abmfP_obj_is_struct_obj(structObj))
{
abio_printf(genCodeInfo->code_file, nlstr);
write_struct_def(genCodeInfo, structObj);
}
}
trav_close(&trav);
return 0;
}
/*
* Write out the decl of one shared variable
*/
static int
write_shared_var_decl(GenCodeInfo genCodeInfo, ABObj structObj)
{
File codeFile = genCodeInfo->code_file;
if (obj_is_message(structObj))
{
abio_printf(codeFile, "extern %s", "DtbMessageDataRec");
}
else
{
abio_printf(codeFile, "extern %s",
abmfP_get_c_struct_type_name(structObj));
}
abio_printf(codeFile, " %s;\n",
abmfP_get_c_struct_global_name(structObj));
return 0;
}
/*
* Traverse object list and write out user struct objects
* decls.
*/
static int
write_all_shared_var_decls(GenCodeInfo genCodeInfo, ABObj module)
{
File codeFile= genCodeInfo->code_file;
AB_TRAVERSAL trav;
ABObj structObj= NULL;;
abio_printf(codeFile, "\n\n");
for (trav_open(&trav, module, AB_TRAV_ALL);
(structObj= trav_next(&trav)) != NULL; )
{
if (!abmfP_obj_is_struct_obj(structObj))
{
continue;
}
write_shared_var_decl(genCodeInfo, structObj);
}
trav_close(&trav);
return 0;
}
/*
* Traverse object list and write out callback decls, for those
* connections with the proper value of auto_named.
*/
static int
write_action_decls(
GenCodeInfo genCodeInfo,
ABObj module,
BOOL auto_named)
{
AB_TRAVERSAL trav;
ABObj action = NULL;
for (trav_open(&trav, module, AB_TRAV_ACTIONS_FOR_OBJ);
(action = trav_next(&trav)) != NULL;)
{
if ( mfobj_has_flags(action, CGenFlagIsDuplicateDef)
|| mfobj_has_flags(action, CGenFlagWriteDefToProjFile))
{
continue;
}
if (!util_xor(action->info.action.auto_named, auto_named))
{
abmfP_write_action_func_decl(genCodeInfo, action);
}
}
trav_close(&trav);
return 0;
}
/*
* Traverse object list and write out connection decls. (Functions
* that have been automatically generated and named)
*/
static int
write_connection_decls(GenCodeInfo genCodeInfo, ABObj module)
{
return write_action_decls(genCodeInfo, module, TRUE);
}
/*
* Traverse object list and write out callback decls. (Functions that
* have been named by the user)
*/
static int
write_callback_decls(GenCodeInfo genCodeInfo, ABObj module)
{
return write_action_decls(genCodeInfo, module, FALSE);
}
/*
* Write out decls of structure clear procs
*/
static int
write_clear_proc_decls(GenCodeInfo genCodeInfo, ABObj module)
{
AB_TRAVERSAL trav;
ABObj obj = NULL;
for (trav_open(&trav, module, AB_TRAV_ALL);
(obj = trav_next(&trav)) != NULL;)
{
if (!abmfP_obj_has_clear_proc(obj))
{
continue;
}
if (obj_is_window(obj))
{
abmfP_write_clear_proc_decl(genCodeInfo, obj);
}
}
trav_close(&trav);
return 0;
}
/*
* Write out decls structure initialization procs
*/
static int
write_init_proc_decls(GenCodeInfo genCodeInfo, ABObj module)
{
AB_TRAVERSAL trav;
ABObj obj = NULL;
for (trav_open(&trav, module, AB_TRAV_SALIENT_UI);
(obj = trav_next(&trav)) != NULL;)
{
if (!abmfP_obj_has_init_proc(obj))
{
continue;
}
abmfP_write_init_proc_decl(genCodeInfo, obj);
}
trav_close(&trav);
return 0;
}
/*
* Returns a copy of the input string with dots replaced with underscores.
*/
static STRING
remove_dots(STRING s)
{
static char name[MAXPATHLEN];
STRING n = (STRING) name;
for (; *s; ++s, ++n)
if (*s == '.')
*n = '_';
else
*n = *s;
*n = '\0';
return name;
}
/*
* Open the UI header file, write some comments, write the includes, write
* the decls, and close the header file.
*/
int
abmfP_write_ui_header_file(
GenCodeInfo genCodeInfo,
ABObj module,
STRING headerName,
STRING headerDefine
)
{
File codeFile = genCodeInfo->code_file;
char moduleName[1024];
STRING errmsg = NULL;
int i = 0;
*moduleName = 0;
sprintf(moduleName, "module %s", util_strsafe(obj_get_name(module)));
abmfP_write_file_header(
genCodeInfo,
headerName,
TRUE,
moduleName,
util_get_program_name(),
ABMF_MODIFY_NOT,
" * Contains: Declarations of module objects, user create procedures,\n"
" * and callbacks."
);
/*
* Write standard includes.
*/
for (i = 0; std_includes[i] != NULL; ++i)
{
abio_printf(codeFile,
"#include %s\n", std_includes[i]->include_file);
/* REMIND : only write out necessary include files! */
/* std_includes[i]->written = TRUE; */
}
/*
* Write UI object decls.
*/
abmfP_tree_set_written(module, FALSE);
abio_puts(codeFile, "\n");
abio_puts(codeFile, abmfP_comment_begin);
abio_puts(codeFile, abmfP_comment_continue);
abio_printf(codeFile, "User Interface Objects\n");
abio_puts(codeFile, abmfP_comment_end);
write_all_struct_defs(genCodeInfo, module);
write_all_shared_var_decls(genCodeInfo, module);
/*
* Write structure clear proc decls
*/
abio_puts(codeFile, "\n");
abio_puts(codeFile, abmfP_comment_begin);
abio_puts(codeFile, abmfP_comment_continue);
abio_printf(codeFile,
"Structure Clear Procedures: These set the fields to NULL\n");
abio_puts(codeFile, abmfP_comment_end);
write_clear_proc_decls(genCodeInfo, module);
/*
* Write structure init proc decls.
*/
abio_puts(codeFile, "\n");
abio_puts(codeFile, abmfP_comment_begin);
abio_puts(codeFile, abmfP_comment_continue);
abio_printf(codeFile,
"Structure Initialization Procedures: These create the widgets\n");
abio_puts(codeFile, abmfP_comment_end);
write_init_proc_decls(genCodeInfo, module);
/*
* Write Callback decls.
*/
abio_puts(codeFile, "\n");
abmfP_write_c_comment(genCodeInfo, FALSE, "User Callbacks");
write_callback_decls(genCodeInfo, module);
/*
* Write Connection decls.
*/
abio_puts(codeFile, "\n");
abmfP_write_c_comment(genCodeInfo, FALSE, "Connections");
write_connection_decls(genCodeInfo, module);
/*
* Write file footer.
*/
abmfP_write_file_footer(genCodeInfo, headerName, TRUE);
return OK;
}
int
abmfP_write_action_func_decl(GenCodeInfo genCodeInfo, ABObj action)
{
STRING funcName = abmfP_get_action_name(action);
ABObj fromObj = NULL;
AB_TRAVERSAL refTrav;
ABObj refObj = NULL;
ABObj actualFromObj = NULL;
ABObj module = NULL;
fromObj = obj_get_from(action);
module = obj_get_module(fromObj);
switch (obj_get_when(action))
{
case AB_WHEN_DRAGGED_FROM:
abio_printf(genCodeInfo->code_file,
abmfP_lib_default_dragCB->proto, /* fmt string */
funcName);
abio_puts(genCodeInfo->code_file, nlstr);
break;
case AB_WHEN_DROPPED_ON:
abio_printf(genCodeInfo->code_file,
abmfP_lib_default_dropCB->proto, /* fmt string */
funcName);
abio_puts(genCodeInfo->code_file, nlstr);
break;
case AB_WHEN_TOOLTALK_QUIT:
case AB_WHEN_TOOLTALK_DO_COMMAND:
case AB_WHEN_TOOLTALK_GET_STATUS:
case AB_WHEN_TOOLTALK_PAUSE_RESUME:
abmfP_write_tooltalk_callback_decl(genCodeInfo, FALSE, funcName);
break;
case AB_WHEN_SESSION_SAVE:
abmfP_write_session_save_callback_decl(genCodeInfo,
FALSE, funcName);
break;
case AB_WHEN_SESSION_RESTORE:
abmfP_write_session_restore_callback_decl(genCodeInfo,
FALSE, funcName);
break;
default:
abmfP_write_xm_callback_decl(genCodeInfo, FALSE, funcName);
break;
} /* switch obj_get_when() */
return 0;
}

View File

@@ -0,0 +1,50 @@
/*
* $XConsortium: ui_header_fileP.h /main/3 1995/11/06 18:15:59 rswiston $
*
* @(#)ui_header_fileP.h 3.14 14 Jan 1995 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
#ifndef _ABMF_UI_HEADER_FILEP_H_
#define _ABMF_UI_HEADER_FILEP_H_
#include "write_codeP.h"
int abmfP_ui_header_file_init(void); /* call this first !! */
int abmfP_write_ui_header_file(
GenCodeInfo genCodeInfo,
ABObj module,
STRING headerName,
STRING headerDefine
);
int abmfP_write_action_func_decl(GenCodeInfo genCodeInfo, ABObj action);
int abmfP_comp_get_widget_specific_includes(
StringList includes,
ABObj compObj
);
int abmfP_obj_get_widget_specific_includes(
StringList includes,
ABObj obj
);
int abmfP_tree_write_widget_specific_includes(
File codeFile,
ABObj tree
);
#endif /* _ABMF_UI_HEADER_FILEP_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,158 @@
/*
* $XConsortium: utilsP.h /main/3 1995/11/06 18:16:34 rswiston $
*
* @(#)utilsP.h 3.43 16 Feb 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special restrictions in a
* confidential disclosure agreement between HP, IBM, Sun, USL, SCO and
* Univel. Do not distribute this document outside HP, IBM, Sun, USL, SCO,
* or Univel without Sun's specific written approval. This document and all
* copies and derivative works thereof must be returned or destroyed at Sun's
* request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
#ifndef _ABMF_UTILSP_H_
#define _ABMF_UTILSP_H_
#include <ab_private/obj.h>
#include "abmfP.h"
/*
* Pointer to functions.
*/
typedef int (*PFI) ();
typedef char *(*PFS) ();
typedef void (*PFV) ();
extern STRING nlstr; /* "\n" - keep this identifier short! */
extern STRING nlstr2; /* "\n\n" - keep this identifier short! */
/*
* Miscellaneous
*/
ABObj abmfP_get_root_window(ABObj project);
STRING abmfP_backup_file(STRING fileName);
int abmfP_filecopy(STRING file1, STRING file2);
STRING abmfP_convert_wclass_ptr_to_name(WidgetClass wclass);
/*
* strings
*/
STRING abmfP_capitalize_first_char(char *str);
STRING abmfP_uncapitalize_first_char(char *str);
STRING abmfP_get_define_from_file_name(STRING fileName);
BOOL abmfP_file_name_is_bitmap(STRING fileName);
BOOL abmfP_file_name_is_xpm(STRING fileName);
STRING abmfP_cvt_file_name_to_bitmap_data_vars(
STRING fileName,
STRING *widthVarPtr,
STRING *heightVarPtr,
STRING *bitsVarPtr);
STRING abmfP_cvt_file_name_to_xpm_data_var(STRING fileName);
/*
* object functions
*/
ABObj abmfP_parent(ABObj obj); /* same abmfP_obj_find_codegen_parent */
ABObj abmfP_obj_find_codegen_parent(ABObj obj);
BOOL abmfP_obj_create_proc_has_parent_param(ABObj obj);
BOOL abmfP_obj_create_proc_has_name_param(ABObj obj);
BOOL abmfP_obj_create_proc_has_instance_param(ABObj obj);
BOOL abmfP_obj_create_proc_has_submenu_params(ABObj);
int abmfP_get_num_cp_submenu_params(ABObj);
ABObj abmfP_get_cp_submenu_param_obj(ABObj, int which);
STRING abmfP_get_cp_submenu_param_name(ABObj, int which);
STRING abmfP_get_cp_submenu_param_type_name(ABObj, int which);
STRING abmfP_obj_get_create_proc_instance_param_type(ABObj);
int abmfP_obj_get_num_create_proc_return_widgets(ABObj);
STRING abmfP_obj_get_create_proc_return_widget_name(
ABObj obj, int which_param);
BOOL abmfP_obj_has_clear_proc(ABObj obj);
BOOL abmfP_obj_has_create_proc(ABObj obj);
BOOL abmfP_obj_has_init_proc(ABObj obj);
BOOL abmfP_obj_has_menu(ABObj);
BOOL abmfP_obj_has_item_with_menu(ABObj);
BOOL abmfP_module_has_menu_struct(ABObj obj);
int abmfP_get_num_substruct_fields(ABObj obj);
ABObj abmfP_obj_get_struct_obj(ABObj obj);
ABObj abmfP_obj_get_substruct_obj(ABObj obj);
BOOL abmfP_objs_in_same_struct(ABObj obj1, ABObj obj2);
BOOL abmfP_objs_in_same_substruct(ABObj obj1, ABObj obj2);
int abmfP_assign_widget_names(ABObj tree);
ABObj abmfP_get_parent_of_type(ABObj obj, AB_OBJECT_TYPE parent_type);
ABObj abmfP_get_window_parent(ABObj obj);
int abmfP_obj_is_duplicate(ABObj obj1, ABObj obj2);
ABObj abmfP_get_actual_control(ABObj obj);
int abmfP_tree_set_written(ABObj root, BOOL written);
int abmfP_obj_set_subobjs_written(ABObj root, BOOL written);
int abmfP_obj_set_items_written(ABObj root, BOOL written);
BOOL abmfP_obj_has_glyph_label(ABObj obj);
BOOL abmfP_obj_has_item_with_glyph_label(ABObj obj);
BOOL abmfP_obj_has_string_label(ABObj obj);
BOOL abmfP_obj_has_item_with_string_label(ABObj obj);
ABObj abmfP_find_callback_scope(ABObj project, STRING func_name);
BOOL abmfP_proj_needs_session_save(ABObj proj);
BOOL abmfP_proj_needs_session_restore(ABObj proj);
BOOL abmfP_obj_needs_centering_handler(ABObj obj);
STRING abmfP_obj_get_centering_type(ABObj obj);
BOOL abmfP_obj_needs_align_handler(ABObj obj);
STRING abmfP_obj_get_group_type(ABObj obj);
STRING abmfP_obj_get_row_align_type(ABObj obj);
STRING abmfP_obj_get_col_align_type(ABObj obj);
BOOL abmfP_items_are_homogeneous(ABObj obj);
BOOL abmfP_items_have_mnemonics(ABObj obj);
BOOL abmfP_items_have_accelerators(ABObj obj);
BOOL abmfP_proj_has_message(ABObj proj);
/*
* Memory
*/
void* abmfP_calloc(size_t n, size_t size);
void* abmfP_malloc(size_t size);
void* abmfP_realloc(void *buf, unsigned int size);
int abmfP_free(void *buf);
/*
** refs
*/
ABObjList abmfP_find_refs_to(ABObj obj);
/*************************************************************************
** **
** INLINE IMPLEMENTATION **
** **
*************************************************************************/
#define abmfP_free(ptr) util_free(ptr)
#define abmfP_obj_has_clear_proc(obj) \
(abmfP_obj_is_struct_obj(obj))
#define abmfP_obj_has_init_proc(obj) \
(abmfP_obj_is_struct_obj(obj))
/*
* shortcut for abmfP_obj_find_codegen_parent. Checks to see if it
* can avoid the function call, first (which is most of the time).
*/
#define abmfP_parent(obj) \
((obj)->parent == NULL? \
NULL \
: \
obj_has_flag((obj)->parent, NoCodeGenFlag)? \
abmfP_obj_find_codegen_parent(obj) \
: \
((obj)->parent) \
)
#endif /* _ABMF_UTILSP_H_ */

View File

@@ -0,0 +1,654 @@
/*
* $XConsortium: utils_c_file.c /main/3 1995/11/06 18:16:48 rswiston $
*
* @(#)utils_c_file.c 1.25 08 May 1995 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* utils_c_file.c - writes dtb_utils.c
*/
#include <ab_private/abio.h>
#include "lib_func_stringsP.h"
#include "write_cP.h"
#include "utils_c_fileP.h"
/*************************************************************************
** **
** Constants (#define and const) **
** **
**************************************************************************/
/*************************************************************************
** **
** Private Functions (C declarations and macros) **
** **
**************************************************************************/
static int write_lib_func(GenCodeInfo genCodeInfo, LibFunc libFunc);
static int write_all_lib_funcs(GenCodeInfo genCodeInfo, ABObj project);
static int write_all_vars(GenCodeInfo genCodeInfo, ABObj project);
static int write_all_macros(GenCodeInfo genCodeInfo, ABObj project);
static int write_all_types(GenCodeInfo genCodeInfo, ABObj project);
static int write_all_static_func_decls(GenCodeInfo genCodeInfo, ABObj project);
static int write_save_toplevel_widget_var(GenCodeInfo genCodeInfo, ABObj project);
static int write_save_command_var(GenCodeInfo genCodeInfo, ABObj project);
static int write_session_CB_vars(GenCodeInfo genCodeInfo, ABObj project);
static int write_tooltalk_CB_vars(GenCodeInfo genCodeInfo, ABObj project);
static int write_dnd_vars(GenCodeInfo genCodeInfo, ABObj project);
static int write_popup_menu_vars(GenCodeInfo genCodeInfo, ABObj project);
static int write_centering_static_func_decls(GenCodeInfo genCodeInfo, ABObj project);
static int write_msg_static_func_decls( GenCodeInfo genCodeInfo, ABObj project);
static int write_align_static_func_decls(GenCodeInfo genCodeInfo, ABObj project);
/*************************************************************************
** **
** Data **
** **
**************************************************************************/
/*************************************************************************
** **
** Function Definitions **
** **
**************************************************************************/
int
abmfP_write_utils_c_file(
GenCodeInfo genCodeInfo,
STRING fileName,
ABObj project
)
{
char projName[1024];
sprintf(projName, "project %s", obj_get_name(project));
abmfP_write_file_header(
genCodeInfo,
fileName,
FALSE,
projName,
util_get_program_name(),
ABMF_MODIFY_NOT,
" * CDE Application Builder General Utility Functions"
);
abmfP_write_c_system_include(genCodeInfo, "unistd.h");
abmfP_write_c_system_include(genCodeInfo, "stdlib.h");
abmfP_write_c_system_include(genCodeInfo, "stdio.h");
abmfP_write_c_system_include(genCodeInfo, "sys/param.h");
abmfP_write_c_system_include(genCodeInfo, "sys/stat.h");
abmfP_write_c_system_include(genCodeInfo, "Xm/Xm.h");
abmfP_write_c_system_include(genCodeInfo, "Xm/Form.h");
abmfP_write_c_system_include(genCodeInfo, "Xm/Frame.h");
abmfP_write_c_system_include(genCodeInfo, "Xm/Label.h");
abmfP_write_c_system_include(genCodeInfo, "Xm/MessageB.h");
abmfP_write_c_system_include(genCodeInfo, "Xm/PanedW.h");
abmfP_write_c_system_include(genCodeInfo, "Xm/PushB.h");
abmfP_write_c_system_include(genCodeInfo, "Xm/SashP.h");
abmfP_write_c_system_include(genCodeInfo, "Xm/RowColumn.h");
abmfP_write_c_system_include(genCodeInfo, "Dt/Help.h");
abmfP_write_c_system_include(genCodeInfo, "Dt/HelpDialog.h");
abmfP_write_c_system_include(genCodeInfo, "Dt/HelpQuickD.h");
abmfP_write_c_system_include(genCodeInfo, "Dt/Session.h");
abmfP_write_c_system_include(genCodeInfo, "Dt/Dnd.h");
abmfP_write_c_local_include(genCodeInfo, "dtb_utils.h");
write_all_macros(genCodeInfo, project);
write_all_types(genCodeInfo, project);
write_all_static_func_decls(genCodeInfo, project);
write_all_vars(genCodeInfo, project);
write_all_lib_funcs(genCodeInfo, project);
return 0;
}
static int
write_all_macros(GenCodeInfo genCodeInfo, ABObj project)
{
project = project; /* avoid warning */
abio_puts(genCodeInfo->code_file, nlstr);
abio_puts(genCodeInfo->code_file,
"#ifndef min\n"
"#define min(a,b) ((a) < (b)? (a):(b))\n"
"#endif\n\n");
abio_puts(genCodeInfo->code_file,
"#ifndef max\n"
"#define max(a,b) ((a) > (b)? (a):(b))\n"
"#endif\n\n");
abio_puts(genCodeInfo->code_file,
"#ifndef ABS\n"
"#define ABS(x) ((x) >= 0? (x):(-(x)))\n"
"#endif\n\n");
return 0;
}
static int
write_all_types(GenCodeInfo genCodeInfo, ABObj project)
{
File codeFile = genCodeInfo->code_file;
project = project; /* avoid warning */
abio_puts(codeFile,
"typedef struct\n"
"{\n"
" Widget widget;\n"
" DtDndProtocol protocol;\n"
" unsigned char operations;\n"
" Boolean bufferIsText;\n"
" Boolean allowDropOnRootWindow;\n"
" Widget sourceIcon;\n"
" DtbDndDragCallback callback;\n"
" XtCallbackRec convertCBRec[2];\n"
" XtCallbackRec dragToRootCBRec[2];\n"
" XtCallbackRec dragFinishCBRec[2];\n"
"} DtbDragSiteRec, *DtbDragSite;\n"
"\n");
abio_puts(codeFile,
"typedef struct\n"
"{\n"
" Widget widget;\n"
" DtDndProtocol protocols;\n"
" unsigned char operations;\n"
" Boolean textIsBuffer;\n"
" Boolean dropsOnChildren;\n"
" Boolean preservePreviousRegistration;\n"
" DtbDndDropCallback callback;\n"
" XtCallbackRec animateCBRec[2];\n"
" XtCallbackRec transferCBRec[2];\n"
"} DtbDropSiteRec, *DtbDropSite;\n"
"\n");
abio_puts(codeFile,
"/*\n"
" * This structure keeps track of widget/menu pairs\n"
" */\n"
"typedef struct\n"
"{\n"
" Widget widget;\n"
" Widget menu;\n"
"} DtbMenuRefRec, *DtbMenuRef;\n"
"\n");
return 0;
}
static int
write_all_static_func_decls(GenCodeInfo genCodeInfo, ABObj project)
{
File codeFile= genCodeInfo->code_file;
write_centering_static_func_decls(genCodeInfo, project);
if (abmfP_proj_has_message(project))
write_msg_static_func_decls(genCodeInfo, project);
/*
* Write out static functions for aligning objects in groups
*/
write_align_static_func_decls(genCodeInfo, project);
/*
* private path-determing functions
*/
abio_puts(genCodeInfo->code_file, nlstr);
abmfP_write_c_comment(genCodeInfo, FALSE,
"Private functions used for finding paths");
abio_printf(codeFile, "%s\n\n", abmfP_lib_determine_exe_dir->proto);
abio_printf(codeFile, "%s\n\n", abmfP_lib_determine_exe_dir_from_argv->proto);
abio_printf(codeFile, "%s\n\n", abmfP_lib_determine_exe_dir_from_path->proto);
abio_printf(codeFile, "%s\n\n", abmfP_lib_path_is_executable->proto);
/* private popup menu functions */
abio_printf(codeFile, "%s\n\n", abmfP_lib_popup_menu->proto);
abio_printf(codeFile, "%s\n\n", abmfP_lib_popup_menu_destroyCB->proto);
/*
* static drag functions
*/
abio_printf(codeFile, "%s\n\n", abmfP_lib_drag_terminate->proto);
abio_printf(codeFile, "%s\n\n", abmfP_lib_drag_button1_motion_handler->proto);
abio_printf(codeFile, "%s\n\n", abmfP_lib_drag_start->proto);
abio_printf(codeFile, "%s\n\n", abmfP_lib_drag_convertCB->proto);
abio_printf(codeFile, "%s\n\n", abmfP_lib_drag_to_rootCB->proto);
abio_printf(codeFile, "%s\n\n", abmfP_lib_drag_finishCB->proto);
abio_printf(codeFile, "%s\n\n", abmfP_lib_drop_animateCB->proto);
abio_printf(codeFile, "%s\n\n", abmfP_lib_drop_transferCB->proto);
return 0;
}
static int
write_all_vars(GenCodeInfo genCodeInfo, ABObj project)
{
File codeFile = genCodeInfo->code_file;
write_session_CB_vars(genCodeInfo, project);
write_tooltalk_CB_vars(genCodeInfo, project);
write_save_toplevel_widget_var(genCodeInfo, project);
write_save_command_var(genCodeInfo, project);
write_popup_menu_vars(genCodeInfo, project);
write_dnd_vars(genCodeInfo, project);
/*
* write path-to-executable var
*/
abio_puts(codeFile, nlstr);
abmfP_write_c_comment(genCodeInfo, FALSE,
"Directory where the binary for this process whate loaded from");
abio_puts(codeFile,
"static char\t\t\t\t*dtb_exe_dir = (char *)NULL;\n");
return 0;
}
static int
write_session_CB_vars(GenCodeInfo genCodeInfo, ABObj project)
{
File codeFile;
if (!genCodeInfo || !project)
return (0);
codeFile = genCodeInfo->code_file;
abio_puts(codeFile, "\n");
abio_puts(codeFile, "/*\n");
abio_puts(codeFile, " * Variable for storing client session save callback\n");
abio_puts(codeFile, " */\n");
abio_puts(codeFile,
"static DtbClientSessionSaveCB\t\tdtb_client_session_saveCB = NULL;\n");
if (abmfP_proj_needs_session_restore(project))
{
abio_puts(codeFile, "/*\n");
abio_puts(codeFile, " * Variable for storing client session restore callback\n");
abio_puts(codeFile, " */\n");
abio_puts(codeFile,
"static DtbClientSessionRestoreCB\tdtb_client_session_restoreCB = NULL;\n");
}
return (0);
}
static int
write_tooltalk_CB_vars(GenCodeInfo genCodeInfo, ABObj project)
{
File codeFile;
if (!genCodeInfo || !project ||
obj_get_tooltalk_level(project) != AB_TOOLTALK_DESKTOP_ADVANCED)
return (0);
codeFile = genCodeInfo->code_file;
abio_puts(codeFile, "\n");
abio_puts(codeFile, "/*\n");
abio_puts(codeFile, " * Variable for storing ToolTalk Message Quit callback\n");
abio_puts(codeFile, " */\n");
abio_puts(codeFile,
"static DtbTTMsgHandlerCB\t\tdtb_tt_msg_quitCB = NULL;\n");
abio_puts(codeFile, "/*\n");
abio_puts(codeFile, " * Variable for storing ToolTalk Message Do Command callback\n");
abio_puts(codeFile, " */\n");
abio_puts(codeFile,
"static DtbTTMsgHandlerCB\t\tdtb_tt_msg_do_commandCB = NULL;\n");
abio_puts(codeFile, "/*\n");
abio_puts(codeFile, " * Variable for storing ToolTalk Message Get Status callback\n");
abio_puts(codeFile, " */\n");
abio_puts(codeFile,
"static DtbTTMsgHandlerCB\t\tdtb_tt_msg_get_statusCB = NULL;\n");
abio_puts(codeFile, "/*\n");
abio_puts(codeFile, " * Variable for storing ToolTalk Message Pause/Resume callback\n");
abio_puts(codeFile, " */\n");
abio_puts(codeFile,
"static DtbTTMsgHandlerCB\t\tdtb_tt_msg_pause_resumeCB = NULL;\n");
return (0);
}
static int
write_save_toplevel_widget_var(GenCodeInfo genCodeInfo, ABObj project)
{
File codeFile;
if (!genCodeInfo || !project)
return (0);
codeFile = genCodeInfo->code_file;
abio_puts(codeFile, "\n");
abio_puts(codeFile, "/*\n");
abio_puts(codeFile, " * Variable for storing top level widget\n");
abio_puts(codeFile, " */\n");
abio_puts(codeFile,
"static Widget\t\tdtb_project_toplevel_widget = (Widget)NULL;\n");
return (0);
}
static int
write_save_command_var(GenCodeInfo genCodeInfo, ABObj project)
{
File codeFile;
if (!genCodeInfo || !project)
return (0);
codeFile = genCodeInfo->code_file;
abio_puts(codeFile, nlstr);
abmfP_write_c_comment(genCodeInfo, FALSE,
"Variable for storing command used to invoke application");
abio_puts(codeFile,
"static char\t\t\t\t*dtb_save_command_str = (char *)NULL;\n");
return (0);
}
static int
write_popup_menu_vars(GenCodeInfo genCodeInfo, ABObj project)
{
abio_puts(genCodeInfo->code_file, nlstr);
abmfP_write_c_comment(genCodeInfo, FALSE,
"Variables that keep track of which menus go with which widgets");
abio_puts(genCodeInfo->code_file,
"static DtbMenuRef\tpopupMenus = NULL;\n"
"static int\tnumPopupMenus = 0;\n");
return 0;
}
static int
write_dnd_vars(GenCodeInfo genCodeInfo, ABObj project)
{
File codeFile = genCodeInfo->code_file;
project = project; /* avoid warning */
abio_puts(codeFile,
"#include <Dt/Dnd.h>"
"\n"
"\n"
"#define DRAG_THRESHOLD 4\n"
"static Boolean dragInProgress = False;\n"
"static int dragInitialX = -1;\n"
"static int dragInitialY = -1;\n"
"\n");
return 0;
}
static int
write_centering_static_func_decls(GenCodeInfo genCodeInfo, ABObj project)
{
File codeFile;
if (!genCodeInfo || !project)
return (0);
codeFile = genCodeInfo->code_file;
abio_puts(codeFile, "/*\n");
abio_puts(codeFile, " * Private functions used for dynamic centering of objects\n");
abio_puts(codeFile, " */\n");
abio_printf(codeFile, "%s\n", abmfP_lib_center_widget->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_uncenter_widget->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_centering_handler->proto);
return (0);
}
static int
write_align_static_func_decls(GenCodeInfo genCodeInfo, ABObj project)
{
File codeFile;
if (!genCodeInfo || !project)
return (0);
codeFile = genCodeInfo->code_file;
abio_puts(codeFile, "/*\n");
abio_puts(codeFile, " * Static functions used for dynamic aligning of group objects\n");
abio_puts(codeFile, " */\n");
abio_printf(codeFile, "%s\n", abmfP_lib_get_label_widget->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_get_offset_from_ancestor->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_get_label_width->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_get_widest_label->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_get_widest_value->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_get_widget_rect->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_get_greatest_size->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_get_group_cell_size->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_get_group_row_col->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_get_group_child->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_align_children->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_align_handler->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_expose_handler->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_free_group_info->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_align_rows->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_align_cols->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_align_left->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_align_right->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_align_labels->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_align_vcenter->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_align_top->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_align_bottom->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_align_hcenter->proto);
return (0);
}
static int
write_all_lib_funcs(GenCodeInfo genCodeInfo, ABObj project)
{
File codeFile= genCodeInfo->code_file;
abio_puts(codeFile, "\n");
abmfP_write_c_comment(genCodeInfo, FALSE,
"Application Builder utility funcs");
write_lib_func(genCodeInfo, abmfP_lib_cvt_file_to_pixmap);
write_lib_func(genCodeInfo, abmfP_lib_set_label_from_bitmap_data);
write_lib_func(genCodeInfo, abmfP_lib_set_label_pixmaps);
write_lib_func(genCodeInfo, abmfP_lib_file_has_extension);
write_lib_func(genCodeInfo, abmfP_lib_cvt_filebase_to_pixmap);
write_lib_func(genCodeInfo, abmfP_lib_cvt_image_file_to_pixmap);
write_lib_func(genCodeInfo, abmfP_lib_set_label_from_image_file);
write_lib_func(genCodeInfo, abmfP_lib_cvt_resource_from_string);
write_lib_func(genCodeInfo, abmfP_lib_create_greyed_pixmap);
write_lib_func(genCodeInfo, abmfP_lib_save_toplevel_widget);
write_lib_func(genCodeInfo, abmfP_lib_get_toplevel_widget);
write_lib_func(genCodeInfo, abmfP_lib_remove_sash_focus);
write_lib_func(genCodeInfo, abmfP_lib_save_command);
write_lib_func(genCodeInfo, abmfP_lib_get_command);
write_lib_func(genCodeInfo, abmfP_lib_help_dispatch);
write_lib_func(genCodeInfo, abmfP_lib_more_help_dispatch);
write_lib_func(genCodeInfo, abmfP_lib_help_back_hdlr);
write_lib_func(genCodeInfo, abmfP_lib_do_onitem_help);
write_lib_func(genCodeInfo, abmfP_lib_show_help_volume_info);
write_lib_func(genCodeInfo, abmfP_lib_call_help_callback);
/*
* The session save callback is written out always
*/
write_lib_func(genCodeInfo, abmfP_lib_session_save);
write_lib_func(genCodeInfo, abmfP_lib_get_client_session_saveCB);
if (abmfP_proj_needs_session_save(project))
{
write_lib_func(genCodeInfo, abmfP_lib_set_client_session_saveCB);
}
if (abmfP_proj_needs_session_restore(project))
{
write_lib_func(genCodeInfo, abmfP_lib_session_restore);
write_lib_func(genCodeInfo, abmfP_lib_set_client_session_restoreCB);
write_lib_func(genCodeInfo, abmfP_lib_get_client_session_restoreCB);
}
/*
* Write out ToolTalk functions if needed
*/
switch(obj_get_tooltalk_level(project))
{
case AB_TOOLTALK_DESKTOP_ADVANCED:
write_lib_func(genCodeInfo, abmfP_lib_set_tt_msg_quitCB);
write_lib_func(genCodeInfo, abmfP_lib_get_tt_msg_quitCB);
write_lib_func(genCodeInfo, abmfP_lib_tt_msg_quit);
write_lib_func(genCodeInfo, abmfP_lib_set_tt_msg_do_commandCB);
write_lib_func(genCodeInfo, abmfP_lib_get_tt_msg_do_commandCB);
write_lib_func(genCodeInfo, abmfP_lib_tt_msg_do_command);
write_lib_func(genCodeInfo, abmfP_lib_set_tt_msg_get_statusCB);
write_lib_func(genCodeInfo, abmfP_lib_get_tt_msg_get_statusCB);
write_lib_func(genCodeInfo, abmfP_lib_tt_msg_get_status);
write_lib_func(genCodeInfo, abmfP_lib_set_tt_msg_pause_resumeCB);
write_lib_func(genCodeInfo, abmfP_lib_get_tt_msg_pause_resumeCB);
write_lib_func(genCodeInfo, abmfP_lib_tt_msg_pause_resume);
write_lib_func(genCodeInfo, abmfP_lib_tt_contractCB);
/* fall through */
case AB_TOOLTALK_DESKTOP_BASIC:
write_lib_func(genCodeInfo, abmfP_lib_tt_close);
break;
default:
break;
}
/* Write out Message posting utilities */
if (abmfP_proj_has_message(project))
{
write_lib_func(genCodeInfo, abmfP_lib_create_message_dlg);
write_lib_func(genCodeInfo, abmfP_lib_destroyCB);
write_lib_func(genCodeInfo, abmfP_lib_MessageBoxGetActionButton);
write_lib_func(genCodeInfo, abmfP_lib_show_message);
write_lib_func(genCodeInfo, abmfP_lib_show_modal_message);
write_lib_func(genCodeInfo, abmfP_lib_modal_dlgCB);
}
/* Write out centering routines */
write_lib_func(genCodeInfo, abmfP_lib_children_center);
write_lib_func(genCodeInfo, abmfP_lib_children_uncenter);
write_lib_func(genCodeInfo, abmfP_lib_center);
write_lib_func(genCodeInfo, abmfP_lib_uncenter);
write_lib_func(genCodeInfo, abmfP_lib_center_widget);
write_lib_func(genCodeInfo, abmfP_lib_uncenter_widget);
write_lib_func(genCodeInfo, abmfP_lib_centering_handler);
/* Write out align routines */
write_lib_func(genCodeInfo, abmfP_lib_get_label_widget);
write_lib_func(genCodeInfo, abmfP_lib_get_offset_from_ancestor);
write_lib_func(genCodeInfo, abmfP_lib_get_label_width);
write_lib_func(genCodeInfo, abmfP_lib_get_widest_label);
write_lib_func(genCodeInfo, abmfP_lib_get_widest_value);
write_lib_func(genCodeInfo, abmfP_lib_get_widget_rect);
write_lib_func(genCodeInfo, abmfP_lib_get_greatest_size);
write_lib_func(genCodeInfo, abmfP_lib_get_group_cell_size);
write_lib_func(genCodeInfo, abmfP_lib_get_group_row_col);
write_lib_func(genCodeInfo, abmfP_lib_get_group_child);
write_lib_func(genCodeInfo, abmfP_lib_children_align);
write_lib_func(genCodeInfo, abmfP_lib_align_children);
write_lib_func(genCodeInfo, abmfP_lib_align_handler);
write_lib_func(genCodeInfo, abmfP_lib_expose_handler);
write_lib_func(genCodeInfo, abmfP_lib_free_group_info);
write_lib_func(genCodeInfo, abmfP_lib_align_rows);
write_lib_func(genCodeInfo, abmfP_lib_align_cols);
write_lib_func(genCodeInfo, abmfP_lib_align_left);
write_lib_func(genCodeInfo, abmfP_lib_align_right);
write_lib_func(genCodeInfo, abmfP_lib_align_labels);
write_lib_func(genCodeInfo, abmfP_lib_align_vcenter);
write_lib_func(genCodeInfo, abmfP_lib_align_top);
write_lib_func(genCodeInfo, abmfP_lib_align_bottom);
write_lib_func(genCodeInfo, abmfP_lib_align_hcenter);
/* Write out path-finding routines */
write_lib_func(genCodeInfo, abmfP_lib_get_exe_dir);
write_lib_func(genCodeInfo, abmfP_lib_determine_exe_dir);
write_lib_func(genCodeInfo, abmfP_lib_determine_exe_dir_from_argv);
write_lib_func(genCodeInfo, abmfP_lib_determine_exe_dir_from_path);
write_lib_func(genCodeInfo, abmfP_lib_path_is_executable);
/* write out popup menu routines */
write_lib_func(genCodeInfo, abmfP_lib_popup_menu_register);
write_lib_func(genCodeInfo, abmfP_lib_popup_menu);
write_lib_func(genCodeInfo, abmfP_lib_popup_menu_destroyCB);
/* Write out drag and drop routines */
write_lib_func(genCodeInfo, abmfP_lib_drag_site_register);
write_lib_func(genCodeInfo, abmfP_lib_drop_site_register);
write_lib_func(genCodeInfo, abmfP_lib_drag_terminate);
write_lib_func(genCodeInfo, abmfP_lib_drag_button1_motion_handler);
write_lib_func(genCodeInfo, abmfP_lib_drag_start);
write_lib_func(genCodeInfo, abmfP_lib_drag_convertCB);
write_lib_func(genCodeInfo, abmfP_lib_drag_to_rootCB);
write_lib_func(genCodeInfo, abmfP_lib_drag_finishCB);
write_lib_func(genCodeInfo, abmfP_lib_drop_animateCB);
write_lib_func(genCodeInfo, abmfP_lib_drop_transferCB);
return 0;
}
static int
write_lib_func(GenCodeInfo genCodeInfo, LibFunc libFunc)
{
abio_puts(genCodeInfo->code_file, libFunc->def);
abio_puts(genCodeInfo->code_file, "\n\n\n");
return 0;
}
static int
write_msg_static_func_decls(
GenCodeInfo genCodeInfo,
ABObj project
)
{
File codeFile;
if (!genCodeInfo || !project)
return (0);
codeFile = genCodeInfo->code_file;
abio_puts(codeFile, "/*\n");
abio_puts(codeFile, " * Static functions used for messages.\n");
abio_puts(codeFile, " */\n");
abio_printf(codeFile, "%s\n", abmfP_lib_destroyCB->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_modal_dlgCB->proto);
return (0);
}

View File

@@ -0,0 +1,39 @@
/*
* $XConsortium: utils_c_fileP.h /main/3 1995/11/06 18:17:05 rswiston $
*
* @(#)utils_c_fileP.h 1.2 11 Jul 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* utils_c_fileP.h - writes dtb_utils.c
*/
#ifndef _ABMF_UTILS_C_FILEP_H_
#define _ABMF_UTILS_C_FILEP_H_
#include "abmfP.h"
#include "write_codeP.h"
int abmfP_write_utils_c_file(
GenCodeInfo genCodeInfo,
STRING fileName,
ABObj project
);
#endif /* _ABMF_UTILS_C_FILEP_H_ */

View File

@@ -0,0 +1,614 @@
/*
* $XConsortium: utils_header_file.c /main/3 1995/11/06 18:17:19 rswiston $
*
* @(#)utils_header_file.c 1.24 30 Apr 1995 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* utils_header_file.c - writes dtb_utils.h
*/
#include <ab_private/abio.h>
#include "lib_func_stringsP.h"
#include "write_cP.h"
#include "utils_header_fileP.h"
/*************************************************************************
** **
** Constants (#define and const) **
** i*
**************************************************************************/
/*************************************************************************
** **
** Private Functions (C declarations and macros) **
** **
**************************************************************************/
static int write_session_typedefs(
GenCodeInfo genCodeInfo,
ABObj project
);
static int write_tooltalk_typedefs(GenCodeInfo genCodeInfo, ABObj project);
static int write_help_typedefs(GenCodeInfo genCodeInfo, ABObj project);
static int write_message_typedefs(GenCodeInfo genCodeInfo);
static int write_drag_types(GenCodeInfo genCodeInfo, ABObj project);
static int write_message_struct(GenCodeInfo genCodeInfo);
static int write_lib_func_decls(GenCodeInfo genCodeInfo, ABObj project);
static int write_lib_macros(GenCodeInfo genCodeInfo, ABObj project);
static int write_includes(GenCodeInfo genCodeInfo, ABObj project);
static int write_centering_types(GenCodeInfo genCodeInfo);
static int write_group_struct(GenCodeInfo genCodeInfo);
static int write_group_types(GenCodeInfo genCodeInfo);
static int write_align_types(GenCodeInfo genCodeInfo);
/*************************************************************************
** **
** Data **
** **
**************************************************************************/
/*************************************************************************
** **
** Function Definitions **
** **
**************************************************************************/
int
abmfP_write_utils_header_file(
GenCodeInfo genCodeInfo,
STRING fileName,
ABObj project
)
{
char name[1024];
sprintf(name, "project %s", obj_get_name(project));
abmfP_write_file_header(
genCodeInfo,
fileName,
TRUE,
name,
util_get_program_name(),
ABMF_MODIFY_NOT,
" * CDE Application Builder General Utility Functions"
);
write_includes(genCodeInfo, project);
/*
* data types
*/
write_session_typedefs(genCodeInfo, project);
write_tooltalk_typedefs(genCodeInfo, project);
write_help_typedefs(genCodeInfo, project);
write_message_typedefs(genCodeInfo);
write_centering_types(genCodeInfo);
write_drag_types(genCodeInfo, project);
/*
* Write out types used by group layout code
*/
write_group_types(genCodeInfo);
write_align_types(genCodeInfo);
/*
* structs
*/
if (abmfP_proj_has_message(project))
write_message_struct(genCodeInfo);
/*
* Write out structure for group
* information
*/
write_group_struct(genCodeInfo);
/*
* library function declarations
*/
abio_puts(genCodeInfo->code_file, nlstr);
write_lib_func_decls(genCodeInfo, project);
abio_puts(genCodeInfo->code_file, nlstr);
write_lib_macros(genCodeInfo, project);
abmfP_write_file_footer(
genCodeInfo,
fileName,
TRUE);
return 0;
}
static int
write_includes(GenCodeInfo genCodeInfo, ABObj project)
{
abmfP_write_c_system_include(genCodeInfo, "stdlib.h");
abmfP_write_c_system_include(genCodeInfo, "X11/Intrinsic.h");
abmfP_write_c_system_include(genCodeInfo, "Xm/Xm.h");
abmfP_write_c_system_include(genCodeInfo, "Dt/Dnd.h");
if (obj_get_tooltalk_level(project) != AB_TOOLTALK_NONE)
abmfP_write_c_system_include(genCodeInfo, "Tt/tttk.h");
return 0;
}
static int
write_session_typedefs(
GenCodeInfo genCodeInfo,
ABObj project
)
{
File codeFile;
if (!genCodeInfo || !project)
return (0);
codeFile = genCodeInfo->code_file;
abio_puts(codeFile,"\n");
abmfP_write_c_comment(genCodeInfo,
FALSE, "Function type for client session save callback");
abio_puts(codeFile,"typedef Boolean (*DtbClientSessionSaveCB) (\n");
abio_puts(codeFile," Widget,\n");
abio_puts(codeFile," char *,\n");
abio_puts(codeFile," char ***,\n");
abio_puts(codeFile," int *\n");
abio_puts(codeFile,");\n");
if (abmfP_proj_needs_session_restore(project))
{
abio_puts(codeFile,"\n");
abmfP_write_c_comment(genCodeInfo,
FALSE, "Function type for client session restore callback");
abio_puts(codeFile,"typedef Boolean (*DtbClientSessionRestoreCB) (\n");
abio_puts(codeFile," Widget,\n");
abio_puts(codeFile," char *\n");
abio_puts(codeFile,");\n");
}
return (0);
}
static int
write_tooltalk_typedefs(
GenCodeInfo genCodeInfo,
ABObj project
)
{
File codeFile;
if (!genCodeInfo || !project ||
obj_get_tooltalk_level(project) != AB_TOOLTALK_DESKTOP_ADVANCED)
return (0);
codeFile = genCodeInfo->code_file;
abio_puts(codeFile,"\n");
abmfP_write_c_comment(genCodeInfo,
FALSE, "Function type for ToolTalk Desktop Message callback");
abio_puts(codeFile,"typedef Boolean (*DtbTTMsgHandlerCB) (\n");
abio_puts(codeFile," Tt_message,\n");
abio_puts(codeFile," void *\n");
abio_puts(codeFile,");\n");
return (0);
}
static int
write_help_typedefs(GenCodeInfo genCodeInfo, ABObj project)
{
File codeFile = genCodeInfo->code_file;
project = project; /* avoid warning */
/*
* Write declaration for special help data callback structure */
abio_puts(codeFile,"typedef struct {\n");
abio_puts(codeFile," char\t*help_text;\n");
abio_puts(codeFile," char\t*help_volume;\n");
abio_puts(codeFile," char\t*help_locationID;\n");
abio_puts(codeFile,"} DtbObjectHelpDataRec, *DtbObjectHelpData;\n");
return 0;
}
/*
* This actually writes out the drop types, as well.
*/
static int
write_drag_types(GenCodeInfo genCodeInfo, ABObj project)
{
project = project; /* avoid warning */
abmfP_write_c_comment(genCodeInfo,
FALSE, "Types for Drag and Drop utilities");
abio_puts(genCodeInfo->code_file,
"typedef enum\n"
"{\n"
" DTB_DND_UNDEF = 0,\n"
" DTB_DND_ANIMATE,\n"
" DTB_DND_CONVERT,\n"
" DTB_DND_DELETE,\n"
" DTB_DND_DRAG_START,\n"
" DTB_DND_DROPPED_ON,\n"
" DTB_DND_DROPPED_ON_ROOT_WINDOW,\n"
" DTB_DND_FINISH,\n"
" DTB_DND_RECEIVE_DATA,\n"
" DTB_DND_REGISTER\n"
"} DTB_DND_REQUEST;\n"
"\n"
"typedef struct\n"
"{\n"
" DtDndProtocol protocol;\n"
" unsigned char operations; /* XmCopy | XmMove | XmLink */\n"
" Boolean bufferIsText;\n"
" Boolean allowDropOnRootWindow;\n"
" int numItems;\n"
" Widget cursor; /* from DtDndCreateSourceIcon() */\n"
"} DtbDndDragStartInfoRec, *DtbDndDragStartInfo;\n"
"\n"
"typedef struct\n"
"{\n"
" Boolean droppedOnRootWindow;\n"
"} DtbDndDroppedOnRootWindowInfoRec, *DtbDndDroppedOnRootWindowInfo;\n"
"\n"
"typedef void (*DtbDndDragCallback)(\n"
" DTB_DND_REQUEST request,\n"
" DtbDndDragStartInfo dragStart,\n"
" DtDndConvertCallback convert,\n"
" DtbDndDroppedOnRootWindowInfo droppedOnRootWindow,\n"
" DtDndConvertCallback deleteSource,\n"
" DtDndDragFinishCallback finish\n"
" );\n"
"\n"
"typedef unsigned long DtbDragSiteHandle;\n"
"\n"
"\n"
"typedef struct {\n"
"DtDndProtocol protocols;\n"
"unsigned char operations; /* XmCopy | XmMove | XmLink */\n"
"Boolean textIsBuffer;\n"
"Boolean preservePreviousRegistration;\n"
"Boolean respondToDropsOnChildren;\n"
"} DtbDndDropRegisterInfoRec, *DtbDndDropRegisterInfo;\n"
"\n"
"typedef void (*DtbDndDropCallback)(\n"
" Widget widget,\n"
" DTB_DND_REQUEST request,\n"
" DtbDndDropRegisterInfo registerInfo,\n"
" DtDndTransferCallback receiveInfo,\n"
" DtDndDropAnimateCallback animateInfo\n"
" );\n"
"\n"
"typedef unsigned long DtbDropSiteHandle;\n"
"\n"
);
return 0;
}
/*
* In the future, this should only declare functions that get used
*/
static int
write_lib_func_decls(GenCodeInfo genCodeInfo, ABObj project)
{
File codeFile = genCodeInfo->code_file;
project = project; /* avoid warnings */
abio_puts(codeFile, nlstr);
abmfP_write_c_comment(genCodeInfo, FALSE,
"Application Builder utility functions");
abio_printf(codeFile, "%s\n", abmfP_lib_cvt_file_to_pixmap->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_set_label_pixmaps->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_set_label_from_bitmap_data->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_file_has_extension->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_cvt_filebase_to_pixmap->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_cvt_image_file_to_pixmap->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_set_label_from_image_file->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_cvt_resource_from_string->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_create_greyed_pixmap->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_save_toplevel_widget->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_get_toplevel_widget->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_remove_sash_focus->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_save_command->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_get_command->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_get_exe_dir->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_help_dispatch->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_more_help_dispatch->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_help_back_hdlr->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_do_onitem_help->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_show_help_volume_info->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_call_help_callback->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_popup_menu_register->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_drag_site_register->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_drop_site_register->proto);
/*
* Write out centering routines
*/
abio_printf(codeFile, "%s\n", abmfP_lib_children_center->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_children_uncenter->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_center->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_uncenter->proto);
/*
* Write out align routine
*/
abio_printf(codeFile, "%s\n", abmfP_lib_children_align->proto);
/*
* The session save callback is always generated
*/
abio_printf(codeFile, "%s\n", abmfP_lib_session_save->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_get_client_session_saveCB->proto);
if (abmfP_proj_needs_session_save(project))
{
abio_printf(codeFile, "%s\n", abmfP_lib_set_client_session_saveCB->proto);
}
if (abmfP_proj_needs_session_restore(project))
{
abio_printf(codeFile, "%s\n", abmfP_lib_session_restore->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_set_client_session_restoreCB->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_get_client_session_restoreCB->proto);
}
/*
* Write out ToolTalk prototypes if needed
*/
switch(obj_get_tooltalk_level(project))
{
case AB_TOOLTALK_DESKTOP_ADVANCED:
abio_printf(codeFile, "%s\n", abmfP_lib_set_tt_msg_quitCB->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_set_tt_msg_do_commandCB->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_set_tt_msg_get_statusCB->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_set_tt_msg_pause_resumeCB->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_tt_contractCB->proto);
/* fall through */
case AB_TOOLTALK_DESKTOP_BASIC:
abio_printf(codeFile, "%s\n", abmfP_lib_tt_close->proto);
break;
default:
break;
}
/* Write out message creation and posting routines if the
* project contains message objects.
*/
if (abmfP_proj_has_message(project))
{
abio_printf(codeFile, "%s\n", abmfP_lib_create_message_dlg->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_MessageBoxGetActionButton->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_show_message->proto);
abio_printf(codeFile, "%s\n", abmfP_lib_show_modal_message->proto);
}
abio_printf(codeFile, "\n");
return 0;
}
static int
write_lib_macros(GenCodeInfo genCodeInfo, ABObj project)
{
File codeFile = genCodeInfo->code_file;
project = project; /* avoid warning */
abio_printf(codeFile,
"#define dtb_cvt_string_to_pixel(parent, str) \\\n"
" ((Pixel)dtb_cvt_resource_from_string( \\\n"
" (parent), XtRPixel, sizeof(Pixel), (str), 0))\n"
"\n");
return 0;
}
static int
write_message_typedefs(
GenCodeInfo genCodeInfo
)
{
File codeFile;
if (!genCodeInfo)
return (0);
codeFile = genCodeInfo->code_file;
abio_puts(codeFile,"\n");
abmfP_write_c_comment(genCodeInfo,
FALSE, "Returns answer value for modal MessageBox");
abio_puts(codeFile,"typedef enum {\n");
abio_puts(codeFile," DTB_ANSWER_NONE,\n");
abio_puts(codeFile," DTB_ANSWER_ACTION1,\n");
abio_puts(codeFile," DTB_ANSWER_ACTION2,\n");
abio_puts(codeFile," DTB_ANSWER_ACTION3,\n");
abio_puts(codeFile," DTB_ANSWER_CANCEL,\n");
abio_puts(codeFile," DTB_ANSWER_HELP\n");
abio_puts(codeFile,"} DTB_MODAL_ANSWER;\n");
abio_puts(codeFile,"\n");
abmfP_write_c_comment(genCodeInfo,
FALSE, "Values for MessageBox default button");
abio_puts(codeFile,"typedef enum {\n");
abio_puts(codeFile," DTB_ACTION1_BUTTON,\n");
abio_puts(codeFile," DTB_ACTION2_BUTTON,\n");
abio_puts(codeFile," DTB_ACTION3_BUTTON,\n");
abio_puts(codeFile," DTB_CANCEL_BUTTON,\n");
abio_puts(codeFile," DTB_NONE\n");
abio_puts(codeFile,"} DTB_BUTTON;\n");
return (0);
}
static int
write_centering_types(
GenCodeInfo genCodeInfo
)
{
File codeFile;
if (!genCodeInfo)
return (0);
codeFile = genCodeInfo->code_file;
abio_puts(codeFile,"\n");
abmfP_write_c_comment(genCodeInfo,
FALSE, "Types/ways of centering an object");
abio_puts(codeFile,"typedef enum {\n");
abio_puts(codeFile," DTB_CENTER_NONE,\n");
abio_puts(codeFile," DTB_CENTER_POSITION_VERT,\n");
abio_puts(codeFile," DTB_CENTER_POSITION_HORIZ,\n");
abio_puts(codeFile," DTB_CENTER_POSITION_BOTH\n");
abio_puts(codeFile,"} DTB_CENTERING_TYPES;\n");
abio_puts(codeFile,"\n\n");
return (0);
}
static int
write_group_types(
GenCodeInfo genCodeInfo
)
{
File codeFile;
if (!genCodeInfo)
return (0);
codeFile = genCodeInfo->code_file;
abio_puts(codeFile,"\n");
abmfP_write_c_comment(genCodeInfo,
FALSE, "Types of group layout");
abio_puts(codeFile,"typedef enum {\n");
abio_puts(codeFile," DTB_GROUP_NONE,\n");
abio_puts(codeFile," DTB_GROUP_ROWS,\n");
abio_puts(codeFile," DTB_GROUP_COLUMNS,\n");
abio_puts(codeFile," DTB_GROUP_ROWSCOLUMNS\n");
abio_puts(codeFile,"} DTB_GROUP_TYPES;\n");
return (0);
}
static int
write_align_types(
GenCodeInfo genCodeInfo
)
{
File codeFile;
if (!genCodeInfo)
return (0);
codeFile = genCodeInfo->code_file;
abio_puts(codeFile,"\n");
abmfP_write_c_comment(genCodeInfo,
FALSE, "Types/ways of aligning the children of a group");
abio_puts(codeFile,"typedef enum {\n");
abio_puts(codeFile," DTB_ALIGN_NONE,\n");
abio_puts(codeFile," DTB_ALIGN_TOP,\n");
abio_puts(codeFile," DTB_ALIGN_RIGHT,\n");
abio_puts(codeFile," DTB_ALIGN_BOTTOM,\n");
abio_puts(codeFile," DTB_ALIGN_LEFT,\n");
abio_puts(codeFile," DTB_ALIGN_VCENTER,\n");
abio_puts(codeFile," DTB_ALIGN_HCENTER,\n");
abio_puts(codeFile," DTB_ALIGN_LABELS\n");
abio_puts(codeFile,"} DTB_ALIGN_TYPES;\n");
return (0);
}
static int
write_message_struct(
GenCodeInfo genCodeInfo
)
{
File codeFile;
if (!genCodeInfo)
return (0);
codeFile = genCodeInfo->code_file;
abio_puts(codeFile,"\n");
abmfP_write_c_comment(genCodeInfo,
FALSE, "Structure to store values for Messages");
abio_puts(codeFile,"typedef struct {\n");
abio_puts(codeFile," Boolean initialized;\n");
abio_puts(codeFile," unsigned char type;\n");
abio_puts(codeFile," XmString title;\n");
abio_puts(codeFile," XmString message;\n");
abio_puts(codeFile," XmString action1_label;\n");
abio_puts(codeFile," XtCallbackProc action1_callback;\n");
abio_puts(codeFile," XmString action2_label;\n");
abio_puts(codeFile," XtCallbackProc action2_callback;\n");
abio_puts(codeFile," XmString action3_label;\n");
abio_puts(codeFile," XtCallbackProc action3_callback;\n");
abio_puts(codeFile," Boolean cancel_button;\n");
abio_puts(codeFile," XtCallbackProc cancel_callback;\n");
abio_puts(codeFile," Boolean help_button;\n");
abio_puts(codeFile," DtbObjectHelpDataRec help_data;\n");
abio_puts(codeFile," DTB_BUTTON default_button;\n");
abio_puts(codeFile,"} DtbMessageDataRec, *DtbMessageData;\n");
abio_puts(codeFile,"\n");
return (0);
}
static int
write_group_struct(
GenCodeInfo genCodeInfo
)
{
File codeFile;
if (!genCodeInfo)
return (0);
codeFile = genCodeInfo->code_file;
abio_puts(codeFile,"\n");
abmfP_write_c_comment(genCodeInfo,
FALSE, "Structure to store attributes of a group");
abio_puts(codeFile,"typedef struct {\n");
abio_puts(codeFile," DTB_GROUP_TYPES group_type;\n");
abio_puts(codeFile," DTB_ALIGN_TYPES row_align;\n");
abio_puts(codeFile," DTB_ALIGN_TYPES col_align;\n");
abio_puts(codeFile," int margin;\n");
abio_puts(codeFile," int num_rows;\n");
abio_puts(codeFile," int num_cols;\n");
abio_puts(codeFile," int hoffset;\n");
abio_puts(codeFile," int voffset;\n");
abio_puts(codeFile," Widget ref_widget;\n");
abio_puts(codeFile,"} DtbGroupInfo;\n");
abio_puts(codeFile,"\n");
return (0);
}

View File

@@ -0,0 +1,37 @@
/*
* $XConsortium: utils_header_fileP.h /main/3 1995/11/06 18:17:35 rswiston $
*
* @(#)utils_header_fileP.h 1.2 11 Jul 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* utils_header_fileP.h - writes dtb_utils.h
*/
#ifndef _ABMF_UTILS_HEADER_FILEP_H_
#define _ABMF_UTILS_HEADER_FILEP_H_
#include "abmfP.h"
#include "write_codeP.h"
int abmfP_write_utils_header_file(
GenCodeInfo genCodeInfo,
STRING fileName,
ABObj project
);
#endif /* _ABMF_UTILS_HEADER_FILEP_H_ */

View File

@@ -0,0 +1,969 @@
/*
* $XConsortium: write_c.c /main/3 1995/11/06 18:17:49 rswiston $
*
* @(#)write_c.c 1.12 16 Feb 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* write_c.c - generic functions to write out C code
*/
#include <stdarg.h>
#include <ab_private/abio.h>
#include "cdefsP.h"
#include "obj_namesP.h"
#include "utilsP.h"
#include "write_cP.h"
/*************************************************************************
** **
** Constants (#define and const) **
** **
**************************************************************************/
/*************************************************************************
** **
** Private Functions (C declarations and macros) **
** **
**************************************************************************/
static int write_func_def_params(
File file,
BOOL use_prototypes,
va_list va_params);
/*************************************************************************
** **
** Data **
** **
**************************************************************************/
extern STRING abmfP_str_bool= "Boolean";
extern STRING abmfP_str_int= "int";
extern STRING abmfP_str_string= "String";
extern STRING abmfP_str_void= "void";
extern STRING abmfP_str_widget = "Widget";
extern STRING abmfP_str_xtpointer = "XtPointer";
extern STRING abmfP_str_tt_msg= "Tt_message";
extern STRING abmfP_str_voidpointer= "void *";
extern STRING abmfP_str_intpointer= "int *";
extern STRING abmfP_str_argvpointer= "char ***";
extern STRING abmfP_str_empty = "";
extern STRING abmfP_str_null = "NULL";
extern STRING abmfP_str_zero = "0";
/*************************************************************************
** **
** Function Definitions **
** **
**************************************************************************/
int
abmfP_write_c_block_begin(GenCodeInfo genCodeInfo)
{
abio_puts(genCodeInfo->code_file, "{\n");
abio_indent(genCodeInfo->code_file);
return 0;
}
int
abmfP_write_c_block_end(GenCodeInfo genCodeInfo)
{
abio_outdent(genCodeInfo->code_file);
abio_puts(genCodeInfo->code_file, "}\n");
return 0;
}
int
abmfP_write_c_comment(
GenCodeInfo genCodeInfo,
BOOL oneLiner,
STRING comment
)
{
File file= genCodeInfo->code_file;
if (oneLiner)
{
abio_printf(file, "/* %s */\n", comment);
}
else
{
abio_puts(file, abmfP_comment_begin);
abio_puts(file, abmfP_comment_continue);
abio_puts(file, comment);
abio_puts(file, "\n");
abio_puts(file, abmfP_comment_end);
}
return 0;
}
int
abmfP_write_c_func_decl(
GenCodeInfo genCodeInfo,
BOOL is_static,
STRING return_type,
STRING func_name,
...
)
{
#define va_start_params() (va_start(params, func_name))
va_list params;
File file= genCodeInfo->code_file;
int i= 0;
int num_params = 0;
int num_params_written= 0;
BOOL list_params= TRUE; /* use multiline format for params */
va_start_params();
/*
* Count pairs of strings
*/
num_params= 0;
va_start_params();
while ( (va_arg(params, STRING) != NULL)
&& (va_arg(params, STRING) != NULL))
{
++num_params;
}
list_params= (num_params > 1);
if (is_static)
{
abio_puts(file, "static ");
}
if (return_type != NULL)
{
abio_puts(file, return_type);
}
if (func_name != NULL)
{
abio_printf(file, " %s(", func_name);
}
if ((genCodeInfo->prototype_funcs) && (num_params > 0))
{
BOOL paramsDone = FALSE;
STRING curParamType = NULL;
STRING curParamName = NULL;
num_params_written= 0;
if (list_params)
{
abio_puts(file, "\n");
abio_indent(file);
}
va_start_params();
while (!paramsDone)
{
curParamType = va_arg(params, STRING);
if (curParamType != NULL)
{
curParamName = va_arg(params, STRING);
}
if ((curParamType == NULL) || (curParamName == NULL))
{
paramsDone = TRUE;
continue;
}
abio_puts(file, curParamType);
abio_puts(file, (list_params? "\t":" "));
abio_puts(file, curParamName);
++num_params_written;
if (num_params_written < num_params)
{
abio_puts(file, ",");
if (list_params)
{
abio_puts(file, "\n");
}
}
}
if (list_params)
{
abio_outdent(file);
abio_puts(file, "\n");
}
}
abio_puts(file, ");\n");
va_end(params);
return 0;
#undef va_start_params
}
int
abmfP_write_c_func_begin(
GenCodeInfo genCodeInfo,
BOOL is_static,
STRING return_type,
STRING func_name,
...
)
{
#define va_start_params() (va_start(params, func_name))
va_list params;
File file= genCodeInfo->code_file;
va_start_params();
abio_set_indent(file, 0);
if (is_static)
{
abio_puts(file, "static ");
}
if (return_type != NULL)
{
abio_puts(file, return_type);
abio_puts(file, " ");
}
abio_puts(file, "\n");
if (func_name != NULL)
{
abio_puts(file, func_name);
abio_puts(file, "(");
}
va_start_params();
write_func_def_params(file, genCodeInfo->prototype_funcs, params);
abio_puts(file, "{\n"); /* } let vi match braces */
abio_indent(file);
va_end(params);
return 0;
#undef va_start_params
}
/*
* If return_value is null, no return is written
*/
int
abmfP_write_c_func_end(
GenCodeInfo genCodeInfo,
STRING return_value
)
{
File file= genCodeInfo->code_file;
if (return_value != NULL)
{
abio_printf(file, "return %s;\n", return_value);
}
abio_set_indent(file, 0); /* { vi hack */
abio_puts(file, "}\n\n");
return 0;
}
/*
* writes #include X
*/
int
abmfP_write_c_include(GenCodeInfo genCodeInfo, STRING fileName)
{
File codeFile = genCodeInfo->code_file;
abio_puts(codeFile, "#include ");
abio_put_string(codeFile, fileName);
abio_puts(codeFile, "\n");
return 0;
}
/*
* writes #include "blah.h"
*/
int
abmfP_write_c_local_include(GenCodeInfo genCodeInfo, STRING fileName)
{
File codeFile = genCodeInfo->code_file;
abio_puts(codeFile, "#include ");
abio_put_string(codeFile, fileName);
abio_puts(codeFile, "\n");
return 0;
}
/*
* writes #include <blah.h>
*/
int
abmfP_write_c_system_include(GenCodeInfo genCodeInfo, STRING fileName)
{
File codeFile = genCodeInfo->code_file;
abio_printf(codeFile, "#include <%s>\n", fileName);
return 0;
}
/*
* Assumes: function name and opening "(" have been written
*/
static int
write_func_def_params(
File file,
BOOL use_prototypes,
va_list va_params
)
{
#ifdef __ppc
#define va_start_params() __va_copy(params, va_params)
#else
#define va_start_params() (params = va_params)
#endif
#define va_end_params() (0)
va_list params;
int num_params_written= 0;
int num_params= 0;
BOOL list_params= FALSE;
int i= 0;
STRING curParamType = NULL;
STRING curParamName = NULL;
BOOL paramsDone = FALSE;
va_start_params();
/*
* Count non-NULL string pairs
*/
num_params = 0;
va_start_params();
while ( (va_arg(params, STRING) != NULL)
&& (va_arg(params, STRING) != NULL))
{
++num_params;
}
list_params= (num_params > 1); /* use "list" format */
if (num_params > 0)
{
if (list_params)
{
abio_puts(file, "\n");
abio_indent(file);
}
paramsDone = FALSE;
va_start_params();
while (!paramsDone)
{
curParamType = va_arg(params, STRING);
if (curParamType != NULL)
{
curParamName = va_arg(params, STRING);
}
if ((curParamType == NULL) || (curParamName == NULL))
{
paramsDone = TRUE;
continue;
}
if (use_prototypes)
{
abio_puts(file, curParamType);
abio_puts(file, " ");
}
abio_puts(file, curParamName);
++num_params_written;
if (num_params_written < num_params)
{
abio_puts(file, ",");
}
if (list_params)
{
abio_puts(file, "\n");
}
}
if (list_params)
{
abio_outdent(file);
}
}
abio_puts(file, ")\n");
/*
* Write out old-style parameter types
*/
num_params_written= 0;
if (!use_prototypes)
{
paramsDone = FALSE;
va_start_params();
while (!paramsDone)
{
curParamType = va_arg(params, STRING);
if (curParamType != NULL)
{
curParamName = va_arg(params, STRING);
}
if ((curParamType == NULL) || (curParamName == NULL))
{
paramsDone = TRUE;
continue;
}
abio_printf(file, "\t%s %s", curParamType, curParamName);
++num_params_written;
if (num_params_written < num_params)
{
abio_puts(file, ",");
}
abio_puts(file, "\n");
}
}
va_end_params();
return 0;
#undef va_start_params
#undef va_end_params
}
int
abmfP_write_xm_callback_decl(
GenCodeInfo genCodeInfo,
BOOL is_static,
STRING func_name
)
{
return abmfP_write_c_func_decl(
genCodeInfo,
is_static,
abmfP_str_void,
func_name,
abmfP_str_widget, abmfP_widget_var_name,
abmfP_str_xtpointer, abmfP_client_data_var_name,
abmfP_str_xtpointer, abmfP_call_data_var_name,
NULL
);
}
int
abmfP_write_xm_callback_begin(
GenCodeInfo genCodeInfo,
BOOL is_static,
STRING func_name
)
{
return abmfP_write_c_func_begin(
genCodeInfo,
is_static,
abmfP_str_void,
func_name,
abmfP_str_widget, abmfP_widget_var_name,
abmfP_str_xtpointer, abmfP_client_data_var_name,
abmfP_str_xtpointer, abmfP_call_data_var_name,
NULL
);
}
int
abmfP_write_tooltalk_callback_decl(
GenCodeInfo genCodeInfo,
BOOL is_static,
STRING func_name
)
{
return abmfP_write_c_func_decl(
genCodeInfo,
is_static,
abmfP_str_bool,
func_name,
abmfP_str_tt_msg, abmfP_tt_msg_var_name,
abmfP_str_voidpointer, abmfP_call_data_var_name,
NULL
);
}
int
abmfP_write_session_save_callback_decl(
GenCodeInfo genCodeInfo,
BOOL is_static,
STRING func_name
)
{
return abmfP_write_c_func_decl(
genCodeInfo,
is_static,
abmfP_str_bool,
func_name,
abmfP_str_widget, abmfP_widget_var_name,
abmfP_str_string, abmfP_ss_session_file_var_name,
abmfP_str_argvpointer, "argv",
abmfP_str_intpointer, "argc",
NULL
);
}
int
abmfP_write_session_restore_callback_decl(
GenCodeInfo genCodeInfo,
BOOL is_static,
STRING func_name
)
{
return abmfP_write_c_func_decl(
genCodeInfo,
is_static,
abmfP_str_bool,
func_name,
abmfP_str_widget, abmfP_widget_var_name,
abmfP_str_string, abmfP_ss_session_file_var_name,
NULL
);
}
int
abmfP_write_tooltalk_callback_begin(
GenCodeInfo genCodeInfo,
BOOL is_static,
STRING func_name
)
{
return abmfP_write_c_func_begin(
genCodeInfo,
is_static,
abmfP_str_bool,
func_name,
abmfP_str_tt_msg, abmfP_tt_msg_var_name,
abmfP_str_voidpointer, abmfP_call_data_var_name,
NULL
);
}
abmfP_write_clear_proc_decl(
GenCodeInfo genCodeInfo,
ABObj obj
)
{
return abmfP_write_c_func_decl(
genCodeInfo,
FALSE, /* Is static */
abmfP_str_int, /* return type */
abmfP_get_clear_proc_name(obj), /* function name */
abmfP_get_c_struct_ptr_type_name(obj), /* Argument type */
abmfP_instance_ptr_var_name, /* Argument name */
NULL
);
}
int
abmfP_write_create_proc_begin_or_decl(
GenCodeInfo genCodeInfo,
ABObj obj,
BOOL declaration
)
{
#define MAX_CREATE_PARAMS 11 /* need lots for widget return params*/
int return_value = 0;
STRING param_types[MAX_CREATE_PARAMS];
STRING param_names[MAX_CREATE_PARAMS];
int num_params = 0;
int i = 0;
int num_widgets = 0;
int first_widget_return_param = -1;
int num_submenu_params = 0;
int first_submenu_param = -1;
for (num_params = 0; num_params < MAX_CREATE_PARAMS; ++num_params)
{
param_types[num_params] = NULL;
param_names[num_params] = NULL;
}
/*
* Set up parameters, in order : instance, name, parent, widget*
*/
num_params = 0;
/*
* Instance pointer
*/
if (abmfP_obj_create_proc_has_instance_param(obj))
{
param_types[num_params]=
abmfP_obj_get_create_proc_instance_param_type(obj);
param_names[num_params]= abmfP_instance_ptr_var_name;
++num_params;
if (!declaration)
{
/* The ipObj field is set, so we don't need to save the var. */
}
}
/*
* Name
*/
if (abmfP_obj_create_proc_has_name_param(obj))
{
param_types[num_params] = abmfP_str_string;
param_names[num_params] = "name";
++num_params;
if (!declaration)
{
abmfP_name_param(genCodeInfo)= istr_const("name");
abmfP_name_param_has_value(genCodeInfo)= TRUE;
}
}
/*
* Parent
*/
if (abmfP_obj_create_proc_has_parent_param(obj))
{
param_types[num_params]= abmfP_str_widget;
param_names[num_params]= "parent";
++num_params;
if (!declaration)
{
abmfP_name_param(genCodeInfo)= istr_const("parent");
abmfP_name_param_has_value(genCodeInfo)= TRUE;
}
}
/*
* Widget* for returning widget values
*/
num_widgets = abmfP_obj_get_num_create_proc_return_widgets(obj);
if (num_widgets > 0)
{
first_widget_return_param = num_params;
for (i = 0; (i < num_widgets) && (num_params < MAX_CREATE_PARAMS); ++i)
{
param_types[num_params]= "Widget *";
param_names[num_params]=
strdup(abmfP_obj_get_create_proc_return_widget_name(obj, i));
++num_params;
}
}
/*
* submenu id params
*/
num_submenu_params = abmfP_get_num_cp_submenu_params(obj);
if (num_submenu_params > 0)
{
StringList submenu_param_list =
&(abmfP_submenu_params(genCodeInfo));
StringList submenu_param_type_list =
&(abmfP_submenu_param_types(genCodeInfo));
int num_strings = 0;
strlist_make_empty(submenu_param_list);
strlist_make_empty(submenu_param_type_list);
for (i = 0; i < num_submenu_params; ++i)
{
strlist_add_str(submenu_param_type_list,
abmfP_get_cp_submenu_param_type_name(obj, i), NULL);
strlist_add_str(submenu_param_list,
abmfP_get_cp_submenu_param_name(obj, i), NULL);
}
num_strings = strlist_get_num_strs(submenu_param_list);
for (i = 0; (i < num_strings) && (num_params < MAX_CREATE_PARAMS); ++i)
{
param_types[num_params] =
strlist_get_str(submenu_param_type_list, i, NULL);
param_names[num_params] =
strlist_get_str(submenu_param_list, i, NULL);
++num_params;
}
}
/*
* Check for max # params
*/
assert(num_params < MAX_CREATE_PARAMS);
if (declaration)
{
return_value =
abmfP_write_c_func_decl(
genCodeInfo,
TRUE,
abmfP_str_int, abmfP_get_create_proc_name(obj),
param_types[0], param_names[0],
param_types[1], param_names[1],
param_types[2], param_names[2],
param_types[3], param_names[3],
param_types[4], param_names[4],
param_types[5], param_names[5],
param_types[6], param_names[6],
param_types[7], param_names[7],
param_types[8], param_names[8],
param_types[9], param_names[9],
NULL
);
}
else
{
return_value =
abmfP_write_c_func_begin(
genCodeInfo,
TRUE,
abmfP_str_int, abmfP_get_create_proc_name(obj),
param_types[0], param_names[0],
param_types[1], param_names[1],
param_types[2], param_names[2],
param_types[3], param_names[3],
param_types[4], param_names[4],
param_types[5], param_names[5],
param_types[6], param_names[6],
param_types[7], param_names[7],
param_types[8], param_names[8],
param_types[9], param_names[9],
NULL
);
}
if (first_widget_return_param >= 0)
{
for (i= first_widget_return_param; i < MAX_CREATE_PARAMS; ++i)
{
if (param_names[i] != NULL)
{
util_free(param_names[i]); param_names[i] = NULL;
}
}
}
return return_value;
#undef MAX_CREATE_PARAMS
}
int
abmfP_write_create_proc_decl(
GenCodeInfo genCodeInfo,
ABObj obj
)
{
return abmfP_write_create_proc_begin_or_decl(
genCodeInfo, obj, TRUE);
}
int
abmfP_write_create_proc_begin(
GenCodeInfo genCodeInfo,
ABObj obj
)
{
return abmfP_write_create_proc_begin_or_decl(
genCodeInfo, obj, FALSE);
}
abmfP_write_clear_proc_begin(
GenCodeInfo genCodeInfo,
ABObj obj
)
{
return abmfP_write_c_func_begin(
genCodeInfo,
FALSE, /* Is static */
abmfP_str_int, /* return type */
abmfP_get_clear_proc_name(obj), /* function name */
abmfP_get_c_struct_ptr_type_name(obj), /* Argument type */
abmfP_instance_ptr_var_name, /* Argument name */
NULL
);
}
abmfP_write_init_proc_decl(
GenCodeInfo genCodeInfo,
ABObj obj
)
{
if (obj_is_message(obj))
{
return abmfP_write_c_func_decl(
genCodeInfo,
FALSE, /* Is static */
abmfP_str_int, /* return type */
abmfP_get_init_proc_name(obj), /* function name */
"DtbMessageData", /* Argument type */
abmfP_instance_ptr_var_name, /* Argument name */
NULL
);
}
else if (obj_is_window(obj))
{
return abmfP_write_c_func_decl(
genCodeInfo,
FALSE, /* Is static */
abmfP_str_int, /* return type */
abmfP_get_init_proc_name(obj), /* function name */
abmfP_get_c_struct_ptr_type_name(obj), /* Argument type */
abmfP_instance_ptr_var_name, /* Argument name */
abmfP_str_widget, "parent", /* Argument type */
NULL /* Argument name */
);
}
}
abmfP_write_init_proc_begin(
GenCodeInfo genCodeInfo,
ABObj obj
)
{
if (obj_is_message(obj))
{
return abmfP_write_c_func_begin(
genCodeInfo,
FALSE, /* Is static */
abmfP_str_int, /* return type */
abmfP_get_init_proc_name(obj), /* function name */
"DtbMessageData", /* Argument type */
abmfP_instance_ptr_var_name, /* Argument name */
NULL
);
}
else
{
return abmfP_write_c_func_begin(
genCodeInfo,
FALSE, /* Is static */
abmfP_str_int, /* return type */
abmfP_get_init_proc_name(obj), /* function name */
abmfP_get_c_struct_ptr_type_name(obj), /* Argument type */
abmfP_instance_ptr_var_name, /* Argument name */
abmfP_str_widget, /* Argument type */
"parent", /* Argument name */
NULL
);
}
}
int
abmfP_write_file_header(
GenCodeInfo genCodeInfo,
STRING fileName,
BOOL openIfdef,
STRING gennedFrom,
STRING gennedBy,
ABMF_MODIFY_TYPE modifyType,
STRING description
)
{
File codeFile = genCodeInfo->code_file;
STRING comment = NULL;
abio_printf(codeFile,
"/*\n"
" * File: %s\n",
fileName);
if (description != NULL)
{
abio_printf(codeFile, "%s\n", description);
}
abio_puts(codeFile, " *\n");
abio_printf(codeFile, " * This file was generated by %s, from %s\n",
gennedBy, gennedFrom);
abio_puts(codeFile, " *\n");
comment = NULL;
switch (modifyType)
{
case ABMF_MODIFY_NOT:
comment =
" * ** DO NOT MODIFY BY HAND - ALL MODIFICATIONS WILL BE LOST **\n";
break;
case ABMF_MODIFY_USER_SEGS:
comment =
" * Any text may be added between the DTB_USER_CODE_START and\n"
" * DTB_USER_CODE_END comments (even non-C code). Descriptive comments\n"
" * are provided only as an aid.\n"
" *\n"
" * ** EDIT ONLY WITHIN SECTIONS MARKED WITH DTB_USER_CODE COMMENTS. **\n"
" * ** ALL OTHER MODIFICATIONS WILL BE OVERWRITTEN. DO NOT MODIFY OR **\n"
" * ** DELETE THE GENERATED COMMENTS! **\n";
break;
}
if (comment != NULL)
{
abio_puts(codeFile, comment);
}
abio_puts(codeFile, " */\n");
if (openIfdef)
{
STRING defineToken = abmfP_get_define_from_file_name(fileName);
abio_printf(codeFile, "#ifndef %s\n", defineToken);
abio_printf(codeFile, "#define %s\n", defineToken);
}
abio_puts(codeFile, "\n");
return 0;
}
int
abmfP_write_file_footer(
GenCodeInfo genCodeInfo,
STRING fileName,
BOOL closeIfdef
)
{
if (closeIfdef)
{
abio_printf(genCodeInfo->code_file, "#endif /* %s */\n",
abmfP_get_define_from_file_name(fileName));
}
return 0;
}
abmfP_write_msg_clear_proc_decl(
GenCodeInfo genCodeInfo,
ABObj module
)
{
return abmfP_write_c_func_decl(
genCodeInfo,
FALSE, /* Is static */
abmfP_str_int, /* return type */
abmfP_get_msg_clear_proc_name(module), /* function name */
"DtbMessageData", /* Argument type */
abmfP_instance_ptr_var_name, /* Argument name */
NULL);
}

View File

@@ -0,0 +1,184 @@
/*
* $XConsortium: write_cP.h /main/3 1995/11/06 18:18:07 rswiston $
*
* @(#)write_cP.h 1.6 16 Feb 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* write_cP.h - generic utilities for writing C output
*/
#ifndef _ABMF_WRITE_CP_H_
#define _ABMF_WRITE_CP_H_
#include "abmfP.h"
#include "write_codeP.h"
typedef enum
{
ABMF_MODIFY_UNDEF = 0,
ABMF_MODIFY_NOT,
ABMF_MODIFY_USER_SEGS,
ABMF_MODIFY_UNMARKED,
ABMF_MODIFY_ANY,
ABMF_MODIFY_TYPE_NUM_VALUES
} ABMF_MODIFY_TYPE;
int abmfP_write_c_block_begin(GenCodeInfo genCodeInfo);
int abmfP_write_c_block_end(GenCodeInfo genCodeInfo);
int abmfP_write_c_comment(
GenCodeInfo genCodeInfo,
BOOL oneLiner,
STRING comment
);
int abmfP_write_c_func_decl(
GenCodeInfo genCodeInfo,
BOOL is_static,
STRING return_type,
STRING func_name,
... /* "type", "name", ..., NULL */
);
int abmfP_write_c_func_begin(
GenCodeInfo genCodeInfo,
BOOL is_static,
STRING return_type,
STRING func_name,
... /* "type", "name", ..., NULL */
);
int abmfP_write_c_func_end(
GenCodeInfo,
STRING return_value
);
int abmfP_write_c_include(GenCodeInfo, STRING file_name);
/* wriutes #include "blah" */
int abmfP_write_c_local_include(GenCodeInfo, STRING file_name);
/* writes #include <blah> */
int abmfP_write_c_system_include(GenCodeInfo, STRING file_name);
int abmfP_write_xm_callback_decl(
GenCodeInfo,
BOOL is_static,
STRING func_name
);
int abmfP_write_xm_callback_begin(
GenCodeInfo,
BOOL is_static,
STRING func_name
);
int abmfP_write_tooltalk_callback_decl(
GenCodeInfo,
BOOL is_static,
STRING func_name
);
int abmfP_write_session_save_callback_decl(
GenCodeInfo,
BOOL is_static,
STRING func_name
);
int abmfP_write_session_restore_callback_decl(
GenCodeInfo,
BOOL is_static,
STRING func_name
);
int abmfP_write_tooltalk_callback_begin(
GenCodeInfo,
BOOL is_static,
STRING func_name
);
int abmfP_write_clear_proc_decl(
GenCodeInfo,
ABObj obj
);
int abmfP_write_msg_clear_proc_decl(
GenCodeInfo,
ABObj obj
);
int abmfP_write_clear_proc_begin(
GenCodeInfo,
ABObj obj
);
int abmfP_write_create_proc_decl(
GenCodeInfo,
ABObj obj
);
int abmfP_write_create_proc_begin(
GenCodeInfo,
ABObj obj
);
int abmfP_write_init_proc_decl(
GenCodeInfo,
ABObj obj
);
int abmfP_write_init_proc_begin(
GenCodeInfo,
ABObj obj
);
int abmfP_write_file_header(
GenCodeInfo genCodeInfo,
STRING fileName,
BOOL openIfdef,
STRING gennedFrom,
STRING gennedBy,
ABMF_MODIFY_TYPE modifyType,
STRING description
);
int abmfP_write_file_footer(
GenCodeInfo genCodeInfo,
STRING fileName,
BOOL closeIfdef
);
/* types */
extern STRING abmfP_str_bool;
extern STRING abmfP_str_int;
extern STRING abmfP_str_string;
extern STRING abmfP_str_void;
extern STRING abmfP_str_void_ptr;
extern STRING abmfP_str_widget;
extern STRING abmfP_str_xtpointer;
/* common values */
extern STRING abmfP_str_empty; /* "" */
extern STRING abmfP_str_null; /* "NULL" */
extern STRING abmfP_str_zero; /* "0" */
#endif /* _ABMF_WRITE_CP_H_ */

View File

@@ -0,0 +1,503 @@
/*
* $XConsortium: write_code.c /main/3 1995/11/06 18:18:22 rswiston $
*
* @(#)write_code.c 1.18 16 Feb 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special restrictions in a
* confidential disclosure agreement between HP, IBM, Sun, USL, SCO and
* Univel. Do not distribute this document outside HP, IBM, Sun, USL, SCO,
* or Univel without Sun's specific written approval. This document and all
* copies and derivative works thereof must be returned or destroyed at Sun's
* request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* write_code.c
*
* Writes entire files, projects, et cetera.
*/
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE 1
#endif
#include <stdlib.h>
#include <ctype.h>
#include <time.h>
#include <string.h>
#include <sys/types.h>
#include <limits.h>
#include <sys/stat.h>
#include <ab_private/util.h>
#include <ab_private/util_err.h>
#include <ab_private/abio.h>
#include "utilsP.h"
#include "instancesP.h"
#include "write_codeP.h"
#include "msg_file.h"
/*************************************************************************
** **
** Constants (#define and const) **
** **
**************************************************************************/
/*************************************************************************
** **
** Private Functions (C declarations and macros) **
** **
**************************************************************************/
/************************************************************************
** **
** Data **
** **
**************************************************************************/
char *const abmfP_cmt_user_code_start = "DTB_USER_CODE_START";
char *const abmfP_cmt_user_code_end = "DTB_USER_CODE_END";
/*************************************************************************
** **
** Function Definitions **
** **
**************************************************************************/
/*************************************************************************
** **
** GenCodeInfo type **
** **
*************************************************************************/
int
abmfP_gencode_construct(GenCodeInfo gen)
{
gen->code_file = NULL;
gen->resource_file = NULL;
gen->prototype_funcs = TRUE;
gen->dumped_resources = AB_ARG_CLASS_FLAGS_NONE;
gen->i18n_method = ABMF_I18N_NONE;
gen->msg_src_file_name = (STRING)NULL;
gen->msg_file_obj = (MsgFile)NULL;
/* init cur_func substructure */
abmfP_gencode_enter_func(gen);
gen->writing_func = FALSE;
return 0;
}
int
abmfP_gencode_destruct(GenCodeInfo gen)
{
abmfP_gencode_exit_func(gen);
return 0;
}
/*
*/
int
abmfP_gencode_enter_func(GenCodeInfo genCodeInfo)
{
genCodeInfo->writing_func= TRUE;
genCodeInfo->cur_func.ip_obj = NULL;
genCodeInfo->cur_func.create_obj = NULL;
genCodeInfo->cur_func.args_var = NULL;
genCodeInfo->cur_func.args_var_has_value = FALSE;
genCodeInfo->cur_func.counter_var = NULL;
genCodeInfo->cur_func.counter_var_has_value = FALSE;
genCodeInfo->cur_func.arg_counter_var = NULL;
genCodeInfo->cur_func.arg_counter_var_has_value = FALSE;
genCodeInfo->cur_func.display_var = NULL;
genCodeInfo->cur_func.display_var_has_value = FALSE;
genCodeInfo->cur_func.drawable_var = NULL;
genCodeInfo->cur_func.drawable_var_has_value = FALSE;
genCodeInfo->cur_func.icon_pixmap_var = NULL;
genCodeInfo->cur_func.icon_pixmap_var_has_value = FALSE;
genCodeInfo->cur_func.icon_mask_pixmap_var = NULL;
genCodeInfo->cur_func.icon_mask_pixmap_var_has_value = FALSE;
genCodeInfo->cur_func.label_pixmap_var = NULL;
genCodeInfo->cur_func.label_pixmap_var_has_value = FALSE;
genCodeInfo->cur_func.label_str_var = NULL;
genCodeInfo->cur_func.label_str_var_has_value = FALSE;
genCodeInfo->cur_func.label_xmstr_var = NULL;
genCodeInfo->cur_func.label_xmstr_var_has_value = FALSE;
genCodeInfo->cur_func.acceltext_xmstr_var = NULL;
genCodeInfo->cur_func.acceltext_xmstr_var_has_value = FALSE;
genCodeInfo->cur_func.label_array_var = NULL;
genCodeInfo->cur_func.label_array_has_nulls = FALSE;
genCodeInfo->cur_func.mnemonic_array_var = NULL;
genCodeInfo->cur_func.mnemonic_array_var_has_value = FALSE;
genCodeInfo->cur_func.name_array_var = NULL;
genCodeInfo->cur_func.name_array_var_has_value = FALSE;
genCodeInfo->cur_func.name_param = NULL;
genCodeInfo->cur_func.name_param_has_value = FALSE;
genCodeInfo->cur_func.parent_param = NULL;
genCodeInfo->cur_func.parent_param_has_value = FALSE;
genCodeInfo->cur_func.return_code_var = NULL;
genCodeInfo->cur_func.return_code_var_has_value = FALSE;
genCodeInfo->cur_func.title_str_var = NULL;
genCodeInfo->cur_func.title_str_var_has_value = FALSE;
genCodeInfo->cur_func.value_str_var = NULL;
genCodeInfo->cur_func.value_str_var_has_value = FALSE;
genCodeInfo->cur_func.icon_name_str_var = NULL;
genCodeInfo->cur_func.icon_name_str_var_has_value = FALSE;
genCodeInfo->cur_func.ok_label_xmstr_var = NULL;
genCodeInfo->cur_func.ok_label_xmstr_var_has_value = FALSE;
genCodeInfo->cur_func.directory_xmstr_var = NULL;
genCodeInfo->cur_func.directory_xmstr_var_has_value = FALSE;
genCodeInfo->cur_func.pattern_xmstr_var = NULL;
genCodeInfo->cur_func.pattern_xmstr_var_has_value = FALSE;
strlist_construct(&(genCodeInfo->cur_func.submenu_params));
strlist_set_is_unique(
&(genCodeInfo->cur_func.submenu_params), FALSE);
strlist_construct(&(genCodeInfo->cur_func.submenu_param_types));
strlist_set_is_unique(
&(genCodeInfo->cur_func.submenu_params), FALSE);
return 0;
}
/*
*/
int
abmfP_gencode_exit_func(GenCodeInfo genCodeInfo)
{
genCodeInfo->writing_func= FALSE;
istr_destroy(genCodeInfo->cur_func.args_var);
istr_destroy(genCodeInfo->cur_func.counter_var);
istr_destroy(genCodeInfo->cur_func.arg_counter_var);
istr_destroy(genCodeInfo->cur_func.display_var);
istr_destroy(genCodeInfo->cur_func.drawable_var);
istr_destroy(genCodeInfo->cur_func.icon_pixmap_var);
istr_destroy(genCodeInfo->cur_func.icon_mask_pixmap_var);
istr_destroy(genCodeInfo->cur_func.label_pixmap_var);
istr_destroy(genCodeInfo->cur_func.label_str_var);
istr_destroy(genCodeInfo->cur_func.label_xmstr_var);
istr_destroy(genCodeInfo->cur_func.acceltext_xmstr_var);
istr_destroy(genCodeInfo->cur_func.label_array_var);
istr_destroy(genCodeInfo->cur_func.mnemonic_array_var);
istr_destroy(genCodeInfo->cur_func.name_array_var);
istr_destroy(genCodeInfo->cur_func.name_param);
istr_destroy(genCodeInfo->cur_func.parent_param);
istr_destroy(genCodeInfo->cur_func.return_code_var);
strlist_make_empty(&(genCodeInfo->cur_func.submenu_params));
strlist_make_empty(&(genCodeInfo->cur_func.submenu_param_types));
istr_destroy(genCodeInfo->cur_func.title_str_var);
istr_destroy(genCodeInfo->cur_func.value_str_var);
istr_destroy(genCodeInfo->cur_func.icon_name_str_var);
istr_destroy(genCodeInfo->cur_func.ok_label_xmstr_var);
istr_destroy(genCodeInfo->cur_func.directory_xmstr_var);
istr_destroy(genCodeInfo->cur_func.pattern_xmstr_var);
return 0;
}
BOOL
abmfP_obj_is_struct_obj(ABObj obj)
{
return (obj_is_window(obj) || obj_is_message(obj));
}
BOOL
abmfP_obj_has_struct_field(ABObj obj)
{
switch (obj_get_type(obj))
{
case AB_TYPE_ITEM:
return FALSE; /* all items are substruct fields */
}
if (obj_has_flag(obj, NoCodeGenFlag))
{
return FALSE;
}
switch (obj_get_type(obj))
{
case AB_TYPE_MODULE:
case AB_TYPE_PROJECT:
case AB_TYPE_UNKNOWN:
return FALSE;
}
return TRUE;
}
BOOL
abmfP_obj_has_substruct_field(ABObj obj)
{
return ((obj_is_item(obj)) &&
(obj_get_item_type(obj) != AB_ITEM_FOR_LIST) &&
(obj_get_item_type(obj) != AB_ITEM_FOR_COMBO_BOX) &&
(obj_get_item_type(obj) != AB_ITEM_FOR_SPIN_BOX));
}
BOOL
abmfP_obj_has_field(ABObj obj)
{
return ( abmfP_obj_has_struct_field(obj)
|| abmfP_obj_has_substruct_field(obj) );
}
/*
* A substruct consists of any items the object may have. List items
* never have fields, because they are not widgets.
*/
BOOL
abmfP_obj_is_substruct_obj(ABObj obj)
{
ABObj item = NULL;
if (mfobj_has_flags(obj, CGenFlagIsSubstructObjValid))
{
goto epilogue;
}
mfobj_set_flags(obj, CGenFlagIsSubstructObjValid);
item = obj_get_item(obj, 0);
if ((item != NULL) &&
(obj_get_item_type(item) != AB_ITEM_FOR_LIST) &&
(obj_get_item_type(item) != AB_ITEM_FOR_COMBO_BOX) &&
(obj_get_item_type(item) != AB_ITEM_FOR_SPIN_BOX))
{
mfobj_set_flags(obj, CGenFlagIsSubstructObj);
}
epilogue:
return mfobj_has_flags(obj, CGenFlagIsSubstructObj);
}
/*
* The substruct consists of our composite subobjects and items
*/
static int
count_possible_substruct_fields(ABObj obj)
{
return obj_get_num_items(obj);
}
/*
* A substruct object is one that could have a structure defined to
* define it (as opposed to being only a widget).
*/
BOOL
abmfP_obj_could_be_substruct_obj(ABObj obj)
{
return abmfP_obj_is_substruct_obj(obj);
}
int
abmfP_write_user_start_comment(
GenCodeInfo genCodeInfo,
STRING desc
)
{
abio_printf(genCodeInfo->code_file, "/*** %s %s ***/\n",
abmfP_cmt_user_code_start,
desc);
return 0;
}
int
abmfP_write_user_long_start_comment(
GenCodeInfo genCodeInfo,
STRING desc
)
{
File codeFile = genCodeInfo->code_file;
if (desc == NULL)
{
desc = "Add additional code here";
}
abio_printf(codeFile, "/**************************************************************************\n");
abio_printf(codeFile, " *** %s\n", abmfP_cmt_user_code_start);
abio_printf(codeFile, " ***\n");
abio_printf(codeFile, " *** %s\n", desc);
abio_printf(codeFile, " ***/\n");
return 0;
}
int
abmfP_write_user_end_comment(
GenCodeInfo genCodeInfo,
STRING desc
)
{
abio_printf(genCodeInfo->code_file, "/*** %s %s ***/\n",
abmfP_cmt_user_code_end,
desc);
return 0;
}
int
abmfP_write_user_long_end_comment(
GenCodeInfo genCodeInfo,
STRING desc
)
{
File codeFile = genCodeInfo->code_file;
if (desc == NULL)
{
desc = "End of user code section";
}
abio_printf(codeFile, "/*** %s\n", abmfP_cmt_user_code_end);
abio_printf(codeFile, " ***\n");
abio_printf(codeFile, " *** %s\n", desc);
abio_printf(codeFile, " ***\n");
abio_printf(codeFile, " **************************************************************************/\n");
return 0;
}
int
abmfP_write_user_seg(GenCodeInfo genCodeInfo, STRING desc, STRING contents)
{
File codeFile = genCodeInfo->code_file;
/* start comment */
abio_printf(codeFile, "/*** %s vvv %s below vvv ***/\n",
abmfP_cmt_user_code_start,
desc);
/* contents */
if (contents != NULL)
{
abio_puts(codeFile, contents);
}
/* end comment */
abio_printf(codeFile, "/*** %s ^^^ %s above ^^^ ***/\n",
abmfP_cmt_user_code_end,
desc);
return 0;
}
int
abmfP_write_user_long_seg(GenCodeInfo genCodeInfo, STRING desc)
{
abio_puts(genCodeInfo->code_file, nlstr);
abmfP_write_user_long_start_comment(genCodeInfo, desc);
abio_puts(genCodeInfo->code_file, nlstr);
abmfP_write_user_long_end_comment(genCodeInfo, NULL);
abio_puts(genCodeInfo->code_file, "\n\n");
return 0;
}
int
abmfP_write_user_type_and_var_seg(GenCodeInfo genCodeInfo)
{
return abmfP_write_user_seg(genCodeInfo,
"Add type and variable definitions", NULL);
}
int
abmfP_write_user_struct_fields_seg(GenCodeInfo genCodeInfo)
{
return abmfP_write_user_seg(genCodeInfo, "Add structure fields", NULL);
}
int
abmfP_write_user_funcs_seg(GenCodeInfo genCodeInfo)
{
return abmfP_write_user_seg(genCodeInfo, "Add user-defined functions", NULL);
}
int
abmfP_write_user_code_seg(GenCodeInfo genCodeInfo, STRING contents)
{
return abmfP_write_user_seg(genCodeInfo, "Add C code", contents);
}
int
abmfP_write_user_var_seg(GenCodeInfo genCodeInfo)
{
return abmfP_write_user_seg(genCodeInfo, "Add C variables", NULL);
}
int
abmfP_write_user_var_and_code_seg(GenCodeInfo genCodeInfo, STRING contents)
{
return abmfP_write_user_seg(genCodeInfo,
"Add C variables and code", contents);
}
int
abmfP_write_user_header_seg(GenCodeInfo genCodeInfo)
{
return abmfP_write_user_seg(genCodeInfo, "Add file header", NULL);
}
int
abmfP_write_user_file_top_seg(GenCodeInfo genCodeInfo)
{
File codeFile = genCodeInfo->code_file;
abio_printf(codeFile, nlstr);
abio_printf(codeFile, "/**************************************************************************\n");
abio_printf(codeFile, " *** %s\n", abmfP_cmt_user_code_start);
abio_printf(codeFile, " ***\n");
abio_printf(codeFile, " *** All necessary header files have been included.\n");
abio_printf(codeFile, " ***\n");
abio_printf(codeFile, " *** Add include files, types, macros, externs, and user functions here.\n");
abio_printf(codeFile, " ***/\n");
abio_puts(codeFile, nlstr);
abmfP_write_user_long_end_comment(genCodeInfo, NULL);
abio_puts(codeFile, "\n\n");
return 0;
}
int
abmfP_write_user_file_bottom_seg(GenCodeInfo genCodeInfo)
{
File codeFile = genCodeInfo->code_file;
abio_printf(codeFile, nlstr);
abio_printf(codeFile, "/**************************************************************************\n");
abio_printf(codeFile, " *** %s\n", abmfP_cmt_user_code_start);
abio_printf(codeFile, " ***\n");
abio_printf(codeFile, " *** All automatically-generated data and functions have been defined.\n");
abio_printf(codeFile, " ***\n");
abio_printf(codeFile, " *** Add new functions here, or at the top of the file.\n");
abio_printf(codeFile, " ***/\n");
abio_printf(codeFile, nlstr);
abmfP_write_user_long_end_comment(genCodeInfo, NULL);
abio_puts(codeFile, "\n\n");
return 0;
}

View File

@@ -0,0 +1,331 @@
/*
* $XConsortium: write_codeP.h /main/3 1995/11/06 18:18:40 rswiston $
*
* @(#)write_codeP.h 1.18 16 Feb 1994 cde_app_builder/src/abmf
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* write_codeP.h - write code in entire files, projects, et cetera
*/
#ifndef _ABMF_WRITE_CODEP_H_
#define _ABMF_WRITE_CODEP_H_
#include <ab_private/strlist.h>
#include "utilsP.h"
#include "abmfP.h"
#include "msg_file.h"
/*
* Info about a function being written
*
* If a local variable exists, the _var member will have a value.
* (e.g. display_var = "display"). If, in the generated code, it
* has been assigned a value, _has_value will be TRUE.
*/
typedef struct
{
ABObj create_obj; /* func is to create this obj */
ABObj ip_obj; /* object referenced by instance pointer */
/* local vars - if ISTRING is not NULL, variable exists */
ISTRING acceltext_xmstr_var;
BOOL acceltext_xmstr_var_has_value;
ISTRING arg_counter_var;
BOOL arg_counter_var_has_value;
ISTRING args_var;
BOOL args_var_has_value;
ISTRING counter_var;
BOOL counter_var_has_value;
ISTRING display_var;
BOOL display_var_has_value;
ISTRING drawable_var;
BOOL drawable_var_has_value;
ISTRING icon_pixmap_var;
BOOL icon_pixmap_var_has_value;
ISTRING icon_mask_pixmap_var;
BOOL icon_mask_pixmap_var_has_value;
ISTRING label_array_var;
BOOL label_array_has_nulls;
ISTRING label_pixmap_var;
BOOL label_pixmap_var_has_value;
ISTRING label_str_var;
BOOL label_str_var_has_value;
ISTRING label_xmstr_var;
BOOL label_xmstr_var_has_value;
ISTRING mnemonic_array_var;
BOOL mnemonic_array_var_has_value;
ISTRING name_array_var;
BOOL name_array_var_has_value;
ISTRING name_param;
BOOL name_param_has_value;
ISTRING parent_param;
BOOL parent_param_has_value;
ISTRING return_code_var;
BOOL return_code_var_has_value;
StringListRec submenu_params;
StringListRec submenu_param_types;
BOOL submenu_params_has_value;
ISTRING title_str_var;
BOOL title_str_var_has_value;
ISTRING value_str_var;
BOOL value_str_var_has_value;
ISTRING icon_name_str_var;
BOOL icon_name_str_var_has_value;
ISTRING ok_label_xmstr_var;
BOOL ok_label_xmstr_var_has_value;
ISTRING directory_xmstr_var;
BOOL directory_xmstr_var_has_value;
ISTRING pattern_xmstr_var;
BOOL pattern_xmstr_var_has_value;
} GenFuncInfoRec, *GenFuncInfo;
/*
* Parameters for code generation and status of generation in progress
*/
typedef struct
{
/* ** NOTE: "write" arg = write to C file
* ** "dump" arg = dump to resource file
*/
File code_file; /* C code */
File resource_file; /* dumped resources */
BOOL prototype_funcs; /* write prototypes? */
AB_ARG_CLASS_FLAGS dumped_resources; /* resources to "dump" */
ABMF_I18N_METHOD i18n_method; /* intl'zation method */
STRING msg_src_file_name; /* i18n msg src file name */
MsgFile msg_file_obj; /* ADT for Msg Src File */
BOOL writing_func; /* currently writing a func? */
GenFuncInfoRec cur_func; /* func currently being generated */
} GenCodeInfoRec, *GenCodeInfo;
/*
* Get/Set fields
*/
#define abmfP_cur_func(genCodeInfo) (&((genCodeInfo)->cur_func))
#define abmfP_create_obj(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->create_obj)
#define abmfP_ip_obj(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->ip_obj)
#define abmfP_args_var(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->args_var)
#define abmfP_args_var_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->args_var_has_value)
#define abmfP_counter_var(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->counter_var)
#define abmfP_counter_var_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->counter_var_has_value)
#define abmfP_arg_counter_var(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->arg_counter_var)
#define abmfP_arg_counter_var_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->arg_counter_var_has_value)
#define abmfP_display_var(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->display_var)
#define abmfP_display_var_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->display_var_has_value)
#define abmfP_drawable_var(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->drawable_var)
#define abmfP_drawable_var_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->drawable_var_has_value)
#define abmfP_icon_pixmap_var(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->icon_pixmap_var)
#define abmfP_icon_pixmap_var_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->icon_pixmap_var_has_value)
#define abmfP_icon_mask_pixmap_var(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->icon_mask_pixmap_var)
#define abmfP_icon_mask_pixmap_var_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->icon_mask_pixmap_var_has_value)
#define abmfP_label_pixmap_var(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->label_pixmap_var)
#define abmfP_label_pixmap_var_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->label_pixmap_var_has_value)
#define abmfP_label_str_var(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->label_str_var)
#define abmfP_label_str_var_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->label_str_var_has_value)
#define abmfP_label_array_var(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->label_array_var)
#define abmfP_label_array_has_nulls(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->label_array_has_nulls)
#define abmfP_mnemonic_array_var(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->mnemonic_array_var)
#define abmfP_mnemonic_array_var_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->mnemonic_array_var_has_value)
#define abmfP_name_array_var(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->name_array_var)
#define abmfP_name_array_var_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->name_array_var_has_value)
#define abmfP_label_xmstr_var(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->label_xmstr_var)
#define abmfP_label_xmstr_var_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->label_xmstr_var_has_value)
#define abmfP_acceltext_xmstr_var(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->acceltext_xmstr_var)
#define abmfP_acceltext_xmstr_var_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->acceltext_xmstr_var_has_value)
#define abmfP_name_param(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->name_param)
#define abmfP_name_param_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->name_param_has_value)
#define abmfP_parent_param(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->parent_param)
#define abmfP_parent_param_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->parent_param_has_value)
#define abmfP_return_code_var(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->return_code_var)
#define abmfP_return_code_var_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->return_code_var_has_value)
#define abmfP_submenu_params(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->submenu_params)
#define abmfP_submenu_param_types(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->submenu_param_types)
#define abmfP_submenu_params_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->submenu_params_has_value)
#define abmfP_title_str_var(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->title_str_var)
#define abmfP_title_str_var_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->title_str_var_has_value)
#define abmfP_value_str_var(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->value_str_var)
#define abmfP_value_str_var_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->value_str_var_has_value)
#define abmfP_icon_name_str_var(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->icon_name_str_var)
#define abmfP_icon_name_str_var_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->icon_name_str_var_has_value)
#define abmfP_ok_label_xmstr_var(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->ok_label_xmstr_var)
#define abmfP_ok_label_xmstr_var_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->ok_label_xmstr_var_has_value)
#define abmfP_directory_xmstr_var(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->directory_xmstr_var)
#define abmfP_directory_xmstr_var_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->directory_xmstr_var_has_value)
#define abmfP_pattern_xmstr_var(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->pattern_xmstr_var)
#define abmfP_pattern_xmstr_var_has_value(genCodeInfo) \
(abmfP_cur_func(genCodeInfo)->pattern_xmstr_var_has_value)
/*
* Functions
*/
int abmfP_gencode_construct(GenCodeInfo genCodeInfo);
int abmfP_gencode_destruct(GenCodeInfo genCodeInfo);
int abmfP_gencode_enter_func(GenCodeInfo genCodeInfo);
int abmfP_gencode_exit_func(GenCodeInfo genCodeInfo);
/*
* A struct obj has a C structure defined for it to contain all of its
* children
*/
BOOL abmfP_obj_is_struct_obj(ABObj obj);
BOOL abmfP_obj_is_substruct_obj(ABObj obj);
BOOL abmfP_obj_could_be_substruct_obj(ABObj obj);
/*
* Does the object have a field of its own in a structure?
*/
BOOL abmfP_obj_has_field(ABObj obj);
BOOL abmfP_obj_has_struct_field(ABObj obj);
BOOL abmfP_obj_has_substruct_field(ABObj obj);
/*
* Routines to write out magic comments
*/
int abmfP_write_user_start_comment(GenCodeInfo, STRING desc);
int abmfP_write_user_long_start_comment(GenCodeInfo, STRING desc);
int abmfP_write_user_end_comment(GenCodeInfo, STRING desc);
int abmfP_write_user_seg(GenCodeInfo, STRING desc, STRING contents);
int abmfP_write_user_long_seg(GenCodeInfo, STRING desc);
int abmfP_write_user_code_seg(GenCodeInfo, STRING contents);
int abmfP_write_user_funcs_seg(GenCodeInfo);
int abmfP_write_user_struct_fields_seg(GenCodeInfo);
int abmfP_write_user_type_and_var_seg(GenCodeInfo);
int abmfP_write_user_var_seg(GenCodeInfo);
int abmfP_write_user_var_and_code_seg(GenCodeInfo, STRING contents);
int abmfP_write_user_long_var_and_code_seg(GenCodeInfo);
int abmfP_write_user_header_seg(GenCodeInfo);
int abmfP_write_user_file_top_seg(GenCodeInfo);
int abmfP_write_user_file_bottom_seg(GenCodeInfo);
/*
* Data
*/
extern char *const abmfP_cmt_user_code_start;
extern char *const abmfP_cmt_user_code_end;
/*************************************************************************
** **
** INLINE DEFINITION **
** **
*************************************************************************/
#endif /* _ABMF_WRITE_CODEP_H_ */