Imported Upstream version 1.41.0
[platform/upstream/grpc.git] / src / ruby / ext / grpc / rb_grpc.h
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18
19 #ifndef GRPC_RB_H_
20 #define GRPC_RB_H_
21
22 #include <ruby/ruby.h>
23
24 #include <sys/time.h>
25
26 #include <grpc/support/time.h>
27
28 /* grpc_rb_mGrpcCore is the module containing the ruby wrapper GRPC classes. */
29 extern VALUE grpc_rb_mGrpcCore;
30
31 /* grpc_rb_sNewServerRpc is the struct that holds new server rpc details. */
32 extern VALUE grpc_rb_sNewServerRpc;
33
34 /* grpc_rb_sStruct is the struct that holds status details. */
35 extern VALUE grpc_rb_sStatus;
36
37 /* sym_code is the symbol for the code attribute of grpc_rb_sStatus. */
38 extern VALUE sym_code;
39
40 /* sym_details is the symbol for the details attribute of grpc_rb_sStatus. */
41 extern VALUE sym_details;
42
43 /* sym_metadata is the symbol for the metadata attribute of grpc_rb_sStatus. */
44 extern VALUE sym_metadata;
45
46 /* GC_NOT_MARKED is used in calls to Data_Wrap_Struct to indicate that the
47    wrapped struct does not need to participate in ruby gc. */
48 #define GRPC_RB_GC_NOT_MARKED (RUBY_DATA_FUNC)(NULL)
49
50 /* GC_DONT_FREED is used in calls to Data_Wrap_Struct to indicate that the
51    wrapped struct should not be freed the wrapped ruby object is released by
52    the garbage collector. */
53 #define GRPC_RB_GC_DONT_FREE (RUBY_DATA_FUNC)(NULL)
54
55 /* GRPC_RB_MEMSIZE_UNAVAILABLE is used in rb_data_type_t to indicate that the
56  * number of bytes used by the wrapped struct is not available. */
57 #define GRPC_RB_MEMSIZE_UNAVAILABLE (size_t(*)(const void*))(NULL)
58
59 /* A ruby object alloc func that fails by raising an exception. */
60 VALUE grpc_rb_cannot_alloc(VALUE cls);
61
62 /* A ruby object init func that fails by raising an exception. */
63 VALUE grpc_rb_cannot_init(VALUE self);
64
65 /* A ruby object clone init func that fails by raising an exception. */
66 VALUE grpc_rb_cannot_init_copy(VALUE copy, VALUE self);
67
68 /* grpc_rb_time_timeval creates a gpr_timespec from a ruby time object. */
69 gpr_timespec grpc_rb_time_timeval(VALUE time, int interval);
70
71 void grpc_ruby_fork_guard();
72
73 void grpc_ruby_init();
74
75 void grpc_ruby_shutdown();
76
77 #endif /* GRPC_RB_H_ */