Add doc with ai
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,3 +4,4 @@
|
||||
**/*.log
|
||||
**/*.old
|
||||
xxx
|
||||
/dcai/
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
## Installing documentation system Doc-Gen
|
||||
|
||||
https://github.com/fynnfluegge/doc-comments-ai
|
||||
|
||||
|
||||
for f in upnp/*.go ; do
|
||||
dcai/bin/aicomment --ollama-model deepseek-coder:33b-instruct $f
|
||||
done
|
||||
@@ -48,12 +48,14 @@ func toBool(val interface{}) (bool, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// cmpBool compares two boolean values 'a' and 'b'. If they are equal it returns 0, if 'a' is false and 'b' is true it returns -1 else it returns 1.
|
||||
func cmpBool(a, b bool) int {
|
||||
if a == b {
|
||||
if a == b { // if both booleans are the same, return 0
|
||||
return 0
|
||||
}
|
||||
if !a && b {
|
||||
if !a && b { // if 'a' is false and 'b' is true, return -1
|
||||
return -1
|
||||
}
|
||||
return 1
|
||||
// otherwise, return 1
|
||||
return 1 // if 'a' is true or 'a' and 'b' are not the same
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// maxFloat returns the maximum value for floating point numbers given number of bits.
|
||||
// If bits is neither 32 nor 64, it defaults to returning the maximum float64 value.
|
||||
func maxFloat(bits int) float64 {
|
||||
switch bits {
|
||||
case 32:
|
||||
@@ -17,6 +19,9 @@ func maxFloat(bits int) float64 {
|
||||
}
|
||||
}
|
||||
|
||||
// minFloat returns the minimum float value for the given number of bits.
|
||||
// If bits are not recognized as either 32 or 64, it will default to the maximum
|
||||
// possible float64 value.
|
||||
func minFloat(bits int) float64 {
|
||||
switch bits {
|
||||
case 32:
|
||||
@@ -76,6 +81,8 @@ func toFloat(v interface{}, bits int) (float64, error) {
|
||||
return f, nil
|
||||
}
|
||||
|
||||
// cmpFloat64 compares two float64 values and returns an integer indicating their relation.
|
||||
// If a is less than b, it returns -1; if a is greater than b, it returns 1; otherwise, it returns 0.
|
||||
func cmpFloat64(a, b float64) int {
|
||||
switch {
|
||||
case a < b:
|
||||
|
||||
@@ -115,6 +115,7 @@ func checkIntBounds(v int64, bits int) (int64, error) {
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// cmpInt compares two integers 'a' and 'b'. If 'a' is less than 'b', it returns -1, if 'a' is greater than 'b' it returns 1, else it returns 0.
|
||||
func cmpInt(a, b int64) int {
|
||||
switch {
|
||||
case a < b:
|
||||
@@ -126,6 +127,10 @@ func cmpInt(a, b int64) int {
|
||||
}
|
||||
}
|
||||
|
||||
// cmpUint compares two unsigned integers, a and b.
|
||||
// It returns -1 if a < b.
|
||||
// It returns 1 if a > b.
|
||||
// It returns 0 if a == b.
|
||||
func cmpUint(a, b uint64) int {
|
||||
switch {
|
||||
case a < b:
|
||||
|
||||
@@ -2,6 +2,8 @@ package upnp
|
||||
|
||||
import "fmt"
|
||||
|
||||
// valuesToNumericOperands takes two interface{} values, casts them to a numeric type based on a given StateVarType, and returns their float64 equivalents.
|
||||
// If any error occurs during casting or conversion to float64, it is returned along with zero values for the operands.
|
||||
func valuesToNumericOperands(t StateVarType, a interface{}, b interface{}) (float64, float64, error) {
|
||||
var err error
|
||||
if !t.IsNumeric() {
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// toTime converts the given value to a time.Time type if possible, otherwise it returns an error.
|
||||
// The supported types for conversion are: time.Time, string, int64 and float64.
|
||||
func toTime(v interface{}) (time.Time, error) {
|
||||
switch val := v.(type) {
|
||||
case time.Time:
|
||||
@@ -43,6 +45,8 @@ func toTime(v interface{}) (time.Time, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// cmpTime compares two time.Times, returning -1 if the first is before the second,
|
||||
// 1 if the first is after the second, and 0 if they're equal.
|
||||
func cmpTime(a, b time.Time) int {
|
||||
switch {
|
||||
case a.Before(b):
|
||||
|
||||
Reference in New Issue
Block a user