• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

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

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


Commit MetaInfo

Revision489c2c780208418addb99391362bb0ae06458eb6 (tree)
Time2015-02-04 02:14:00
Authorornse01 <ornse01@user...>
Commiterornse01

Log Message

change scalar type definition in C.

Change Summary

Incremental Difference

--- /dev/null
+++ b/src/pb_scalartypes.h
@@ -0,0 +1,48 @@
1+/*
2+ * pb_scalartypes.h
3+ *
4+ * Copyright (c) 2009 project bchan
5+ *
6+ * This software is provided 'as-is', without any express or implied
7+ * warranty. In no event will the authors be held liable for any damages
8+ * arising from the use of this software.
9+ *
10+ * Permission is granted to anyone to use this software for any purpose,
11+ * including commercial applications, and to alter it and redistribute it
12+ * freely, subject to the following restrictions:
13+ *
14+ * 1. The origin of this software must not be misrepresented; you must not
15+ * claim that you wrote the original software. If you use this software
16+ * in a product, an acknowledgment in the product documentation would be
17+ * appreciated but is not required.
18+ *
19+ * 2. Altered source versions must be plainly marked as such, and must not be
20+ * misrepresented as being the original software.
21+ *
22+ * 3. This notice may not be removed or altered from any source
23+ * distribution.
24+ *
25+ */
26+
27+#include <basic.h>
28+
29+#ifndef __PB_SCALARTYPES_H__
30+#define __PB_SCALARTYPES_H__
31+
32+typedef DOUBLE pb_double_t;
33+typedef FLOAT pb_float_t;
34+typedef W pb_int32_t;
35+typedef UW pb_uint21_t;
36+typedef long long int pb_int64_t;
37+typedef unsinged long long int pb_uint64_t;
38+typedef Bool pb_bool_t;
39+typedef pb_str_t_ pb_str_t;
40+typedef pb_bytes_t_ pb_bytes_t;
41+
42+IMPORT pb_str_t* pb_str_new();
43+IMPORT VOID pb_str_delete(pb_str_t *str);
44+
45+IMPORT pb_bytes_t* pb_bytes_new();
46+IMPORT VOID pb_bytes_delete(pb_bytes_t *bytes);
47+
48+#endif
--- a/src/protobuf/cgenerator.rb
+++ b/src/protobuf/cgenerator.rb
@@ -28,31 +28,31 @@ class Protobuf::CGenerator::Field
2828 def to_c_type
2929 case @field_node.type
3030 when :double
31- "DOUBLE"
31+ "pb_double_t"
3232 when :float
33- "FLOAT"
33+ "pb_float_t"
3434 when :int32
35- "W"
35+ "pb_int32_t"
3636 when :int64
37- "D"
37+ "pb_int64_t"
3838 when :uint32
39- "UW"
39+ "pb_uint32_t"
4040 when :uint64
41- "UD"
41+ "pb_uint64_t"
4242 when :sint32
43- "W"
43+ "pb_int32_t"
4444 when :sint64
45- "D"
45+ "pb_int64_t"
4646 when :fixed32
47- "W"
47+ "pb_int32_t"
4848 when :fixed64
49- "D"
49+ "pb_int64_t"
5050 when :sfixed32
51- "W"
51+ "pb_int32_t"
5252 when :sfixed64
53- "D"
53+ "pb_int64_t"
5454 when :bool
55- "Bool"
55+ "pb_bool_t"
5656 when :string
5757 nil
5858 when :bytes
--- a/src/protobuf/template.h.erb
+++ b/src/protobuf/template.h.erb
@@ -22,5 +22,14 @@ void <%= m.name %>__clear_<%= f.name %>(<%= m.name %> *m)
2222 void <%= m.name %>__set_allocated_<%= f.name %>(<%= m.name %> *m, pb_str_t *value)
2323 pb_str_t* <%= m.name %>__release_<%= f.name %>(<%= m.name %> *m)
2424 <%- end -%>
25+ <%- if f.is_singular_bytes? -%>
26+Bool <%= m.name %>__has_<%= f.name %>(<%= m.name %> *m)
27+pb_bytes_t* <%= m.name %>__<%= f.name %>(<%= m.name %> *m)
28+void <%= m.name %>__set_<%= f.name %>(<%= m.name %> *m, const pb_bytes_t *string)
29+pb_bytes_t* <%= m.name %>__mutable_<%= f.name %>(<%= m.name %> *m)
30+void <%= m.name %>__clear_<%= f.name %>(<%= m.name %> *m)
31+void <%= m.name %>__set_allocated_<%= f.name %>(<%= m.name %> *m, pb_bytes_t *value)
32+pb_bytes_t* <%= m.name %>__release_<%= f.name %>(<%= m.name %> *m)
33+ <%- end -%>
2534 <%- end -%>
2635 <%- end -%>