Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cppdap
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
cppdap
Commits
c9630a9a
Commit
c9630a9a
authored
Jun 11, 2020
by
Ben Clayton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TypeOf: Move Move TypeInfos to anon namespace
Instead of constructing them as static fields. Slightly less cludgy. Related issue: #40
parent
ed0af8fa
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
35 deletions
+38
-35
typeof.cpp
src/typeof.cpp
+38
-35
No files found.
src/typeof.cpp
View file @
c9630a9a
...
@@ -14,55 +14,58 @@
...
@@ -14,55 +14,58 @@
#include "dap/typeof.h"
#include "dap/typeof.h"
namespace
{
struct
NullTI
:
public
dap
::
TypeInfo
{
using
null
=
dap
::
null
;
inline
std
::
string
name
()
const
{
return
"null"
;
}
inline
size_t
size
()
const
{
return
sizeof
(
null
);
}
inline
size_t
alignment
()
const
{
return
alignof
(
null
);
}
inline
void
construct
(
void
*
ptr
)
const
{
new
(
ptr
)
null
();
}
inline
void
copyConstruct
(
void
*
dst
,
const
void
*
src
)
const
{
new
(
dst
)
null
(
*
reinterpret_cast
<
const
null
*>
(
src
));
}
inline
void
destruct
(
void
*
ptr
)
const
{
reinterpret_cast
<
null
*>
(
ptr
)
->~
null
();
}
inline
bool
deserialize
(
const
dap
::
Deserializer
*
,
void
*
)
const
{
return
true
;
}
inline
bool
serialize
(
dap
::
Serializer
*
,
const
void
*
)
const
{
return
true
;
}
};
static
dap
::
BasicTypeInfo
<
dap
::
boolean
>
booleanTI
(
"boolean"
);
static
dap
::
BasicTypeInfo
<
dap
::
string
>
stringTI
(
"string"
);
static
dap
::
BasicTypeInfo
<
dap
::
integer
>
integerTI
(
"integer"
);
static
dap
::
BasicTypeInfo
<
dap
::
number
>
numberTI
(
"number"
);
static
dap
::
BasicTypeInfo
<
dap
::
object
>
objectTI
(
"object"
);
static
dap
::
BasicTypeInfo
<
dap
::
any
>
anyTI
(
"any"
);
static
NullTI
nullTI
;
}
// namespace
namespace
dap
{
namespace
dap
{
const
TypeInfo
*
TypeOf
<
boolean
>::
type
()
{
const
TypeInfo
*
TypeOf
<
boolean
>::
type
()
{
static
BasicTypeInfo
<
boolean
>
typeinfo
(
"boolean"
);
return
&
booleanTI
;
return
&
typeinfo
;
}
}
const
TypeInfo
*
TypeOf
<
string
>::
type
()
{
const
TypeInfo
*
TypeOf
<
string
>::
type
()
{
static
BasicTypeInfo
<
string
>
typeinfo
(
"string"
);
return
&
stringTI
;
return
&
typeinfo
;
}
}
const
TypeInfo
*
TypeOf
<
integer
>::
type
()
{
const
TypeInfo
*
TypeOf
<
integer
>::
type
()
{
static
BasicTypeInfo
<
integer
>
typeinfo
(
"integer"
);
return
&
integerTI
;
return
&
typeinfo
;
}
}
const
TypeInfo
*
TypeOf
<
number
>::
type
()
{
const
TypeInfo
*
TypeOf
<
number
>::
type
()
{
static
BasicTypeInfo
<
number
>
typeinfo
(
"number"
);
return
&
numberTI
;
return
&
typeinfo
;
}
}
const
TypeInfo
*
TypeOf
<
object
>::
type
()
{
const
TypeInfo
*
TypeOf
<
object
>::
type
()
{
static
BasicTypeInfo
<
object
>
typeinfo
(
"object"
);
return
&
objectTI
;
return
&
typeinfo
;
}
}
const
TypeInfo
*
TypeOf
<
any
>::
type
()
{
const
TypeInfo
*
TypeOf
<
any
>::
type
()
{
static
BasicTypeInfo
<
any
>
typeinfo
(
"any"
);
return
&
anyTI
;
return
&
typeinfo
;
}
}
const
TypeInfo
*
TypeOf
<
null
>::
type
()
{
const
TypeInfo
*
TypeOf
<
null
>::
type
()
{
struct
TI
:
public
TypeInfo
{
return
&
nullTI
;
inline
std
::
string
name
()
const
{
return
"null"
;
}
}
inline
size_t
size
()
const
{
return
sizeof
(
null
);
}
inline
size_t
alignment
()
const
{
return
alignof
(
null
);
}
inline
void
construct
(
void
*
ptr
)
const
{
new
(
ptr
)
null
();
}
inline
void
copyConstruct
(
void
*
dst
,
const
void
*
src
)
const
{
new
(
dst
)
null
(
*
reinterpret_cast
<
const
null
*>
(
src
));
}
inline
void
destruct
(
void
*
ptr
)
const
{
reinterpret_cast
<
null
*>
(
ptr
)
->~
null
();
}
inline
bool
deserialize
(
const
Deserializer
*
,
void
*
)
const
{
return
true
;
}
inline
bool
serialize
(
Serializer
*
,
const
void
*
)
const
{
return
true
;
}
};
static
TI
typeinfo
;
return
&
typeinfo
;
}
// namespace dap
}
// namespace dap
}
// namespace dap
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