blob: 577902319edf769242ad86cbce0f5c8a73e1338e [file] [log] [blame]
nnoble097ef9b2014-12-01 17:06:10 -08001/*
2 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003 * Copyright 2015 gRPC authors.
nnoble097ef9b2014-12-01 17:06:10 -08004 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02005 * 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
nnoble097ef9b2014-12-01 17:06:10 -08008 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009 * http://www.apache.org/licenses/LICENSE-2.0
nnoble097ef9b2014-12-01 17:06:10 -080010 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +020011 * 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.
nnoble097ef9b2014-12-01 17:06:10 -080016 *
17 */
18
19#ifndef GRPC_RB_H_
20#define GRPC_RB_H_
21
Nicolas "Pixel" Noble357cb812015-05-14 05:33:43 +020022#include <ruby/ruby.h>
Craig Tiller5b1c5f22017-04-19 09:52:18 -070023#include <sys/time.h>
Nicolas "Pixel" Noble357cb812015-05-14 05:33:43 +020024
nnoble097ef9b2014-12-01 17:06:10 -080025#include <grpc/support/time.h>
26
Yuki Yugui Sonodaa7d369e2015-04-11 11:48:36 +090027/* grpc_rb_mGrpcCore is the module containing the ruby wrapper GRPC classes. */
28extern VALUE grpc_rb_mGrpcCore;
nnoble097ef9b2014-12-01 17:06:10 -080029
Yuki Yugui Sonodaa7d369e2015-04-11 11:48:36 +090030/* grpc_rb_sNewServerRpc is the struct that holds new server rpc details. */
31extern VALUE grpc_rb_sNewServerRpc;
temiola21bb60c2014-12-18 10:58:22 -080032
Yuki Yugui Sonodaa7d369e2015-04-11 11:48:36 +090033/* grpc_rb_sStruct is the struct that holds status details. */
34extern VALUE grpc_rb_sStatus;
temiola21bb60c2014-12-18 10:58:22 -080035
Yuki Yugui Sonodaa7d369e2015-04-11 11:48:36 +090036/* sym_code is the symbol for the code attribute of grpc_rb_sStatus. */
Yuki Yugui Sonoda99eb9f92015-04-16 20:09:55 +090037extern VALUE sym_code;
Tim Emiola98a32d32015-03-28 01:48:44 -070038
Yuki Yugui Sonodaa7d369e2015-04-11 11:48:36 +090039/* sym_details is the symbol for the details attribute of grpc_rb_sStatus. */
Yuki Yugui Sonoda99eb9f92015-04-16 20:09:55 +090040extern VALUE sym_details;
Tim Emiola98a32d32015-03-28 01:48:44 -070041
Yuki Yugui Sonodaa7d369e2015-04-11 11:48:36 +090042/* sym_metadata is the symbol for the metadata attribute of grpc_rb_sStatus. */
Yuki Yugui Sonoda99eb9f92015-04-16 20:09:55 +090043extern VALUE sym_metadata;
Tim Emiola98a32d32015-03-28 01:48:44 -070044
nnoble097ef9b2014-12-01 17:06:10 -080045/* GC_NOT_MARKED is used in calls to Data_Wrap_Struct to indicate that the
46 wrapped struct does not need to participate in ruby gc. */
Yuki Yugui Sonoda76801d22015-04-11 14:20:27 +090047#define GRPC_RB_GC_NOT_MARKED (RUBY_DATA_FUNC)(NULL)
nnoble097ef9b2014-12-01 17:06:10 -080048
49/* GC_DONT_FREED is used in calls to Data_Wrap_Struct to indicate that the
50 wrapped struct should not be freed the wrapped ruby object is released by
51 the garbage collector. */
Yuki Yugui Sonoda76801d22015-04-11 14:20:27 +090052#define GRPC_RB_GC_DONT_FREE (RUBY_DATA_FUNC)(NULL)
53
54/* GRPC_RB_MEMSIZE_UNAVAILABLE is used in rb_data_type_t to indicate that the
55 * number of bytes used by the wrapped struct is not available. */
Craig Tiller5b1c5f22017-04-19 09:52:18 -070056#define GRPC_RB_MEMSIZE_UNAVAILABLE (size_t(*)(const void*))(NULL)
nnoble097ef9b2014-12-01 17:06:10 -080057
58/* A ruby object alloc func that fails by raising an exception. */
59VALUE grpc_rb_cannot_alloc(VALUE cls);
60
61/* A ruby object init func that fails by raising an exception. */
62VALUE grpc_rb_cannot_init(VALUE self);
63
64/* A ruby object clone init func that fails by raising an exception. */
65VALUE grpc_rb_cannot_init_copy(VALUE copy, VALUE self);
66
67/* grpc_rb_time_timeval creates a gpr_timespec from a ruby time object. */
68gpr_timespec grpc_rb_time_timeval(VALUE time, int interval);
69
Alexander Polcyn2a9b5d72017-04-14 12:10:55 -070070void grpc_ruby_once_init();
71
Craig Tillerb5dcec52015-01-13 11:13:42 -080072#endif /* GRPC_RB_H_ */