• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

超漢字アプリケーション開発用のProtocol Buffersコンパイラの開発


コミットメタ情報

リビジョン805a36d5adc7ff5e0c2b27a24812185d25c3acf6 (tree)
日時2015-03-04 02:35:29
作者ornse01 <ornse01@user...>
コミッターornse01

ログメッセージ

add field implementation partially.

変更サマリ

差分

--- a/src/protobuf/template.c.erb
+++ b/src/protobuf/template.c.erb
@@ -1,24 +1,66 @@
11 /* this file is automaticall generated. */
22
33 #include <basic.h>
4+#include <stdlib.h>
45 #include <coding/pb_scalartypes.h>
56
67 #include "<%= header_file_name %>"
78
89 <%- msg_list.each do |m| -%>
910 struct <%= m.name %>_ {
11+ <%- m.each_field do |f| -%>
12+ <%- if f.is_singular_numeric? -%>
13+ Bool <%= f.name %>_exist;
14+ <%= f.to_c_type %> <%= f.name %>;
15+ <%- end -%>
16+ <%- if f.is_singular_string? -%>
17+ pb_str_t *<%= f.name %>;
18+ <%- end -%>
19+ <%- if f.is_singular_bytes? -%>
20+ pb_bytes_t *<%= f.name %>;
21+ <%- end -%>
22+ <%- end -%>
1023 };
1124
1225 <%- end -%>
1326
1427 <%- msg_list.each do |m| -%>
1528 /* <%= m.name %> */
29+LOCAL VOID <%= m.name %>__initialize(<%= m.name %> *m)
30+{
31+ <%- m.each_field do |f| -%>
32+ <%- if f.is_singular_numeric? -%>
33+ m-><%= f.name %>_exist = False;
34+ m-><%= f.name %> = 0;
35+ <%- end -%>
36+ <%- if f.is_singular_string? -%>
37+ m-><%= f.name %> = NULL;
38+ <%- end -%>
39+ <%- if f.is_singular_bytes? -%>
40+ m-><%= f.name %> = NULL;
41+ <%- end -%>
42+ <%- end -%>
43+}
44+
45+LOCAL VOID <%= m.name %>__finalize(<%= m.name %> *m)
46+{
47+}
48+
1649 EXPORT <%= m.name %>* <%= m.name %>__new()
1750 {
51+ <%= m.name %> *m;
52+ m = (<%= m.name %>*)malloc(sizeof(<%= m.name %>));
53+ if (m == NULL) {
54+ return NULL;
55+ }
56+ <%= m.name %>__initialize(m);
57+ return m;
1858 }
1959
2060 EXPORT VOID <%= m.name %>__delete(<%= m.name %> *m)
2161 {
62+ <%= m.name %>__finalize(m);
63+ free(m);
2264 }
2365
2466 EXPORT Bool <%= m.name %>__isequal(<%= m.name %> *m, <%= m.name %> *other)
@@ -34,28 +76,35 @@ EXPORT VOID <%= m.name %>__swap(<%= m.name %> *m, <%= m.name %> *other)
3476 <%- if f.is_singular_numeric? -%>
3577 EXPORT Bool <%= m.name %>__has_<%= f.name %>(<%= m.name %> *m)
3678 {
79+ return m-><%= f.name %>_exist;
3780 }
3881
3982 EXPORT <%= f.to_c_type %> <%= m.name %>__<%= f.name %>(<%= m.name %> *m)
4083 {
84+ return m-><%= f.name %>;
4185 }
4286
4387 EXPORT VOID <%= m.name %>__set_<%= f.name %>(<%= m.name %> *m, <%= f.to_c_type %> value)
4488 {
89+ m-><%= f.name %> = value;
4590 }
4691
4792 EXPORT VOID <%= m.name %>__clear_<%= f.name %>(<%= m.name %> *m)
4893 {
94+ m-><%= f.name %>_exist = False;
95+ m-><%= f.name %> = 0;
4996 }
5097
5198 <%- end -%>
5299 <%- if f.is_singular_string? -%>
53-EXPORT Bool <%= m.name %>__has_<%= f.name %>(<%= m.name %> *m)
54-{
100+EXPORT Bool <%= m.name %>__has_<%= f.name %>(<%= m.name %> *m){
101+
102+ return m-><%= f.name %> != NULL;
55103 }
56104
57105 EXPORT pb_str_t* <%= m.name %>__<%= f.name %>(<%= m.name %> *m)
58106 {
107+ return m-><%= f.name %>;
59108 }
60109
61110 EXPORT void <%= m.name %>__set_<%= f.name %>(<%= m.name %> *m, const pb_str_t *string)
@@ -82,10 +131,12 @@ EXPORT pb_str_t* <%= m.name %>__release_<%= f.name %>(<%= m.name %> *m)
82131 <%- if f.is_singular_bytes? -%>
83132 EXPORT Bool <%= m.name %>__has_<%= f.name %>(<%= m.name %> *m)
84133 {
134+ return m-><%= f.name %> != NULL;
85135 }
86136
87137 EXPORT pb_bytes_t* <%= m.name %>__<%= f.name %>(<%= m.name %> *m)
88138 {
139+ return m-><%= f.name %>;
89140 }
90141
91142 EXPORT void <%= m.name %>__set_<%= f.name %>(<%= m.name %> *m, const pb_bytes_t *string)