just starting
This commit is contained in:
14
kiwi.lua
14
kiwi.lua
@@ -345,7 +345,7 @@ end
|
||||
do
|
||||
--- Variables are the values the constraint solver calculates.
|
||||
---@class kiwi.Var: ffi.cdata*
|
||||
---@overload fun(name: string): kiwi.Var
|
||||
---@overload fun(name: string?): kiwi.Var
|
||||
---@operator mul(number): kiwi.Term
|
||||
---@operator div(number): kiwi.Term
|
||||
---@operator unm: kiwi.Term
|
||||
@@ -559,7 +559,7 @@ do
|
||||
---@param expr kiwi.Expression
|
||||
---@param constant number
|
||||
---@nodiscard
|
||||
local function mul_expr_constant(expr, constant)
|
||||
local function mul_expr_coeff(expr, constant)
|
||||
local ret = ffi_gc(ffi_new(Expression, expr.term_count), ckiwi.kiwi_expression_del_vars) --[[@as kiwi.Expression]]
|
||||
for i = 0, expr.term_count - 1 do
|
||||
local st = expr.terms_[i] --[[@as kiwi.Term]]
|
||||
@@ -662,9 +662,9 @@ do
|
||||
|
||||
function Expression_mt.__mul(a, b)
|
||||
if type(a) == "number" then
|
||||
return mul_expr_constant(b, a)
|
||||
return mul_expr_coeff(b, a)
|
||||
elseif type(b) == "number" then
|
||||
return mul_expr_constant(a, b)
|
||||
return mul_expr_coeff(a, b)
|
||||
end
|
||||
op_error(a, b, "*")
|
||||
end
|
||||
@@ -673,11 +673,11 @@ do
|
||||
if type(b) ~= "number" then
|
||||
op_error(a, b, "/")
|
||||
end
|
||||
return mul_expr_constant(a, 1.0 / b)
|
||||
return mul_expr_coeff(a, 1.0 / b)
|
||||
end
|
||||
|
||||
function Expression_mt:__unm()
|
||||
return mul_expr_constant(self, -1.0)
|
||||
return mul_expr_coeff(self, -1.0)
|
||||
end
|
||||
|
||||
function Expression_mt.__add(a, b)
|
||||
@@ -719,7 +719,7 @@ do
|
||||
--- Constraints can be built with arbitrary left and right hand expressions. But
|
||||
--- ultimately they all have the form `expression [op] 0`.
|
||||
---@class kiwi.Constraint: ffi.cdata*
|
||||
---@overload fun(lhs: kiwi.Expression, rhs: kiwi.Expression?, op: kiwi.RelOp?, strength: number?): kiwi.Constraint
|
||||
---@overload fun(lhs: kiwi.Expression?, rhs: kiwi.Expression?, op: kiwi.RelOp?, strength: number?): kiwi.Constraint
|
||||
local Constraint_cls = {
|
||||
--- The strength of the constraint.
|
||||
---@type fun(self: kiwi.Constraint): number
|
||||
|
||||
Reference in New Issue
Block a user