Re: Reflection in game engine (c++)

"Adrian Stone" <[email protected]> Thu, 14 Mar 2013 19:28:56 -0400
Newsgroups gmane.games.devel.sweng
Message-ID <B8F8230520D14C9290FF61D183D7BACE@8MILES>
This is a multi-part message in MIME format.

--===============0427071214==
Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_017D_01CE20EA.2BDC0A40"

This is a multi-part message in MIME format.

------=_NextPart_000_017D_01CE20EA.2BDC0A40
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

 

I'm not sure which number describes our approach, but we've been using it
for about 8 years on many different projects and I believe everyone on the
team has been very happy with it.  I've written about it pretty extensively
here: http://gameangst.com/?p=107

 

There are some implementation details I'd change if I were starting over
from scratch, but I still think that using advanced C++ features to create
an embedded DSL is the best option for reflection in C++.

 

Adrian

 

 

  _____  

From: [email protected]
[mailto:[email protected]] On Behalf Of Alen
Ladavac
Sent: Thursday, March 14, 2013 6:45 PM
To: Gabriel Sassone
Cc: [email protected]; [email protected]
Subject: Re: [Sweng-Gamedev] Reflection in game engine (c++)

 

We've been using #4 in our projects for a decade already and it works a
treat. And... why couldn't you invoke methods? :)

That method is the only really fully portable (AFAIK), as it doesn't really
care what compiler/toolset you have. It is also very light in terms of
runtime requirements, and very easy to use (not much extra typing for each
class, member or function). 

Though it is rather involved to implement.

JM2C,
Alen

Thursday, March 14, 2013, 7:09:30 PM, you wrote:


 

Hello gents,
   I wanted to experiment with reflection and I found different way to
obtain it:

  1) Invasive macro based registration
  2) Reflection visitor pattern
  3) Parsing pdb/clang stuff and create a manual table of what you want/need
  4) c++ custom parser that uses tags to create reflection informations
(like a comment near a member, ...) (exuberant ctags???)
  5) create serializable/reflected classes in a data format, then run a tool
that generates headers and cpps

I am trying to figure out flaws and merits of each kind, and even if there
are other solutions.
I love the idea to have the possibility to serialize in and out structures,
access fields and change values, stream in/out stuff from network ,and maybe
link with scripting.

My goal is to have fast iteration times, both artists and programmers, and I
achieved it for rendering programmers already with having json binarized
configurable rendering, but still there are code stuff that are not easy to
achieve.

Here are my thoughts, but I would like to hear your ideas and experiences!

1) Very precise on what you can register/serialize, but painful to maintain
or plug into an existing codebase
2) Less precise but you just need one method per class, that you can use to
serialize/reflect. Still bad in maintaining, but better in plugging in.
3) You make the compiler do the work, then translate the informations you
need in your format. Easy to maintain, to plug...maybe slow in parsing? Slow
your build pipeline?
4) maybe easier than using pdbs, but less powerful (you cannot invoke
methods on objects). should be faster than 3.
5) crazy idea. requires generation of code from outside...powerful like 4,
so data reflection, but you cannot invoke methods if you want.

What are your experiences/thoughts?

Thanks to everyone that read this mail!
 
    Gabriel





-- 
Best regards,
 Alen                            mailto:[email protected]


------=_NextPart_000_017D_01CE20EA.2BDC0A40
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:st1=3D"urn:schemas-microsoft-com:office:smarttags" =
xmlns=3D"http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<title>Re: [Sweng-Gamedev] Reflection in game engine (c++)</title>
<o:SmartTagType =
namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags"
 name=3D"City"/>
<o:SmartTagType =
namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags"
 name=3D"place"/>
<o:SmartTagType =
namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags"
 name=3D"PersonName"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:blue;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-reply;
	font-family:Arial;
	color:navy;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
	{page:Section1;}
-->
</style>

</head>

<body lang=3DEN-US link=3Dblue vlink=3Dblue>

<div class=3DSection1>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>I&#8217;m not sure which number =
describes
our approach, but we&#8217;ve been using it for about 8 years on many =
different
projects and I believe everyone on the team has been very happy with =
it.&nbsp;
I&#8217;ve written about it pretty extensively here: <a
href=3D"http://gameangst.com/?p=3D107">http://gameangst.com/?p=3D107</a><=
o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>There are some implementation =
details I&#8217;d
change if I were starting over from scratch, but I still think that =
using
advanced C++ features to create an embedded DSL is the best option for
reflection in C++.<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><st1:City w:st=3D"on"><st1:place w:st=3D"on"><font =
size=3D2
  color=3Dnavy face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;
  color:navy'>Adrian</span></font></st1:place></st1:City><font size=3D2
color=3Dnavy face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;
color:navy'><o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<div style=3D'border:none;border-left:solid blue 1.5pt;padding:0in 0in =
0in 4.0pt'>

<div>

<div class=3DMsoNormal align=3Dcenter style=3D'text-align:center'><font =
size=3D3
face=3D"Times New Roman"><span style=3D'font-size:12.0pt'>

<hr size=3D2 width=3D"100%" align=3Dcenter tabindex=3D-1>

