summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-07-08 13:07:17 +0200
committerAlexander Larsson <alexl@redhat.com>2010-07-08 13:07:17 +0200
commitf0f623ddc0f0cc6b647ed432af23bb8564fb4f5c (patch)
tree64d4f821462c4466ead3d6c2cefb178a59e9ea36
parent31d2d6e4e485f1addece7139c82b4f3e64b1bd91 (diff)
downloadspice-f0f623ddc0f0cc6b647ed432af23bb8564fb4f5c.tar.gz
spice-f0f623ddc0f0cc6b647ed432af23bb8564fb4f5c.tar.xz
spice-f0f623ddc0f0cc6b647ed432af23bb8564fb4f5c.zip
codegen: No SPICE_ADDRESS types left, drop @c_ptr
-rw-r--r--python_modules/demarshal.py24
-rw-r--r--python_modules/ptypes.py7
-rw-r--r--spice.proto26
-rw-r--r--spice1.proto24
4 files changed, 37 insertions, 44 deletions
diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py
index 1ae1911b..e8afabb2 100644
--- a/python_modules/demarshal.py
+++ b/python_modules/demarshal.py
@@ -82,9 +82,8 @@ def write_parser_helpers(writer):
writer.begin_block("struct PointerInfo")
writer.variable_def("uint64_t", "offset")
writer.variable_def("parse_func_t", "parse")
- writer.variable_def("void *", "dest")
+ writer.variable_def("void **", "dest")
writer.variable_def("uint32_t", "nelements")
- writer.variable_def("int", "is_ptr")
writer.end_block(semicolon=True)
def write_read_primitive(writer, start, container, name, scope):
@@ -195,7 +194,7 @@ def write_validate_struct_function(writer, struct):
writer.set_is_generated("validator", validate_function)
writer = writer.function_helper()
- scope = writer.function(validate_function, "static intptr_t", "uint8_t *message_start, uint8_t *message_end, SPICE_ADDRESS offset, int minor")
+ scope = writer.function(validate_function, "static intptr_t", "uint8_t *message_start, uint8_t *message_end, uint64_t offset, int minor")
scope.variable_def("uint8_t *", "start = message_start + offset")
scope.variable_def("SPICE_GNUC_UNUSED uint8_t *", "pos");
scope.variable_def("size_t", "mem_size", "nw_size");
@@ -809,16 +808,14 @@ def write_array_parser(writer, nelements, array, dest, scope):
writer.assign("end", "(uint8_t *)SPICE_ALIGN((size_t)end, 4)")
def write_parse_pointer(writer, t, at_end, dest, member_name, scope):
- as_c_ptr = t.has_attr("c_ptr")
target_type = t.target_type
writer.assign("ptr_info[n_ptr].offset", "consume_%s(&in)" % t.primitive_type())
writer.assign("ptr_info[n_ptr].parse", write_parse_ptr_function(writer, target_type))
if at_end:
- writer.assign("ptr_info[n_ptr].dest", "end")
- writer.increment("end", "sizeof(void *)" if as_c_ptr else "sizeof(SPICE_ADDRESS)");
+ writer.assign("ptr_info[n_ptr].dest", "(void **)end")
+ writer.increment("end", "sizeof(void *)");
else:
- writer.assign("ptr_info[n_ptr].dest", "&%s" % dest.get_ref(member_name))
- writer.assign("ptr_info[n_ptr].is_ptr", "1" if as_c_ptr else "0")
+ writer.assign("ptr_info[n_ptr].dest", "(void **)&%s" % dest.get_ref(member_name))
if target_type.is_array():
nelements = read_array_len(writer, member_name, target_type, dest, scope)
writer.assign("ptr_info[n_ptr].nelements", nelements)
@@ -932,20 +929,13 @@ def write_ptr_info_check(writer):
with writer.for_loop(index, "n_ptr") as scope:
offset = "ptr_info[%s].offset" % index
function = "ptr_info[%s].parse" % index
- is_ptr = "ptr_info[%s].is_ptr" % index
dest = "ptr_info[%s].dest" % index
with writer.if_block("%s == 0" % offset, newline=False):
- with writer.if_block(is_ptr, newline=False):
- writer.assign("*(void **)(%s)" % dest, "NULL")
- with writer.block(" else"):
- writer.assign("*(SPICE_ADDRESS *)(%s)" % dest, "0")
+ writer.assign("*%s" % dest, "NULL")
with writer.block(" else"):
writer.comment("Align to 32 bit").newline()
writer.assign("end", "(uint8_t *)SPICE_ALIGN((size_t)end, 4)")
- with writer.if_block(is_ptr, newline=False):
- writer.assign("*(void **)(%s)" % dest, "(void *)end")
- with writer.block(" else"):
- writer.assign("*(SPICE_ADDRESS *)(%s)" % dest, "(SPICE_ADDRESS)end")
+ writer.assign("*%s" % dest, "(void *)end")
writer.assign("end", "%s(message_start, message_end, end, &ptr_info[%s], minor)" % (function, index))
writer.error_check("end == NULL")
writer.newline()
diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index 715544fb..5e18aa33 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -60,7 +60,7 @@ class FixedSize:
# only to attributes that affect pointer or array attributes, as these
# are member local types, unlike e.g. a Struct that may be used by
# other members
-propagated_attributes=["ptr_array", "c_ptr", "nonnull", "chunk"]
+propagated_attributes=["ptr_array", "nonnull", "chunk"]
class Type:
def __init__(self):
@@ -469,7 +469,10 @@ class PointerType(Type):
return self.pointer_size
def c_type(self):
- return "SPICE_ADDRESS"
+ if self.pointer_size == 4:
+ return "uint32_t"
+ else:
+ return "uint64_t"
def has_pointer(self):
return True
diff --git a/spice.proto b/spice.proto
index bd56eb2c..f6aa34ea 100644
--- a/spice.proto
+++ b/spice.proto
@@ -400,7 +400,7 @@ struct Clip {
clip_type type;
switch (type) {
case RECTS:
- ClipRects *rects @outvar(cliprects) @c_ptr @marshall @nonnull;
+ ClipRects *rects @outvar(cliprects) @marshall @nonnull;
} u @anon;
};
@@ -437,7 +437,7 @@ struct BitmapData {
case PAL_FROM_CACHE:
uint64 palette_id;
default:
- Palette *palette @outvar(bitmap) @c_ptr;
+ Palette *palette @outvar(bitmap);
} pal @anon;
uint8 *data[image_size(8, stride, y)] @chunk; /* pointer to array, not array of pointers as in C */
} @ctype(SpiceBitmap);
@@ -454,7 +454,7 @@ struct LZPLTData {
case PAL_FROM_CACHE:
uint64 palette_id;
default:
- Palette *palette @nonnull @outvar(lzplt) @c_ptr;
+ Palette *palette @nonnull @outvar(lzplt);
} pal @anon;
uint8 data[data_size] @nomarshal @chunk;
};
@@ -508,7 +508,7 @@ struct Image {
};
struct Pattern {
- Image *pat @nonnull @c_ptr;
+ Image *pat @nonnull;
Point pos;
};
@@ -525,7 +525,7 @@ struct Brush {
struct QMask {
mask_flags flags;
Point pos;
- Image *bitmap @c_ptr;
+ Image *bitmap;
};
struct LineAttr {
@@ -536,7 +536,7 @@ struct LineAttr {
} u1 @anon;
switch (flags) {
case STYLED:
- fixed28_4 *style[style_nseg] @c_ptr;
+ fixed28_4 *style[style_nseg];
} u2 @anon;
};
@@ -654,7 +654,7 @@ channel DisplayChannel : BaseChannel {
message {
DisplayBase base;
struct Opaque {
- Image *src_bitmap @c_ptr;
+ Image *src_bitmap;
Rect src_area;
Brush brush;
ropd rop_descriptor;
@@ -666,7 +666,7 @@ channel DisplayChannel : BaseChannel {
message {
DisplayBase base;
struct Copy {
- Image *src_bitmap @c_ptr;
+ Image *src_bitmap;
Rect src_area;
ropd rop_descriptor;
image_scale_mode scale_mode;
@@ -677,7 +677,7 @@ channel DisplayChannel : BaseChannel {
message {
DisplayBase base;
struct Blend {
- Image *src_bitmap @c_ptr;
+ Image *src_bitmap;
Rect src_area;
ropd rop_descriptor;
image_scale_mode scale_mode;
@@ -709,7 +709,7 @@ channel DisplayChannel : BaseChannel {
message {
DisplayBase base;
struct Rop3 {
- Image *src_bitmap @c_ptr;
+ Image *src_bitmap;
Rect src_area;
Brush brush;
uint8 rop3;
@@ -721,7 +721,7 @@ channel DisplayChannel : BaseChannel {
message {
DisplayBase base;
struct Stroke {
- Path *path @c_ptr @marshall @nonnull;
+ Path *path @marshall @nonnull;
LineAttr attr;
Brush brush;
uint16 fore_mode;
@@ -744,7 +744,7 @@ channel DisplayChannel : BaseChannel {
message {
DisplayBase base;
struct Transparent {
- Image *src_bitmap @c_ptr;
+ Image *src_bitmap;
Rect src_area;
uint32 src_color;
uint32 true_color;
@@ -756,7 +756,7 @@ channel DisplayChannel : BaseChannel {
struct AlphaBlnd {
alpha_flags alpha_flags;
uint8 alpha;
- Image *src_bitmap @c_ptr;
+ Image *src_bitmap;
Rect src_area;
} data;
} draw_alpha_blend;
diff --git a/spice1.proto b/spice1.proto
index 23ce9f1c..d1efb552 100644
--- a/spice1.proto
+++ b/spice1.proto
@@ -382,7 +382,7 @@ struct Clip {
clip_type type;
switch (type) {
case RECTS:
- ClipRects *rects @outvar(cliprects) @c_ptr;
+ ClipRects *rects @outvar(cliprects);
default:
uint64 data @zero;
} u @anon;
@@ -421,7 +421,7 @@ struct BitmapData {
case PAL_FROM_CACHE:
uint64 palette_id;
default:
- Palette *palette @outvar(bitmap) @c_ptr;
+ Palette *palette @outvar(bitmap);
} pal @anon;
uint8 *data[image_size(8, stride, y)] @chunk; /* pointer to array, not array of pointers as in C */
} @ctype(SpiceBitmap);
@@ -438,7 +438,7 @@ struct LZPLTData {
case PAL_FROM_CACHE:
uint64 palette_id;
default:
- Palette *palette @nonnull @outvar(lzplt) @c_ptr;
+ Palette *palette @nonnull @outvar(lzplt);
} pal @anon;
uint8 data[data_size] @nomarshal @chunk;
};
@@ -466,7 +466,7 @@ struct Image {
};
struct Pattern {
- Image *pat @nonnull @c_ptr;
+ Image *pat @nonnull;
Point pos;
};
@@ -483,7 +483,7 @@ struct Brush {
struct QMask {
mask_flags flags;
Point pos;
- Image *bitmap @c_ptr;
+ Image *bitmap;
};
struct LineAttr {
@@ -493,7 +493,7 @@ struct LineAttr {
uint8 style_nseg;
fixed28_4 width @zero;
fixed28_4 miter_limit @zero;
- fixed28_4 *style[style_nseg] @c_ptr;
+ fixed28_4 *style[style_nseg];
};
struct RasterGlyphA1 {
@@ -611,7 +611,7 @@ channel DisplayChannel : BaseChannel {
message {
DisplayBase base;
struct Opaque {
- Image *src_bitmap @c_ptr;
+ Image *src_bitmap;
Rect src_area;
Brush brush;
ropd rop_descriptor;
@@ -623,7 +623,7 @@ channel DisplayChannel : BaseChannel {
message {
DisplayBase base;
struct Copy {
- Image *src_bitmap @c_ptr;
+ Image *src_bitmap;
Rect src_area;
ropd rop_descriptor;
image_scale_mode scale_mode;
@@ -634,7 +634,7 @@ channel DisplayChannel : BaseChannel {
message {
DisplayBase base;
struct Blend {
- Image *src_bitmap @c_ptr;
+ Image *src_bitmap;
Rect src_area;
ropd rop_descriptor;
image_scale_mode scale_mode;
@@ -666,7 +666,7 @@ channel DisplayChannel : BaseChannel {
message {
DisplayBase base;
struct Rop3 {
- Image *src_bitmap @c_ptr;
+ Image *src_bitmap;
Rect src_area;
Brush brush;
uint8 rop3;
@@ -701,7 +701,7 @@ channel DisplayChannel : BaseChannel {
message {
DisplayBase base;
struct Transparent {
- Image *src_bitmap @c_ptr;
+ Image *src_bitmap;
Rect src_area;
uint32 src_color;
uint32 true_color;
@@ -713,7 +713,7 @@ channel DisplayChannel : BaseChannel {
struct AlphaBlnd {
int8 alpha_flags @virtual(0);
uint8 alpha;
- Image *src_bitmap @c_ptr;
+ Image *src_bitmap;
Rect src_area;
} data;
} draw_alpha_blend;