Files
five/hbrtl/setcmd.go
Charles KWON OhJun 59568f3301 Five v0.9 — Harbour + Go fusion language
- Compiler: PP → Lexer → Parser → Analyzer → Gengo pipeline
- Parser: 232/236 (98%) Harbour compatibility, registry-based dispatch
- RTL: 351 Harbour-compatible functions
- RDD: DBF/NTX/CDX engines with Rushmore bitmap optimization
- Go Interop: IMPORT + pkg.Func() + obj:Method() with FastPath (15M calls/sec)
- HB_FUNC API: Full Harbour C API compatible Go bridge
- Concurrency: SPAWN/LAUNCH/GOROUTINE, <-, WATCH, PARALLEL FOR, ASYNC/AWAIT
- Extensions: Multi-return, DEFER, Slice, f-string, Nil-safe ?:, CONST
- Macro Compiler: Runtime AST parsing and evaluation
- Debugger: TUI debugger with source display, breakpoints, stepping
- FRB: Native + Pcode dual mode runtime binary
- Tests: 13 packages ALL PASS

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 09:41:50 +09:00

117 lines
2.5 KiB
Go

// Copyright (c) 2026 Charles KWON OhJun (charleskwonohjun@gmail.com)
// All rights reserved.
// SET command functions: SET EXACT, SET SOFTSEEK, SET DELETED, SET EXCLUSIVE,
// SET(_SET_xxx, lValue) pattern.
// Harbour: src/rtl/set.c — 47+ settings in HB_SET_ENUM.
package hbrtl
import (
"five/hbrt"
"sync"
)
// SET indices (Harbour HB_SET_ENUM compatible)
const (
SetExact = 1
SetFixed = 2
SetDecimals = 3
SetDateFmt = 4
SetEpoch = 5
SetPath = 6
SetDefault = 7
SetDeleted = 8
SetExclusive = 11
SetSoftSeek = 12
SetUnique = 13
SetCancel = 14
SetConfirm = 15
SetConsole = 16
SetAlternate = 17
SetDevice = 18
SetPrinter = 19
SetBell = 20
SetEscape = 21
SetInsert = 22
SetExit = 23
SetIntensity = 24
SetScoreB = 25
SetColorIdx = 26
SetCursorIdx = 27
SetWrap = 28
SetMessage = 29
)
var (
settings = map[int]hbrt.Value{
SetExact: hbrt.MakeBool(false),
SetFixed: hbrt.MakeBool(false),
SetDecimals: hbrt.MakeInt(2),
SetDeleted: hbrt.MakeBool(false),
SetExclusive: hbrt.MakeBool(true),
SetSoftSeek: hbrt.MakeBool(false),
SetUnique: hbrt.MakeBool(false),
SetCancel: hbrt.MakeBool(true),
SetConfirm: hbrt.MakeBool(false),
SetConsole: hbrt.MakeBool(true),
SetBell: hbrt.MakeBool(false),
SetEscape: hbrt.MakeBool(true),
SetInsert: hbrt.MakeBool(false),
SetExit: hbrt.MakeBool(false),
SetIntensity: hbrt.MakeBool(true),
SetWrap: hbrt.MakeBool(false),
}
setMu sync.Mutex
)
// SET(nSpecifier [, xNewValue]) → xOldValue
// Generic SET function matching Harbour's Set() function.
func SetFunc(t *hbrt.Thread) {
nParams := t.ParamCount()
t.Frame(nParams, 0)
defer t.EndProc()
nSet := t.Local(1).AsInt()
setMu.Lock()
defer setMu.Unlock()
old, exists := settings[nSet]
if !exists {
old = hbrt.MakeNil()
}
if nParams >= 2 && !t.Local(2).IsNil() {
settings[nSet] = t.Local(2)
}
t.RetVal(old)
}
// GetSetting returns a SET value (called internally).
func GetSetting(nSet int) hbrt.Value {
setMu.Lock()
defer setMu.Unlock()
v, ok := settings[nSet]
if !ok {
return hbrt.MakeNil()
}
return v
}
// GetSetDeleted returns SET DELETED state.
func GetSetDeleted() bool {
return GetSetting(SetDeleted).AsBool()
}
// GetSetExact returns SET EXACT state.
func GetSetExact() bool {
return GetSetting(SetExact).AsBool()
}
// GetSetSoftSeek returns SET SOFTSEEK state.
func GetSetSoftSeek() bool {
return GetSetting(SetSoftSeek).AsBool()
}