Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

[linux-port] Implement CA2W/CW2A conversion (#172) - #180

Closed
pow2clk wants to merge 1 commit into
google:linuxfrom
pow2clk:pow2clk-fixup2
Closed

pow2clk wants to merge 1 commit into
google:linuxfrom
pow2clk:pow2clk-fixup2

Conversation

@pow2clk

@pow2clk pow2clk commented May 16, 2018

Copy link
Copy Markdown

Add a non-windows implementation of CW2AEX and CA2WEX using std::
character conversion functions to WinTypes.h header. Includes
CW2A and CW2A macros the same way Windows does

fix #172

@googlebot

Copy link
Copy Markdown

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

@pow2clk

pow2clk commented May 16, 2018

Copy link
Copy Markdown
Author

Sigh. I guess I need to use my real email with github to make googlebot happy.

@AppVeyorBot

Copy link
Copy Markdown

❌ Build DirectXShaderCompiler 1.0.19 failed (commit e72baee604 by @)

@ehsannas

Copy link
Copy Markdown

This is failing because I have used CW2A(pFileName).c_str() in a couple of places as a quick way of getting a cstr out of a wstr.

e.g.

../lib/DxcSupport/dxcapi.use.cpp:121:45: error: no member named 'c_str' in 'CW2AEX<128>'
  std::ofstream outputFile (CW2A(pFileName).c_str(), std::ios::out | std::ios::binary);

@ehsannas

Copy link
Copy Markdown

I guess these can be replaced with CA2W(wstr).m_psz ?

@ehsannas
ehsannas self-requested a review May 16, 2018 18:10
@pow2clk

pow2clk commented May 16, 2018

Copy link
Copy Markdown
Author

That or just the variable. It has a conversion operator. I'll address this on my end. I still need to get this branch building locally and I guess I can't fake it.

@pow2clk

pow2clk commented May 16, 2018

Copy link
Copy Markdown
Author

I've exposed my gmail email through github. I don't know what else I can do to satisfy the CLA check. It tells me I'm valid, but one of the authors isn't, but I'm the only author.

Add a non-windows implementation of CW2AEX and CA2WEX using std::
character conversion functions to WinTypes.h header. Includes
CW2A and CW2A macros the same way Windows does

fix google#172
@AppVeyorBot

Copy link
Copy Markdown

❌ Build DirectXShaderCompiler 1.0.23 failed (commit 9a25bb323c by @)

@pow2clk

pow2clk commented May 16, 2018

Copy link
Copy Markdown
Author

Abandoning in hopes that a brand new pull request will allow the CLA to pass.

@pow2clk pow2clk closed this May 16, 2018
CW2AEX( LPCWSTR psz , UINT nCodePage = CP_UTF8)
{
if (nCodePage != CP_UTF8) {
// you have reached the limits of this half-assed implementation. So sorry.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The style guide requires proper punctual comments.
Although a pain at first, I have found this to be nice in the long run.

Can change to:

// Current implementation only supports UTF8.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hah! sorry. I forgot about that comment. It's the kind of snark I'd include in reviews but not source code.

if (nCodePage != CP_UTF8) {
// you have reached the limits of this half-assed implementation. So sorry.
m_psz = NULL;
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it does not cause crashes/errors in the basic use-case (running dxc on an hlsl file), then we should die here, so that we know when some bad usage occurs, rather than silently chasing a nullptr.

assert(false && "CW2AEX implementation for Linux does not handle non-UTF8 code pages");
return;

operator LPSTR() const { return m_psz; }

char *m_psz;
char m_szBuffer[t_nBufferLength]; // dunno what this is for

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete this line completely?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason for including that is it's part of the published interface of CW2AEX. Plus, if I remember my template edge cases correctly, compilers get cross if you don't use the template variable anywhere and if it's no longer a template, then it can't be used like CW2AEX<> as it is in various places. I will certainly remove the comment and maybe explain this in a comment instead.

I will test the unused template variable though.

CA2WEX( LPCSTR psz, UINT nCodePage = CP_UTF8 )
{
if (nCodePage != CP_UTF8) {
// you have reached the limits of this half-assed implementation. So sorry.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

if (nCodePage != CP_UTF8) {
// you have reached the limits of this half-assed implementation. So sorry.
m_psz = NULL;
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above.

@pow2clk
pow2clk deleted the pow2clk-fixup2 branch May 16, 2018 20:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants