Commit cd921d7d authored by claes's avatar claes

New classeditor and template plc

parent 146df424
......@@ -8,20 +8,20 @@
<h2 id="mainmenu">wb_load example </h2>
<xmp>
!/**
! @Version 1.0
! @Author Homer Simpson
! @Code rs_plc_mycode.c
! @Group MyGroup
! @Summary Brief description of my class
! More desciption of my class
! ..
! @image orm_myclass_fo.gif
!
! @b See also
! @classlink MyOtherClass pwrb_myotherclass.html
!*/
SObject pwrb:Class
!/**
! @Version 1.0
! @Author Homer Simpson
! @Code rs_plc_mycode.c
! @Group MyGroup
! @Summary Brief description of my class
! More desciption of my class
! ..
! @image orm_myclass_fo.gif
!
! @b See also
! @classlink MyOtherClass pwrb_myotherclass.html
!*/
Object MyClass $ClassDef 301
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
......
......@@ -115,6 +115,10 @@ int ClassRead::read( char *filename)
nr > 2 &&
strcmp( low( line_part[2]), "pwr_eclass_param") == 0)
linetype = cread_eLine_Attribute;
else if ( strcmp( low( line_part[0]), "object") == 0 &&
nr > 2 &&
strcmp( low( line_part[2]), "$typedef") == 0)
linetype = cread_eLine_TypeDef;
else if ( strcmp( low( line_part[0]), "object") == 0 &&
nr > 2 &&
strcmp( low( line_part[2]), "$objbodydef") == 0)
......@@ -161,6 +165,8 @@ int ClassRead::read( char *filename)
linetype = cread_eLine_Buffer;
else if ( strcmp( low( line_part[0]), "object") == 0)
linetype = cread_eLine_Object;
else if ( strcmp( low( line_part[0]), "object") == 0)
linetype = cread_eLine_Object;
else if ( strcmp( low( line_part[0]), "!/**") == 0)
linetype = cread_eLine_Doc;
else if ( strcmp( low( line_part[0]), "!*/") == 0)
......@@ -173,6 +179,10 @@ int ClassRead::read( char *filename)
linetype = cread_eLine_EndVolume;
else if ( strcmp( low( line_part[0]), "range") == 0)
linetype = cread_eLine_Range;
else if ( strcmp( low( line_part[0]), "buffer") == 0)
linetype = cread_eLine_Buff;
else if ( strcmp( low( line_part[0]), "endbuffer") == 0)
linetype = cread_eLine_EndBuff;
else
linetype = cread_eLine_Unknown;
......@@ -207,6 +217,15 @@ int ClassRead::read( char *filename)
if ( nr > 3)
strcpy( class_id, line_part[3]);
break;
case cread_eLine_TypeDef:
state |= cread_mState_TypeDef;
object_state = cread_mState_TypeDef;
typedef_init();
if ( line_part[1][0] == '$')
strcpy( typedef_name, &line_part[1][1]);
else
strcpy( typedef_name, line_part[1]);
break;
case cread_eLine_SysBody:
state |= cread_mState_SysBody;
break;
......@@ -335,6 +354,15 @@ int ClassRead::read( char *filename)
if ( generate_struct && struct_class_open)
struct_class_close();
}
else if ( state & cread_mState_TypeDef) {
state &= ~cread_mState_TypeDef;
#if 0
if ( generate_html && html_class_open)
html_class_close();
if ( generate_struct && struct_class_open)
struct_class_close();
#endif
}
else if ( state & cread_mState_Object)
{
object_level--;
......@@ -378,6 +406,9 @@ int ClassRead::read( char *filename)
case cread_mState_ClassDef:
class_attr( attr_name, attr_value);
break;
case cread_mState_TypeDef:
typedef_attr( attr_name, attr_value);
break;
case cread_mState_ObjBodyDef:
body_attr( attr_name, attr_value);
break;
......@@ -423,6 +454,9 @@ int ClassRead::read( char *filename)
case cread_mState_ClassDef:
class_attr( attr_name, attr_value);
break;
case cread_mState_TypeDef:
typedef_attr( attr_name, attr_value);
break;
case cread_mState_ObjBodyDef:
body_attr( attr_name, attr_value);
break;
......@@ -473,6 +507,7 @@ int ClassRead::read( char *filename)
case cread_eLine_Volume:
{
state |= cread_mState_Volume;
strcpy( volume_name, line_part[1]);
break;
}
case cread_eLine_EndVolume:
......@@ -483,6 +518,9 @@ int ClassRead::read( char *filename)
}
case cread_eLine_Range:
break;
case cread_eLine_Buff:
case cread_eLine_EndBuff:
break;
case cread_eLine_EOF:
break;
......@@ -962,6 +1000,9 @@ int ClassRead::object_close()
case cread_mState_ClassDef:
class_close();
break;
case cread_mState_TypeDef:
typedef_close();
break;
case cread_mState_Object:
break;
default:
......@@ -971,6 +1012,47 @@ int ClassRead::object_close()
return 1;
}
void ClassRead::typedef_init()
{
strcpy( typedef_name, "");
strcpy( typedef_typeref, "");
typedef_elements = 0;
}
int ClassRead::typedef_attr( char *name, char *value)
{
if ( strcmp( low( name), "typeref") == 0)
{
if ( strncmp( value, "pwrs:Type-$", 11) == 0)
strcpy( typedef_typeref, &value[11]);
else
strcpy( typedef_typeref, value);
}
else if ( strcmp( low( name), "elements") == 0)
{
sscanf( value, "%d", &typedef_elements);
}
return 1;
}
int ClassRead::typedef_close()
{
if ( first_class) {
if ( generate_struct)
struct_init();
first_class = 0;
}
if ( generate_struct)
struct_typedef();
doc_fresh = 0;
return 1;
}
char *ClassRead::low( char *in)
{
static char str[400];
......
......@@ -50,7 +50,10 @@ typedef enum {
cread_eLine_EndVolume,
cread_eLine_DParam,
cread_eLine_DAttr,
cread_eLine_Buff,
cread_eLine_EndBuff,
cread_eLine_Range,
cread_eLine_TypeDef,
cread_eLine_Unknown
} cread_eLine;
......@@ -73,7 +76,8 @@ typedef enum {
cread_mState_Doc = 1 << 15,
cread_mState_Template = 1 << 16,
cread_mState_Volume = 1 << 17,
cread_mState_DParam = 1 << 18
cread_mState_DParam = 1 << 18,
cread_mState_TypeDef = 1 << 19
} cread_mState;
#define cread_cTmpFile1 "classread1.tmp"
......@@ -126,6 +130,9 @@ class ClassRead {
int body_rtvirtual;
char graphplcnode_name[80];
char graphplccon_name[20];
char typedef_name[80];
char typedef_typeref[80];
int typedef_elements;
char doc_author[200];
char doc_version[80];
char doc_groups[10][40];
......@@ -159,6 +166,9 @@ class ClassRead {
void class_init();
int class_attr( char *name, char *value);
int class_close();
void typedef_init();
int typedef_attr( char *name, char *value);
int typedef_close();
void body_init();
int body_attr( char *name, char *value);
int body_close();
......@@ -249,6 +259,7 @@ class ClassRead {
int struct_body();
int struct_body_close();
int struct_attribute();
int struct_typedef();
int struct_volname_to_id();
void struct_cix_to_classid( unsigned int cix, pwr_tClassId *cid);
int struct_cixstr_to_classid( char *cix_str, pwr_tClassId *cid);
......
......@@ -312,7 +312,10 @@ int ClassRead::struct_attribute()
if ( strcmp( low(attr_type), "buffer") == 0)
{
strcpy( type_name, "pwr_s");
strcat( type_name, &attr_typeref[11]);
if ( attr_typeref[11] == '$')
strcat( type_name, &attr_typeref[12]);
else
strcat( type_name, &attr_typeref[11]);
}
else if ( strcmp( low(attr_typeref), "attrref") == 0)
{
......@@ -537,6 +540,19 @@ int ClassRead::struct_attribute()
return 1;
}
int ClassRead::struct_typedef()
{
if ( strcmp( typedef_typeref, "String") == 0)
fp_struct <<
"typedef char pwr_t" << typedef_name << "[" << typedef_elements << "];" << endl << endl;
else
fp_struct <<
"typedef pwr_t" << typedef_typeref << " pwr_t" << typedef_name << "[" << typedef_elements << "];" << endl << endl;
return 1;
}
int ClassRead::struct_volname_to_id()
{
FILE *fp;
......
......@@ -581,7 +581,9 @@ union pwr_m_Adef {
pwr_Bits( isclass , 1), /* class is a reserved word */
pwr_Bits( subclass , 1),
pwr_Bits( buffer , 1),
pwr_Bits( fill_0 , 4),,,,
pwr_Bits( nowbl , 1),
pwr_Bits( alwayswbl , 1),
pwr_Bits( fill_0 , 2),,
pwr_Bits( fill_1 , 8),,,,,,,
) b;
......@@ -606,6 +608,8 @@ union pwr_m_Adef {
#define pwr_mAdef_class pwr_Bit(17)
#define pwr_mAdef_subclass pwr_Bit(18)
#define pwr_mAdef_buffer pwr_Bit(19)
#define pwr_mAdef_nowbl pwr_Bit(20) /* Don't print to wbl file */
#define pwr_mAdef_alwayswbl pwr_Bit(21) /* Always print to wbl file */
};
#define PWR_MASK_POINTER pwr_mAdef_pointer
......@@ -629,6 +633,8 @@ union pwr_m_Adef {
#define PWR_MASK_CLASS pwr_mAdef_class
#define PWR_MASK_SUBCLASS pwr_mAdef_subclass
#define PWR_MASK_BUFFER pwr_mAdef_buffer
#define PWR_MASK_NOWBL pwr_mAdef_nowbl
#define PWR_MASK_ALWAYSWBL pwr_mAdef_alwayswbl
struct pwr_s_Param
{
......
......@@ -582,6 +582,7 @@ void wow_CreateFileSelDia( Widget parent_wid,
XtSetArg( args[i], XmNpattern, cpattern); i++;
break;
case wow_eFileSelType_Wbl:
case wow_eFileSelType_WblClass:
dcli_translate_filename( directory, "$pwrp_db/");
cdirectory = XmStringCreateLtoR( directory, XmSTRING_DEFAULT_CHARSET);
cpattern = XmStringCreateLtoR( "*.wb_load", XmSTRING_DEFAULT_CHARSET);
......
......@@ -18,7 +18,8 @@ extern "C" {
typedef enum {
wow_eFileSelType_All,
wow_eFileSelType_Dbs,
wow_eFileSelType_Wbl
wow_eFileSelType_Wbl,
wow_eFileSelType_WblClass
} wow_eFileSelType;
typedef struct {
......
......@@ -278,6 +278,71 @@
#define ItoA_exec(obj,in) \
obj->ActVal = in;
/**
StoDattr
@aref stodattr StoDattr
*/
#define StoDattr_exec(attr,in) \
attr = in;
/**
SetDattr
@aref setdattr SetDattr
*/
#define SetDattr_exec(attr,in) \
if ( in) attr = true;
/**
ResDattr
@aref resdattr ResDattr
*/
#define ResDattr_exec(attr,in) \
if ( in) attr = false;
/**
StoIattr
@aref stoiattr StoIattr
*/
#define StoIattr_exec(attr,in) \
attr = in;
/**
CStoIattr
@aref cstoiattr CStoIattr
*/
#define CStoIattr_exec(attr,in,cond) \
if ( cond) attr = in;
/**
StoAattr
@aref stoaattr StoAattr
*/
#define StoAattr_exec(attr,in) \
attr = in;
/**
CStoAattr
@aref cstoaattr CStoAattr
*/
#define CStoAattr_exec(attr,in,cond) \
if ( cond) attr = in;
/**
StoSattr
@aref stosattr StoSattr
*/
#define StoSattr_exec(attr,in,size) \
strncpy( attr, in, size); \
attr[size-1] = 0;
/**
CStoSattr
@aref cstosattr CStoSattr
*/
#define CStoSattr_exec(attr,in,cond,size) \
if ( cond) { \
strncpy( attr, in, size); \
attr[size-1] = 0; \
}
......@@ -170,6 +170,11 @@ static types_sEnumElement mask_Attribute_Flags[] = {
{ pwr_mAdef_noremove , "NoRemove"},
{ pwr_mAdef_rtdbref , "RtdbRef"},
{ pwr_mAdef_private , "Private"},
{ pwr_mAdef_class , "IsClass"},
{ pwr_mAdef_subclass , "SubClass"},
{ pwr_mAdef_buffer , "Buffer"},
{ pwr_mAdef_nowbl , "NoWbl"},
{ pwr_mAdef_alwayswbl , "AlwaysWbl"},
{ 0, ""}};
static types_sEnumElement mask_ClassDef_Flags[] = {
......
......@@ -86,6 +86,7 @@ nobuildhost <cannot get build host name> /error
nothread <Invalid thread object> /error
invthread <Invalid thread object, plc will not be executed> /warning
generic <Generic object is not connected> /error
templateplc <Template plc not found> /error
.facility FOE,280 /prefix = FOE__ ! Function object editor
......
......@@ -102,7 +102,7 @@ memincon <buffer inconsistency> /error
access <no such access for this configuration> /error
attrconv <attribute conversion error> /error
nosuchfile <no such file> /error
classmisplaced <Misplaced object in class volume> /error
......
......@@ -11,3 +11,4 @@
success <successful completion> /succ
chanclass <channel class not allowed on this card> /error
alochan <could not allocate a new channel> /error
graphaction <no action defined in graph object> /error
......@@ -24,3 +24,13 @@ swerrconn <selected object was incorrectly connected with object pointed at> /wa
xreffull <all connections are used> /error
idxref <inconnectable cross reference identities> /error
stxref <inconnectable source, target pair> /error
posclassdef <a ClassDef should be child to a ClassHier object> /error
posclasshier <a ClassHier should be a root object> /error
posattribute <an attribute or buffer object should be child to a ObjBodyDef object> /error
posobjbodydef <a body object should be child to a ClassDef object> /error
moveattribute <an attribute object can only be moved within the same childhood> /error
movebody <a body object can only be moved within the same childhood> /error
......@@ -50,6 +50,7 @@ extern "C" {
#include "wb_erep.h"
#include "wb_vrepwbl.h"
#include "wb_vrepdbs.h"
#include "wb_vrepmem.h"
using namespace std;
......@@ -285,7 +286,7 @@ void pwr_wtt_open_volume( void *wttctx, wb_eType type, char *filename, wow_eFile
type);
}
else {
// Open the file... TODO
// Open the file
if ( file_type == wow_eFileSelType_Wbl) {
printf( "Wb opening wb_load-file %s...\n", filename);
......@@ -338,13 +339,64 @@ void pwr_wtt_open_volume( void *wttctx, wb_eType type, char *filename, wow_eFile
wtt->time_to_exit_cb = pwr_time_to_exit;
}
}
else if ( file_type == wow_eFileSelType_WblClass) {
printf( "Wb opening wb_load-file %s...\n", filename);
// Load volume and import to vrepmem
wb_erep *erep = (wb_erep *)(*(wb_env *)wbctx);
#if 0
wb_vrepwbl *vrep = new wb_vrepwbl( erep);
sts = vrep->load( filename);
if ( vrep->vid() == 0) {
delete vrep;
return;
}
vrep->ref();
wb_vrepmem *mem = new wb_vrepmem(erep, vrep->vid());
mem->name( vrep->name());
erep->addExtern( &sts, mem);
mem->importVolume( *vrep);
vrep->unref();
#endif
wb_vrepmem *mem = new wb_vrepmem(erep, 0);
mem->loadWbl( filename, &sts);
if ( EVEN(sts)) {
delete mem;
return;
}
erep->addExtern( &sts, mem);
// Display buffer
wb_volume *vol = new wb_volume(mem);
// Display filename i title, without path
char *name_p;
if ( (name_p = strrchr( filename, '/')))
name_p++;
else
name_p = filename;
Wtt *wtt = new Wtt( 0, toplevel, name_p,
"Navigator", wbctx, mem->vid(), vol, 0, &sts);
if (ODD(sts)) {
appl_count++;
wtt->close_cb = pwr_wtt_close;
wtt->open_volume_cb = pwr_wtt_open_volume;
wtt->time_to_exit_cb = pwr_time_to_exit;
}
}
else
printf( "Unknown file type\n");
}
}
else
else {
printf( "No privileges to enter development environment");
exit(LOGIN__NOPRIV);
}
}
int pwr_vsel_success( void *vselctx,
......
......@@ -18,7 +18,8 @@ typedef enum {
wb_eType_Volume,
wb_eType_Directory,
wb_eType_Class,
wb_eType_Buffer
wb_eType_Buffer,
wb_eType_ClassEditor
} wb_eType;
typedef enum {
......
......@@ -248,6 +248,16 @@ wb_attribute::~wb_attribute()
}
bool wb_attribute::operator==(const wb_attribute& x) const
{
if ( m_orep->oid().vid == x.m_orep->oid().vid &&
m_orep->oid().oix == x.m_orep->oid().oix &&
m_size == x.m_size &&
m_offset == x.m_offset)
return true;
return false;
}
wb_attribute& wb_attribute::operator=(const wb_attribute& x)
{
if ( x.m_orep)
......
......@@ -68,7 +68,5 @@ pwr_dExport pwr_BindMethods(SharedVolumeConfig) = {
pwr_BindMethod(OpenDb),
pwr_NullMethod
};
pwr_dExport pwr_BindMethods(ClassVolumeConfig) = {
pwr_BindMethod(OpenDb),
pwr_NullMethod
};
......@@ -37,10 +37,10 @@ static pwr_tStatus OpenGraph (
free( (char *)action);
if ( strstr( graph_name, ".pwg"))
{
// ge_new( NULL, ip->WindowContext, ip->PointedSession, 0, graph_name);
ge_new( NULL, ip->WindowContext, ip->PointedSession, 0, graph_name);
return 1;
}
return 0;
return PWRB__GRAPHACTION;
}
......@@ -52,3 +52,8 @@ pwr_dExport pwr_BindMethods(XttGraph) = {
pwr_BindMethod(OpenGraph),
pwr_NullMethod
};
......@@ -96,6 +96,8 @@ public:
bool importDbody(pwr_tOid oid, size_t size, void *body);
bool importDocBlock(pwr_tOid oid, size_t size, char *block) { return true;}
bool importMeta(dbs_sEnv *ep);
......
......@@ -143,6 +143,8 @@ public:
virtual bool importDbody(pwr_tOid oid, size_t size, void *body);
virtual bool importDocBlock(pwr_tOid oid, size_t size, char *block) { return true;}
virtual bool importMeta(dbs_sEnv *ep);
private:
......
......@@ -15,6 +15,8 @@ public:
virtual bool exportDbody(wb_import &e) = 0;
virtual bool exportDocBlock(wb_import &e) = 0;
virtual bool exportMeta(wb_import &e) = 0;
};
......
......@@ -157,6 +157,7 @@ struct s_foe_ctx
int set_focus_disabled;
XtIntervalId focus_timerid;
Atom objid_atom;
int classeditor;
};
/* Methods */
......
......@@ -140,9 +140,11 @@ XmAnyCallbackStruct *data;
}
}
CLOCK_CURSOR;
sts = gre_set_trace_attributes( foectx->grectx);
sts = gre_save( foectx->grectx);
sts = gre_undelete_reset( foectx->grectx);
if ( !foectx->classeditor) {
sts = gre_set_trace_attributes( foectx->grectx);
sts = gre_save( foectx->grectx);
sts = gre_undelete_reset( foectx->grectx);
}
foe_disable_ldh_cb(foectx);
sts = vldh_wind_save( foectx->grectx->window_object);
foe_enable_ldh_cb(foectx);
......
......@@ -1493,6 +1493,7 @@ int foe_new_local(
pwr_tClassId plcclass;
int plc_loaded;
int function;
pwr_tClassId classid;
if ( cdh_ObjidIsNotNull( plcprogram))
{
......@@ -1791,6 +1792,17 @@ int foe_new_local(
trace_simsetup( foectx);
}
// Check if class editor
sts = ldh_GetVolumeClass( ldh_SessionToWB(windowobject->hw.ldhsession),
windowobject->lw.objdid.vid, &classid);
if ( EVEN(sts)) return sts;
if ( ldh_VolRepType( windowobject->hw.ldhsession) == ldh_eVolRep_Mem &&
classid == pwr_eClass_ClassVolume)
foectx->classeditor = 1;
if ( foectx->access == foe_eFuncAccess_Edit)
foe_edit_set_entries ( foectx);
return FOE__SUCCESS;
}
......@@ -2715,22 +2727,36 @@ static int foe_edit_set_entries (
)
{
Arg args[20];
int i;
i=0;
XtSetArg(args[i],XmNsensitive,1 ); i++;
XtSetValues( foectx->widgets.save,args,i);
XtSetValues( foectx->widgets.exit,args,i);
XtSetValues( foectx->widgets.syntax,args,i);
XtSetValues( foectx->widgets.compile,args,i);
XtSetValues( foectx->widgets.savetrace,args,i);
XtSetValues( foectx->widgets.restoretrace,args,i);
XtSetValues( foectx->widgets.redraw,args,i);
XtSetValues( foectx->widgets.plcattribute,args,i);
XtSetValues( foectx->widgets.winddelete,args,i);
XtSetValues( foectx->widgets.edit_entry,args,i);
Arg sensitive[1];
Arg insensitive[1];
XtSetArg(sensitive[0],XmNsensitive, 1);
XtSetArg(insensitive[0],XmNsensitive, 0);
if ( !foectx->classeditor) {
XtSetValues( foectx->widgets.save,sensitive,1);
XtSetValues( foectx->widgets.exit,sensitive,1);
XtSetValues( foectx->widgets.syntax,sensitive,1);
XtSetValues( foectx->widgets.compile,sensitive,1);
XtSetValues( foectx->widgets.savetrace,sensitive,1);
XtSetValues( foectx->widgets.restoretrace,sensitive,1);
XtSetValues( foectx->widgets.redraw,sensitive,1);
XtSetValues( foectx->widgets.plcattribute,sensitive,1);
XtSetValues( foectx->widgets.winddelete,sensitive,1);
XtSetValues( foectx->widgets.edit_entry,sensitive,1);
}
else {
XtSetValues( foectx->widgets.save,sensitive,1);
XtSetValues( foectx->widgets.exit,sensitive,1);
XtSetValues( foectx->widgets.syntax,insensitive,1);
XtSetValues( foectx->widgets.compile,insensitive,1);
XtSetValues( foectx->widgets.savetrace,insensitive,1);
XtSetValues( foectx->widgets.restoretrace,insensitive,1);
XtSetValues( foectx->widgets.redraw,sensitive,1);
XtSetValues( foectx->widgets.plcattribute,sensitive,1);
XtSetValues( foectx->widgets.winddelete,sensitive,1);
XtSetValues( foectx->widgets.edit_entry,sensitive,1);
}
return FOE__SUCCESS ;
......
This diff is collapsed.
......@@ -14,6 +14,10 @@ pwr_dImport pwr_BindMethods($ObjXRef);
pwr_dImport pwr_BindMethods($Objid);
pwr_dImport pwr_BindMethods($RootVolume);
pwr_dImport pwr_BindMethods($SubVolume);
pwr_dImport pwr_BindMethods($ClassDef);
pwr_dImport pwr_BindMethods($ClassHier);
pwr_dImport pwr_BindMethods($Attribute);
pwr_dImport pwr_BindMethods($ObjBodyDef);
pwr_dExport pwr_BindClasses(System) = {
pwr_BindClass($AttrXRef),
......@@ -23,5 +27,9 @@ pwr_dExport pwr_BindClasses(System) = {
pwr_BindClass($Objid),
pwr_BindClass($RootVolume),
pwr_BindClass($SubVolume),
pwr_BindClass($ClassDef),
pwr_BindClass($ClassHier),
pwr_BindClass($Attribute),
pwr_BindClass($ObjBodyDef),
pwr_NullClass
};
......@@ -22,6 +22,8 @@ public:
virtual bool importDbody(pwr_tOid oid, size_t size, void *body) = 0;
virtual bool importDocBlock(pwr_tOid oid, size_t size, char *block) = 0;
virtual bool importMeta(dbs_sEnv *ep) = 0;
};
......
......@@ -1300,9 +1300,14 @@ ldh_SetObjectPar(ldh_tSession session, pwr_tOid oid, char *bname,
wb_attribute a = o.attribute(bname, aname);
if (!a) return a.sts();
sp->writeAttribute(a, value, size);
return sp->sts();
try {
sp->writeAttribute(a, value, size);
return sp->sts();
}
catch (wb_error& e) {
return e.sts();
}
}
pwr_tStatus
......@@ -1465,8 +1470,9 @@ ldh_WbDump( ldh_tSession session, char *objname, char *dumpfile)
wb_session *sp = (wb_session*)session;
char fname[200];
if ( sp->type() == ldh_eVolRep_Wbl ||
sp->cid() == pwr_eClass_ClassVolume)
if ( sp->type() == ldh_eVolRep_Wbl
// || sp->cid() == pwr_eClass_ClassVolume
)
return LDH__NYI;
dcli_translate_filename( fname, dumpfile);
......@@ -1560,6 +1566,33 @@ ldh_VolRepType( ldh_tSession session)
return ((wb_session*)session)->type();
}
pwr_tStatus
ldh_GetDocBlock(ldh_tSession session, pwr_tOid oid, char **block, int *size)
{
wb_session *sp = (wb_session*)session;
wb_object o = sp->object(oid);
if (!o) return o.sts();
if ( o.docBlock( block, size))
return LDH__SUCCESS;
return LDH__NOSUCHBUFFER;
}
pwr_tStatus
ldh_SetDocBlock(ldh_tSession session, pwr_tOid oid, char *block)
{
wb_session *sp = (wb_session*)session;
wb_object o = sp->object(oid);
if (!o) return o.sts();
if ( o.docBlock( block))
return LDH__SUCCESS;
return LDH__NOSUCHBUFFER;
}
#endif
......
......@@ -987,6 +987,21 @@ ldh_VolRepType(
ldh_tSession session
);
pwr_tStatus
ldh_GetDocBlock(
ldh_tSession session,
pwr_tOid oid,
char **block,
int *size
);
pwr_tStatus
ldh_SetDocBlock(
ldh_tSession session,
pwr_tOid oid,
char *block
);
#ifdef __cplusplus
}
#endif
......
......@@ -377,3 +377,17 @@ pwr_tStatus wb_object::checkXref(const char *name)
return LDH__SUCCESS;
}
bool wb_object::docBlock( char **block, int *size)
{
check();
return m_orep->docBlock( block, size);
}
bool wb_object::docBlock( char *block)
{
check();
return m_orep->docBlock( block);
}
......@@ -94,6 +94,9 @@ public:
wb_destination destination(ldh_eDest dest);
bool docBlock( char **block, int *size);
bool docBlock( char *block);
private:
bool check();
bool check(string str);
......
......@@ -59,6 +59,8 @@ public:
virtual wb_adrep *attribute(pwr_tStatus*, const char *name) = 0;
virtual wb_adrep *attribute(pwr_tStatus*) = 0;
virtual bool docBlock( char **block, int *size) const { return false;}
virtual bool docBlock( char *block) { return false;}
virtual wb_erep *erep() const = 0;
virtual wb_vrep *vrep() const = 0;
......
......@@ -155,3 +155,20 @@ wb_adrep *wb_orepmem::attribute(pwr_tStatus*)
return 0;
}
bool wb_orepmem::docBlock( char **block, int *size) const
{
return m_memobject->docBlock( block, size);
}
bool wb_orepmem::docBlock( char *block)
{
return m_memobject->docBlock( block);
}
......@@ -59,6 +59,9 @@ public:
wb_erep *erep() const { return m_vrep->erep();}
wb_vrep *vrep() const { return m_vrep;}
virtual bool docBlock( char **block, int *size) const;
virtual bool docBlock( char *block);
};
#endif
......
......@@ -154,3 +154,8 @@ wb_adrep *wb_orepwbl::attribute(pwr_tStatus*)
return 0;
}
bool wb_orepwbl::docBlock( char **block, int *size) const
{
return m_wblnode->docBlock( block, size);
}
......@@ -59,6 +59,8 @@ public:
wb_erep *erep() const { return m_vrep->erep();}
wb_vrep *vrep() const { return m_vrep;}
bool docBlock( char **block, int *size) const;
};
#endif
......
......@@ -378,6 +378,10 @@ PalItemClass::PalItemClass( Pal *pal, char *item_name,
case pwr_cClass_GetIi:
case pwr_cClass_GetIo:
case pwr_cClass_GetIv:
case pwr_cClass_GetDattr:
case pwr_cClass_GetAattr:
case pwr_cClass_GetIattr:
case pwr_cClass_GetSattr:
pixmap = pal->pixmap_get;
break;
case pwr_cClass_GetAp:
......@@ -406,6 +410,9 @@ PalItemClass::PalItemClass( Pal *pal, char *item_name,
case pwr_cClass_cstosv:
case pwr_cClass_cstosp:
case pwr_cClass_stosp:
case pwr_cClass_CStoAattr:
case pwr_cClass_CStoIattr:
case pwr_cClass_CStoSattr:
pixmap = pal->pixmap_stop;
break;
case pwr_cClass_Text: pixmap = pal->pixmap_text; break;
......
......@@ -45,7 +45,8 @@ void wb_print_wbl::printAttribute(wb_volume& v,
wb_attribute& tattr, ///< template
wb_adef& adef)
{
if (adef.flags() & PWR_MASK_POINTER)
if (adef.flags() & PWR_MASK_POINTER ||
adef.flags() & PWR_MASK_NOWBL)
return;
if (attr.isClass())
......@@ -129,6 +130,10 @@ void wb_print_wbl::printClass(wb_volume& v,
wb_adef adef2;
const char* bname;
if ( strcmp( attr.name(), "Template") == 0 && v.cid() == pwr_eClass_ClassVolume)
// The parser can't handle subclasses in template objects yet...
return;
wb_object co = v.object(cdh_ClassIdToObjid(subClass));
if (!co) {
m_os << "! %WBDUMP-E-Error Unknown sub class: " << subClass << endl;
......@@ -213,6 +218,23 @@ void wb_print_wbl::printObject(wb_volume& v, wb_object& o, bool recursive)
unsigned int idx;
wb_cdef cdef = v.cdef(o);
const char* cname = cdef.name();
char *block;
int size;
if ( o.docBlock( &block, &size) && strcmp( block, "") != 0) {
indent(0) << "!/**" << endl;
indent(0) << "! ";
for ( char *s = block; *s; s++) {
if ( *s == '\n') {
m_os << *s;
indent(0) << "! ";
continue;
}
m_os << *s;
}
m_os << endl;
indent(0) << "!*/" << endl;
}
indent(1) << "Object " << o.name() << " " << cname;
......@@ -299,6 +321,9 @@ void wb_print_wbl::printParameter(wb_volume& v,
return;
}
if ( attr == tattr)
// This is the template object itself, print all nonzero
tvalueb = (char *)calloc( 1, tattr.size());
for (int i = 0; i < nElement; i++) {
switch (adef.type()) {
......@@ -328,7 +353,7 @@ void wb_print_wbl::printParameter(wb_volume& v,
val = valueb + varOffset;
tval = tvalueb + varOffset;
if (memcmp(val, tval, varSize) == 0)
if (memcmp(val, tval, varSize) == 0 && !(adef.flags() & PWR_MASK_ALWAYSWBL))
continue;
parValOk = printValue(v, adef, val, varSize, &svalp);
......@@ -362,6 +387,8 @@ void wb_print_wbl::printParameter(wb_volume& v,
break;
}
}
if ( attr == tattr)
free( tvalueb);
}
//
......
......@@ -62,7 +62,7 @@ typedef pwr_tStatus (* wb_tMethodMenu)( ldh_sMenuCall *);
typedef pwr_tStatus (* wb_tMethodMenuFilter)( ldh_sMenuCall *, pwr_sMenuButton *);
typedef pwr_tStatus (* wb_tMethodAnteCreate) (ldh_tSesContext, pwr_tOid, pwr_tCid);
typedef pwr_tStatus (* wb_tMethodPostCreate) (ldh_tSesContext, pwr_tOid, pwr_tOid, pwr_tCid);
typedef pwr_tStatus (* wb_tMethodAnteMove) (ldh_tSesContext, pwr_tOid, pwr_tOid, pwr_tCid);
typedef pwr_tStatus (* wb_tMethodAnteMove) (ldh_tSesContext, pwr_tOid, pwr_tOid, pwr_tOid);
typedef pwr_tStatus (* wb_tMethodPostMove) (ldh_tSesContext, pwr_tOid, pwr_tOid, pwr_tCid);
typedef pwr_tStatus (* wb_tMethodAnteAdopt) (ldh_tSesContext, pwr_tOid, pwr_tCid);
typedef pwr_tStatus (* wb_tMethodPostAdopt) (ldh_tSesContext, pwr_tOid, pwr_tOid, pwr_tCid);
......@@ -86,7 +86,7 @@ static pwr_tStatus AnteMove (
ldh_tSesContext Session,
pwr_tObjid Object, /* object about to be moved */
pwr_tObjid Father, /* new father */
pwr_tClassId Class /* class of father */
pwr_tObjid OldFather /* old father */
);
static pwr_tStatus AnteUnadopt (
ldh_tSesContext Session,
......@@ -126,3 +126,15 @@ static pwr_tStatus SyntaxCheck (
);
#endif
#endif
......@@ -165,7 +165,7 @@ bool wb_session::moveObject(wb_object o, wb_destination d)
}
wb_object old_parent = o.parent();
m_sts = triggAnteMove(o, parent);
m_sts = triggAnteMove(o, parent, old_parent);
if (evenSts()) return false;
m_sts = triggAnteUnadopt(old_parent, o);
if (evenSts()) return false;
......@@ -336,7 +336,13 @@ bool wb_session::copyOset( pwr_sAttrRef *arp, bool keepref)
continue;
}
m_vrep->exportTree( *mem, ap->Objid);
if ( m_vrep->vid() == ap->Objid.vid)
m_vrep->exportTree( *mem, ap->Objid);
else {
// Other volume
wb_vrep *vrep = m_vrep->erep()->volume( &sts, ap->Objid.vid);
vrep->exportTree( *mem, ap->Objid);
}
ap++;
}
return mem->importTree( keepref);
......@@ -521,7 +527,11 @@ pwr_tStatus wb_session::getMenu( ldh_sMenuCall *ip)
Class = cdh_ClassObjidToId(ip->Pointed.Objid);
}
else {
o = m_vrep->erep()->object( &sts, ip->Pointed.Objid);
if ( m_vrep->vid() == ip->Pointed.Objid.vid)
o = m_vrep->object( &sts, ip->Pointed.Objid);
else
// Other volume
o = m_vrep->erep()->object( &sts, ip->Pointed.Objid);
if ( EVEN(sts)) return sts;
o->ref();
Class = o->cid();
......@@ -585,7 +595,11 @@ pwr_tStatus wb_session::getMenu( ldh_sMenuCall *ip)
Class = cdh_ClassObjidToId(ip->Pointed.Objid);
}
else {
o = m_vrep->erep()->object( &sts, ip->Pointed.Objid);
if ( m_vrep->vid() == ip->Pointed.Objid.vid)
o = m_vrep->object( &sts, ip->Pointed.Objid);
else
// Other volume
o = m_vrep->erep()->object( &sts, ip->Pointed.Objid);
if ( EVEN(sts)) return sts;
o->ref();
Class = o->cid();
......
......@@ -423,6 +423,7 @@ pwr_tStatus wb_volume::triggAnteAdopt( wb_object& father, pwr_tCid cid)
pwr_tStatus sts;
char *methodName;
wb_tMethod method;
pwr_tOid foid;
if ( !father)
return LDH__SUCCESS;
......@@ -437,7 +438,12 @@ pwr_tStatus wb_volume::triggAnteAdopt( wb_object& father, pwr_tCid cid)
m_vrep->erep()->method( &sts, methodName, &method);
if ( EVEN(sts)) return LDH__SUCCESS;
sts = ((wb_tMethodAnteAdopt) (method))( (ldh_tSesContext)this, father.oid(), cid);
if ( !father)
foid = pwr_cNObjid;
else
foid = father.oid();
sts = ((wb_tMethodAnteAdopt) (method))( (ldh_tSesContext)this, foid, cid);
return sts;
}
......@@ -446,6 +452,7 @@ pwr_tStatus wb_volume::triggAnteCreate( wb_object& father, pwr_tCid cid)
pwr_tStatus sts;
char *methodName;
wb_tMethod method;
pwr_tOid foid;
wb_cdrep *cdrep = m_vrep->merep()->cdrep( &sts, cid);
......@@ -460,20 +467,27 @@ pwr_tStatus wb_volume::triggAnteCreate( wb_object& father, pwr_tCid cid)
m_vrep->erep()->method( &sts, methodName, &method);
if ( EVEN(sts)) return LDH__SUCCESS;
sts = ((wb_tMethodAnteCreate) (method))( (ldh_tSesContext)this, father.oid(), cid);
if ( !father)
foid = pwr_cNObjid;
else
foid = father.oid();
sts = ((wb_tMethodAnteCreate) (method))( (ldh_tSesContext)this, foid, cid);
return sts;
}
pwr_tStatus wb_volume::triggAnteMove( wb_object& o, wb_object& father)
pwr_tStatus wb_volume::triggAnteMove( wb_object& o, wb_object& father, wb_object& old_father)
{
pwr_tStatus sts;
char *methodName;
wb_tMethod method;
pwr_tOid foid;
pwr_tOid old_foid;
wb_cdrep *cdrep = m_vrep->merep()->cdrep( &sts, o.cid());
if ( EVEN(sts)) return sts;
cdrep->dbCallBack( &sts, ldh_eDbCallBack_AnteCreate, &methodName, 0);
cdrep->dbCallBack( &sts, ldh_eDbCallBack_AnteMove, &methodName, 0);
delete cdrep;
if ( EVEN(sts)) return LDH__SUCCESS;
......@@ -481,11 +495,17 @@ pwr_tStatus wb_volume::triggAnteMove( wb_object& o, wb_object& father)
if ( EVEN(sts)) return LDH__SUCCESS;
if ( father)
sts = ((wb_tMethodAnteMove) (method))( (ldh_tSesContext)this, o.oid(), father.oid(),
father.cid());
foid = father.oid();
else
sts = ((wb_tMethodAnteMove) (method))( (ldh_tSesContext)this, o.oid(), pwr_cNObjid,
pwr_cNClassId);
foid = pwr_cNObjid;
if ( old_father)
old_foid = old_father.oid();
else
old_foid = pwr_cNObjid;
sts = ((wb_tMethodAnteMove) (method))( (ldh_tSesContext)this, o.oid(), foid,
old_foid);
return sts;
}
......@@ -501,7 +521,7 @@ pwr_tStatus wb_volume::triggAnteUnadopt( wb_object& father, wb_object& o)
wb_cdrep *cdrep = m_vrep->merep()->cdrep( &sts, father.cid());
if ( EVEN(sts)) return sts;
cdrep->dbCallBack( &sts, ldh_eDbCallBack_AnteCreate, &methodName, 0);
cdrep->dbCallBack( &sts, ldh_eDbCallBack_AnteAdopt, &methodName, 0);
delete cdrep;
if ( EVEN(sts)) return LDH__SUCCESS;
......
......@@ -87,7 +87,7 @@ public:
pwr_tStatus triggSyntaxCheck( wb_object& o, int *errorcount, int *warningcount);
pwr_tStatus triggAnteAdopt( wb_object& o, pwr_tCid cid);
pwr_tStatus triggAnteCreate( wb_object& father, pwr_tCid cid);
pwr_tStatus triggAnteMove( wb_object& o, wb_object& father);
pwr_tStatus triggAnteMove( wb_object& o, wb_object& father, wb_object& old_father);
pwr_tStatus triggAnteUnadopt( wb_object& father, wb_object& o);
pwr_tStatus triggPostAdopt( wb_object& father, wb_object& o);
pwr_tStatus triggPostCreate( wb_object& o);
......
......@@ -1121,6 +1121,11 @@ bool wb_vrepdb::exportDbody(wb_import &i)
return true;
}
bool wb_vrepdb::exportDocBlock(wb_import &i)
{
return false;
}
bool wb_vrepdb::exportMeta(wb_import &i)
{
return false;
......
......@@ -125,6 +125,8 @@ public:
virtual bool exportDbody(wb_import &e);
virtual bool exportDocBlock(wb_import &e);
virtual bool exportMeta(wb_import &e);
virtual bool exportTree(wb_treeimport &i, pwr_tOid oid) { return false;}
......
......@@ -66,8 +66,10 @@ wb_orep *wb_vrepdbs::object(pwr_tStatus *sts, pwr_tOid oid)
*sts = LDH__SUCCESS;
dbs_sObject *op = dbs_OidToObject(sts, dbsenv(), oid);
if (op == 0)
if (op == 0) {
*sts = LDH__NOSUCHOBJ;
return 0;
}
return new (this) wb_orepdbs(op);
}
......@@ -479,6 +481,11 @@ bool wb_vrepdbs::exportDbody(wb_import &i)
return true;
}
bool wb_vrepdbs::exportDocBlock(wb_import &i)
{
return false;
}
bool wb_vrepdbs::exportMeta(wb_import &i)
{
return false;
......
......@@ -131,6 +131,7 @@ public:
virtual bool exportHead(wb_import &e);
virtual bool exportRbody(wb_import &e);
virtual bool exportDbody(wb_import &e);
virtual bool exportDocBlock(wb_import &e);
virtual bool exportMeta(wb_import &e);
virtual bool exportTree(wb_treeimport &i, pwr_tOid oid);
bool wb_vrepdbs::exportTreeObject(wb_treeimport &i, dbs_sObject *op, bool isRoot);
......
This diff is collapsed.
......@@ -7,6 +7,8 @@
#include "wb_erep.h"
#include "wb_attrname.h"
#include "wb_treeimport.h"
#include "co_dbs.h"
#include "wb_import.h"
class wb_vrepmem;
......@@ -15,8 +17,8 @@ class mem_object
friend class wb_vrepmem;
public:
mem_object() : rbody_size(0), dbody_size(0), rbody(0), dbody(0),
m_cid(0), m_tid(0), fth(0), bws(0), fws(0), fch(0),
mem_object() : rbody_size(0), dbody_size(0), docblock_size(0), rbody(0), dbody(0),
docblock(0), m_cid(0), m_tid(0), fth(0), bws(0), fws(0), fch(0),
is_built(0)
{
strcpy( m_name, "");
......@@ -28,6 +30,7 @@ class mem_object
~mem_object() {
if ( rbody_size) free( rbody);
if ( dbody_size) free( dbody);
if ( docblock_size) free( docblock);
}
char *name() { return m_name; }
mem_object *get_lch() {
......@@ -41,6 +44,7 @@ class mem_object
bool exportHead(wb_import &i) { return false;}
bool exportDbody(wb_import &i) { return false;}
bool exportRbody(wb_import &i) { return false;}
bool exportDocBlock(wb_import &i) { return false;}
bool exportTree( wb_treeimport &i, bool isRoot) {
pwr_tOid fthoid = (fth && !isRoot) ? fth->m_oid : pwr_cNOid;
pwr_tOid bwsoid = (bws && !isRoot) ? bws->m_oid : pwr_cNOid;
......@@ -103,11 +107,45 @@ class mem_object
}
mem_object *find( wb_name *oname, int level);
bool docBlock( char **block, int *size) const {
switch ( m_cid) {
case pwr_eClass_ClassDef:
case pwr_eClass_Param:
case pwr_eClass_Intern:
case pwr_eClass_Input:
case pwr_eClass_Output:
case pwr_eClass_ObjXRef:
case pwr_eClass_AttrXRef:
break;
default:
return false;
}
if ( docblock) {
*block = (char *) malloc( docblock_size);
memcpy( *block, docblock, docblock_size);
*size = docblock_size;
}
else {
// Return nullstring
*block = (char *) calloc( 1, 1);
*size = 1;
}
return true;
}
bool docBlock( char *block) {
docblock_size = strlen(block) + 1;
docblock = (char *) malloc( docblock_size);
memcpy( docblock, block, docblock_size);
return true;
}
size_t rbody_size;
size_t dbody_size;
size_t docblock_size;
void *rbody;
void *dbody;
char *docblock;
pwr_tCid m_cid;
pwr_tTid m_tid;
pwr_tOid m_oid;
......@@ -118,19 +156,27 @@ class mem_object
mem_object *bws;
mem_object *fws;
mem_object *fch;
pwr_tOid fthoid;
pwr_tOid bwsoid;
pwr_tOid fwsoid;
pwr_tOid fchoid;
int is_built;
pwr_tTime time;
};
class wb_orepmem;
class wb_vrepmem : public wb_vrep
class wb_vrepmem : public wb_vrep, public wb_import
{
wb_erep *m_erep;
wb_merep *m_merep;
unsigned int m_nRef;
mem_object *root_object;
mem_object *volume_object;
int m_nextOix;
pwr_tVid m_source_vid;
char m_filename[200];
bool m_classeditor;
map<pwr_tOix, mem_object *> m_oix_list;
......@@ -138,7 +184,8 @@ class wb_vrepmem : public wb_vrep
public:
wb_vrepmem( wb_erep *erep) :
m_erep(erep), m_merep(erep->merep()), m_nRef(0), root_object(0), m_nextOix(0) {}
m_erep(erep), m_merep(erep->merep()), m_nRef(0), root_object(0),
volume_object(0), m_nextOix(0) {}
wb_vrepmem( wb_erep *erep, pwr_tVid vid);
~wb_vrepmem();
......@@ -215,8 +262,8 @@ public:
bool renameObject(pwr_tStatus *sts, wb_orep *orep, wb_name &name);
bool commit(pwr_tStatus *sts) {return true;}
bool abort(pwr_tStatus *sts) {return true;}
bool commit(pwr_tStatus *sts);
bool abort(pwr_tStatus *sts);
virtual bool writeAttribute(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, size_t offset, size_t size, void *p);
......@@ -255,6 +302,7 @@ public:
virtual bool exportHead(wb_import &i);
virtual bool exportRbody(wb_import &i);
virtual bool exportDbody(wb_import &i);
virtual bool exportDocBlock(wb_import &i);
virtual bool exportMeta(wb_import &i);
virtual bool exportTree(wb_treeimport &i, pwr_tOid oid);
bool exportPaste(wb_treeimport &i, pwr_tOid destination, ldh_eDest destcode, bool keepoid,
......@@ -274,6 +322,25 @@ public:
bool updateSubClass( wb_adrep *subattr, char *body, bool keepref);
virtual bool accessSupported( ldh_eAccess access) { return true;}
virtual bool importVolume(wb_export &e);
virtual bool importHead(pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, pwr_tOid aoid, pwr_tOid foid, pwr_tOid loid,
const char *name, const char *normname, pwr_mClassDef flags,
pwr_tTime ohTime, pwr_tTime rbTime, pwr_tTime dbTime,
size_t rbSize, size_t dbSize);
virtual bool importRbody(pwr_tOid oid, size_t size, void *body);
virtual bool importDbody(pwr_tOid oid, size_t size, void *body);
virtual bool importDocBlock(pwr_tOid oid, size_t size, char *block);
virtual bool importMeta(dbs_sEnv *ep) { return true;}
bool importBuildObject( mem_object *memo);
void loadWbl( char *filename, pwr_tStatus *sts);
void freeObject( mem_object *mem);
void clear();
bool classeditorCheck( ldh_eDest dest_code, mem_object *dest, pwr_tCid cid,
pwr_tOix *oix, char *name, pwr_tStatus *sts, bool import_paste);
bool classeditorCheckMove( mem_object *memo, ldh_eDest dest_code,
mem_object *dest, pwr_tStatus *sts);
private:
bool nameCheck( mem_object *memo);
bool nameCheck( mem_object *parent, char *name, ldh_eDest code);
......
......@@ -182,6 +182,14 @@ bool wb_vrepwbl::exportRbody(wb_import &i)
return false;
}
bool wb_vrepwbl::exportDocBlock(wb_import &i)
{
if ( root_object)
return root_object->exportDocBlock(i);
else
return false;
}
bool wb_vrepwbl::exportMeta(wb_import &i)
{
return false;
......@@ -586,13 +594,24 @@ int wb_vrepwbl::getTypeInfo( pwr_tTid tid, pwr_eType *type, size_t *size,
// Search type in other volumes
pwr_tStatus sts;
wb_tdrep *tdrep = m_merep->tdrep( &sts, tid);
if ( EVEN(sts)) return 0;
*type = tdrep->type();
*size = tdrep->size();
*elements = tdrep->nElement();
delete tdrep;
try {
wb_tdrep *tdrep = m_merep->tdrep( &sts, tid);
if ( EVEN(sts)) return 0;
*type = tdrep->type();
*size = tdrep->size();
*elements = tdrep->nElement();
delete tdrep;
} catch (wb_error& e) {
// Try cdrep
wb_cdrep *cdrep = m_merep->cdrep( &sts, tid);
if ( EVEN(sts)) return 0;
*type = (pwr_eType) cdrep->cid();
*size = cdrep->size( pwr_eBix_rt);
*elements = 1;
delete cdrep;
}
}
}
}
......@@ -748,10 +767,10 @@ int wb_vrepwbl::getAttrInfoRec( wb_attrname *attr, pwr_eBix bix, pwr_tCid cid, s
if ( bix != pwr_eBix_sys)
return 0;
IF_ATTR( Type, pwr_eType_UInt32, 1, level)
else IF_ATTR( Size, pwr_eType_Int32, 1, level)
else IF_ATTR( TypeRef, pwr_eType_TypeId, 1, level)
else IF_ATTR( Elements, pwr_eType_Int32, 1, level)
return 1;
else IF_ATTR( Size, pwr_eType_Int32, 1, level)
else IF_ATTR( TypeRef, pwr_eType_TypeId, 1, level)
else IF_ATTR( Elements, pwr_eType_Int32, 1, level)
return 1;
}
case pwr_eClass_ClassDef:
{
......@@ -760,11 +779,11 @@ int wb_vrepwbl::getAttrInfoRec( wb_attrname *attr, pwr_eBix bix, pwr_tCid cid, s
if ( bix != pwr_eBix_sys)
return 0;
IF_ATTR( Editor, pwr_eType_UInt32, 1, level)
else IF_ATTR( Method, pwr_eType_UInt32, 1, level)
else IF_ATTR( Flags, pwr_eType_UInt32, 1, level)
else IF_ATTR( NumOfObjBodies, pwr_eType_UInt32, 1, level)
else IF_ATTR( PopEditor, pwr_eType_UInt32, 1, level)
return 1;
else IF_ATTR( Method, pwr_eType_UInt32, 1, level)
else IF_ATTR( Flags, pwr_eType_UInt32, 1, level)
else IF_ATTR( NumOfObjBodies, pwr_eType_UInt32, 1, level)
else IF_ATTR( PopEditor, pwr_eType_UInt32, 1, level)
return 1;
}
case pwr_eClass_ClassVolume:
{
......@@ -773,14 +792,31 @@ int wb_vrepwbl::getAttrInfoRec( wb_attrname *attr, pwr_eBix bix, pwr_tCid cid, s
if ( bix != pwr_eBix_sys)
return 0;
IF_ATTR( Description, pwr_eType_String, 1, level)
else IF_ATTR( NextOix, pwr_eType_ObjectIx, 1, level)
else IF_ATTR( RtVersion, pwr_eType_UInt32, 1, level)
else IF_ATTR( RtCreTime, pwr_eType_Time, 1, level)
else IF_ATTR( RtCreator, pwr_eType_String, 1, level)
else IF_ATTR( RtCardinality, pwr_eType_UInt32, 1, level)
else IF_ATTR( RtBodySize, pwr_eType_UInt32, 1, level)
else IF_ATTR( NextCix, pwr_eType_ObjectIx, 1, level)
return 1;
else IF_ATTR( NextOix, pwr_eType_ObjectIx, 1, level)
else IF_ATTR( RtVersion, pwr_eType_UInt32, 1, level)
else IF_ATTR( RtCreTime, pwr_eType_Time, 1, level)
else IF_ATTR( RtCreator, pwr_eType_String, 1, level)
else IF_ATTR( RtCardinality, pwr_eType_UInt32, 1, level)
else IF_ATTR( RtBodySize, pwr_eType_UInt32, 1, level)
else IF_ATTR( NextCix, pwr_eType_ObjectIx, 1, level)
else if ( attr->attributeIsEqual( "NextTix", level)) {
if ( attr->hasAttrIndex()) {
*size = sizeof( o.NextTix[0]);
*offset = (unsigned long) &o.NextTix - (unsigned long) &o +
attr->attrIndex() * *size;
*tid = *type = pwr_eType_ObjectIx;
*elements = 1;
*flags = 0;
}
else {
*size = sizeof( o.NextTix);
*offset = (unsigned long) &o.NextTix - (unsigned long) &o;
*tid = *type = pwr_eType_ObjectIx;
*elements = sizeof(o.NextTix)/sizeof(o.NextTix[0]);
*flags = 0;
}
}
return 1;
}
case pwr_eClass_ClassHier:
case pwr_eClass_TypeHier:
......@@ -792,11 +828,11 @@ int wb_vrepwbl::getAttrInfoRec( wb_attrname *attr, pwr_eBix bix, pwr_tCid cid, s
if ( bix != pwr_eBix_sys)
return 0;
IF_ATTR( StructName, pwr_eType_String, 1, level)
else IF_ATTR( NumOfParams, pwr_eType_UInt32, 1, level)
else IF_ATTR( Size, pwr_eType_UInt32, 1, level)
else IF_ATTR( NextAix, pwr_eType_ObjectIx, 1, level)
else IF_ATTR( Flags, pwr_eType_Mask, 1, level)
return 1;
else IF_ATTR( NumOfParams, pwr_eType_UInt32, 1, level)
else IF_ATTR( Size, pwr_eType_UInt32, 1, level)
else IF_ATTR( NextAix, pwr_eType_ObjectIx, 1, level)
else IF_ATTR( Flags, pwr_eType_Mask, 1, level)
return 1;
}
case pwr_eClass_Param:
{
......
......@@ -185,6 +185,7 @@ public:
virtual bool exportHead(wb_import &i);
virtual bool exportRbody(wb_import &i);
virtual bool exportDbody(wb_import &i);
virtual bool exportDocBlock(wb_import &i);
virtual bool exportMeta(wb_import &i);
virtual bool exportTree(wb_treeimport &i, pwr_tOid oid);
virtual bool importTree(bool keepref) { return false;}
......
......@@ -186,6 +186,28 @@ int WAttNav::check_attr( int *multiline, brow_tObject *node,
*node = ((WItemObjectName *)base_item)->node;
break;
}
case wnav_eItemType_DocBlock:
{
static char block[10000];
char *p;
if ( !editmode)
return WATT__NOEDIT;
sts = ((WItemDocBlock *)base_item)->get_value( &p);
if ( ODD(sts)) {
strcpy( block, p);
free( p);
}
else
strcpy( name, "");
*init_value = block;
*multiline = 1;
*size = sizeof( block);
*node = ((WItemDocBlock *)base_item)->node;
break;
}
default:
*multiline = 0;
return WATT__ATTRNOEDIT;
......@@ -415,6 +437,7 @@ static int wattnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
(wattnav->change_value_cb)( wattnav->parent_ctx);
break;
case wnav_eItemType_ObjectName:
case wnav_eItemType_DocBlock:
if ( wattnav->advanced_user && wattnav->change_value_cb)
(wattnav->change_value_cb)( wattnav->parent_ctx);
break;
......@@ -690,6 +713,8 @@ int WAttNav::object_attr()
int input_cnt = 0;
int output_cnt = 0;
int elements;
char *block;
int size;
brow_SetNodraw( brow->ctx);
......@@ -852,6 +877,13 @@ int WAttNav::object_attr()
}
}
free((char *) bodydef);
sts = ldh_GetDocBlock( ldhses, objid, &block, &size);
if ( ODD(sts)) {
new WItemDocBlock( brow, ldhses, objid, block, size,
NULL, flow_eDest_IntoLast);
attr_exist = 1;
}
}
brow_ResetNodraw( brow->ctx);
brow_Redraw( brow->ctx, 0);
......@@ -1029,6 +1061,19 @@ int WAttNav::set_attr_value( brow_tObject node, char *name, char *value_str)
item->update();
return sts;
}
case wnav_eItemType_DocBlock:
{
WItemDocBlock *item = (WItemDocBlock *)base_item;
// Check that objid is still the same
if ( ! cdh_ObjidIsEqual( objid, base_item->objid))
return WATT__DISAPPEARD;
sts = ldh_SetDocBlock( ldhses, item->objid, value_str);
if ( EVEN(sts)) return sts;
item->update();
return sts;
}
default:
;
}
......
This diff is collapsed.
......@@ -34,6 +34,7 @@ tokens {
NUM_FLOAT;
INT;
OID;
DOCBLOCK;
}
EQ : '='
......@@ -51,11 +52,33 @@ WS : (' '
;
COMMENT
: "!"
(~'\n')* '\n'
: ("!" ( ' ' | '\t') (~'\n')* '\n'
| "!" '\n')
{ _ttype = antlr::Token::SKIP; newline(); }
;
DOCBLOCK
: "!/**"
( /* '\r' '\n' can be matched in one alternative or by matching
'\r' in one iteration and '\n' in another. I am trying to
handle any flavor of newline that comes in, but the language
that allows both "\r\n" and "\r" and "\n" to all be valid
newline is ambiguous. Consequently, the resulting grammar
must be ambiguous. I'm shutting this warning off.
*/
options {
generateAmbigWarnings=false;
}
:
{ LA(2)!='*' }? '!'
| '\r' '\n' {newline();}
| '\r' {newline();}
| '\n' {newline();}
| ~('!'|'\n'|'\r')
)*
"!*/"
;
INDEX
options {
paraphrase="an index";
......@@ -144,3 +167,14 @@ ESC : '\\'
protected
SWEC : '\345' | '\344' | '\366' | '\305' | '\304' | '\326';
......@@ -25,6 +25,7 @@ public:
public: void mOREQ(bool _createToken);
public: void mWS(bool _createToken);
public: void mCOMMENT(bool _createToken);
public: void mDOCBLOCK(bool _createToken);
public: void mINDEX(bool _createToken);
public: void mVALUE(bool _createToken);
protected: void mSWEC(bool _createToken);
......@@ -44,6 +45,8 @@ private:
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_3;
static const unsigned long _tokenSet_4_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_4;
static const unsigned long _tokenSet_5_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_5;
};
#endif /*INC_wb_wbllexer_hpp_*/
......@@ -241,6 +241,11 @@ static wbl_sSym attr_flags[] =
,{ "PWR_MASK_NOREMOVE", PWR_MASK_NOREMOVE }
,{ "PWR_MASK_RTDBREF", PWR_MASK_RTDBREF }
,{ "PWR_MASK_PRIVATE", PWR_MASK_PRIVATE }
,{ "PWR_MASK_CLASS", PWR_MASK_CLASS }
,{ "PWR_MASK_SUBCLASS", PWR_MASK_SUBCLASS }
,{ "PWR_MASK_BUFFER", PWR_MASK_BUFFER }
,{ "PWR_MASK_NOWBL", PWR_MASK_NOWBL }
,{ "PWR_MASK_ALWAYSWBL", PWR_MASK_ALWAYSWBL }
,{ "pwr_mClassDef_DevOnly", pwr_mClassDef_DevOnly }
,{ "pwr_mClassDef_System", pwr_mClassDef_System }
......@@ -520,6 +525,18 @@ void wb_wblnode::build( bool recursive)
o->ty.type = ((pwr_sTypeDef *)o->rbody)->Type;
o->ty.size = ((pwr_sTypeDef *)o->rbody)->Size;
o->ty.elements = ((pwr_sTypeDef *)o->rbody)->Elements;
if ( o->ty.type == 0) {
pwr_eType type;
size_t size;
int elements;
if ( !m_vrep->getTypeInfo( o->ty.tid, &type, &size, &elements)) {
m_vrep->error( "Can't find TypeDef type", getFileName(), line_number);
return;
}
o->ty.type = ((pwr_sTypeDef *)o->rbody)->Type = type;
o->ty.size = ((pwr_sTypeDef *)o->rbody)->Size = o->ty.elements * size;
}
}
else if ( isObjBodyDef()) {
}
......@@ -1145,7 +1162,7 @@ void wb_wblnode::buildBuffAttr( ref_wblnode object, pwr_eBix bix, pwr_tCid buffe
next_sibling->buildBuffAttr( object, bix, buffer_cid, buffer_offset, buffer_size);
}
void wb_wblnode::link( wb_vrepwbl *vol, ref_wblnode father)
void wb_wblnode::link( wb_vrepwbl *vol, ref_wblnode father, ref_wblnode parent_ast)
{
ref_wblnode first_child;
ref_wblnode next_sibling;
......@@ -1171,8 +1188,22 @@ void wb_wblnode::link( wb_vrepwbl *vol, ref_wblnode father)
next_sibling = getNextSibling();
if ( next_sibling)
next_sibling->link( vol, father);
next_sibling->link( vol, father, parent_ast);
// Link docblock, previous child to parent ast
if ( !parent_ast)
parent_ast = father;
if ( parent_ast) {
ref_wblnode prev = 0;
ref_wblnode child = parent_ast->getFirstChild();
while ( child && child != this) {
prev = child;
child = child->getNextSibling();
}
if ( prev && prev->getType() == tokens.DOCBLOCK)
o->docblock = prev;
}
// cout << "Linking " << name << endl;
break;
case tokens.SOBJECT:
......@@ -1185,7 +1216,7 @@ void wb_wblnode::link( wb_vrepwbl *vol, ref_wblnode father)
first_child = getFirstChild();
if ( first_child)
first_child->link( vol, snode);
first_child->link( vol, snode, this);
next_sibling = getNextSibling();
if ( next_sibling)
......@@ -1199,7 +1230,7 @@ void wb_wblnode::link( wb_vrepwbl *vol, ref_wblnode father)
next_sibling = getNextSibling();
if ( next_sibling)
next_sibling->link( vol, father);
next_sibling->link( vol, father, parent_ast);
}
}
......@@ -1209,6 +1240,10 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
m_vrep = vol;
switch ( getType()) {
case tokens.DOCBLOCK: {
string txt = getText();
break;
}
case tokens.OBJECT:
{
......@@ -1572,6 +1607,25 @@ bool wb_wblnode::exportRbody( wb_import &i)
return true;
}
bool wb_wblnode::exportDocBlock( wb_import &i)
{
char *block;
int size;
if ( o->docblock && docBlock( &block, &size)) {
i.importDocBlock( o->m_oid, size, block);
free( block);
}
if ( o->fch)
o->fch->exportDocBlock( i);
if ( o->fws)
o->fws->exportDocBlock( i);
return true;
}
bool wb_wblnode::exportTree( wb_treeimport &i, bool isRoot)
{
pwr_tOid fthoid = (o->fth && !isRoot) ? o->fth->o->m_oid : pwr_cNOid;
......@@ -1726,8 +1780,16 @@ int wb_wblnode::attrStringToValue( int type_id, char *value_str,
if ( m_vrep->getTypeInfo( value_str, &val_typeid, &type,
&size, &elements))
memcpy( buffer_ptr, (char *) &val_typeid, sizeof(val_typeid));
else
return 0;
else {
pwr_tClassId classid;
pwr_tObjid objid;
// Try classid
sts = m_vrep->nameToOid( value_str, &objid);
if (EVEN(sts)) return 0;
classid = cdh_ClassObjidToId( objid);
memcpy( buffer_ptr, (char *) &classid, sizeof(classid));
}
break;
}
case pwr_eType_ObjectIx:
......@@ -1790,3 +1852,69 @@ int wb_wblnode::attrStringToValue( int type_id, char *value_str,
}
return 1;
}
bool wb_wblnode::docBlock( char **block, int *size) const
{
switch ( o->m_cid) {
case pwr_eClass_ClassDef:
case pwr_eClass_Param:
case pwr_eClass_Intern:
case pwr_eClass_Input:
case pwr_eClass_Output:
case pwr_eClass_ObjXRef:
case pwr_eClass_AttrXRef:
break;
default:
return false;
}
if ( !o->docblock) {
// Return nullstring
*block = (char *) calloc( 1, 1);
*size = 1;
return true;
}
*size = strlen( o->docblock->getText().c_str()) + 1;
*block = (char *) calloc( 1, *size);
// strncpy( *block, o->docblock->getText().c_str(), *size);
// Remove first and last row, and the beginning ! on each row
char *s = (char *)o->docblock->getText().c_str();
char *t = *block;
char *start_t = t;
// Skip first line
while ( *s && *s != '\n')
s++;
s++;
// Skip leading '!'
bool skip = true;
while( *s) {
if ( t - start_t >= *size - 1)
break;
if ( *s == '!') {
skip = false;
s++;
// Skip first space also
if ( *s == ' ')
s++;
}
if ( !skip)
*t++ = *s;
if ( *s == '\n')
skip = true;
s++;
}
// Skip last line
while ( *t != '\n') {
if ( t <= start_t)
break;
t--;
}
*t = 0;
*size = t - start_t + 1;
return true;
}
......@@ -79,7 +79,7 @@ class wbl_attribute {
class wbl_object {
public:
wbl_object() : rbody_size(0), dbody_size(0), rbody(0), dbody(0),
m_cid(0), m_tid(0), fth(0), bws(0), fws(0), fch(0),
m_cid(0), m_tid(0), fth(0), bws(0), fws(0), fch(0), docblock(0),
is_built(0)
{
strcpy( cname, "");
......@@ -104,6 +104,7 @@ class wbl_object {
wb_wblnode *bws;
wb_wblnode *fws;
wb_wblnode *fch;
wb_wblnode *docblock;
int is_built;
wbl_class c;
......@@ -232,7 +233,7 @@ public:
int buffer_offset, int buffer_size);
void buildBuffAttr( ref_wblnode object, pwr_eBix bix, pwr_tCid buffer_cid,
size_t buffer_offset, size_t buffer_size);
void link( wb_vrepwbl *vol, ref_wblnode father_node);
void link( wb_vrepwbl *vol, ref_wblnode father_node, ref_wblnode parent_ast = 0);
void info_link( int level);
ref_wblnode find( wb_name *oname, int level);
ref_wblnode get_o_lch();
......@@ -245,25 +246,13 @@ public:
bool exportHead(wb_import &i);
bool exportDbody(wb_import &i);
bool exportRbody(wb_import &i);
bool exportDocBlock(wb_import &i);
bool exportTree(wb_treeimport &i, bool isRoot);
#if 0
void iterObject(wb_dbs *);
void iterRbody(wb_dbs *);
void iterDbody(wb_dbs *);
void iterObject( void *udata,
pwr_tStatus (*bc)(void *, pwr_tOid, pwr_tCid, pwr_tOid, pwr_tOid,
pwr_tOid, pwr_tOid, pwr_tOid, char *,
pwr_tTime, int, int));
void iterBody( void *udata,
pwr_tStatus (*bc)(void *, pwr_tOid, void *, void *));
#endif
static int lookup( int *type, const char *keyword, wbl_sSym *table);
static int convconst( int *val, char *str);
const char *name() { return getText().c_str();}
bool docBlock( char **block, int *size) const;
wbl_eNodeType node_type;
wb_vrepwbl *m_vrep;
......
This diff is collapsed.
......@@ -8,7 +8,7 @@ header {
header "post_include_hpp" {
extern int wblparser_error_cnt;
#This declarations should be moved inside parser class !!
# This declarations should be moved inside parser class in wb_wblparser.hpp !!
void reportError(const RecognitionException& ex);
}
header "post_include_cpp" {
......@@ -41,15 +41,15 @@ unit
;
volume
: VOLUME^ cid OID (body)* (object)* ENDVOLUME
: VOLUME^ cid OID (body)* ((DOCBLOCK)? object)* ENDVOLUME
;
sobject
: SOBJECT^ (object)* ENDSOBJECT
: SOBJECT^ ((DOCBLOCK)? object)* ENDSOBJECT
;
object
: OBJECT^ cid (oix)? (body)* (object)* ENDOBJECT
: OBJECT^ cid (oix)? (body)* ((DOCBLOCK)? object)* ENDOBJECT
;
body
......@@ -88,3 +88,7 @@ oname
......@@ -24,17 +24,18 @@ struct wb_wblparserTokenTypes {
NUM_FLOAT = 20,
INT = 21,
OID = 22,
EQ = 23,
OREQ = 24,
WS = 25,
COMMENT = 26,
INDEX = 27,
VALUE = 28,
CHAR_LITERAL = 29,
STRING_LITERAL = 30,
DIGITS = 31,
ESC = 32,
SWEC = 33,
DOCBLOCK = 23,
EQ = 24,
OREQ = 25,
WS = 26,
COMMENT = 27,
INDEX = 28,
VALUE = 29,
CHAR_LITERAL = 30,
STRING_LITERAL = 31,
DIGITS = 32,
ESC = 33,
SWEC = 34,
NULL_TREE_LOOKAHEAD = 3
};
};
......
......@@ -19,14 +19,15 @@ DATTRIBUTE=19
NUM_FLOAT=20
INT=21
OID=22
EQ=23
OREQ=24
WS=25
COMMENT=26
INDEX("an index")=27
VALUE("an identifer")=28
CHAR_LITERAL=29
STRING_LITERAL=30
DIGITS=31
ESC=32
SWEC=33
DOCBLOCK=23
EQ=24
OREQ=25
WS=26
COMMENT=27
INDEX("an index")=28
VALUE("an identifer")=29
CHAR_LITERAL=30
STRING_LITERAL=31
DIGITS=32
ESC=33
SWEC=34
This diff is collapsed.
This diff is collapsed.
......@@ -445,7 +445,7 @@ void wnav_attrvalue_to_string( ldh_tSesContext ldhses, int type_id, void *value
case pwr_eType_ClassId:
{
objid = cdh_ClassIdToObjid( *(pwr_tClassId *) value_ptr);
sts = ldh_ObjidToName( ldhses, objid, ldh_eName_Object,
sts = ldh_ObjidToName( ldhses, objid, ldh_eName_VolPath,
str, sizeof(str), len);
if (EVEN(sts))
{
......@@ -458,7 +458,7 @@ void wnav_attrvalue_to_string( ldh_tSesContext ldhses, int type_id, void *value
case pwr_eType_TypeId:
{
objid = cdh_TypeIdToObjid( *(pwr_tTypeId *) value_ptr);
sts = ldh_ObjidToName( ldhses, objid, ldh_eName_Object,
sts = ldh_ObjidToName( ldhses, objid, ldh_eName_VolPath,
str, sizeof(str), len);
if (EVEN(sts))
{
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment