Skip to content

Commit c52af0a

Browse files
committed
cherry-pick Disney internal changes:
-- fix rad) function documentation type -- Add ability to register function stats and query them. also allow querying sizes. -- remove commented bison/flex stuff -- fixes SEEXPR-166: crashes occurring when editing numeric vector values -- fix duplicate header includes between v1 and v2
1 parent 36ffb81 commit c52af0a

File tree

6 files changed

+60
-64
lines changed

6 files changed

+60
-64
lines changed

src/SeExpr/CMakeLists.txt

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -16,67 +16,8 @@
1616

1717
FILE(GLOB io_cpp "*.cpp")
1818

19-
20-
## find our parser generators
21-
#find_program(BISON_EXE bison)
22-
#find_program(FLEX_EXE flex)
23-
#find_program(SED_EXE sed)
24-
#
25-
#if((BISON_EXE STREQUAL "BISON_EXE-NOTFOUND") OR (FLEX_EXE STREQUAL "FLEX_EXE-NOTFOUND") OR (SED_EXE STREQUAL "SED_EXE-NOTFOUND"))
26-
# # don't have flex/bison/sed, use pregenerated versions
27-
# set (parser_cpp generated/SeExprParser.cpp generated/SeExprParserLex.cpp )
28-
#else ((BISON_EXE STREQUAL "BISON_EXE-NOTFOUND") OR (FLEX_EXE STREQUAL "FLEX_EXE-NOTFOUND") OR (SED_EXE STREQUAL "SED_EXE-NOTFOUND"))
29-
# ## build the parser from the flex/yacc sources
30-
#
31-
# ADD_CUSTOM_COMMAND(
32-
# SOURCE "SeExprParserLex.l"
33-
# COMMAND "flex"
34-
# ARGS "-oSeExprParserLexIn.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/SeExprParserLex.l"
35-
# OUTPUT SeExprParserLexIn.cpp
36-
# DEPENDS SeExprParserLex.l
37-
# )
38-
#
39-
# ADD_CUSTOM_COMMAND(
40-
# SOURCE "SeExprParserLexIn.cpp"
41-
# COMMAND "sed"
42-
## ARGS -e "'s/SeExprwrap(n)/SeExprwrap()/g'" -e "'s/yy/SeExpr/g'" -e "'s/YY/SeExprYY/g'" SeExprParserLexIn.cpp | tee SeExprParserLex.cpp ${CMAKE_CURRENT_SOURCE_DIR}/generated/SeExprParserLex.cpp > /dev/null
43-
# ARGS -e "'s/SeExprwrap(n)/SeExprwrap()/g'" -e "'s/yy/SeExpr/g'" -e "'s/YY/SeExprYY/g'" SeExprParserLexIn.cpp | tee SeExprParserLex.cpp ${CMAKE_CURRENT_SOURCE_DIR}/generated/SeExprParserLex.cpp > /dev/null
44-
# OUTPUT SeExprParserLex.cpp
45-
# DEPENDS SeExprParserLexIn.cpp
46-
# )
47-
#
48-
# ADD_CUSTOM_COMMAND(
49-
# SOURCE "SeExprParser.y"
50-
# COMMAND "bison"
51-
# ARGS "--defines" "--verbose" "--fixed-output-files" "-p" "SeExpr" "${CMAKE_CURRENT_SOURCE_DIR}/SeExprParser.y"
52-
# OUTPUT y.tab.c y.tab.h
53-
# DEPENDS SeExprParser.y
54-
# )
55-
#
56-
# ADD_CUSTOM_COMMAND(
57-
# SOURCE "y.tab.h"
58-
# COMMAND "sed"
59-
# ARGS -e "'s/yy/SeExpr/g'" -e "'s/YY/SeExprYY/g'" y.tab.h | tee SeExprParser.tab.h ${CMAKE_CURRENT_SOURCE_DIR}/generated/SeExprParser.tab.h > /dev/null
60-
# OUTPUT SeExprParser.tab.h
61-
# DEPENDS y.tab.h
62-
# )
63-
#
64-
# ADD_CUSTOM_COMMAND(
65-
# SOURCE "y.tab.c"
66-
# COMMAND "sed"
67-
# ARGS -e "'s/yy/SeExpr/g'" -e "'s/YY/SeExprYY/g'" y.tab.c | tee SeExprParser.cpp "${CMAKE_CURRENT_SOURCE_DIR}/generated/SeExprParser.cpp" > /dev/null
68-
# OUTPUT SeExprParser.cpp
69-
# DEPENDS y.tab.c SeExprParser.tab.h
70-
# )
71-
#
72-
# ## set build files
73-
# set (parser_cpp SeExprParser.cpp SeExprParserLex.cpp )
74-
#
75-
#endif( (BISON_EXE STREQUAL "BISON_EXE-NOTFOUND") OR (FLEX_EXE STREQUAL "FLEX_EXE-NOTFOUND") OR (SED_EXE STREQUAL "SED_EXE-NOTFOUND"))
76-
7719
BuildParserScanner(SeExprParserLex SeExprParser SeExpr parser_cpp)
7820

79-
8021
## Make the SeExpr library
8122
ADD_LIBRARY (SeExpr SHARED ${io_cpp} ${core_cpp} ${parser_cpp})
8223
ADD_LIBRARY (SeExpr-static ${io_cpp} ${core_cpp} ${parser_cpp})

