mirror of
https://github.com/unclechu/gRPC-haskell.git
synced 2024-11-23 11:39:43 +01:00
match signatures between header and code
This commit is contained in:
parent
6ad6a61c33
commit
8fc5ff2c18
6 changed files with 80 additions and 20 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
dist
|
dist
|
||||||
|
.stack-work/
|
||||||
|
|
|
@ -1,15 +1,23 @@
|
||||||
#include <grpc/grpc.h>
|
#include <grpc/grpc.h>
|
||||||
|
#include <grpc/impl/codegen/grpc_types.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <grpc_haskell.h>
|
||||||
|
|
||||||
grpc_event grpc_completion_queue_next_(grpc_completion_queue *cq,
|
grpc_event *grpc_completion_queue_next_(grpc_completion_queue *cq,
|
||||||
gpr_timespec *deadline,
|
gpr_timespec *deadline,
|
||||||
void *reserved) {
|
void *reserved) {
|
||||||
return grpc_completion_queue_next(cq, *deadline, reserved);
|
grpc_event *toReturn = malloc(sizeof(grpc_event));
|
||||||
|
*toReturn = grpc_completion_queue_next(cq, *deadline, reserved);
|
||||||
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
grpc_event grpc_completion_queue_pluck_(grpc_completion_queue *cq, void *tag,
|
grpc_event *grpc_completion_queue_pluck_(grpc_completion_queue *cq, void *tag,
|
||||||
gpr_timespec *deadline,
|
gpr_timespec *deadline,
|
||||||
void *reserved) {
|
void *reserved) {
|
||||||
return grpc_completion_queue_pluck(cq, tag, *deadline, reserved);
|
grpc_event *toReturn = malloc(sizeof(grpc_event));
|
||||||
|
*toReturn = grpc_completion_queue_pluck(cq, tag, *deadline, reserved);
|
||||||
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
grpc_call *grpc_channel_create_call_(grpc_channel *channel,
|
grpc_call *grpc_channel_create_call_(grpc_channel *channel,
|
||||||
|
@ -19,6 +27,6 @@ grpc_call *grpc_channel_create_call_(grpc_channel *channel,
|
||||||
const char *method, const char *host,
|
const char *method, const char *host,
|
||||||
gpr_timespec *deadline, void *reserved) {
|
gpr_timespec *deadline, void *reserved) {
|
||||||
return grpc_channel_create_call(channel, parent_call, propagation_mask,
|
return grpc_channel_create_call(channel, parent_call, propagation_mask,
|
||||||
completion_queue, method, host, *deadline,
|
completion_queue, method, host,
|
||||||
reserved);
|
*deadline, reserved);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
#include <grpc/grpc.h>
|
#include <grpc/grpc.h>
|
||||||
|
|
||||||
grpc_event *grpc_completion_queue_next_(grpc_completion_queue *cq,
|
grpc_event *grpc_completion_queue_next_(grpc_completion_queue *cq,
|
||||||
gpr_timespec *deadline);
|
gpr_timespec *deadline,
|
||||||
|
void *reserved);
|
||||||
|
|
||||||
grpc_event *grpc_completion_queue_pluck_(grpc_completion_queue *cq, void *tag,
|
grpc_event *grpc_completion_queue_pluck_(grpc_completion_queue *cq, void *tag,
|
||||||
gpr_timespec *deadline);
|
gpr_timespec *deadline,
|
||||||
|
void *reserved);
|
||||||
|
|
||||||
grpc_call *grpc_channel_create_call_(grpc_channel *channel,
|
grpc_call *grpc_channel_create_call_(grpc_channel *channel,
|
||||||
grpc_call *parent_call,
|
grpc_call *parent_call,
|
||||||
|
|
|
@ -5,8 +5,11 @@ module Network.GRPC.Core where
|
||||||
import Foreign.C.String
|
import Foreign.C.String
|
||||||
import Foreign.C.Types
|
import Foreign.C.Types
|
||||||
import Foreign.Ptr
|
import Foreign.Ptr
|
||||||
|
import Foreign.Storable
|
||||||
|
import Foreign.Marshal.Utils
|
||||||
|
|
||||||
import Network.GRPC.Core.Time
|
import Network.GRPC.Core.Time
|
||||||
|
import Network.GRPC.Core.Constants
|
||||||
|
|
||||||
#include <grpc/grpc.h>
|
#include <grpc/grpc.h>
|
||||||
#include <grpc/status.h>
|
#include <grpc/status.h>
|
||||||
|
@ -21,6 +24,8 @@ import Network.GRPC.Core.Time
|
||||||
{#pointer *grpc_channel as Channel newtype #}
|
{#pointer *grpc_channel as Channel newtype #}
|
||||||
{#pointer *grpc_server as Server newtype #}
|
{#pointer *grpc_server as Server newtype #}
|
||||||
{#pointer *grpc_call as Call newtype #}
|
{#pointer *grpc_call as Call newtype #}
|
||||||
|
{#pointer *grpc_call_details as CallDetails newtype #}
|
||||||
|
{#pointer *grpc_metadata_array as MetadataArray newtype #}
|
||||||
|
|
||||||
-- {#enum grpc_arg_type as ArgType {underscoreToCase} deriving (Eq)#}
|
-- {#enum grpc_arg_type as ArgType {underscoreToCase} deriving (Eq)#}
|
||||||
|
|
||||||
|
@ -48,13 +53,13 @@ data ArgValue = ArgString String | ArgInt Int
|
||||||
|
|
||||||
{#fun grpc_completion_queue_create as ^ {`Ptr ()'} -> `CompletionQueue'#}
|
{#fun grpc_completion_queue_create as ^ {`Ptr ()'} -> `CompletionQueue'#}
|
||||||
|
|
||||||
{#fun grpc_completion_queue_next_ as ^ {`CompletionQueue', `CTimeSpecPtr'} -> `Event'#}
|
{#fun grpc_completion_queue_next_ as ^ {`CompletionQueue', `CTimeSpecPtr', `Ptr ()'} -> `Event'#}
|
||||||
{#fun grpc_completion_queue_pluck_ as ^ {`CompletionQueue', `Ptr ()', `CTimeSpecPtr'} -> `Event'#}
|
{#fun grpc_completion_queue_pluck_ as ^ {`CompletionQueue', `Ptr ()', `CTimeSpecPtr', `Ptr ()'} -> `Event'#}
|
||||||
|
|
||||||
{#fun grpc_completion_queue_shutdown as ^ {`CompletionQueue'} -> `()'#}
|
{#fun grpc_completion_queue_shutdown as ^ {`CompletionQueue'} -> `()'#}
|
||||||
{#fun grpc_completion_queue_destroy as ^ {`CompletionQueue'} -> `()'#}
|
{#fun grpc_completion_queue_destroy as ^ {`CompletionQueue'} -> `()'#}
|
||||||
|
|
||||||
{#fun grpc_channel_create_call_ as ^ {`Channel', `Call', `Int', `CompletionQueue', `String', `String', `CTimeSpecPtr', `Ptr ()'} -> `Call'#}
|
{#fun grpc_channel_create_call_ as ^ {`Channel', `Call', fromIntegral `PropagationMask', `CompletionQueue', `String', `String', `CTimeSpecPtr', `Ptr ()'} -> `Call'#}
|
||||||
{#fun grpc_insecure_channel_create as ^ {`String', `ChannelArgsPtr', `Ptr ()'} -> `Channel'#}
|
{#fun grpc_insecure_channel_create as ^ {`String', `ChannelArgsPtr', `Ptr ()'} -> `Channel'#}
|
||||||
{#fun grpc_channel_destroy as ^ {`Channel'} -> `()'#}
|
{#fun grpc_channel_destroy as ^ {`Channel'} -> `()'#}
|
||||||
|
|
||||||
|
@ -62,3 +67,7 @@ data ArgValue = ArgString String | ArgInt Int
|
||||||
{#fun grpc_call_cancel as ^ {`Call', `Ptr ()'} -> `()'#}
|
{#fun grpc_call_cancel as ^ {`Call', `Ptr ()'} -> `()'#}
|
||||||
{#fun grpc_call_cancel_with_status as ^ {`Call', `StatusCode', `String', `Ptr ()'} -> `()'#}
|
{#fun grpc_call_cancel_with_status as ^ {`Call', `StatusCode', `String', `Ptr ()'} -> `()'#}
|
||||||
{#fun grpc_call_destroy as ^ {`Call'} -> `()'#}
|
{#fun grpc_call_destroy as ^ {`Call'} -> `()'#}
|
||||||
|
|
||||||
|
-- Server stuff
|
||||||
|
|
||||||
|
--{#fun grpc_server_request_call as ^ {`Server',with* `Call' peek*, `CallDetails', `MetadataArray', `CompletionQueue', `CompletionQueue', `Ptr ()'} -> `CallError'#}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||||
|
|
||||||
module Network.GRPC.Core.Constants where
|
module Network.GRPC.Core.Constants where
|
||||||
|
|
||||||
#include "grpc/grpc.h"
|
#include "grpc/grpc.h"
|
||||||
|
@ -19,16 +21,19 @@ writeNoCompress :: Int
|
||||||
writeNoCompress = #const GRPC_WRITE_NO_COMPRESS
|
writeNoCompress = #const GRPC_WRITE_NO_COMPRESS
|
||||||
|
|
||||||
newtype PropagationMask = PropagationMask {unPropagationMask :: Int}
|
newtype PropagationMask = PropagationMask {unPropagationMask :: Int}
|
||||||
deriving (Show, Eq, Ord)
|
deriving (Show, Eq, Ord, Integral, Enum, Real, Num)
|
||||||
|
|
||||||
propagateDeadline :: Int
|
propagateDeadline :: PropagationMask
|
||||||
propagateDeadline = #const GRPC_PROPAGATE_DEADLINE
|
propagateDeadline = PropagationMask $ #const GRPC_PROPAGATE_DEADLINE
|
||||||
|
|
||||||
propagateCensusStatsContext :: Int
|
propagateCensusStatsContext :: PropagationMask
|
||||||
propagateCensusStatsContext = #const GRPC_PROPAGATE_CENSUS_STATS_CONTEXT
|
propagateCensusStatsContext =
|
||||||
|
PropagationMask $ #const GRPC_PROPAGATE_CENSUS_STATS_CONTEXT
|
||||||
|
|
||||||
propagateCensusTracingContext :: Int
|
propagateCensusTracingContext :: PropagationMask
|
||||||
propagateCensusTracingContext = #const GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT
|
propagateCensusTracingContext =
|
||||||
|
PropagationMask $ #const GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT
|
||||||
|
|
||||||
propagateCancellation :: Int
|
propagateCancellation :: PropagationMask
|
||||||
propagateCancellation = #const GRPC_PROPAGATE_CANCELLATION
|
propagateCancellation =
|
||||||
|
PropagationMask $ #const GRPC_PROPAGATE_CANCELLATION
|
||||||
|
|
35
stack.yaml
Normal file
35
stack.yaml
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
# This file was automatically generated by stack init
|
||||||
|
# For more information, see: http://docs.haskellstack.org/en/stable/yaml_configuration/
|
||||||
|
|
||||||
|
# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
|
||||||
|
resolver: lts-5.10
|
||||||
|
|
||||||
|
# Local packages, usually specified by relative directory name
|
||||||
|
packages:
|
||||||
|
- '.'
|
||||||
|
# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)
|
||||||
|
extra-deps: []
|
||||||
|
|
||||||
|
# Override default flag values for local packages and extra-deps
|
||||||
|
flags: {}
|
||||||
|
|
||||||
|
# Extra package databases containing global packages
|
||||||
|
extra-package-dbs: []
|
||||||
|
|
||||||
|
# Control whether we use the GHC we find on the path
|
||||||
|
# system-ghc: true
|
||||||
|
|
||||||
|
# Require a specific version of stack, using version ranges
|
||||||
|
# require-stack-version: -any # Default
|
||||||
|
# require-stack-version: >= 1.0.0
|
||||||
|
|
||||||
|
# Override the architecture used by stack, especially useful on Windows
|
||||||
|
# arch: i386
|
||||||
|
# arch: x86_64
|
||||||
|
|
||||||
|
# Extra directories used by stack for building
|
||||||
|
# extra-include-dirs: [/path/to/dir]
|
||||||
|
# extra-lib-dirs: [/path/to/dir]
|
||||||
|
|
||||||
|
# Allow a newer minor version of GHC than the snapshot specifies
|
||||||
|
# compiler-check: newer-minor
|
Loading…
Reference in a new issue