update code style and fixed #endif error

This commit is contained in:
vcaesar 2018-12-30 12:04:29 -04:00
parent 17c0de747f
commit 6550f4af67
4 changed files with 17 additions and 31 deletions

View File

@ -6,8 +6,7 @@
#include <string.h> /* For strcmp() */ #include <string.h> /* For strcmp() */
#include <ctype.h> /* For tolower() */ #include <ctype.h> /* For tolower() */
const char *getExtension(const char *fname, size_t len) const char *getExtension(const char *fname, size_t len){
{
if (fname == NULL || len <= 0) return NULL; if (fname == NULL || len <= 0) return NULL;
while (--len > 0 && fname[len] != '.' && fname[len] != '\0') while (--len > 0 && fname[len] != '.' && fname[len] != '\0')
@ -16,8 +15,7 @@ const char *getExtension(const char *fname, size_t len)
return fname + len + 1; return fname + len + 1;
} }
MMImageType imageTypeFromExtension(const char *extension) MMImageType imageTypeFromExtension(const char *extension){
{
char ext[4]; char ext[4];
const size_t maxlen = sizeof(ext) / sizeof(ext[0]); const size_t maxlen = sizeof(ext) / sizeof(ext[0]);
size_t i; size_t i;
@ -37,10 +35,7 @@ MMImageType imageTypeFromExtension(const char *extension)
} }
} }
MMBitmapRef newMMBitmapFromFile(const char *path, MMBitmapRef newMMBitmapFromFile(const char *path, MMImageType type, MMIOError *err){
MMImageType type,
MMIOError *err)
{
switch (type) { switch (type) {
case kBMPImageType: case kBMPImageType:
return newMMBitmapFromBMP(path, err); return newMMBitmapFromBMP(path, err);
@ -52,10 +47,7 @@ MMBitmapRef newMMBitmapFromFile(const char *path,
} }
} }
int saveMMBitmapToFile(MMBitmapRef bitmap, int saveMMBitmapToFile(MMBitmapRef bitmap, const char *path, MMImageType type){
const char *path,
MMImageType type)
{
switch (type) { switch (type) {
case kBMPImageType: case kBMPImageType:
return saveMMBitmapAsBMP(bitmap, path); return saveMMBitmapAsBMP(bitmap, path);
@ -66,8 +58,7 @@ int saveMMBitmapToFile(MMBitmapRef bitmap,
} }
} }
const char *MMIOErrorString(MMImageType type, MMIOError error) const char *MMIOErrorString(MMImageType type, MMIOError error){
{
switch (type) { switch (type) {
case kBMPImageType: case kBMPImageType:
return MMBMPReadErrorString(error); return MMBMPReadErrorString(error);

View File

@ -6,8 +6,7 @@
#include <string.h> /* For strcmp() */ #include <string.h> /* For strcmp() */
#include <ctype.h> /* For tolower() */ #include <ctype.h> /* For tolower() */
const char *getExtension(const char *fname, size_t len) const char *getExtension(const char *fname, size_t len){
{
if (fname == NULL || len <= 0) return NULL; if (fname == NULL || len <= 0) return NULL;
while (--len > 0 && fname[len] != '.' && fname[len] != '\0') while (--len > 0 && fname[len] != '.' && fname[len] != '\0')
@ -16,8 +15,7 @@ const char *getExtension(const char *fname, size_t len)
return fname + len + 1; return fname + len + 1;
} }
MMImageType imageTypeFromExtension(const char *extension) MMImageType imageTypeFromExtension(const char *extension){
{
char ext[4]; char ext[4];
const size_t maxlen = sizeof(ext) / sizeof(ext[0]); const size_t maxlen = sizeof(ext) / sizeof(ext[0]);
size_t i; size_t i;
@ -37,10 +35,7 @@ MMImageType imageTypeFromExtension(const char *extension)
} }
} }
MMBitmapRef newMMBitmapFromFile(const char *path, MMBitmapRef newMMBitmapFromFile(const char *path, MMImageType type, MMIOError *err){
MMImageType type,
MMIOError *err)
{
switch (type) { switch (type) {
case kBMPImageType: case kBMPImageType:
return newMMBitmapFromBMP(path, err); return newMMBitmapFromBMP(path, err);
@ -52,10 +47,7 @@ MMBitmapRef newMMBitmapFromFile(const char *path,
} }
} }
int saveMMBitmapToFile(MMBitmapRef bitmap, int saveMMBitmapToFile(MMBitmapRef bitmap, const char *path, MMImageType type){
const char *path,
MMImageType type)
{
switch (type) { switch (type) {
case kBMPImageType: case kBMPImageType:
return saveMMBitmapAsBMP(bitmap, path); return saveMMBitmapAsBMP(bitmap, path);
@ -66,8 +58,7 @@ int saveMMBitmapToFile(MMBitmapRef bitmap,
} }
} }
const char *MMIOErrorString(MMImageType type, MMIOError error) const char *MMIOErrorString(MMImageType type, MMIOError error){
{
switch (type) { switch (type) {
case kBMPImageType: case kBMPImageType:
return MMBMPReadErrorString(error); return MMBMPReadErrorString(error);

View File

@ -10,10 +10,12 @@
#else #else
#include <stdbool.h> #include <stdbool.h>
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#endif #endif
#if defined(IS_MACOSX) #if defined(IS_MACOSX)
typedef enum { typedef enum {

View File

@ -10,11 +10,13 @@
#else #else
#include <stdbool.h> #include <stdbool.h>
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
// #ifdefined(__cplusplus)||defined(c_plusplus) // #ifdefined(__cplusplus)||defined(c_plusplus)
extern "C" extern "C"
{ {
#endif #endif
#if defined(IS_MACOSX) #if defined(IS_MACOSX)
// #include </System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h> // #include </System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h>
@ -96,9 +98,9 @@ void doubleClick(MMMouseButton button);
* TODO: Add a smoothly scroll mouse next. */ * TODO: Add a smoothly scroll mouse next. */
void scrollMouse(int scrollMagnitude, MMMouseWheelDirection scrollDirection); void scrollMouse(int scrollMagnitude, MMMouseWheelDirection scrollDirection);
#endif /* MOUSE_H */
//#ifdefined(__cplusplus)||defined(c_plusplus) //#ifdefined(__cplusplus)||defined(c_plusplus)
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* MOUSE_H */