Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Issue 240013005: read/write function_ptrs as just void*, and not as 'array of bytes' (Closed)

Created:
6 years, 8 months ago by reed1
Modified:
6 years, 8 months ago
Reviewers:
bungeman-skia, mtklein
CC:
skia-review_googlegroups.com
Visibility:
Public.

Description

read/write function_ptrs as just void*, and not as 'array of bytes' BUG=skia: Committed: http://code.google.com/p/skia/source/detail?r=14224

Patch Set 1 #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+3 lines, -8 lines) Patch
M include/core/SkReadBuffer.h View 2 chunks +1 line, -6 lines 1 comment Download
M include/core/SkWriteBuffer.h View 1 chunk +1 line, -1 line 0 comments Download
M tests/PaintTest.cpp View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 7 (0 generated)
reed1
6 years, 8 months ago (2014-04-16 15:57:11 UTC) #1
mtklein
lgtm
6 years, 8 months ago (2014-04-16 15:58:21 UTC) #2
reed1
The CQ bit was checked by reed@google.com
6 years, 8 months ago (2014-04-16 15:59:36 UTC) #3
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://skia-tree-status.appspot.com/cq/reed@google.com/240013005/1
6 years, 8 months ago (2014-04-16 15:59:52 UTC) #4
commit-bot: I haz the power
Change committed as 14224
6 years, 8 months ago (2014-04-16 16:24:11 UTC) #5
bungeman-skia
https://codereview.chromium.org/240013005/diff/1/include/core/SkReadBuffer.h File include/core/SkReadBuffer.h (right): https://codereview.chromium.org/240013005/diff/1/include/core/SkReadBuffer.h#newcode76 include/core/SkReadBuffer.h:76: void* readFunctionPtr() { return fReader.readPtr(); } So, I think ...
6 years, 8 months ago (2014-04-16 16:51:36 UTC) #6
mtklein
6 years, 8 months ago (2014-04-16 16:55:05 UTC) #7
Message was sent while issue was closed.
On 2014/04/16 16:51:36, bungeman1 wrote:
> https://codereview.chromium.org/240013005/diff/1/include/core/SkReadBuffer.h
> File include/core/SkReadBuffer.h (right):
> 
>
https://codereview.chromium.org/240013005/diff/1/include/core/SkReadBuffer.h#...
> include/core/SkReadBuffer.h:76: void* readFunctionPtr() { return
> fReader.readPtr(); }
> So, I think this was 'incorrect' before, so this change makes no real
> difference. However, it is technically undefined to cast a function pointer to
a
> void pointer. POSIX defines the way we do things in the call to dlsym in
> SkFontHost_FreeType.cpp (because dlsym is defined to return a void*). Windows
is
> actually better here, as GetProcAddress returns FARPROC which is actually a
> function pointer.
> 
> The spec does state that you can cast a function pointer to another one, so
long
> as it is cast back to the original before making a call through it. I would
> propose a 'typedef void (*SkVoidProc)()' which would be what this and the
> associated writer would deal in.

Is there a way for us to write a generic "accepts any function pointer" and
we'll do the cast for the caller in writer?  The reader's going to have to do a
cast anyway, but it'd be sad to force all the calls to writer to make an extra
cast to SkVoidProc themselves.

I'm happy, very happy even, to make it inconvenient to do dumb things like pass
in a non-function pointer here.

Powered by Google App Engine
This is Rietveld 408576698