Commit 519231fb

519231fb3f31Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 7 months ago · 1 file · ~1 modified

Description

feat: add String#eql? and String#hash

eql? is equivalent to == for strings (strcmp-based comparison). hash uses the existing sp_str_hash function, useful for building custom hash tables or equality checks.

Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]

Details

Commit
519231fb3f31
Parent
af3fc4d42699

spinel_codegen.rbmodifiedView file

@@ -1491,6 +1491,12 @@
14911491 if mname == "delete_prefix" || mname == "delete_suffix"
14921492 return "string"
14931493 end
1494+ if mname == "eql?"
1495+ return "bool"
1496+ end
1497+ if mname == "hash"
1498+ return "int"
1499+ end
14941500 if mname == "strip"
14951501 return "string"
14961502 end
@@ -11743,6 +11749,12 @@
1174311749 if mname == "delete_suffix"
1174411750 return "sp_str_delete_suffix(" + rc + ", " + compile_arg0(nid) + ")"
1174511751 end
11752+ if mname == "eql?"
11753+ return "(strcmp(" + rc + ", " + compile_arg0(nid) + ") == 0)"
11754+ end
11755+ if mname == "hash"
11756+ return "(mrb_int)sp_str_hash(" + rc + ")"
11757+ end
1174611758 if mname == "strip"
1174711759 return "sp_str_strip(" + rc + ")"
1174811760 end