mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0024863: CLang warnings -Wint-to-void-pointer-cast
Warning was fixed. Remarks were applied. - class VMap in Draw was removed - NCollection_DataMap is used to store objects - name of object is used to associate Tcl variable with the object - creation and changing of objects are correclty handled Redundant casts were removed. Initial value is restored if variable is protected. Tests for bug #24863 were added. Some test cases and tcl command "save" were improved. Useless using of upvar was removed.
This commit is contained in:
@@ -111,11 +111,6 @@ is
|
||||
|
||||
class Printer;
|
||||
|
||||
class VMap instantiates
|
||||
DataMap from TCollection(Integer,
|
||||
Drawable3D from Draw,
|
||||
MapIntegerHasher from TColStd);
|
||||
|
||||
class MapOfAsciiString instantiates IndexedMap from TCollection(AsciiString from TCollection,AsciiString from TCollection);
|
||||
|
||||
Load(theDI: out Interpretor from Draw;
|
||||
|
@@ -30,9 +30,10 @@
|
||||
#include <Draw_Grid.hxx>
|
||||
#include <Draw_Drawable3D.hxx>
|
||||
#include <Draw_SequenceOfDrawable3D.hxx>
|
||||
#include <Draw_VMap.hxx>
|
||||
#include <Draw_ProgressIndicator.hxx>
|
||||
|
||||
#include <NCollection_DataMap.hxx>
|
||||
|
||||
#include <ios>
|
||||
|
||||
#ifdef WNT
|
||||
@@ -60,7 +61,7 @@ extern Draw_Interpretor theCommands;
|
||||
// The Integer Value is the content of the TCl variable
|
||||
//===============================================
|
||||
|
||||
static Draw_VMap theVariables;
|
||||
static NCollection_DataMap<TCollection_AsciiString,Handle(Draw_Drawable3D)> theVariables;
|
||||
|
||||
//=======================================================================
|
||||
//function : FindVariable
|
||||
@@ -310,8 +311,9 @@ static Standard_Integer erase(Draw_Interpretor& di, Standard_Integer n, const ch
|
||||
|
||||
// sauvegarde des proteges visibles
|
||||
Draw_SequenceOfDrawable3D prot;
|
||||
for (i = 1; i <= theVariables.Extent(); i++) {
|
||||
const Handle(Draw_Drawable3D)& D = *((Handle(Draw_Drawable3D)*)&theVariables(i));
|
||||
NCollection_DataMap<TCollection_AsciiString,Handle(Draw_Drawable3D)>::Iterator aMapIt (theVariables);
|
||||
for (; aMapIt.More(); aMapIt.Next()) {
|
||||
const Handle(Draw_Drawable3D)& D = aMapIt.Value();
|
||||
if (!D.IsNull()) {
|
||||
if (D->Protected() && D->Visible())
|
||||
prot.Append(D);
|
||||
@@ -723,27 +725,21 @@ void Draw::Set(const Standard_CString name,
|
||||
}
|
||||
|
||||
// MKV 29.03.05
|
||||
#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
|
||||
static char* tracevar(ClientData CD, Tcl_Interp*,const char*,const char*, Standard_Integer)
|
||||
#else
|
||||
static char* tracevar(ClientData CD, Tcl_Interp*, char*, char*, Standard_Integer)
|
||||
#endif
|
||||
static char* tracevar(ClientData, Tcl_Interp*,const char* name,const char*, Standard_Integer)
|
||||
{
|
||||
// protect if the map was destroyed before the interpretor
|
||||
if (theVariables.IsEmpty()) return NULL;
|
||||
|
||||
// MKV 29.03.05
|
||||
#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
|
||||
Handle(Draw_Drawable3D)& D = *((Handle(Draw_Drawable3D)*)&theVariables((long)CD));
|
||||
#else
|
||||
Standard_Integer index = (Standard_Integer) CD;
|
||||
Handle(Draw_Drawable3D)& D = *((Handle(Draw_Drawable3D)*)&theVariables(index));
|
||||
#endif
|
||||
if (D.IsNull())
|
||||
Handle(Draw_Drawable3D)& D = theVariables(name);
|
||||
if (D.IsNull()) {
|
||||
theVariables.UnBind(name);
|
||||
return NULL;
|
||||
if (D->Protected())
|
||||
}
|
||||
if (D->Protected()) {
|
||||
D->Name(Tcl_SetVar(theCommands.Interp(),name,name,0));
|
||||
return (char*) "variable is protected";
|
||||
else {
|
||||
} else {
|
||||
Tcl_UntraceVar(theCommands.Interp(),name,TCL_TRACE_UNSETS | TCL_TRACE_WRITES,tracevar,NULL);
|
||||
if (D->Visible()) {
|
||||
dout.RemoveDrawable(D);
|
||||
if (D->Is3D())
|
||||
@@ -752,6 +748,7 @@ static char* tracevar(ClientData CD, Tcl_Interp*, char*, char*, Standard_Integer
|
||||
repaint2d = Standard_True;
|
||||
}
|
||||
D.Nullify();
|
||||
theVariables.UnBind(name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -771,28 +768,27 @@ void Draw::Set(const Standard_CString name,
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Tcl_UnsetVar(theCommands.Interp(),name,0);
|
||||
if (theVariables.IsBound(name)) {
|
||||
if (theVariables(name)->Protected()) {
|
||||
cout << "variable is protected" << endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!D.IsNull()) {
|
||||
Standard_Integer ival = theVariables.Extent() + 1;
|
||||
theVariables.Bind(ival,D);
|
||||
Tcl_UnsetVar(theCommands.Interp(),name,0);
|
||||
theVariables.Bind(name,D);
|
||||
// MKV 29.03.05
|
||||
#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
|
||||
D->Name(Tcl_SetVar(theCommands.Interp(),name,name,0));
|
||||
#else
|
||||
D->Name(Tcl_SetVar(theCommands.Interp(),(char*)name,(char*)name,0));
|
||||
#endif
|
||||
|
||||
// set the trace function
|
||||
Tcl_TraceVar(theCommands.Interp(),name,TCL_TRACE_UNSETS,
|
||||
tracevar,(ClientData)ival);
|
||||
|
||||
Tcl_TraceVar(theCommands.Interp(),name,TCL_TRACE_UNSETS | TCL_TRACE_WRITES,tracevar,NULL);
|
||||
if (displ) {
|
||||
if (!D->Visible())
|
||||
dout << D;
|
||||
}
|
||||
else if (D->Visible())
|
||||
dout.RemoveDrawable(D);
|
||||
} else {
|
||||
Tcl_UnsetVar(theCommands.Interp(),name,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -823,11 +819,6 @@ void Draw::Set(const Standard_CString Name, const Standard_Real val)
|
||||
Handle(Draw_Drawable3D) Draw::Get(Standard_CString& name,
|
||||
const Standard_Boolean )
|
||||
{
|
||||
#if !((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) || defined(USE_NON_CONST)
|
||||
Standard_PCharacter pName;
|
||||
pName=(Standard_PCharacter)name;
|
||||
#endif
|
||||
//
|
||||
Standard_Boolean pick = ((name[0] == '.') && (name[1] == '\0'));
|
||||
Handle(Draw_Drawable3D) D;
|
||||
if (pick) {
|
||||
@@ -843,21 +834,7 @@ Handle(Draw_Drawable3D) Draw::Get(Standard_CString& name,
|
||||
}
|
||||
else {
|
||||
// MKV 29.03.05
|
||||
#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
|
||||
Standard_Address index =
|
||||
Tcl_VarTraceInfo(theCommands.Interp(),name,TCL_TRACE_UNSETS,
|
||||
tracevar, NULL);
|
||||
if (index != 0)
|
||||
D = Handle(Draw_Drawable3D)::DownCast(theVariables((long)index));
|
||||
#else
|
||||
Standard_Integer index = (Standard_Integer)
|
||||
Tcl_VarTraceInfo(theCommands.Interp(),
|
||||
pName,
|
||||
TCL_TRACE_UNSETS,
|
||||
tracevar, NULL);
|
||||
if (index != 0)
|
||||
D = Handle(Draw_Drawable3D)::DownCast(theVariables(index));
|
||||
#endif
|
||||
theVariables.Find(name,D);
|
||||
#if 0
|
||||
if (D.IsNull() && complain)
|
||||
cout <<name<<" does not exist"<<endl;
|
||||
|
@@ -267,10 +267,9 @@ help datadir {datadir [directory]} "DRAW Variables management"
|
||||
|
||||
proc save {name {file ""}} {
|
||||
if {$file == ""} {set file $name}
|
||||
upvar $name n
|
||||
if {![isdraw n]} {error "save : $name is not a Draw variable"}
|
||||
if {![isdraw $name]} {error "save : $name is not a Draw variable"}
|
||||
global Draw_DataDir
|
||||
bsave n [file join $Draw_DataDir $file]
|
||||
bsave $name [file join $Draw_DataDir $file]
|
||||
return [file join $Draw_DataDir $file]
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user