No subject


Wed Aug 1 07:28:53 PDT 2012


nique with respect to encapsulation in C++.

I personally believe things have two aspects, e.g. pros and cons. :)
Here pros is strongly clear.
We can save the word for encapsulation.

Then, now my question is what's the cons from this change?
It seems QT project widely uses this kind of technique called D-pointer.
Any report from them?

Kind regards,
Kangil

From: webkit-efl-bounces at lists.webkit.org<mailto:webkit-efl-bounces at lists.w=
ebkit.org> [mailto:webkit-efl-bounces at lists.webkit.org] On Behalf Of Dumez,=
 Christophe
Sent: Thursday, October 18, 2012 5:56 PM
To: webkit-efl at lists.webkit.org<mailto:webkit-efl at lists.webkit.org>
Cc: Kenneth R Christiansen
Subject: [webkit-efl] Use of pimpl idiom for Ewk classes

Hi,

Mikhail and I are currently working on refactoring the Ewk classes to make =
them more C++-like, more convenience to use and less bug-prone.
As part of this work, we came out with a proposal: Use pimpl idom for Ewk c=
lasses.

The Ewk classes are currently defined in the private headers, with all thei=
r members public. The private headers also usually contain C-style function=
s to interact with the Ewk class from inside WebKit.
Now, we would like to get rid of those private C functions and replace them=
 with C++ methods in the Ewk class. The issue is that the Ewk class members=
 are currently public meaning we can alter the members directly from outsid=
e the Ewk class implementation and bypass those class methods.

At the same time, we don't want to make all the Ewk class members private a=
nd create getter / setter methods for all of them. Not only this means a lo=
t of refactoring work and extra code, but also, this means that are public =
C API implementation will need to go through those getters / setters as wel=
l, instead of interacting with the class members directly.

We therefore thought of using the pimpl idiom so that the class members are=
 now stored in a POD struct in the cpp file. This effectively prevents acce=
ss to them from code other than our public C API and Ewk class methods, whi=
ch is what we want. The C API functions can still directly interact with th=
e Ewk class members which is convenient. We can get rid of all C functions =
in the private headers and replace them with Ewk class methods. Therefore, =
the coding style in WK2 EFL port implementation with be more C++ oriented.

I created a meta bug for this task:
https://bugs.webkit.org/show_bug.cgi?id=3D99696

I also wrote a first patch to show what the result looks like for the Ewk_D=
ownload_Job class. The patch also adds convenience macros to ewk_private.h =
to make pimpl idiom usage simpler and less error-prone:
https://bugs.webkit.org/show_bug.cgi?id=3D99697

We hope you like the result as much as we do.
If everyone agrees, Mikhail and I are planning to port other Ewk classes to=
 this proposal and update the WebKit EFL coding style.

Kr,
--
Christophe Dumez
Linux Software Engineer, PhD
Intel Finland Oy - Open Source Technology Center
---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki =

Business Identity Code: 0357606 - 4 =

Domiciled in Helsinki =


This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

--_000_F94DCAC852EDDA4A9A7987755FD9D177193FE7EEIRSMSX102gercor_
Content-Type: text/html; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii">
<meta name=3D"Generator" content=3D"Microsoft Word 12 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
	{font-family:"Malgun Gothic";
	panose-1:2 11 5 3 2 0 0 2 0 4;}