src/SeExpr/SeCurve.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
* You may obtain a copy of the License at
1515
* http://www.apache.org/licenses/LICENSE-2.0
1616
*/
17-
#ifndef _CurveData_h_
18-
#define _CurveData_h_
17+
#pragma once
1918

2019
#include "SeVec3d.h"
2120
#include <vector>
@@ -88,4 +87,3 @@ class SeCurve
8887
};
8988

9089
}
91-
#endif

src/SeExpr/SeExprBuiltins.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static const char* fabs_docstring="float abs(float x)\nabsolute value of x";
3636

3737
// angle conversion functions
3838
static const char* deg_docstring="float deg(float angle)\nradians to degrees";
39-
static const char* rad_docstring="float deg(float angle)\ndegrees to radians";
39+
static const char* rad_docstring="float rad(float angle)\ndegrees to radians";
4040
// trig in degrees
4141
static const char* cosd_docstring="float cosd(float angle)\ncosine in degrees";
4242
static const char* sind_docstring="float sind(float angle)\nsine in degrees";

src/SeExpr/SeExprFunc.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,32 @@ namespace {
6565
void initIfNeeded();
6666
void initBuiltins();
6767

68+
69+
size_t sizeInBytes() const{
70+
size_t totalSize=0;
71+
for(FuncMap::const_iterator it=funcmap.begin();it!=funcmap.end();++it){
72+
totalSize+=it->first.size()+sizeof(FuncMapItem);
73+
const SeExprFunc& function=it->second.second;
74+
if(function.type()==SeExprFunc::FUNCX){
75+
totalSize+=function.funcx()->sizeInBytes();
76+
}
77+
}
78+
return totalSize;
79+
}
80+
81+
SeStatistics statistics() const{
82+
SeStatistics statisticsDump;
83+
size_t totalSize=0;
84+
for(FuncMap::const_iterator it=funcmap.begin();it!=funcmap.end();++it){
85+
totalSize+=it->first.size()+sizeof(FuncMapItem);
86+
const SeExprFunc& function=it->second.second;
87+
if(function.type()==SeExprFunc::FUNCX){
88+
function.funcx()->statistics(statisticsDump);
89+
}
90+
}
91+
return statisticsDump;
92+
}
93+
6894
void getFunctionNames(std::vector<std::string>& names)
6995
{
7096
for(FuncMap::iterator i=funcmap.begin();i!=funcmap.end();++i)
@@ -190,6 +216,19 @@ SeExprFunc::getDocString(const char* functionName)
190216
return ret;
191217
}
192218

219+
size_t
220+
SeExprFunc::sizeInBytes(){
221+
SeExprInternal::AutoMutex locker(mutex);
222+
Functions.initIfNeeded();
223+
return Functions.sizeInBytes();
224+
}
225+
226+
SeStatistics SeExprFunc::statistics() {
227+
SeExprInternal::AutoMutex locker(mutex);
228+
Functions.initIfNeeded();
229+
return Functions.statistics();
230+
}
231+
193232
#ifndef SEEXPR_WIN32
194233

195234
#if defined(__APPLE__) && !defined(__MAC_10_9)

src/SeExpr/SeExprFunc.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@
1919

2020
#include "SeVec3d.h"
2121
#include <vector>
22+
#include <map>
2223

2324
class SeExpression;
2425
class SeExprFuncNode;
2526

27+
/// SeStatistics
28+
typedef std::map<std::string,double> SeStatistics;
29+
2630
//! Extension function spec, used for complicated argument custom functions.
2731
/** Provides the ability to handle all argument type checking and processing manually.
2832
Derive from this class and then make your own SeExprFunc that takes this object.
@@ -49,6 +53,13 @@ class SeExprFuncX {
4953
virtual ~SeExprFuncX(){}
5054

5155
bool isThreadSafe() const {return _threadSafe;}
56+
57+
/// Return memory usage of a funcX in bytes.
58+
virtual size_t sizeInBytes() const {return 0;}
59+
60+
/// Give this function a chance to populate its statistics
61+
virtual void statistics(SeStatistics& /*statistics*/) const {}
62+
5263
private:
5364
bool _threadSafe;
5465
};
@@ -96,6 +107,13 @@ class SeExprFunc {
96107
//! Get doc string for a specific function
97108
static std::string getDocString(const char* functionName);
98109

110+
//! Get the total size estimate of all plugins
111+
static size_t sizeInBytes();
112+
113+
//! Dump statistics
114+
static SeStatistics statistics();
115+
116+
99117
typedef double Func0();
100118
typedef double Func1(double);
101119
typedef double Func2(double, double);

src/SeExprEditor/SeExprEdControl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ void SeExprEdNumberControl::setValue(float value)
383383
}
384384

385385
SeExprEdVectorControl::SeExprEdVectorControl(int id,SeExprEdVectorEditable* editable)
386-
:SeExprEdControl(id,editable,true),_numberEditable(editable)
386+
:SeExprEdControl(id,editable,true),_numberEditable(editable),_swatch(0)
387387
{
388388

389389
if(_numberEditable->isColor){

0 commit comments

Comments
 (0)