</span></font></div>

<p class=3DMsoNormal><b><font size=3D2 face=3DTahoma><span =
style=3D'font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font =
size=3D2
face=3DTahoma><span style=3D'font-size:10.0pt;font-family:Tahoma'>
[email protected]
[mailto:[email protected]] <b><span
style=3D'font-weight:bold'>On Behalf Of </span></b>Alen Ladavac<br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> Thursday, March 14, =
2013
6:45 PM<br>
<b><span style=3D'font-weight:bold'>To:</span></b> Gabriel Sassone<br>
<b><span style=3D'font-weight:bold'>Cc:</span></b>
[email protected]; <st1:PersonName =
w:st=3D"on">[email protected]</st1:PersonName><br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> Re: =
[Sweng-Gamedev]
Reflection in game engine (c++)</span></font><o:p></o:p></p>

</div>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal style=3D'margin-bottom:12.0pt'><font size=3D1 =
face=3D"Courier New"><span
style=3D'font-size:9.0pt;font-family:"Courier New"'>We've been using #4 =
in our
projects for a decade already and it works a treat. And... why couldn't =
you
invoke methods? :)<br>
<br>
That method is the only really fully portable (AFAIK), as it doesn't =
really
care what compiler/toolset you have. It is also very light in terms of =
runtime
requirements, and very easy to use (not much extra typing for each =
class,
member or function).&nbsp;<br>
<br>
Though it is rather involved to implement.<br>
<br>
JM2C,<br>
Alen<br>
<br>
Thursday, March 14, 2013, 7:09:30 PM, you =
wrote:</span></font><o:p></o:p></p>

<table class=3DMsoNormalTable border=3D0 cellpadding=3D0>
 <tr>
  <td width=3D15 bgcolor=3Dblue =
style=3D'width:11.25pt;background:blue;padding:.75pt .75pt .75pt .75pt'>
  <p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span
  style=3D'font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>
  </td>
  <td width=3D1142 style=3D'width:856.5pt;padding:.75pt .75pt .75pt =
.75pt'>
  <p class=3DMsoNormal><font size=3D1 face=3D"Courier New"><span =
style=3D'font-size:
  9.0pt;font-family:"Courier New"'>Hello gents,<br>
  &nbsp; &nbsp;I wanted to experiment with reflection and I found =
different way
  to obtain it:<br>
  <br>
  &nbsp; 1) Invasive macro based registration<br>
  &nbsp; 2) Reflection visitor pattern<br>
  &nbsp; 3) Parsing pdb/clang stuff and create a manual table of what =
you
  want/need<br>
  &nbsp; 4) c++ custom parser that uses tags to create reflection =
informations
  (like a comment near a member, ...) (exuberant ctags???)<br>
  &nbsp; 5) create serializable/reflected classes in a data format, then =
run a
  tool that generates headers and cpps<br>
  <br>
  I am trying to figure out flaws and merits of each kind, and even if =
there
  are other solutions.<br>
  I love the idea to have the possibility to serialize in and out =
structures,
  access fields and change values, stream in/out stuff from network ,and =
maybe
  link with scripting.<br>
  <br>
  My goal is to have fast iteration times, both artists and programmers, =
and I
  achieved it for rendering programmers already with having json =
binarized
  configurable rendering, but still there are code stuff that are not =
easy to
  achieve.<br>
  <br>
  Here are my thoughts, but I would like to hear your ideas and =
experiences!<br>
  <br>
  1) Very precise on what you can register/serialize, but painful to =
maintain
  or plug into an existing codebase<br>
  2) Less precise but you just need one method per class, that you can =
use to
  serialize/reflect. Still bad in maintaining, but better in plugging =
in.<br>
  3) You make the compiler do the work, then translate the informations =
you
  need in your format. Easy to maintain, to plug...maybe slow in =
parsing? Slow
  your build pipeline?<br>
  4) maybe easier than using pdbs, but less powerful (you cannot invoke =
methods
  on objects). should be faster than 3.<br>
  5) crazy idea. requires generation of code from outside...powerful =
like 4, so
  data reflection, but you cannot invoke methods if you want.<br>
  <br>
  What are your experiences/thoughts?<br>
  <br>
  Thanks to everyone that read this mail!<br>
  &nbsp;<br>
  &nbsp; &nbsp; Gabriel</span></font><o:p></o:p></p>
  </td>
 </tr>
</table>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'><br>
<br>
<br>
<br>
</span></font><i><font color=3Dsilver face=3DArial><span =
style=3D'font-family:Arial;
color:silver;font-style:italic'>--&nbsp;<br>
Best regards,<br>
&nbsp;Alen &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;</span></font></i><a
href=3D"mailto:[email protected]">mailto:[email protected]</a><o:p>=
</o:p></p>

</div>

</div>

</body>

</html>

------=_NextPart_000_017D_01CE20EA.2BDC0A40--


--===============0427071214==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Sweng-Gamedev mailing list
[email protected]
http://lists.midnightryder.com/listinfo.cgi/sweng-gamedev-midnightryder.com

--===============0427071214==--