nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 3 | * Copyright 2015 gRPC authors. |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 4 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 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 |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 8 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 10 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 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. |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 16 | * |
| 17 | */ |
| 18 | |
| 19 | #ifndef GRPC_RB_H_ |
| 20 | #define GRPC_RB_H_ |
| 21 | |
Nicolas "Pixel" Noble | 357cb81 | 2015-05-14 05:33:43 +0200 | [diff] [blame] | 22 | #include <ruby/ruby.h> |
Craig Tiller | 5b1c5f2 | 2017-04-19 09:52:18 -0700 | [diff] [blame] | 23 | #include <sys/time.h> |
Nicolas "Pixel" Noble | 357cb81 | 2015-05-14 05:33:43 +0200 | [diff] [blame] | 24 | |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 25 | #include <grpc/support/time.h> |
| 26 | |
Yuki Yugui Sonoda | a7d369e | 2015-04-11 11:48:36 +0900 | [diff] [blame] | 27 | /* grpc_rb_mGrpcCore is the module containing the ruby wrapper GRPC classes. */ |
| 28 | extern VALUE grpc_rb_mGrpcCore; |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 29 | |
Yuki Yugui Sonoda | a7d369e | 2015-04-11 11:48:36 +0900 | [diff] [blame] | 30 | /* grpc_rb_sNewServerRpc is the struct that holds new server rpc details. */ |
| 31 | extern VALUE grpc_rb_sNewServerRpc; |
temiola | 21bb60c | 2014-12-18 10:58:22 -0800 | [diff] [blame] | 32 | |
Yuki Yugui Sonoda | a7d369e | 2015-04-11 11:48:36 +0900 | [diff] [blame] | 33 | /* grpc_rb_sStruct is the struct that holds status details. */ |
| 34 | extern VALUE grpc_rb_sStatus; |
temiola | 21bb60c | 2014-12-18 10:58:22 -0800 | [diff] [blame] | 35 | |
Yuki Yugui Sonoda | a7d369e | 2015-04-11 11:48:36 +0900 | [diff] [blame] | 36 | /* sym_code is the symbol for the code attribute of grpc_rb_sStatus. */ |
Yuki Yugui Sonoda | 99eb9f9 | 2015-04-16 20:09:55 +0900 | [diff] [blame] | 37 | extern VALUE sym_code; |
Tim Emiola | 98a32d3 | 2015-03-28 01:48:44 -0700 | [diff] [blame] | 38 | |
Yuki Yugui Sonoda | a7d369e | 2015-04-11 11:48:36 +0900 | [diff] [blame] | 39 | /* sym_details is the symbol for the details attribute of grpc_rb_sStatus. */ |
Yuki Yugui Sonoda | 99eb9f9 | 2015-04-16 20:09:55 +0900 | [diff] [blame] | 40 | extern VALUE sym_details; |
Tim Emiola | 98a32d3 | 2015-03-28 01:48:44 -0700 | [diff] [blame] | 41 | |
Yuki Yugui Sonoda | a7d369e | 2015-04-11 11:48:36 +0900 | [diff] [blame] | 42 | /* sym_metadata is the symbol for the metadata attribute of grpc_rb_sStatus. */ |
Yuki Yugui Sonoda | 99eb9f9 | 2015-04-16 20:09:55 +0900 | [diff] [blame] | 43 | extern VALUE sym_metadata; |
Tim Emiola | 98a32d3 | 2015-03-28 01:48:44 -0700 | [diff] [blame] | 44 | |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 45 | /* 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 Sonoda | 76801d2 | 2015-04-11 14:20:27 +0900 | [diff] [blame] | 47 | #define GRPC_RB_GC_NOT_MARKED (RUBY_DATA_FUNC)(NULL) |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 48 | |
| 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 Sonoda | 76801d2 | 2015-04-11 14:20:27 +0900 | [diff] [blame] | 52 | #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 Tiller | 5b1c5f2 | 2017-04-19 09:52:18 -0700 | [diff] [blame] | 56 | #define GRPC_RB_MEMSIZE_UNAVAILABLE (size_t(*)(const void*))(NULL) |
nnoble | 097ef9b | 2014-12-01 17:06:10 -0800 | [diff] [blame] | 57 | |
| 58 | /* A ruby object alloc func that fails by raising an exception. */ |
| 59 | VALUE grpc_rb_cannot_alloc(VALUE cls); |
| 60 | |
| 61 | /* A ruby object init func that fails by raising an exception. */ |
| 62 | VALUE grpc_rb_cannot_init(VALUE self); |
| 63 | |
| 64 | /* A ruby object clone init func that fails by raising an exception. */ |
| 65 | VALUE grpc_rb_cannot_init_copy(VALUE copy, VALUE self); |
| 66 | |
| 67 | /* grpc_rb_time_timeval creates a gpr_timespec from a ruby time object. */ |
| 68 | gpr_timespec grpc_rb_time_timeval(VALUE time, int interval); |
| 69 | |
Alexander Polcyn | 2a9b5d7 | 2017-04-14 12:10:55 -0700 | [diff] [blame] | 70 | void grpc_ruby_once_init(); |
| 71 | |
Craig Tiller | b5dcec5 | 2015-01-13 11:13:42 -0800 | [diff] [blame] | 72 | #endif /* GRPC_RB_H_ */ |