Permalink
Browse files

bugfix: nested empty expanded type initialization

  • Loading branch information...
cadrian committed Oct 27, 2015
1 parent 4ea192d commit bbbf037c170d6a6986ab3eb256c63d831319be1e
Showing with 38 additions and 31 deletions.
  1. +34 −27 src/smarteiffel/generation/c/c_header_pass.e
  2. +4 −4 src/smarteiffel/generation/c/c_initializer.e
@@ -168,37 +168,44 @@ feature {}
local
wa: ARRAY[RUN_FEATURE_2]; i: INTEGER; rf2: RUN_FEATURE_2; t: TYPE_MARK
do
- wa := live_type.writable_attributes
- if wa = Void then
- if live_type.is_tagged then
- out_c.extend('{')
- live_type.id.append_in(out_c)
- cpp.memory.extra_c_model(live_type.canonical_type_mark)
- out_c.extend('}')
- else
- out_c.append(cpp.initializer.for(live_type.canonical_type_mark))
- end
+ out_c.append(once "/*init:")
+ out_c.append(live_type.type.canonical_type_mark.written_mark)
+ out_c.append(once "*/")
+ if live_type.is_expanded then
+ out_c.append(cpp.initializer.for(live_type.canonical_type_mark))
else
- out_c.extend('{')
- if live_type.is_tagged then
- live_type.id.append_in(out_c)
- out_c.extend(',')
- end
- cpp.memory.extra_c_model(live_type.canonical_type_mark)
- from
- i := wa.lower
- until
- i > wa.upper
- loop
- if i > wa.lower then
+ wa := live_type.writable_attributes
+ if wa = Void then
+ if live_type.is_tagged then
+ out_c.extend('{')
+ live_type.id.append_in(out_c)
+ cpp.memory.extra_c_model(live_type.canonical_type_mark)
+ out_c.extend('}')
+ else
+ out_c.append(cpp.initializer.for(live_type.canonical_type_mark))
+ end
+ else
+ out_c.extend('{')
+ if live_type.is_tagged then
+ live_type.id.append_in(out_c)
out_c.extend(',')
end
- rf2 := wa.item(i)
- t := rf2.result_type
- out_c.append(cpp.initializer.for(t))
- i := i + 1
+ cpp.memory.extra_c_model(live_type.canonical_type_mark)
+ from
+ i := wa.lower
+ until
+ i > wa.upper
+ loop
+ if i > wa.lower then
+ out_c.extend(',')
+ end
+ rf2 := wa.item(i)
+ t := rf2.result_type
+ out_c.append(cpp.initializer.for(t))
+ i := i + 1
+ end
+ out_c.extend('}')
end
- out_c.extend('}')
end
end
@@ -109,10 +109,10 @@ feature {CLASS_TYPE_MARK}
check
visited.is_user_expanded
end
- if not visited.type.has_external_type then
- c_initialize_user_expanded(visited)
- else
+ if visited.type.has_external_type then
buffer.append(visited.type.external_type.default_value)
+ else
+ c_initialize_user_expanded(visited)
end
else
buffer.append(once "(void*)0")
@@ -182,7 +182,7 @@ feature {}
wa: ARRAY[RUN_FEATURE_2]; i: INTEGER; rf: RUN_FEATURE_2
do
if type_mark.type.is_empty_expanded then
- buffer.extend('0')
+ buffer.append(once "0/*empty expanded*/")
else
buffer.extend('{')
wa := type_mark.type.live_type.writable_attributes

0 comments on commit bbbf037

Please sign in to comment.