GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — cel-python/cel_expr_python/py_cel_activation.cc at main · yarikoptic/cel-python Expand file tree/ Copy pathpy_cel_activation.ccMore file actions 88 lines (75 loc) · 3.18 KB / Copy pathpy_cel_activation.ccFile metadata and controls88 lines (75 loc) · 3.18 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 // Copyright 2025 Google LLC // // 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 // // https://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. #include "cel_expr_python/py_cel_activation.h" #include <Python.h> // IWYU pragma: keep - Needed for PyObject #include <memory> #include <string> #include <unordered_map> #include <utility> #include <vector> #include "absl/log/absl_check.h" #include "absl/strings/string_view.h" #include "common/function_descriptor.h" #include "common/kind.h" #include "cel_expr_python/py_cel_arena.h" #include "cel_expr_python/py_cel_env_internal.h" #include "cel_expr_python/py_cel_function.h" #include "cel_expr_python/py_cel_value_provider.h" #include "google/protobuf/arena.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/message.h" namespace cel_python { namespace py = ::pybind11; static const cel::FunctionDescriptorOptions kFunctionDescriptorOptions = { .is_strict = true, .is_contextual = true}; void PyCelActivation::DefinePythonBindings(py::module& m) { py::class_<PyCelActivation, std::shared_ptr<PyCelActivation>>(m, "Activation"); } PyCelActivation::PyCelActivation( std::shared_ptr<PyCelEnvInternal> env, const std::unordered_map<std::string, PyObject*>& data, const std::vector<std::shared_ptr<PyCelFunction>>& functions, const std::shared_ptr<PyCelArena>& arena) : env_(std::move(env)), arena_(std::move(arena)) { ABSL_CHECK(PyGILState_Check()); for (const auto& [name, value] : data) { auto provider = std::make_unique<PyCelValueProvider>(name, value, env_); activation_.InsertOrAssignValueProvider( name, [p = std::move(provider)]( absl::string_view, const google::protobuf::DescriptorPool* descriptor_pool, google::protobuf::MessageFactory* message_factory, google::protobuf::Arena* arena) { return p->Provide(descriptor_pool, message_factory, arena); }); } for (const auto& function : functions) { std::vector<cel::Kind> parameters; for (const auto& parameter : function->parameters()) { parameters.push_back(parameter.GetKind()); } cel::FunctionDescriptor func_descriptor(function->function_name(), function->is_member(), parameters, kFunctionDescriptorOptions); activation_.InsertFunction( func_descriptor, std::make_unique<PyCelFunctionAdapter>( function->function_name(), function->return_type(), function->impl())); } }; PyCelActivation::~PyCelActivation() = default; std::shared_ptr<PyCelEnvInternal> PyCelActivation::GetEnv() const { return env_; } } // namespace cel_python |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |