Sivelkiria Operating System repository

Commit fbf9b144 authored by Skymagic's avatar Skymagic
Browse files

Добавлен тест на деление A на B. Тип данных: int64

parent f0edf205
......@@ -7,4 +7,5 @@
<type name="mathematics.arithmetics.summer" version-major="0" handle="4" />
<type name="mathematics.arithmetics.substracter" version-major="0" handle="5" />
<type name="mathematics.arithmetics.multiplicator" version-major="0" handle="6" />
<type name="mathematics.arithmetics.devider" version-major="0" handle="7" />
</types>
<?xml version="1.0" encoding="utf-8"?>
<interface xmlns="https://api.sivelkiria.org/sivelkiria_type_definition.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="../sivelkiria_type_definition.xsd" support-type="in-developent">
<name>mathematics.arithmetics.devider</name>
<version-major>0</version-major>
<version-minor-max>0</version-minor-max>
<method name="devide_int64" id="0" since-version-minor="0">
<return type-name="primitive.int64" type-version-major="0">
<description language="en-US">
Devide A by B.
</description>
</return>
<description language="en-US">
Deviding A by B.
</description>
<exception-info language="en-US">
Throws if the result overflows or B = 0.
</exception-info>
<argument name="A" type-name="primitive.int64" type-version-major="0" direction="in">
<description language="en-US">
First of input values (dividend).
</description>
</argument>
<argument name="B" type-name="primitive.int64" type-version-major="0" direction="in">
<description language="en-US">
Second of input values (divisor).
</description>
</argument>
</method>
<description language="en-US">
The quotient of two int64-numbers.
</description>
</interface>
......@@ -8,6 +8,7 @@ set(headers
"include/sivtypes/automobile/interface/external_lighting.0.h"
"include/sivtypes/exceptions/exception.0.h"
"include/sivtypes/geography/location.0.h"
"include/sivtypes/mathematics/arithmetics/devider.0.h"
"include/sivtypes/mathematics/arithmetics/multiplicator.0.h"
"include/sivtypes/mathematics/arithmetics/substracter.0.h"
"include/sivtypes/mathematics/arithmetics/summer.0.h"
......@@ -34,6 +35,7 @@ set(sources
"source/automobile/interface/external_lighting.0.cpp"
"source/exceptions/exception.0.cpp"
"source/geography/location.0.cpp"
"source/mathematics/arithmetics/devider.0.cpp"
"source/mathematics/arithmetics/multiplicator.0.cpp"
"source/mathematics/arithmetics/substracter.0.cpp"
"source/mathematics/arithmetics/summer.0.cpp"
......
#pragma once
#include <sivdk/interface.h>
#include <sivdk/method_info/method_by_id.h>
#include <sivdk/method_info/method_to_id.h>
#include <cstdint>
namespace sivtypes { namespace mathematics { namespace arithmetics {
class devider_0_proxy;
/// The quotient of two int64-numbers.
/// This class stays for the 0 major version of mathematics.arithmetics.devider interface. Inherit it to make sure your
/// code always implements the latest minor version available in SivDK used. When doing so, you will be forced to
/// implement all new methods on each update of the interface as they are all avaoiable as pure virtual functions at
/// this level.
class devider_0 : public virtual ::sivdk::interface
{
private:
/// Noncopyable.
devider_0(const devider_0&) = delete;
/// Nonmoveable.
devider_0(devider_0&&) = delete;
protected:
/// Server object constructor.
devider_0()
{}
public:
/// Type of the proxy object for this interface.
using proxy_type = devider_0_proxy;
/// Interface handle.
static constexpr ::sivdk::interface_handle interface_handle = ::sivdk::interface_handle(7);
/// Gets interface handle in runtime.
/// @return Same handle as calculated by @p interface_handle.
::sivdk::interface_handle get_interface_handle() const override
{
return ::sivdk::interface_handle(7);
}
/// Gets major version of the interface.
/// @return major version of the interface.
static constexpr ::sivdk::version_type get_major_version()
{
return 0;
}
/// Gets minor version of the interface.
/// @return minor version of the interface.
static constexpr ::sivdk::version_type get_minor_version()
{
return 0;
}
/// Gets minor version of the interface.
/// @return minor version of the interface.
::sivdk::version_type get_interface_minor_version() const override
{
return 0;
}
/// Destructor.
virtual ~devider_0() = default;
/// Handles incoming call into current object by parsing kernel data and passsing proper arguments to required
/// method of the required interface and then passing packing return value, changed reference parameters and/or
/// exception information back into kernel data pack.
/// @param interface Handle of interface to call into.
/// @param method Identifier of the method to be called.
/// @param data Binary data pack, as provided by kernel.
/// @return True if data pack was properly parsed and updated, false otherwise.
bool handle_call(::sivdk::interface_handle interface, ::sivdk::method_id method, void* data) override;
/// Handles incoming call into current interface by parsing kernel data and passsing proper arguments to required
/// method and then passing packing return value, changed reference parameters and/or exception information back
/// into kernel data pack.
/// @param method Identifier of the method to be called.
/// @param data Binary data pack, as provided by kernel.
/// @return True if data pack was properly parsed and updated, false otherwise.
bool handle_interface_call(::sivdk::method_id method, void* data);
public:
// Interface methods below.
/// Deviding A by B.
/// @param A First of input values (dividend).
/// @param B Second of input values (divisor).
/// @returns Devide A by B.
/// @throws Throws if the result overflows or B = 0.
virtual int64_t devide_int64(int64_t A, int64_t B) = 0;
private:
static_assert(!std::is_same<proxy_type, void>::value, "Disable warning on unused typedef");
};
/// The quotient of two int64-numbers.
/// This class stays for the 0.0 version of mathematics.arithmetics.devider version 0 interface. Inherit it to make sure
/// your code implements this exact version. If any more methods are being added in later minor versions of the
/// interface, you won't need to implement these. At SivDK level, these are overloaded with virtual functions
/// implementations that always throw 'not supported' exception. However, overriding these is meaningless as the kernel
/// will never initiate these calls because the information on exact minor version implemented is available to it.
class devider_0_0 : public devider_0
{
private:
/// Noncopyable.
devider_0_0(const devider_0_0&) = delete;
/// Nonmoveable.
devider_0_0(devider_0_0&&) = delete;
public:
/// Gets minor version of the interface.
/// @return minor version of the interface.
static constexpr ::sivdk::version_type get_minor_version()
{
return 0;
}
/// Gets minor version of the interface.
/// @return minor version of the interface.
sivdk::version_type get_interface_minor_version() const override
{
return 0;
}
protected:
/// Constructor.
devider_0_0()
{}
public:
/// Destructor.
virtual ~devider_0_0() = default;
public:
// Interface methods below.
};
/// The quotient of two int64-numbers.
/// Proxy implementation that redirects all calls to kernel which in turn redirects them to owner module. There is no
/// need to use this class directly, create or inherit it, and so on,
class devider_0_proxy : public devider_0
{
private:
/// Noncopyable.
devider_0_proxy(const devider_0_proxy&) = delete;
/// Nonmoveable.
devider_0_proxy(devider_0_proxy&&) = delete;
public:
/// Proxy object constructor.
devider_0_proxy(::sivdk::call_data::proxy_handle_holder* handle_holder)
: ::sivdk::interface(handle_holder)
{}
/// Destructor.
virtual ~devider_0_proxy() = default;
/// Gets minor version of the interface.
/// @return minor version of the interface.
::sivdk::version_type get_interface_minor_version() const override
{
return 0;
}
public:
// Interface methods below.
/// Deviding A by B.
/// @param A First of input values (dividend).
/// @param B Second of input values (divisor).
/// @returns Devide A by B.
/// @throws Throws if the result overflows or B = 0.
int64_t devide_int64(int64_t A, int64_t B) override;
};
} } } // namespace sivtypes::mathematics::arithmetics
namespace sivdk { namespace method_info {
template <>
struct method_to_id<decltype(&::sivtypes::mathematics::arithmetics::devider_0::devide_int64), &::sivtypes::mathematics::arithmetics::devider_0::devide_int64> : method_to_id_base<0>
{};
template <>
struct method_by_id<::sivtypes::mathematics::arithmetics::devider_0, 0> : method_by_id_base<decltype(&::sivtypes::mathematics::arithmetics::devider_0::devide_int64), &::sivtypes::mathematics::arithmetics::devider_0::devide_int64>
{};
} } // namespace sivdk::method_info
#include <cstdint>
#include <sivtypes/mathematics/arithmetics/devider.0.h>
#include <sivdk/method_info/method_selector.h>
#include <sivdk/call_data/incoming_call_error_reporter.h>
#include <sivdk/outgoing_call.h>
#include <memory>
bool sivtypes::mathematics::arithmetics::devider_0::handle_call(::sivdk::interface_handle interface, ::sivdk::method_id method, void* data)
{
if (interface == ::sivdk::interface_handle(7))
return ::sivtypes::mathematics::arithmetics::devider_0::handle_interface_call(method, data);
::sivdk::call_data::incoming_call_error_reporter::report_unexpected_interface(data, interface);
return false;
}
bool sivtypes::mathematics::arithmetics::devider_0::handle_interface_call(::sivdk::method_id method, void* data)
{
return ::sivdk::method_info::method_selector<devider_0>::handle_call(this, method, data);
}
int64_t sivtypes::mathematics::arithmetics::devider_0_proxy::devide_int64(int64_t A, int64_t B)
{
::sivdk::outgoing_call<decltype(&devider_0::devide_int64), &devider_0::devide_int64> call(std::shared_ptr<devider_0>(this->shared_from_this(), this), A, B);
return call.wait();
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment