Beispiel #1
0
def multiply(left, right):
    result = protocall_pb2.Literal()
    print "multiply"
    print "left=",type(left)
    print "right=",type(right)
    v_left = value(left)
    v_right = value(right)
    print "v_left=", type(v_left)
    print "v_right=", type(v_right)
    result = v_left * v_right
    print "result=", result
    result.integer.value = result
    return result
Beispiel #2
0
def greater_than(left, right):
    result = protocall_pb2.Literal()
    result.boolean.value = value(left) > value(right)
    return result
Beispiel #3
0
def less_than(left, right):
    result = protocall_pb2.Literal()
    result.boolean.value = value(left) < value(right)
    return result
Beispiel #4
0
def equals(left, right):
    result = protocall_pb2.Literal()
    result.boolean.value = value(left) == value(right)
    return result
Beispiel #5
0
def divide(left, right):
    result = protocall_pb2.Literal()
    result.integer.value = value(left) / value(right)
    return result
Beispiel #6
0
def minus(left, right):
    result = protocall_pb2.Literal()
    result.integer.value = value(left) - value(right)
    return result
Beispiel #7
0
# Copyright 2016 Google Inc. All Rights Reserved.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

#     http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from protocall.proto import protocall_pb2

def is_true(arg):
    if not arg.literal.HasField("boolean"):
        raise RuntimeError
    return arg.literal.boolean.value


true = protocall_pb2.Boolean()
true.value = True
false = protocall_pb2.Boolean()
false.value = False

literal_true = protocall_pb2.Literal()
literal_true.boolean.CopyFrom(true)
literal_false = protocall_pb2.Literal()
literal_false.boolean.CopyFrom(false)