@font-face
	{font-family:"\@Malgun Gothic";
	panose-1:2 11 5 3 2 0 0 2 0 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
	{mso-style-priority:99;
	mso-style-link:"Balloon Text Char";
	margin:0cm;
	margin-bottom:.0001pt;
	font-size:8.0pt;
	font-family:"Tahoma","sans-serif";}
span.EmailStyle17
	{mso-style-type:personal;
	font-family:"Tahoma","sans-serif";
	color:windowtext;
	font-weight:normal;
	font-style:normal;
	text-decoration:none none;}
span.EmailStyle19
	{mso-style-type:personal-reply;
	font-family:"Calibri","sans-serif";
	color:#1F497D;}
span.BalloonTextChar
	{mso-style-name:"Balloon Text Char";
	mso-style-priority:99;
	mso-style-link:"Balloon Text";
	font-family:"Tahoma","sans-serif";}
.MsoChpDefault
	{mso-style-type:export-only;
	font-size:10.0pt;}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:3.0cm 72.0pt 72.0pt 72.0pt;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-GB" link=3D"blue" vlink=3D"purple">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1F497D">Hi Kangil,<o:p></o:p></sp=
an></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1F497D">Well first of all you hav=
e to strictly follow the pattern and not to forget putting macros where the=
y are supposed to be,<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1F497D">It might be confusing fro=
m the beginning. Chris and me however promise &nbsp;to describe the approac=
h in the EFL coding style wiki.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1F497D">Another drawback is passi=
ng calls through an extra pointer because of pimpl, so performance can be a=
ffected in theory.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1F497D">BR,<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1F497D">Mikhail<o:p></o:p></span>=
</p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span><=
/p>
<div>
<div style=3D"border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm =
0cm 0cm">
<p class=3D"MsoNormal"><b><span lang=3D"EN-US" style=3D"font-size:10.0pt;fo=
nt-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span =
lang=3D"EN-US" style=3D"font-size:10.0pt;font-family:&quot;Tahoma&quot;,&qu=
ot;sans-serif&quot;"> webkit-efl-bounces at lists.webkit.org [mailto:webkit-ef=
l-bounces at lists.webkit.org]
<b>On Behalf Of </b>Kangil Han<br>
<b>Sent:</b> Thursday, October 18, 2012 4:58 PM<br>
<b>To:</b> Dumez, Christophe; webkit-efl at lists.webkit.org<br>
<b>Cc:</b> Christiansen, Kenneth R<br>
<b>Subject:</b> Re: [webkit-efl] Use of pimpl idiom for Ewk classes<o:p></o=
:p></span></p>
</div>
</div>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10.0pt;font-=
family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">Hi Chris,<o:p></o:p></spa=
n></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10.0pt;font-=
family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"><o:p>&nbsp;</o:p></span><=
/p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10.0pt;font-=
family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">FOA, thanks for the inter=
esting topic here. :)<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10.0pt;font-=
family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From this, I&#8217;ve lea=
rned about useful design pattern and implementation technique with respect =
to encapsulation in C&#43;&#43;.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10.0pt;font-=
family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"><o:p>&nbsp;</o:p></span><=
/p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10.0pt;font-=
family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">I personally believe thin=
gs have two aspects, e.g. pros and cons. :)<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10.0pt;font-=
family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">Here pros is strongly cle=
ar.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10.0pt;font-=
family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">We can save the word for =
encapsulation.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10.0pt;font-=
family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"><o:p>&nbsp;</o:p></span><=
/p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10.0pt;font-=
family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">Then, now my question is =
what&#8217;s the cons from this change?<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10.0pt;font-=
family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">It seems QT project widel=
y uses this kind of technique called D-pointer.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10.0pt;font-=
family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">Any report from them?<o:p=
></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10.0pt;font-=
family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"><o:p>&nbsp;</o:p></span><=
/p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10.0pt;font-=
family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">Kind regards,<o:p></o:p><=
/span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10.0pt;font-=
family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">Kangil<o:p></o:p></span><=
/p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"font-size:10.0pt;font-=
family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"><o:p>&nbsp;</o:p></span><=
/p>
<div style=3D"border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm =
0cm 0cm">
<p class=3D"MsoNormal"><b><span lang=3D"EN-US" style=3D"font-size:10.0pt;fo=
nt-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span =
lang=3D"EN-US" style=3D"font-size:10.0pt;font-family:&quot;Tahoma&quot;,&qu=
ot;sans-serif&quot;">
<a href=3D"mailto:webkit-efl-bounces at lists.webkit.org">webkit-efl-bounces at l=
ists.webkit.org</a> [<a href=3D"mailto:webkit-efl-bounces at lists.webkit.org"=
>mailto:webkit-efl-bounces at lists.webkit.org</a>]
<b>On Behalf Of </b>Dumez, Christophe<br>
<b>Sent:</b> Thursday, October 18, 2012 5:56 PM<br>
<b>To:</b> <a href=3D"mailto:webkit-efl at lists.webkit.org">webkit-efl at lists.=
webkit.org</a><br>
<b>Cc:</b> Kenneth R Christiansen<br>
<b>Subject:</b> [webkit-efl] Use of pimpl idiom for Ewk classes<o:p></o:p><=
/span></p>
</div>
<p class=3D"MsoNormal"><span lang=3D"EN-US"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt"><span lang=3D"EN-US">=
Hi,<br clear=3D"all">
<br>
Mikhail and I are currently working on refactoring the Ewk classes to make =
them more C&#43;&#43;-like, more convenience to use and less bug-prone.<br>
As part of this work, we came out with a proposal: Use pimpl idom for Ewk c=
lasses.<br>
<br>
The Ewk classes are currently defined in the private headers, with all thei=
r members public. The private headers also usually contain C-style function=
s to interact with the Ewk class from inside WebKit.<br>
Now, we would like to get rid of those private C functions and replace them=
 with C&#43;&#43; methods in the Ewk class. The issue is that the Ewk class=
 members are currently public meaning we can alter the members directly fro=
