- 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>
152 lines
2.8 KiB
Go
152 lines
2.8 KiB
Go
// Copyright (c) 2026 Charles KWON OhJun (charleskwonohjun@gmail.com)
|
|
// All rights reserved.
|
|
|
|
// Index and database introspection RTL functions.
|
|
|
|
package hbrtl
|
|
|
|
import (
|
|
"five/hbrt"
|
|
"five/hbrdd"
|
|
)
|
|
|
|
// INDEXORD() → nCurrentOrder
|
|
func IndexOrd(t *hbrt.Thread) {
|
|
t.Frame(0, 0)
|
|
defer t.EndProc()
|
|
// Simplified: return 0 (no active order)
|
|
t.RetInt(0)
|
|
}
|
|
|
|
// INDEXKEY([nOrder]) → cKeyExpression
|
|
func IndexKey(t *hbrt.Thread) {
|
|
nParams := t.ParamCount()
|
|
t.Frame(nParams, 0)
|
|
defer t.EndProc()
|
|
t.RetString("")
|
|
}
|
|
|
|
// ORDSETFOCUS([nOrder|cTag]) → nOldOrder
|
|
func OrdSetFocus(t *hbrt.Thread) {
|
|
nParams := t.ParamCount()
|
|
t.Frame(nParams, 0)
|
|
defer t.EndProc()
|
|
wam := getWA(t)
|
|
if wam == nil {
|
|
t.RetInt(0)
|
|
return
|
|
}
|
|
area := wam.Current()
|
|
if area == nil {
|
|
t.RetInt(0)
|
|
return
|
|
}
|
|
if nParams >= 1 && !t.Local(1).IsNil() {
|
|
if idx, ok := area.(hbrdd.Indexer); ok {
|
|
tag := t.Local(1).AsString()
|
|
idx.OrderListFocus(tag)
|
|
}
|
|
}
|
|
t.RetInt(0)
|
|
}
|
|
|
|
// ORDCOUNT() → nOrders
|
|
func OrdCount(t *hbrt.Thread) {
|
|
t.Frame(0, 0)
|
|
defer t.EndProc()
|
|
t.RetInt(0)
|
|
}
|
|
|
|
// ORDNAME([nOrder]) → cTagName
|
|
func OrdName(t *hbrt.Thread) {
|
|
nParams := t.ParamCount()
|
|
t.Frame(nParams, 0)
|
|
defer t.EndProc()
|
|
t.RetString("")
|
|
}
|
|
|
|
// ORDKEY([nOrder]) → cKeyExpression
|
|
func OrdKey(t *hbrt.Thread) {
|
|
nParams := t.ParamCount()
|
|
t.Frame(nParams, 0)
|
|
defer t.EndProc()
|
|
t.RetString("")
|
|
}
|
|
|
|
// ORDFOR([nOrder]) → cForExpression
|
|
func OrdFor(t *hbrt.Thread) {
|
|
nParams := t.ParamCount()
|
|
t.Frame(nParams, 0)
|
|
defer t.EndProc()
|
|
t.RetString("")
|
|
}
|
|
|
|
// DBINFO(nInfoType [, xNewSetting]) → xInfo
|
|
func DbInfo(t *hbrt.Thread) {
|
|
nParams := t.ParamCount()
|
|
t.Frame(nParams, 0)
|
|
defer t.EndProc()
|
|
t.RetNil()
|
|
}
|
|
|
|
// ORDINFO(nInfoType [, cOrder]) → xInfo
|
|
func OrdInfo(t *hbrt.Thread) {
|
|
nParams := t.ParamCount()
|
|
t.Frame(nParams, 0)
|
|
defer t.EndProc()
|
|
t.RetNil()
|
|
}
|
|
|
|
// RDDSETDEFAULT([cDriver]) → cOldDriver
|
|
func RddSetDefault(t *hbrt.Thread) {
|
|
nParams := t.ParamCount()
|
|
t.Frame(nParams, 0)
|
|
defer t.EndProc()
|
|
t.RetString("DBFNTX")
|
|
}
|
|
|
|
// DBCREATE(cFile, aStruct [, cDriver]) → NIL
|
|
func DbCreate(t *hbrt.Thread) {
|
|
nParams := t.ParamCount()
|
|
t.Frame(nParams, 0)
|
|
defer t.EndProc()
|
|
|
|
cFile := t.Local(1).AsString()
|
|
aStruct := t.Local(2)
|
|
cDriver := "DBFNTX"
|
|
if nParams >= 3 && !t.Local(3).IsNil() {
|
|
cDriver = t.Local(3).AsString()
|
|
}
|
|
|
|
if !aStruct.IsArray() {
|
|
t.RetNil()
|
|
return
|
|
}
|
|
|
|
arr := aStruct.AsArray()
|
|
fields := make([]hbrdd.FieldInfo, len(arr.Items))
|
|
for i, item := range arr.Items {
|
|
row := item.AsArray()
|
|
if row == nil || len(row.Items) < 4 {
|
|
continue
|
|
}
|
|
fields[i] = hbrdd.FieldInfo{
|
|
Name: row.Items[0].AsString(),
|
|
Type: row.Items[1].AsString()[0],
|
|
Len: row.Items[2].AsInt(),
|
|
Dec: row.Items[3].AsInt(),
|
|
}
|
|
}
|
|
|
|
drv, err := hbrdd.GetDriver(cDriver)
|
|
if err != nil {
|
|
t.RetNil()
|
|
return
|
|
}
|
|
drv.Create(hbrdd.CreateParams{
|
|
Path: cFile,
|
|
Fields: fields,
|
|
})
|
|
t.RetNil()
|
|
}
|