3 * Copyright 2015 gRPC authors.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <ruby/ruby.h>
26 #include <grpc/support/time.h>
28 /* grpc_rb_mGrpcCore is the module containing the ruby wrapper GRPC classes. */
29 extern VALUE grpc_rb_mGrpcCore;
31 /* grpc_rb_sNewServerRpc is the struct that holds new server rpc details. */
32 extern VALUE grpc_rb_sNewServerRpc;
34 /* grpc_rb_sStruct is the struct that holds status details. */
35 extern VALUE grpc_rb_sStatus;
37 /* sym_code is the symbol for the code attribute of grpc_rb_sStatus. */
38 extern VALUE sym_code;
40 /* sym_details is the symbol for the details attribute of grpc_rb_sStatus. */
41 extern VALUE sym_details;
43 /* sym_metadata is the symbol for the metadata attribute of grpc_rb_sStatus. */
44 extern VALUE sym_metadata;
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)
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)
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)
59 /* A ruby object alloc func that fails by raising an exception. */
60 VALUE grpc_rb_cannot_alloc(VALUE cls);
62 /* A ruby object init func that fails by raising an exception. */
63 VALUE grpc_rb_cannot_init(VALUE self);
65 /* A ruby object clone init func that fails by raising an exception. */
66 VALUE grpc_rb_cannot_init_copy(VALUE copy, VALUE self);
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);
71 void grpc_ruby_fork_guard();
73 void grpc_ruby_init();
75 void grpc_ruby_shutdown();
77 #endif /* GRPC_RB_H_ */