m outside the Ewk class implementation and
 bypass those class methods.<br>
<br>
At the same time, we don't want to make all the Ewk class members private a=
nd create getter / setter methods for all of them. Not only this means a lo=
t of refactoring work and extra code, but also, this means that are public =
C API implementation will need to
 go through those getters / setters as well, instead of interacting with th=
e class members directly.<br>
<br>
We therefore thought of using the pimpl idiom so that the class members are=
 now stored in a POD struct in the cpp file. This effectively prevents acce=
ss to them from code other than our public C API and Ewk class methods, whi=
ch is what we want. The C API functions
 can still directly interact with the Ewk class members which is convenient=
. We can get rid of all C functions in the private headers and replace them=
 with Ewk class methods. Therefore, the coding style in WK2 EFL port implem=
entation with be more C&#43;&#43; oriented.<br>
<br>
I created a meta bug for this task:<br>
<a href=3D"https://bugs.webkit.org/show_bug.cgi?id=3D99696">https://bugs.we=
bkit.org/show_bug.cgi?id=3D99696</a><br>
<br>
I also wrote a first patch to <b>show what the result looks</b> like for th=
e Ewk_Download_Job class. The patch also adds convenience macros to ewk_pri=
vate.h to make pimpl idiom usage simpler and less error-prone:<br>
<b><a href=3D"https://bugs.webkit.org/show_bug.cgi?id=3D99697">https://bugs=
.webkit.org/show_bug.cgi?id=3D99697</a></b><br>
<br>
We hope you like the result as much as we do.<br>
If everyone agrees, Mikhail and I are planning to port other Ewk classes to=
 this proposal and update the WebKit EFL coding style.<br>
<br>
Kr,<br>
-- <br>
Christophe Dumez<br>
Linux Software Engineer, PhD<br>
Intel Finland Oy - Open Source Technology Center<o:p></o:p></span></p>
</div>
<p>---------------------------------------------------------------------<br>
Intel Finland Oy<br>
Registered Address: PL 281, 00181 Helsinki <br>
Business Identity Code: 0357606 - 4 <br>
Domiciled in Helsinki </p>

<p>This e-mail and any attachments may contain confidential material for<br>
the sole use of the intended recipient(s). Any review or distribution<br>
by others is strictly prohibited. If you are not the intended<br>
recipient, please contact the sender and delete all copies.</p></body>
</html>

--_000_F94DCAC852EDDA4A9A7987755FD9D177193FE7EEIRSMSX102gercor_--



More information about the webkit-efl mailing list