Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compile errors warnings #53

Merged
1 change: 0 additions & 1 deletion c_src/device/cairo/cairo_gtk.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <cairo.h>
#include <errno.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
Expand Down
7 changes: 4 additions & 3 deletions c_src/device/cairo/cairo_script_ops.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <cairo.h>
#define _GNU_SOURCE
#include <math.h>

#include "cairo_ctx.h"
Expand Down Expand Up @@ -258,7 +259,7 @@ void script_ops_draw_text(void* v_ctx,
cairo_text_extents_t text_extents;
cairo_scaled_font_glyph_extents(scaled_font, glyphs, glyph_count, &text_extents);

float align_offset;
float align_offset = 0;
switch (p_ctx->text_align) {
case TEXT_ALIGN_LEFT:
align_offset = 0;
Expand All @@ -271,7 +272,7 @@ void script_ops_draw_text(void* v_ctx,
break;
}

float base_offset;
float base_offset = 0;
switch (p_ctx->text_base) {
case TEXT_BASE_TOP:
base_offset = font_extents.ascent;
Expand Down Expand Up @@ -345,7 +346,7 @@ void script_ops_draw_sprites(void* v_ctx,

image_pattern_data_t* image_data = find_image_pattern(p_ctx, p_image->image_id);

for (int i = 0; i < count; i++) {
for (uint32_t i = 0; i < count; i++) {
draw_sprite(p_ctx, image_data->surface, sprites[i]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion c_src/font/font.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ font_t* get_font(sid_t id)
}

//---------------------------------------------------------
void put_font(int* p_msg_length, void* v_ctx)
void put_font(uint32_t* p_msg_length, void* v_ctx)
{
// read in the id size, which is in the first four bytes
uint32_t id_length;
Expand Down
2 changes: 1 addition & 1 deletion c_src/font/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
#include "font_ops.h"

void init_fonts(void);
void put_font(int* p_msg_length, void* v_ctx);
void put_font(uint32_t* p_msg_length, void* v_ctx);
font_t* get_font(sid_t id);

8 changes: 5 additions & 3 deletions c_src/image/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#include "common.h"
#include "comms.h"
#include "image.h"
#include "image_ops.h"
#include "scenic_types.h"
#include "utils.h"
#include "image_ops.h"

#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
Expand Down Expand Up @@ -80,7 +80,7 @@ void reset_images(void* v_ctx)
int read_pixels(void* p_pixels,
uint32_t width, uint32_t height,
image_format_t format_in,
int* p_msg_length)
uint32_t* p_msg_length)
{
// read incoming data into a temporary buffer
int buffer_size = *p_msg_length;
Expand Down Expand Up @@ -145,6 +145,8 @@ int read_pixels(void* p_pixels,
case IMAGE_FORMAT_RGBA:
memcpy(p_pixels, p_buffer, pixel_count * 4);
break;
default:
break;
}

// clean up
Expand All @@ -154,7 +156,7 @@ int read_pixels(void* p_pixels,
}

//---------------------------------------------------------
void put_image(int* p_msg_length, void* v_ctx)
void put_image(uint32_t* p_msg_length, void* v_ctx)
{
// read in the fixed size data
uint32_t id_length;
Expand Down
3 changes: 1 addition & 2 deletions c_src/image/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ typedef enum {
IMAGE_FORMAT_GRAY_ALPHA = 2,
IMAGE_FORMAT_RGB = 3,
IMAGE_FORMAT_RGBA = 4,
IMAGE_FORMAT_SIZE = 0xffffffff, // ensure enum is 32 bits wide
} image_format_t;

void init_images(void);
void put_image(int* p_msg_length, void* v_ctx);
void put_image(uint32_t* p_msg_length, void* v_ctx);
void reset_images(void* v_ctx);
image_t* get_image(sid_t id);
70 changes: 35 additions & 35 deletions c_src/scenic/comms.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@ extern device_info_t g_device_info;

//---------------------------------------------------------
// the length indicator from erlang is always big-endian
int write_cmd(byte* buf, unsigned int len)
int write_cmd(uint8_t* buf, unsigned int len)
{
int written = 0;

uint32_t cmd_len = len;
cmd_len = hton_ui32(cmd_len);
write_exact((byte*) &cmd_len, sizeof(uint32_t));
write_exact((uint8_t*) &cmd_len, sizeof(uint32_t));
written = write_exact(buf, len);

return written;
}

//---------------------------------------------------------
bool read_bytes_down(void* p_buff, int bytes_to_read, int* p_bytes_to_remaining)
bool read_bytes_down(void* p_buff, int bytes_to_read, uint32_t* p_bytes_to_remaining)
{
if (p_bytes_to_remaining <= 0)
return false;
Expand Down Expand Up @@ -89,9 +89,9 @@ void logv(uint32_t cmd, const char* msg, va_list args)
uint32_t msg_len = vasprintf(&output, msg, args);
uint32_t cmd_len = ntoh_ui32(msg_len + sizeof(uint32_t));

write_exact((byte*) &cmd_len, sizeof(uint32_t));
write_exact((byte*) &cmd, sizeof(uint32_t));
write_exact((byte*) output, msg_len);
write_exact((uint8_t*) &cmd_len, sizeof(uint32_t));
write_exact((uint8_t*) &cmd, sizeof(uint32_t));
write_exact((uint8_t*) output, msg_len);
free(output);
}

Expand Down Expand Up @@ -163,9 +163,9 @@ void send_write(const char* msg)

cmd_len = ntoh_ui32(cmd_len);

write_exact((byte*) &cmd_len, sizeof(uint32_t));
write_exact((byte*) &cmd, sizeof(uint32_t));
write_exact((byte*) msg, msg_len);
write_exact((uint8_t*) &cmd_len, sizeof(uint32_t));
write_exact((uint8_t*) &cmd, sizeof(uint32_t));
write_exact((uint8_t*) msg, msg_len);
}

//---------------------------------------------------------
Expand All @@ -176,8 +176,8 @@ void send_inspect(void* data, int length)

ntoh_ui32(cmd_len);

write_exact((byte*) &cmd_len, sizeof(uint32_t));
write_exact((byte*) &cmd, sizeof(uint32_t));
write_exact((uint8_t*) &cmd_len, sizeof(uint32_t));
write_exact((uint8_t*) &cmd, sizeof(uint32_t));
write_exact(data, length);
}

Expand All @@ -190,9 +190,9 @@ void send_static_texture_miss(const char* key)

ntoh_ui32(cmd_len);

write_exact((byte*) &cmd_len, sizeof(uint32_t));
write_exact((byte*) &cmd, sizeof(uint32_t));
write_exact((byte*) key, msg_len);
write_exact((uint8_t*) &cmd_len, sizeof(uint32_t));
write_exact((uint8_t*) &cmd, sizeof(uint32_t));
write_exact((uint8_t*) key, msg_len);
}

//---------------------------------------------------------
Expand All @@ -204,9 +204,9 @@ void send_dynamic_texture_miss(const char* key)

ntoh_ui32(cmd_len);

write_exact((byte*) &cmd_len, sizeof(uint32_t));
write_exact((byte*) &cmd, sizeof(uint32_t));
write_exact((byte*) key, msg_len);
write_exact((uint8_t*) &cmd_len, sizeof(uint32_t));
write_exact((uint8_t*) &cmd, sizeof(uint32_t));
write_exact((uint8_t*) key, msg_len);
}

//---------------------------------------------------------
Expand All @@ -218,9 +218,9 @@ void send_font_miss(const char* key)

ntoh_ui32(cmd_len);

write_exact((byte*) &cmd_len, sizeof(uint32_t));
write_exact((byte*) &cmd, sizeof(uint32_t));
write_exact((byte*) key, msg_len);
write_exact((uint8_t*) &cmd_len, sizeof(uint32_t));
write_exact((uint8_t*) &cmd, sizeof(uint32_t));
write_exact((uint8_t*) key, msg_len);
}

//---------------------------------------------------------
Expand All @@ -234,7 +234,7 @@ PACK(typedef struct msg_reshape_t
void send_reshape( int window_width, int window_height )
{
msg_reshape_t msg = { MSG_OUT_RESHAPE, window_width, window_height };
write_cmd((byte*) &msg, sizeof(msg_reshape_t));
write_cmd((uint8_t*) &msg, sizeof(msg_reshape_t));
}

//---------------------------------------------------------
Expand All @@ -251,7 +251,7 @@ PACK(typedef struct msg_key_t
void send_key(keymap_t keymap, int key, int scancode, int action, int mods)
{
msg_key_t msg = { MSG_OUT_KEY, keymap, key, scancode, action, mods };
write_cmd((byte*) &msg, sizeof(msg_key_t));
write_cmd((uint8_t*) &msg, sizeof(msg_key_t));
}

//---------------------------------------------------------
Expand All @@ -266,7 +266,7 @@ PACK(typedef struct msg_codepoint_t
void send_codepoint(keymap_t keymap, unsigned int codepoint, int mods)
{
msg_codepoint_t msg = { MSG_OUT_CODEPOINT, keymap, codepoint, mods };
write_cmd((byte*) &msg, sizeof(msg_codepoint_t));
write_cmd((uint8_t*) &msg, sizeof(msg_codepoint_t));
}

//---------------------------------------------------------
Expand All @@ -280,7 +280,7 @@ PACK(typedef struct msg_cursor_pos_t
void send_cursor_pos(float xpos, float ypos)
{
msg_cursor_pos_t msg = { MSG_OUT_CURSOR_POS, xpos, ypos };
write_cmd((byte*) &msg, sizeof(msg_cursor_pos_t));
write_cmd((uint8_t*) &msg, sizeof(msg_cursor_pos_t));
}

//---------------------------------------------------------
Expand All @@ -306,7 +306,7 @@ void send_mouse_button(keymap_t keymap, int button, int action, int mods, float
xpos,
ypos
};
write_cmd((byte*) &msg, sizeof(msg_mouse_button_t));
write_cmd((uint8_t*) &msg, sizeof(msg_mouse_button_t));
}

//---------------------------------------------------------
Expand All @@ -322,7 +322,7 @@ PACK(typedef struct msg_scroll_t
void send_scroll(float xoffset, float yoffset, float xpos, float ypos)
{
msg_scroll_t msg = { MSG_OUT_MOUSE_SCROLL, xoffset, yoffset, xpos, ypos };
write_cmd((byte*) &msg, sizeof(msg_scroll_t));
write_cmd((uint8_t*) &msg, sizeof(msg_scroll_t));
}

//---------------------------------------------------------
Expand All @@ -337,7 +337,7 @@ PACK(typedef struct msg_cursor_enter_t
void send_cursor_enter(int entered, float xpos, float ypos)
{
msg_cursor_enter_t msg = { MSG_OUT_CURSOR_ENTER, entered, xpos, ypos };
write_cmd((byte*) &msg, sizeof(msg_cursor_enter_t));
write_cmd((uint8_t*) &msg, sizeof(msg_cursor_enter_t));
}

//---------------------------------------------------------
Expand All @@ -350,7 +350,7 @@ PACK(typedef struct msg_close_t
void send_close( int reason )
{
msg_close_t msg = { MSG_OUT_CLOSE, reason };
write_cmd((byte*) &msg, sizeof(msg_close_t));
write_cmd((uint8_t*) &msg, sizeof(msg_close_t));
}

//---------------------------------------------------------
Expand All @@ -363,14 +363,14 @@ PACK(typedef struct img_miss_t
void send_image_miss( unsigned int img_id )
{
img_miss_t msg = { MSG_OUT_IMG_MISS, img_id };
write_cmd((byte*) &msg, sizeof(img_miss_t));
write_cmd((uint8_t*) &msg, sizeof(img_miss_t));
}

//---------------------------------------------------------
void send_ready()
{
uint32_t msg_id = MSG_OUT_READY;
write_cmd((byte*) &msg_id, sizeof(msg_id));
write_cmd((uint8_t*) &msg_id, sizeof(msg_id));
}

//=============================================================================
Expand Down Expand Up @@ -420,23 +420,23 @@ void render(driver_data_t* p_data)
}

//---------------------------------------------------------
void set_global_tx(int* p_msg_length, driver_data_t* p_data)
void set_global_tx(uint32_t* p_msg_length, driver_data_t* p_data)
{
for (int i = 0; i < 6; i++) {
read_bytes_down(&p_data->global_tx[i], sizeof(float), p_msg_length);
}
}

//---------------------------------------------------------
void set_cursor_tx(int* p_msg_length, driver_data_t* p_data)
void set_cursor_tx(uint32_t* p_msg_length, driver_data_t* p_data)
{
for (int i = 0; i < 6; i++) {
read_bytes_down(&p_data->cursor_tx[i], sizeof(float), p_msg_length);
}
}

//---------------------------------------------------------
void update_cursor(int* p_msg_length, driver_data_t* p_data)
void update_cursor(uint32_t* p_msg_length, driver_data_t* p_data)
{
read_bytes_down(&p_data->f_show_cursor, sizeof(uint32_t), p_msg_length);
for (int i = 0; i < 2; i++) {
Expand All @@ -445,9 +445,9 @@ void update_cursor(int* p_msg_length, driver_data_t* p_data)
}

//---------------------------------------------------------
void clear_color(int* p_msg_length)
void clear_color(uint32_t* p_msg_length)
{
byte r, g, b, a;
uint8_t r, g, b, a;
read_bytes_down(&r, 1, p_msg_length);
read_bytes_down(&g, 1, p_msg_length);
read_bytes_down(&b, 1, p_msg_length);
Expand Down
18 changes: 7 additions & 11 deletions c_src/scenic/comms.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,20 @@ typedef enum {
MSG_OUT_WARN = 0XA1,
MSG_OUT_ERROR = 0XA2,
MSG_OUT_DEBUG = 0XA3,

_MSG_OUT_SIZE_ = 0XFFFFFFFF,
} msg_out_t;

typedef enum {
KEYMAP_GLFW = 0x01,
KEYMAP_GDK = 0x02,

_KEYMAP_SIZE_ = 0xFFFFFFFF,
} keymap_t;

int read_exact(byte* buf, int len);
int write_exact(byte* buf, int len);
int read_exact(uint8_t* buf, int len);
int write_exact(uint8_t* buf, int len);
int read_msg_length(struct timeval * ptv);
bool isCallerDown();

bool read_bytes_down(void* p_buff, int bytes_to_read,
int* p_bytes_to_remaining);
uint32_t* p_bytes_to_remaining);

// basic events to send up to the caller
void send_puts(const char* msg, ...);
Expand All @@ -124,10 +120,10 @@ void log_info(const char* msg, ...);
void log_warn(const char* msg, ...);
void log_error(const char* msg, ...);

void set_global_tx(int* p_msg_length, driver_data_t* p_data);
void set_cursor_tx(int* p_msg_length, driver_data_t* p_data);
void update_cursor(int* p_msg_length, driver_data_t* p_data);
void clear_color(int* p_msg_length);
void set_global_tx(uint32_t* p_msg_length, driver_data_t* p_data);
void set_cursor_tx(uint32_t* p_msg_length, driver_data_t* p_data);
void update_cursor(uint32_t* p_msg_length, driver_data_t* p_data);
void clear_color(uint32_t* p_msg_length);
void receive_crash();
void receive_quit(driver_data_t* p_data);
void render(driver_data_t* p_data);
Expand Down
2 changes: 1 addition & 1 deletion c_src/scenic/scenic_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void scenic_ops_crash()
receive_crash();
}

void dispatch_scenic_ops(int msg_length, driver_data_t* p_data)
void dispatch_scenic_ops(uint32_t msg_length, driver_data_t* p_data)
{
scenic_op_t op;
read_bytes_down(&op, sizeof(uint32_t), &msg_length);
Expand Down
2 changes: 1 addition & 1 deletion c_src/scenic/scenic_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ void scenic_ops_put_font(uint32_t* p_msg_length, driver_data_t* p_data);
void scenic_ops_put_image(uint32_t* p_msg_length, driver_data_t* p_data);
void scenic_ops_crash();

void dispatch_scenic_ops(int msg_length, driver_data_t* p_data);
void dispatch_scenic_ops(uint32_t msg_length, driver_data_t* p_data);
Loading