Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
85abf746
Commit
85abf746
authored
Nov 22, 2018
by
Christoffer Ackelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backported unique_ptr from C++11.
parent
17c471c9
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
271 additions
and
185 deletions
+271
-185
sev/exe/sev_xtt/src/xtt_tbl_command.cpp
sev/exe/sev_xtt/src/xtt_tbl_command.cpp
+6
-2
src/lib/co/src/co_smart_ptr.h
src/lib/co/src/co_smart_ptr.h
+167
-0
xtt/lib/flow/qt/flow_draw_qt.cqt
xtt/lib/flow/qt/flow_draw_qt.cqt
+36
-71
xtt/lib/flow/qt/flow_draw_qt.h
xtt/lib/flow/qt/flow_draw_qt.h
+3
-4
xtt/lib/glow/qt/glow_draw_qt.cqt
xtt/lib/glow/qt/glow_draw_qt.cqt
+54
-103
xtt/lib/glow/qt/glow_draw_qt.h
xtt/lib/glow/qt/glow_draw_qt.h
+5
-5
No files found.
sev/exe/sev_xtt/src/xtt_tbl_command.cpp
View file @
85abf746
...
...
@@ -465,7 +465,9 @@ int XttTbl::command(char* input_str)
/* Read command file */
sts
=
readcmdfile
(
&
command
[
1
]);
if
(
sts
==
DCLI__NOFILE
)
{
message
(
'E'
,
"Unable to open file"
);
char
tmp
[
200
];
snprintf
(
tmp
,
200
,
"Unable to open file
\"
%s
\"
"
,
&
command
[
1
]);
message
(
'E'
,
tmp
);
return
DCLI__SUCCESS
;
}
else
if
(
EVEN
(
sts
))
return
sts
;
...
...
@@ -486,7 +488,9 @@ int XttTbl::command(char* input_str)
/* Read command file */
sts
=
readcmdfile
(
&
symbol_value
[
1
]);
if
(
sts
==
DCLI__NOFILE
)
{
message
(
'E'
,
"Unable to open file"
);
char
tmp
[
200
];
snprintf
(
tmp
,
200
,
"Unable to open file
\"
%s
\"
"
,
&
symbol_value
[
1
]);
message
(
'E'
,
tmp
);
return
DCLI__SUCCESS
;
}
else
if
(
EVEN
(
sts
))
return
sts
;
...
...
src/lib/co/src/co_smart_ptr.h
0 → 100644
View file @
85abf746
#ifndef CO_UNIQUE_PTR
#define CO_UNIQUE_PTR
#include "co_debug.h"
// std::remove_reference
template
<
typename
T
>
struct
remove_reference
{
typedef
T
type
;
};
template
<
typename
T
>
struct
remove_reference
<
T
&>
{
typedef
T
type
;
};
template
<
typename
T
>
struct
remove_reference
<
T
&&>
{
typedef
T
type
;
};
// std::forward
template
<
typename
T
>
T
&&
forward
(
typename
remove_reference
<
T
>::
type
&
x
)
{
return
static_cast
<
T
&&>
(
x
);
}
template
<
typename
T
>
T
&&
forward
(
typename
remove_reference
<
T
>::
type
&&
x
)
{
return
static_cast
<
T
&&>
(
x
);
}
// std::move
template
<
typename
T
>
typename
remove_reference
<
T
>::
type
&&
move
(
T
&&
x
)
{
return
((
typename
remove_reference
<
T
>::
type
&&
)
x
);
}
template
<
typename
T
>
class
default_delete
{
public:
void
operator
()(
T
*
ptr
)
const
{
delete
ptr
;
}
};
template
<
typename
T
>
class
default_delete
<
T
[]
>
{
public:
void
operator
()(
T
*
ptr
)
const
{
delete
[]
ptr
;
}
};
// std::unique_ptr for single objects -> free memory with 'delete'
template
<
typename
T
,
typename
Deleter
=
default_delete
<
T
>
>
class
unique_ptr
{
public:
typedef
unique_ptr
<
T
,
Deleter
>
this_type
;
unique_ptr
(
T
*
p
)
:
value
(
p
)
{
}
unique_ptr
(
T
*
p
,
Deleter
d
)
:
value
(
p
),
del
(
d
)
{
}
unique_ptr
(
this_type
&&
x
)
:
value
(
x
.
release
()),
del
(
forward
<
Deleter
>
(
x
.
get_deleter
()))
{
}
this_type
&
operator
=
(
this_type
&&
x
)
{
reset
(
x
.
release
());
del
=
move
(
forward
<
Deleter
>
(
x
.
get_deleter
()));
return
*
this
;
}
~
unique_ptr
()
{
reset
();
}
void
reset
(
T
*
p
=
NULL
)
{
if
(
p
!=
value
)
{
get_deleter
()(
value
);
value
=
p
;
}
}
T
*
release
()
{
T
*
const
tmp
=
value
;
value
=
NULL
;
return
tmp
;
}
T
&
operator
*
()
const
{
return
*
value
;
}
T
*
operator
->
()
const
{
return
value
;
}
T
*
get
()
const
{
return
value
;
}
Deleter
&
get_deleter
()
{
return
del
;
}
const
Deleter
&
get_deleter
()
const
{
return
del
;
}
protected:
T
*
value
;
Deleter
del
;
unique_ptr
(
const
this_type
&
);
unique_ptr
&
operator
=
(
const
this_type
&
);
unique_ptr
&
operator
=
(
T
*
p
);
};
// std::unique_ptr for arrays -> free memory with 'delete[]'
template
<
typename
T
,
typename
Deleter
>
class
unique_ptr
<
T
[],
Deleter
>
{
public:
typedef
unique_ptr
<
T
[],
Deleter
>
this_type
;
unique_ptr
(
T
*
p
,
Deleter
d
=
default_delete
<
T
[]
>
())
:
value
(
p
),
del
(
d
)
{
}
unique_ptr
(
this_type
&&
x
)
:
value
(
x
.
release
()),
del
(
forward
<
Deleter
>
(
x
.
get_deleter
()))
{
}
this_type
&
operator
=
(
this_type
&&
x
)
{
reset
(
x
.
release
());
del
=
move
(
forward
<
Deleter
>
(
x
.
get_deleter
()));
return
*
this
;
}
~
unique_ptr
()
{
reset
();
}
void
reset
(
T
*
p
=
NULL
)
{
if
(
p
!=
value
)
{
get_deleter
()(
value
);
value
=
p
;
}
}
T
*
release
()
{
T
*
const
tmp
=
value
;
value
=
NULL
;
return
tmp
;
}
T
&
operator
[](
int
i
)
const
{
return
value
[
i
];
}
T
*
get
()
const
{
return
value
;
}
Deleter
&
get_deleter
()
{
return
del
;
}
const
Deleter
&
get_deleter
()
const
{
return
del
;
}
protected:
T
*
value
;
Deleter
del
;
unique_ptr
(
const
this_type
&
);
unique_ptr
&
operator
=
(
const
this_type
&
);
unique_ptr
&
operator
=
(
T
*
p
);
};
#endif
\ No newline at end of file
xtt/lib/flow/qt/flow_draw_qt.cqt
View file @
85abf746
This diff is collapsed.
Click to expand it.
xtt/lib/flow/qt/flow_draw_qt.h
View file @
85abf746
...
...
@@ -37,6 +37,8 @@
#ifndef flow_draw_qt_h
#define flow_draw_qt_h
#include "co_smart_ptr.h"
#include "flow_draw.h"
#include <QColor>
...
...
@@ -205,9 +207,6 @@ public:
void
set_click_sensitivity
(
FlowCtx
*
ctx
,
int
value
);
void
set_image_clip_mask
(
QPainter
*
painter
,
flow_tPixmap
pixmap
,
int
x
,
int
y
);
void
set_white_background
(
FlowCtx
*
ctx
);
int
image_get_width
(
flow_tImImage
image
);
...
...
@@ -233,7 +232,7 @@ public:
void
*
flow_ctx
,
int
page_border
,
int
*
sts
);
private:
QPainter
*
get_painter
(
int
painter_type
,
int
size
,
bool
nav
=
false
);
unique_ptr
<
QPainter
>
get_painter
(
int
painter_type
,
int
size
,
bool
nav
=
false
);
int
rect_helper
(
FlowCtx
*
ctx
,
int
painter_type
,
int
size
,
int
x
,
int
y
,
int
width
,
int
height
,
bool
nav
=
false
,
bool
fill
=
false
);
...
...
xtt/lib/glow/qt/glow_draw_qt.cqt
View file @
85abf746
This diff is collapsed.
Click to expand it.
xtt/lib/glow/qt/glow_draw_qt.h
View file @
85abf746
...
...
@@ -37,7 +37,7 @@
#ifndef glow_draw_qt_h
#define glow_draw_qt_h
#include
<stack>
#include
"co_smart_ptr.h"
#include "glow_customcolors.h"
#include "glow_draw.h"
...
...
@@ -175,7 +175,7 @@ public:
int
pixmap_height
);
virtual
void
reset_background
(
GlowWind
*
w
);
virtual
void
set_image_clip_mask
(
QPainter
*
painter
,
glow_tPixmap
pixmap
,
int
x
,
int
y
);
unique_ptr
<
QPainter
>&
painter
,
glow_tPixmap
pixmap
,
int
x
,
int
y
);
virtual
int
set_clip_rectangle
(
GlowWind
*
w
,
int
ll_x
,
int
ll_y
,
int
ur_x
,
int
ur_y
);
...
...
@@ -192,13 +192,13 @@ public:
virtual
void
buffer_background
(
DrawWind
*
w
,
GlowCtx
*
cctx
);
virtual
int
print
(
char
*
filename
,
double
x0
,
double
x1
,
int
end
);
virtual
int
export_image
(
char
*
filename
);
void
set_clip
(
DrawWind
*
w
,
QPainter
*
painter
);
void
set_clip
(
DrawWind
*
w
,
unique_ptr
<
QPainter
>&
painter
);
virtual
void
set_timer
(
GlowCtx
*
ctx
,
int
time_ms
,
void
(
*
callback_func
)(
GlowCtx
*
ctx
),
void
**
id
);
virtual
void
remove_timer
(
void
*
id
);
int
init_nav
(
QWidget
*
nav_widget
);
QPoint
*
points_to_qt_points
(
glow_sPointX
*
points
,
int
point_cnt
);
QPoint
*
points_to_qt_points_curve
(
unique_ptr
<
QPoint
[]
>
points_to_qt_points
(
glow_sPointX
*
points
,
int
point_cnt
);
unique_ptr
<
QPoint
[]
>
points_to_qt_points_curve
(
GlowWind
*
w
,
glow_sPointX
*
points
,
int
point_cnt
,
int
*
cnt
);
int
image_get_width
(
glow_tImImage
image
);
int
image_get_height
(
glow_tImImage
image
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment