Skip to content

Commit

Permalink
Format with AlignAfterOpenBracket: AlwaysBreak; BinPackArguments: fal…
Browse files Browse the repository at this point in the history
…se; BinPackParameters: false
  • Loading branch information
hugovk committed Jul 10, 2020
1 parent f714356 commit a48cc59
Show file tree
Hide file tree
Showing 57 changed files with 2,427 additions and 1,050 deletions.
36 changes: 25 additions & 11 deletions src/Tk/_tkmini.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,18 @@ typedef struct Tcl_Interp Tcl_Interp;
typedef struct Tcl_Command_ *Tcl_Command;
typedef void *ClientData;

typedef int(Tcl_CmdProc)(ClientData clientData, Tcl_Interp *interp, int argc,
const char *argv[]);
typedef int(Tcl_CmdProc)(
ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[]);
typedef void(Tcl_CmdDeleteProc)(ClientData clientData);

/* Typedefs derived from function signatures in Tcl header */
/* Tcl_CreateCommand */
typedef Tcl_Command (*Tcl_CreateCommand_t)(Tcl_Interp *interp, const char *cmdName,
Tcl_CmdProc *proc, ClientData clientData,
Tcl_CmdDeleteProc *deleteProc);
typedef Tcl_Command (*Tcl_CreateCommand_t)(
Tcl_Interp *interp,
const char *cmdName,
Tcl_CmdProc *proc,
ClientData clientData,
Tcl_CmdDeleteProc *deleteProc);
/* Tcl_AppendResult */
typedef void (*Tcl_AppendResult_t)(Tcl_Interp *interp, ...);

Expand Down Expand Up @@ -117,13 +120,24 @@ typedef struct Tk_PhotoImageBlock {

/* Typedefs derived from function signatures in Tk header */
/* Tk_PhotoPutBlock for Tk <= 8.4 */
typedef void (*Tk_PhotoPutBlock_84_t)(Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height, int compRule);
typedef void (*Tk_PhotoPutBlock_84_t)(
Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr,
int x,
int y,
int width,
int height,
int compRule);
/* Tk_PhotoPutBlock for Tk >= 8.5 */
typedef int (*Tk_PhotoPutBlock_85_t)(Tcl_Interp *interp, Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height, int compRule);
typedef int (*Tk_PhotoPutBlock_85_t)(
Tcl_Interp *interp,
Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr,
int x,
int y,
int width,
int height,
int compRule);
/* Tk_PhotoSetSize for Tk <= 8.4 */
typedef void (*Tk_PhotoSetSize_84_t)(Tk_PhotoHandle handle, int width, int height);
/* Tk_FindPhoto */
Expand Down
61 changes: 39 additions & 22 deletions src/Tk/tkImaging.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ ImagingFind(const char *name) {
}

static int
PyImagingPhotoPut(ClientData clientdata, Tcl_Interp *interp, int argc,
const char **argv) {
PyImagingPhotoPut(
ClientData clientdata, Tcl_Interp *interp, int argc, const char **argv) {
Imaging im;
Tk_PhotoHandle photo;
Tk_PhotoImageBlock block;

if (argc != 3) {
TCL_APPEND_RESULT(interp, "usage: ", argv[0], " destPhoto srcImage",
(char *)NULL);
TCL_APPEND_RESULT(
interp, "usage: ", argv[0], " destPhoto srcImage", (char *)NULL);
return TCL_ERROR;
}

Expand Down Expand Up @@ -131,33 +131,40 @@ PyImagingPhotoPut(ClientData clientdata, Tcl_Interp *interp, int argc,
block.pixelPtr = (unsigned char *)im->block;

if (TK_LT_85) { /* Tk 8.4 */
TK_PHOTO_PUT_BLOCK_84(photo, &block, 0, 0, block.width, block.height,
TK_PHOTO_COMPOSITE_SET);
TK_PHOTO_PUT_BLOCK_84(
photo, &block, 0, 0, block.width, block.height, TK_PHOTO_COMPOSITE_SET);
if (strcmp(im->mode, "RGBA") == 0) {
/* Tk workaround: we need apply ToggleComplexAlphaIfNeeded */
/* (fixed in Tk 8.5a3) */
TK_PHOTO_SET_SIZE_84(photo, block.width, block.height);
}
} else {
/* Tk >=8.5 */
TK_PHOTO_PUT_BLOCK_85(interp, photo, &block, 0, 0, block.width, block.height,
TK_PHOTO_COMPOSITE_SET);
TK_PHOTO_PUT_BLOCK_85(
interp,
photo,
&block,
0,
0,
block.width,
block.height,
TK_PHOTO_COMPOSITE_SET);
}

return TCL_OK;
}

static int
PyImagingPhotoGet(ClientData clientdata, Tcl_Interp *interp, int argc,
const char **argv) {
PyImagingPhotoGet(
ClientData clientdata, Tcl_Interp *interp, int argc, const char **argv) {
Imaging im;
Tk_PhotoHandle photo;
Tk_PhotoImageBlock block;
int x, y, z;

if (argc != 3) {
TCL_APPEND_RESULT(interp, "usage: ", argv[0], " srcPhoto destImage",
(char *)NULL);
TCL_APPEND_RESULT(
interp, "usage: ", argv[0], " srcPhoto destImage", (char *)NULL);
return TCL_ERROR;
}

Expand Down Expand Up @@ -192,10 +199,18 @@ PyImagingPhotoGet(ClientData clientdata, Tcl_Interp *interp, int argc,

void
TkImaging_Init(Tcl_Interp *interp) {
TCL_CREATE_COMMAND(interp, "PyImagingPhoto", PyImagingPhotoPut, (ClientData)0,
(Tcl_CmdDeleteProc *)NULL);
TCL_CREATE_COMMAND(interp, "PyImagingPhotoGet", PyImagingPhotoGet, (ClientData)0,
(Tcl_CmdDeleteProc *)NULL);
TCL_CREATE_COMMAND(
interp,
"PyImagingPhoto",
PyImagingPhotoPut,
(ClientData)0,
(Tcl_CmdDeleteProc *)NULL);
TCL_CREATE_COMMAND(
interp,
"PyImagingPhotoGet",
PyImagingPhotoGet,
(ClientData)0,
(Tcl_CmdDeleteProc *)NULL);
}

/*
Expand Down Expand Up @@ -406,13 +421,15 @@ _func_loader(void *lib) {
/* Tk_PhotoPutBlock_Panic defined as of 8.5.0 */
TK_LT_85 = (dlsym(lib, "Tk_PhotoPutBlock_Panic") == NULL);
if (TK_LT_85) {
return (((TK_PHOTO_PUT_BLOCK_84 = (Tk_PhotoPutBlock_84_t)_dfunc(
lib, "Tk_PhotoPutBlock")) == NULL) ||
((TK_PHOTO_SET_SIZE_84 =
(Tk_PhotoSetSize_84_t)_dfunc(lib, "Tk_PhotoSetSize")) == NULL));
return (
((TK_PHOTO_PUT_BLOCK_84 =
(Tk_PhotoPutBlock_84_t)_dfunc(lib, "Tk_PhotoPutBlock")) == NULL) ||
((TK_PHOTO_SET_SIZE_84 =
(Tk_PhotoSetSize_84_t)_dfunc(lib, "Tk_PhotoSetSize")) == NULL));
}
return ((TK_PHOTO_PUT_BLOCK_85 =
(Tk_PhotoPutBlock_85_t)_dfunc(lib, "Tk_PhotoPutBlock")) == NULL);
return (
(TK_PHOTO_PUT_BLOCK_85 =
(Tk_PhotoPutBlock_85_t)_dfunc(lib, "Tk_PhotoPutBlock")) == NULL);
}

int
Expand Down
Loading

0 comments on commit a48cc59

Please sign in to comment.