diff --git a/CommKrnl.dll b/CommKrnl.dll index da97f81..37f2325 100644 Binary files a/CommKrnl.dll and b/CommKrnl.dll differ diff --git a/TSLDebugModule.dll b/TSLDebugModule.dll index 56c5cec..4311836 100644 Binary files a/TSLDebugModule.dll and b/TSLDebugModule.dll differ diff --git a/TSLInterp.dll b/TSLInterp.dll index c4ea5cf..99f8008 100644 Binary files a/TSLInterp.dll and b/TSLInterp.dll differ diff --git a/TSSVRAPI.DLL b/TSSVRAPI.DLL index 5028901..c974271 100644 Binary files a/TSSVRAPI.DLL and b/TSSVRAPI.DLL differ diff --git a/designer/utslcodeeditor.tsf b/designer/utslcodeeditor.tsf index ecc2b16..d33a391 100644 --- a/designer/utslcodeeditor.tsf +++ b/designer/utslcodeeditor.tsf @@ -5241,7 +5241,7 @@ type tfincodemap = class(tcustomcontrol) end else FString := s; flistv := getblocktypes(); - if s then r := unit(utssvr_tsltoken_c).get_tsl_tokenizeex(s,flistv);// tsl_tokenizeex_2_(s,flistv); + if s then r := unit(utssvr_api_c).get_tsl_tokenizeex(s,flistv);// tsl_tokenizeex_2_(s,flistv); else r := array(); fcaretya := -1; fcaretyb := -1; diff --git a/designer/utslsynmemo.tsf b/designer/utslsynmemo.tsf index 9b0b0be..f98331a 100644 --- a/designer/utslsynmemo.tsf +++ b/designer/utslsynmemo.tsf @@ -339,7 +339,7 @@ type TTSLCompletion= class(TSynCompletion) r[idx]["order"] := 0; idx++; end - gjz := unit(utssvr_tsltoken_c).get_sys_functions();//tslL_getfunctions_2_(); + gjz := unit(utssvr_api_c).get_sys_functions();//tslL_getfunctions_2_(); for i,v in gjz do begin c := v+" "; @@ -400,7 +400,7 @@ type TTslSynHighLighter = class(TSynHighLighter) FKeyWords[v] := v; end FBinFunc := array(); - for i,v in unit(utssvr_tsltoken_c).get_sys_functions() do + for i,v in unit(utssvr_api_c).get_sys_functions() do begin FBinFunc[v]:=v; end @@ -1885,7 +1885,7 @@ type TTsfFileParser = class() // s := d["value"]; if not(s and ifstring(s)) then return rt ; if errtslcode(s) then return rt; - r := unit(utssvr_tsltoken_c).get_tsl_tokenizeex(s,1);//tsl_tokenizeex_2_(s,1); + r := unit(utssvr_api_c).get_tsl_tokenizeex(s,1);//tsl_tokenizeex_2_(s,1); if not( r and ifarray(r)) then return rt; cls := array(); ScriptDelBlocks(r["blcks"],str2array(s,"\n"),cls); @@ -2176,7 +2176,7 @@ type TTsfFileParser = class() // r := array(); rdd := ""; end else - r := unit(utssvr_tsltoken_c).get_tsl_tokenizeex(rdd,1);//tsl_tokenizeex_2_(rdd,1); + r := unit(utssvr_api_c).get_tsl_tokenizeex(rdd,1);//tsl_tokenizeex_2_(rdd,1); end else begin r := array(); diff --git a/designer/utslvcldebuger.tsf b/designer/utslvcldebuger.tsf index 69f1b9a..1f55fa6 100644 --- a/designer/utslvcldebuger.tsf +++ b/designer/utslvcldebuger.tsf @@ -1549,7 +1549,7 @@ type TTslDebuga=class(TCustomControl) FRuningfile := item.OrigScriptPath; // %% E:\TSUIGROUP\script\tgdb.tsl%%; FDebugtsfs["__main__"]:= FRuningfile; ls := item.FEditer.lines; - d := unit(utssvr_tsltoken_c).get_tsl_tokenizeex(item.FEditer.Text,0xffff);//tsl_tokenizeex_2_(item.FEditer.Text,0xffff); + d := unit(utssvr_api_c).get_tsl_tokenizeex(item.FEditer.Text,0xffff);//tsl_tokenizeex_2_(item.FEditer.Text,0xffff); for i,v in d["blcks"] do begin s := ls.GetStringByIndex(v["mbeg"]-1); diff --git a/designer/utslvcldesigner.tsf b/designer/utslvcldesigner.tsf index 06b4d56..08292e7 100644 --- a/designer/utslvcldesigner.tsf +++ b/designer/utslvcldesigner.tsf @@ -2074,8 +2074,8 @@ begin unit(utssvr_api_c).get_tssvr_api_c(); np := getdesignerpath()+"dcmps"+ioFileseparator(); CreateDirWithFileName(np+"1.txt"); - g_orig_lib_path := get_self_libpath()+";"+Getfuncextdir();//tsl_getlibpath_() - set_self_libpath( np+";"+g_orig_lib_path);//tsl_setlibpath_ + g_orig_lib_path := sysgettsllibpath()+";"+Getfuncextdir();//tsl_getlibpath_() + syssettsllibpath( np+";"+g_orig_lib_path);//tsl_setlibpath_ ini := static getdesginerini(); //class(TDSocketServer),class(TDSocketClient), //注册的componet diff --git a/editor-install.exe b/editor-install.exe index c964e16..7f6e885 100644 Binary files a/editor-install.exe and b/editor-install.exe differ diff --git a/funcext/tvclib/cstructurelib.tsf b/funcext/tvclib/cstructurelib.tsf index 415c85e..3ac192f 100644 --- a/funcext/tvclib/cstructurelib.tsf +++ b/funcext/tvclib/cstructurelib.tsf @@ -1232,7 +1232,7 @@ type t_mem_mgr = class() //if not _tool then _tool := 0; try - _tool := new aefclassobj_(); + if findclass("aefclassobj_") then _tool := new aefclassobj_(); except end; diff --git a/funcext/tvclib/tslvcl.tsf b/funcext/tvclib/tslvcl.tsf index 739a62e..fcd907f 100644 --- a/funcext/tvclib/tslvcl.tsf +++ b/funcext/tvclib/tslvcl.tsf @@ -6088,7 +6088,7 @@ type Ttfm2Component = class(TTmfParser) function GetLibPaths(); //获得libpath begin unit(utssvr_api_c).get_tssvr_api_c(); - p := get_self_libpath(); + p := sysgettsllibpath(); if not p then return array(); wapi := gettswin32api(); FCurrentp := wapi.get_current_directory(); diff --git a/funcext/tvclib/utslvclcefinterface.tsf b/funcext/tvclib/utslvclcefinterface.tsf index 7cfd588..93348e3 100644 --- a/funcext/tvclib/utslvclcefinterface.tsf +++ b/funcext/tvclib/utslvclcefinterface.tsf @@ -1,6 +1,7 @@ unit utslvclcefinterface; interface uses cstructurelib; +function cef_version_info(entry:integer); function cef_object_get(ptr,cls); function cef_object_del(ptr); function cef_dictionary_value_create(); diff --git a/funcext/tvclib/utssvr_api_c.tsf b/funcext/tvclib/utssvr_api_c.tsf index 596ede0..886d2d0 100644 --- a/funcext/tvclib/utssvr_api_c.tsf +++ b/funcext/tvclib/utssvr_api_c.tsf @@ -2,7 +2,10 @@ unit utssvr_api_c; interface function get_tssvr_api_c(); function get_func_finder_register(); +function get_sys_functions(); +function get_tsl_tokenizeex(s,flg); implementation +uses cstructurelib; function get_tssvr_api_c(); begin return static new t_tssvr_api_c(); @@ -11,6 +14,21 @@ function get_func_finder_register(); begin return static new t_func_finder_register(); end +function get_sys_functions(); +begin + return static get_tokener().tslL_getfunctions(); +end +function get_tsl_tokenizeex(s,flg); +begin + o := get_tokener(); + o.flags := flg; + o.source := s; + return o.result(); +end +function get_tokener(); +begin + return static new t_tsltokenex2(); +end type tsl_c_api_const = class() {$ifdef linux} static const C_TSSVRAPI="libTSSVRAPI.so"; @@ -22,9 +40,25 @@ type tsl_c_api_const = class() static const C_TSLInterp="TSLInterp.dll"; {$endif} end +function main_thread_check(ck_name); +begin + myid := systhreadid(); + mytd := nil; + if getglobalcache(ck_name,mytd) then + begin + return mytd<>myid; + end else + begin + setglobalcache(ck_name,myid); + end + return false ; +end type t_func_finder_register = class(tsl_c_api_const) //函数注册类型 function create(); begin + //////////////////////////////////////////////////////////////// + if main_thread_check("~@~create-thread-func-finder~@~") then raise "t_func_finder_register created must in main thread!"; + ////////////////////////////////////////////////////// t := C_TSSVRAPI; fhookseted := false; fhooks := array(); @@ -83,16 +117,221 @@ type t_func_finder_register = class(tsl_c_api_const) // fhookptr; fhooks; end +type t_tsltokenex2 = class(tsl_c_api_const) //脚本解析 + public + function create(); + begin + t := C_TSSVRAPI; + //TSL_TokenizeEx2(s,flg); + if findfunction("tsl_tokenizeex_2_") then fustslulib := true; + else fustslulib := false; + fsource := array(); + fresult := array(); + skiperror := true; + fflags := 2^13-1; + end + function tslL_getfunctions();//系统函数 + begin + //return array(); + if fustslulib then + begin + return tsll_getfunctions_2_(); + end + fs := 0; + cnt := 0; + _f_ := static procedure(var fs:pointer;var cnt:integer);cdecl ;external getdlsymaddress(C_PLUGIN,functionname(1)); + ##_f_(fs,ct); + return strs_ptr_to_array(fs,ct-1,1); + end + property source read fsource write set_source; + property result read get_result; + property flags read fflags write set_lags; + private + fustslulib;//替换 + function strs_ptr_to_array(ps,n,fr); //一维字符串数组 + begin + mt := get_mem_mgr(); + r := array(); + i := 0; + if ps=0 then return r; + while true do + begin + if n>0 and i>=n then break; + p := mt.readptr(ps+8*i); + if p=0 then + begin + n := i-1; + break; + end + r[i] := mt.readstr(p); + if not fr then + mt.tfree(p); + i++; + end + return r; + end + function strs_ptr_to_array2(ps,n);//二维字符串数组 + begin + mt := get_mem_mgr(); + r := array(); + if ps=0 then return r; + i := 0; + while true do + begin + if n>0 and i>=n then break; + p := mt.readptr(ps+8*i); + if p=0 then + begin + n := i; + break; + end + r[i] := strs_ptr_to_array(p); + i++; + end + mt.tfree(ps); + return r; + end + function ints_ptr_to_array(ps,n,flg); + begin + mt := get_mem_mgr(); + r := array(); + if ps=0 then return r; + i := 0; + while true do + begin + if i>=n then break; + t := mt.readint(ps+4*i); + if t=flg then break; + r[i] := t; + i++; + end + mt.tfree(ps); + return r; + end + function TSL_InterpNewErrorInfo(); + begin + _f_ := static function():pointer;cdecl;external getdlsymaddress(C_TSLInterp,functionname(1)); + return static ##_f_(); + end + + function TSL_TokenizeEx2(); + begin + if fustslulib then + begin + fresult := tsl_tokenizeex_2_(fsource,fflags); + return; + end + oResult := TSL_InterpNewErrorInfo(); + _f_ := static function(sc:string;skiperror:integer; + var sWords:pointer; var sUnits:pointer; + var sClasses:pointer;var sFunctions:pointer; + var iLines:pointer;var iBeginEnds:pointer; + var Dependency:pointer;var retBlocks:pointer; + var retBlockCount:integer;fflags:integer; oResult:pointer):integer;cdecl;external getdlsymaddress(C_TSLInterp,functionname(1)); + //echo _f_; + ##_f_(fsource,true,sWords,sUnits,sClasses,sFunctions,iLines,iBeginEnds,sDependency,retBlocks,retBlockCount,fflags,oResult); + fresult := array(); + fresult["words"] :=strs_ptr_to_array(sWords); + fresult["units"] :=strs_ptr_to_array(sUnits); + fresult["class"] :=strs_ptr_to_array(sClasses); + n := 0; + fresult["functions"] := strs_ptr_to_array2(sFunctions,n); + fresult["lines"] := ints_ptr_to_array(iLines,n); + fresult["linebegend"] := ints_ptr_to_array(iBeginEnds,nil,-1); + fresult["dep"] := strs_ptr_to_array(sDependency); + fresult["blcks"] := getblicks(retBlocks,retBlockCount); + end + function getblicks(ptr,n); + begin + r := array(); + if ptr=0 then return r; + mt := get_mem_mgr(); + for i := 0 to n-1 do + begin + p := mt.readptr(ptr+i*8); + bki := new BlockForEditor(p); + r[i,"mtype"] := bki._getvalue_("mType"); + r[i,"mbeg"] := bki._getvalue_("mBeg"); + r[i,"mend"] := bki._getvalue_("mEnd"); + ct := bki._getvalue_("mSubs"); + r[i,"msubs"] := ct; + if ct>0 then + r[i,"msub"] := getblicks(bki._getvalue_("mSub"),ct); + end + return r; + end + function get_result(); + begin + if ifnil(fresult) then + begin + TSL_TokenizeEx2(); + end + return fresult; + end + function set_source(s); + begin + if fsource<>s and ifstring(s) then + begin + fsource := s; + fresult := nil; + end + end + function set_lags(f); + begin + if f>0 and f<>fflags then + begin + fflags := f; + fresult := nil; + end + end + private + fsource; + fflags; + fresult; + private + static const Block_TypeClass = 1; + static const Block_Function = 2; + static const Block_Statements = 4; + static const Block_If = 8; + static const Block_Else = 16; + static const Block_SubCase = 32; + static const Block_Goto_Label = 64; + static const Block_Empty_Begin_End = 128; + static const Block_Try = 256; + static const Block_NeedSql = 512; + static const Block_UnitStruct = 1024; + static const Block_Propertys = 2048; + static const Block_Fields = 4096; +end +type BlockForEditor=class(tslcstructureobj) + public + function create(ptr) + begin + inherited create(getstruct(),ptr); + end + private + static SSTRUCT; + class function getstruct() + begin + if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array( + ("mType","int",0), + ("mBeg","int",0), + ("mEnd","int",0), + ("mSubs","int",0), + ("mFolded","int",0), //这个字段什么意思 + ("mSub","intptr",0), + ("Clear","intptr",0) //cptr := _getvalue_("Clear"); f := procedure();cdecl;external cptr; + )); + return SSTRUCT; + end +end type t_tssvr_api_c = class(tsl_c_api_const) function create(); begin t := C_TSSVRAPI; - isok := 0; - if not getglobalcache("@@tsl_c_api@@",isok) then - begin - setglobalcache("@@tsl_c_api@@","tsl_c_api"); - reg_libpath_funcs(); - end + if main_thread_check("~@~create-thread-tssvr_api~@~") then raise "t_tssvr_api_c created must in main thread!"; + reg_libpath_funcs(); + end class function TSL_ObjToStr(L:pointer;v:pointer):string; begin @@ -247,8 +486,11 @@ type t_tssvr_api_c = class(tsl_c_api_const) private class function reg_libpath_funcs();//注册需要的函数 begin - tslL_register(0,"get_self_libpath",makeinstance(thisfunction(get_self_libpath),"cdecl",0)); - tslL_register(0,"set_self_libpath",makeinstance(thisfunction(set_self_libpath),"cdecl",0)); + if not findfunction("syssettsllibpath") then + begin + tslL_register(0,"sysgettsllibpath",makeinstance(thisfunction(get_self_libpath),"cdecl",0)); + tslL_register(0,"syssettsllibpath",makeinstance(thisfunction(set_self_libpath),"cdecl",0)); + end end // end diff --git a/funcext/tvclib/utssvr_tsltoken_c.tsf b/funcext/tvclib/utssvr_tsltoken_c.tsf deleted file mode 100644 index f20ed67..0000000 --- a/funcext/tvclib/utssvr_tsltoken_c.tsf +++ /dev/null @@ -1,227 +0,0 @@ -unit utssvr_tsltoken_c; -interface -function get_sys_functions(); -function get_tsl_tokenizeex(s,flg); -implementation -uses cstructurelib; -function get_sys_functions(); -begin - return static get_tokener().tslL_getfunctions(); -end -function get_tsl_tokenizeex(s,flg); -begin - o := get_tokener(); - o.flags := flg; - o.source := s; - return o.result(); -end -function get_tokener(); -begin - return static new t_tsltokenex2(); -end - -type t_tsltokenex2 = class() //脚本解析 - {$ifdef linux} - static const C_TSSVRAPI="libTSSVRAPI.so"; - static const C_PLUGIN="libTSLPlugin.so"; - static const C_TSLInterp="libTSLInterp.so"; - {$else} - static const C_TSSVRAPI="TSSVRAPI.dll"; - static const C_PLUGIN="TSLPlugin.dll"; - static const C_TSLInterp="TSLInterp.dll"; - {$endif} - public - function create(); - begin - //TSL_TokenizeEx2(s,flg); - fsource := array(); - fresult := array(); - skiperror := true; - fflags := 2^13-1; - end - function tslL_getfunctions();//系统函数 - begin - //return array(); - fs := 0; - cnt := 0; - _f_ := static procedure(var fs:pointer;var cnt:integer);cdecl ;external getdlsymaddress(C_PLUGIN,functionname(1)); - ##_f_(fs,ct); - return strs_ptr_to_array(fs,ct-1,1); - end - property source read fsource write set_source; - property result read get_result; - property flags read fflags write set_lags; - private - function strs_ptr_to_array(ps,n,fr); //一维字符串数组 - begin - mt := get_mem_mgr(); - r := array(); - i := 0; - if ps=0 then return r; - while true do - begin - if n>0 and i>=n then break; - p := mt.readptr(ps+8*i); - if p=0 then - begin - n := i-1; - break; - end - r[i] := mt.readstr(p); - if not fr then - mt.tfree(p); - i++; - end - return r; - end - function strs_ptr_to_array2(ps,n);//二维字符串数组 - begin - mt := get_mem_mgr(); - r := array(); - if ps=0 then return r; - i := 0; - while true do - begin - if n>0 and i>=n then break; - p := mt.readptr(ps+8*i); - if p=0 then - begin - n := i; - break; - end - r[i] := strs_ptr_to_array(p); - i++; - end - mt.tfree(ps); - return r; - end - function ints_ptr_to_array(ps,n,flg); - begin - mt := get_mem_mgr(); - r := array(); - if ps=0 then return r; - i := 0; - while true do - begin - if i>=n then break; - t := mt.readint(ps+4*i); - if t=flg then break; - r[i] := t; - i++; - end - mt.tfree(ps); - return r; - end - function TSL_InterpNewErrorInfo(); - begin - _f_ := static function():pointer;cdecl;external getdlsymaddress(C_TSLInterp,functionname(1)); - return static ##_f_(); - end - - function TSL_TokenizeEx2(); - begin - oResult := TSL_InterpNewErrorInfo(); - _f_ := static function(sc:string;skiperror:integer; - var sWords:pointer; var sUnits:pointer; - var sClasses:pointer;var sFunctions:pointer; - var iLines:pointer;var iBeginEnds:pointer; - var Dependency:pointer;var retBlocks:pointer; - var retBlockCount:integer;fflags:integer; oResult:pointer):integer;cdecl;external getdlsymaddress(C_TSLInterp,functionname(1)); - //echo _f_; - ##_f_(fsource,true,sWords,sUnits,sClasses,sFunctions,iLines,iBeginEnds,sDependency,retBlocks,retBlockCount,fflags,oResult); - fresult := array(); - fresult["words"] :=strs_ptr_to_array(sWords); - fresult["units"] :=strs_ptr_to_array(sUnits); - fresult["class"] :=strs_ptr_to_array(sClasses); - n := 0; - fresult["functions"] := strs_ptr_to_array2(sFunctions,n); - fresult["lines"] := ints_ptr_to_array(iLines,n); - fresult["linebegend"] := ints_ptr_to_array(iBeginEnds,nil,-1); - fresult["dep"] := strs_ptr_to_array(sDependency); - fresult["blcks"] := getblicks(retBlocks,retBlockCount); - end - function getblicks(ptr,n); - begin - r := array(); - if ptr=0 then return r; - mt := get_mem_mgr(); - for i := 0 to n-1 do - begin - p := mt.readptr(ptr+i*8); - bki := new BlockForEditor(p); - r[i,"mtype"] := bki._getvalue_("mType"); - r[i,"mbeg"] := bki._getvalue_("mBeg"); - r[i,"mend"] := bki._getvalue_("mEnd"); - ct := bki._getvalue_("mSubs"); - r[i,"msubs"] := ct; - if ct>0 then - r[i,"msub"] := getblicks(bki._getvalue_("mSub"),ct); - end - return r; - end - function get_result(); - begin - if ifnil(fresult) then - begin - TSL_TokenizeEx2(); - end - return fresult; - end - function set_source(s); - begin - if fsource<>s and ifstring(s) then - begin - fsource := s; - fresult := nil; - end - end - function set_lags(f); - begin - if f>0 and f<>fflags then - begin - fflags := f; - fresult := nil; - end - end - private - fsource; - fflags; - fresult; - private - static const Block_TypeClass = 1; - static const Block_Function = 2; - static const Block_Statements = 4; - static const Block_If = 8; - static const Block_Else = 16; - static const Block_SubCase = 32; - static const Block_Goto_Label = 64; - static const Block_Empty_Begin_End = 128; - static const Block_Try = 256; - static const Block_NeedSql = 512; - static const Block_UnitStruct = 1024; - static const Block_Propertys = 2048; - static const Block_Fields = 4096; -end -type BlockForEditor=class(tslcstructureobj) - public - function create(ptr) - begin - inherited create(getstruct(),ptr); - end - private - static SSTRUCT; - class function getstruct() - begin - if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array( - ("mType","int",0), - ("mBeg","int",0), - ("mEnd","int",0), - ("mSubs","int",0), - ("mFolded","int",0), //这个字段什么意思 - ("mSub","intptr",0), - ("Clear","intptr",0) //cptr := _getvalue_("Clear"); f := procedure();cdecl;external cptr; - )); - return SSTRUCT; - end -end -end. \ No newline at end of file diff --git a/funcext/tvclib/uvclthreadworker.tsf b/funcext/tvclib/uvclthreadworker.tsf index e9c8307..19a9784 100644 --- a/funcext/tvclib/uvclthreadworker.tsf +++ b/funcext/tvclib/uvclthreadworker.tsf @@ -19,7 +19,6 @@ type TCustomThreadworker = class(t_worker_host) begin eg := unit(utssvr_api_c).get_func_finder_register(); eg.add_hook(thisfunction(finder)); - //fn := "t_thread_call_back_"$tarraycont; fn := add_thread_call(ns); end fp := findfunction(fn); @@ -29,9 +28,10 @@ type TCustomThreadworker = class(t_worker_host) end if not fp then raise ("工作线程构造失败!回调函数错误!" $fn); set_heartbeat(); - p := format_thread_param(systhreadid(),fn); + p := format_thread_param(get_thread_id(),fn); b := static makeinstance(thisfunction(t_thread_worker),"stdcall",1); cid :=create_thread(b,p); + if not cid then raise ("工作线程构造失败!可能是堆栈不够"); inherited create(cid); ////////////////// end @@ -60,15 +60,15 @@ type TCustomThreadworker = class(t_worker_host) begin setglobalcache("~~main~~threader~~",1,(now()+0.015)); end - static lenct; class function dispatch(); begin if not FThreaders then return ; set_heartbeat(); + lsdata := nil; for idx,i in mrows(FThreaders,1) do begin o := FThreaders[i]; - msg := o.fetch(data); + msg := o.fetch(data,nil,lsdata); if msg then begin case msg of @@ -106,8 +106,7 @@ type TCustomThreadworker = class(t_worker_host) end end property handle read FHandle; - private - + private class function init_workerhost(); begin if not ifarray(FThreaders) then @@ -145,12 +144,12 @@ type t_worker_host = class(t_worker_base) inherited; end function destroy();override; - begin + begin if fworkerstate=1 then - begin - clear(); + begin post_to_("qq",1); end + clear(); FCatcheData := array(); inherited; end @@ -165,7 +164,7 @@ type t_worker_host = class(t_worker_base) **} function terminate();override; begin - if fworkerstate=1 then inherited; + if fworkerstate=1 then return inherited; end function ClientReady(flg); //任务句柄改变 begin @@ -276,53 +275,64 @@ type t_worker_base = class() function create(id); begin FData := array(); - fmy_thread := systhreadid(); + fmy_thread := get_thread_id(); fto_thread:=id; fpostct := 0; end function close(); //关闭 begin - terminate(); + return terminate(); end function terminate();virtual; //停止 begin - post_to_("q",1); + return post_to_("q",1); end function postmessage(d);virtual; //发送数据 begin return post_to_("#d",d); - end - function fetch(d); //获取数据 + end + class function fetch_byid(id,cid,d); begin - ls := listglobalcache(); - myid := "#"$fmy_thread$"#"$fto_thread$"#"; nw := now(); + sid := "#"$id$"#"; + ls := select ["name"] from listglobalcache() where(["endtm"]>nw and 1=pos(sid,["name"])) order by ["createtm"] end ; + for i,vd in ls do + begin + v := vd["name"]; + if getglobalcache(v,d) and not ifnil(d) then + begin + r := get_v_type(v); + del_name(v); + ss := str2array(v,"#"); + cid := strtoint64def(ss[2],0); + return r; + end + end + end + function fetch(d,flg,ls); //获取数据 + begin + nw := now(); + if not ifarray(ls) then + begin + if flg then + begin + ls := select ["name"] from listglobalcache() where(["endtm"]>nw) order by ["createtm"] end ; + end else + begin + ls := listglobalcache(); + end + end + myid := "#"$fmy_thread$"#"$fto_thread$"#"; for i,vd in ls do begin v := vd["name"]; endm := vd["endtm"]; - if endm>0 and endm0 and endm5 then + if heartbeatstoped>3 then //主线程已经退出了 begin - this.post_to_("qq",1); + //this.post_to_("qq",1); + this.clear(); return ;//systerminate(2,mypid); end end - msg := this.fetch(d); + msg := this.fetch(d,true,nil); case msg of "d":begin //数据 if iffuncptr(fptr) then - begin + begin try call(fptr,this,d); except this.err(exceptobject.errinfo); end; - end + end sleep(1); end "qq": @@ -436,8 +468,7 @@ begin this.clear(); return 1;//systerminate(1,mypid); end - "q":begin //退出 - + "q":begin //要求退出 this.clear(); this.post_to_("qq",1); return ;//systerminate(1,mypid); @@ -447,18 +478,67 @@ begin sleep(10); end end ; - tslprocessmessages(false); //20230428添加tsl消息分发 - + tslprocessmessages(false); //20230428添加tsl消息分发 end end +function get_thread_id(); +begin +{$ifdef linux} + return systhreadself(); +{$endif} + return systhreadid(); +end function create_thread(f,p);//构造线程 begin -{$ifdef linux} - return g_thread_new(f,p); +{$ifdef linux} + return pthread_create(f,p); + //return g_thread_new(f,p); {$endif} return CreateThread(f,p); end -function g_thread_new(f:pointer;p:pointer):pointer; +///////////////////////////////pthread//////////////////////////////// +{type pthread_attr_t = class(tslcstructureobj) + function create(ptr); + begin + inherited Create(getpstr(),ptr); + end + private + static pstrc; + function getpstr(); + begin + if not pstrc then + begin + d := array( + ("detachstate","int",0),//int detachstate; // 线程的分离状态 + ("schedpolicy","int",0),//int schedpolicy; // 线程调度策略 + ("schedparam","int",0), //structsched_param schedparam; // 线程的调度参数 + ("inheritsched","int",0), //int inheritsched; // 线程的继承性 + ("scope","int",0), //int scope; // 线程的作用域 + ("guardsize","intptr",0), // size_t guardsize; // 线程栈末尾的警戒缓冲区大小 + ("stackaddr_set","int",0), //int stackaddr_set; // 线程的栈设置 + ("stackaddr","intptr",0), //void* stackaddr; // 线程栈的位置 + ("stacksize","intptr",0) //size_t stacksize; // 线程栈的大小 + + ); + pstrc := MemoryAlignmentCalculate(d); + end + return pstrc; + end +end +function pthread_attr_init(attr):integer; +begin + _f_ := static function(attr:pointer):integer;cdecl; external getdlsymaddress( "libc.so.6" ,functionname(1)); + return ##_f_(attr._getptr_()); +end } +function pthread_create(f,p):integer; +begin + //attr := new pthread_attr_t();pthread_attr_init(attr);attr._setvalue_("stacksize",10240000); + pth := 0; + _f_ := static function(var thread:pointer;attr:pointer; f:pointer;arg:pointer):integer;cdecl; external getdlsymaddress( "libc.so.6" ,functionname(1)); + if 0= ##_f_(pth,0,f,p) then return pth; +end +/////////////////////gthread/////////////////////////////// +{function g_thread_new(f:pointer;p:pointer):pointer; begin if not g_thread_get_initialized() then g_thread_init(); _f_ := static function(n:string;f:pointer;p:pointer):pointer;cdecl; external getdlsymaddress( "libgtk-3.so.0" ,functionname(1)); @@ -473,7 +553,8 @@ function g_thread_init():Integer; begin _f_ := static function():Integer;cdecl; external getdlsymaddress( "libgtk-3.so.0" ,functionname(1)); return ##_f_(); -end +end } +/////////////////////////////////////////////////////// function CreateThread(f:pointer;p:pointer):pointer; begin _f_ := static function(attr:pointer;size:pointer;addr:pointer;p:pointer;flag:Integer;var threadid:Integer):pointer;stdcall; external getdlsymaddress( "kernel32.dll" , functionname(1)); diff --git a/plugin/TSLCPLUGIN.DLL b/plugin/TSLCPLUGIN.DLL index 245c9c1..e2e1283 100644 Binary files a/plugin/TSLCPLUGIN.DLL and b/plugin/TSLCPLUGIN.DLL differ diff --git a/plugin/TSLClient.dll b/plugin/TSLClient.dll index 5d0bd68..7b9f0f4 100644 Binary files a/plugin/TSLClient.dll and b/plugin/TSLClient.dll differ diff --git a/plugin/TSSecurity.dll b/plugin/TSSecurity.dll index fb4edf4..809db6d 100644 Binary files a/plugin/TSSecurity.dll and b/plugin/TSSecurity.dll differ diff --git a/protocol.dll b/protocol.dll index 26706bb..e789fb6 100644 Binary files a/protocol.dll and b/protocol.dll differ diff --git a/tsjni.dll b/tsjni.dll index 12e18ca..5cbefde 100644 Binary files a/tsjni.dll and b/tsjni.dll differ diff --git a/tsleditor.exe b/tsleditor.exe index 496722a..c4ed928 100644 Binary files a/tsleditor.exe and b/tsleditor.exe differ diff --git a/tsnet.dll b/tsnet.dll index 85ba489..024e22e 100644 Binary files a/tsnet.dll and b/tsnet.dll differ diff --git a/whatsnew.txt b/whatsnew.txt index d9b486e..0a7ebd7 100644 --- a/whatsnew.txt +++ b/whatsnew.txt @@ -1,3 +1,14 @@ +更新日志--------2024-04-23 + 修订:TS-SQL的JDBC链接模式下在SQLTABLE的使用中比较列名时忽略大小写。 + 修订:解决JDBC链接模式下PG/Gauss下取得的列名都被转换为小写的问题。 + 修订:MakeInstance多线程问题。 + 修订:Linux上threadname设置问题。 + 修订:GetMsgDigest Linux下表现异常问题。 + 修订:Unicode和中文 mbcs在ubuntu下转换的问题。 + 修订:SysExec在某些linux下存在的问题。 + 升级:新增函数:systhreadself,在linux下返回pthread_t类型的pthread_self(),原有systhreadid修正为真实的threadid。 + 升级:新增函数:syssettsllibpath,sysgettsllibpath,允许启动后修改函数的查找路径。 + 更新日志--------2024-04-18 升级:JDBC从数据库传递巨型结果集给TSL的支持。 修订:因openssl 1.0.2库的线程非安全导致的LIBCURL-TSL的多线程并发可能出现的崩溃问题。