Mator

[xEdit] [pascal] wbScriptAdapter.pas <FindRecords>

Sep 15th, 2015
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 71.36 KB | None | 0 0
  1. {*******************************************************************************
  2.  
  3.      The contents of this file are subject to the Mozilla Public License
  4.      Version 1.1 (the "License"); you may not use this file except in
  5.      compliance with the License. You may obtain a copy of the License at
  6.      http://www.mozilla.org/MPL/
  7.  
  8.      Software distributed under the License is distributed on an "AS IS"
  9.      basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
  10.      License for the specific language governing rights and limitations
  11.      under the License.
  12.  
  13. *******************************************************************************}
  14.  
  15. unit wbScriptAdapter;
  16.  
  17. {$I wbDefines.inc}
  18.  
  19. interface
  20.  
  21. uses
  22.   Classes,
  23.   SysUtils,
  24.   Variants,
  25.   Windows,
  26.   Graphics,
  27.   wbInterface,
  28.   wbImplementation,
  29.   wbHelpers,
  30.   wbBSA,
  31.   wbSort,
  32.   wbNifScanner,
  33.   wbLOD;
  34.  
  35. implementation
  36.  
  37. uses
  38.   JvInterpreter_System,
  39.   JvInterpreter_SysUtils,
  40.   JvInterpreter_Classes,
  41.   JvInterpreter_Dialogs,
  42.   JvInterpreter_Windows,
  43.   //JvInterpreter_Math,
  44.   //JvInterpreter_JvEditor,
  45.   JvInterpreter_Buttons,
  46.   JvInterpreter_Comctrls,
  47.   JvInterpreter_Contnrs,
  48.   JvInterpreter_Controls,
  49.   JvInterpreter_StdCtrls,
  50.   JvInterpreter_ExtCtrls,
  51.   JvInterpreter_Forms,
  52.   JvInterpreter_Graphics,
  53.   JvInterpreter_Menus,
  54.   JvInterpreter,
  55.   JvInterpreterFm,
  56.   wbScriptAdapterMisc;
  57.  
  58. const
  59.   cUnit = 'Dummy';
  60.   cInterface = 'wbInterface';
  61.   cTwbVector = 'TwbVector';
  62.   cTwbGridCell = 'TwbGridCell';
  63.  
  64.  
  65. { TElement }
  66. //procedure IwbElement_Name(var Value: Variant; Args: TJvInterpreterArgs);
  67. //var
  68. //  Element: IwbElement;
  69. //begin
  70. //  Value := '';
  71. //  if Supports(IInterface(Pointer(Args.Obj)), IwbElement, Element) then
  72. //    Value := Element.Name;
  73. //end;
  74.  
  75. procedure FindRecords(const aElement: IwbElement; const sig: string; var Records: TDynMainRecords; var Count: Integer);
  76. var
  77.   MainRecord  : IwbMainRecord;
  78.   Container   : IwbContainerElementRef;
  79.   i           : Integer;
  80. begin
  81.   if Supports(aElement, IwbMainRecord, MainRecord) then begin
  82.     if MainRecord.Signature = sig then begin
  83.       if High(Records) < Count then
  84.         SetLength(Records, Length(Records) * 2);
  85.       Records[Count] := MainRecord;
  86.       Inc(count);
  87.     end;
  88.   end
  89.   else if Supports(aElement, IwbContainerElementRef, Container) then
  90.     for i := 0 to Pred(Container.ElementCount) do
  91.       FindRecords(Container.Elements[i], sig, Records, Count);
  92. end;
  93.  
  94. function VarToCardinal(v: Variant): Cardinal;
  95. var
  96.   i64: Int64;
  97. begin
  98.   case VarType(v) and VarTypeMask of
  99.     varSmallInt, varShortInt, varInteger, varByte, varWord, varLongWord:
  100.       Result := v;
  101.     varSingle, varDouble:
  102.       Result := Round(v);
  103.     varInt64, varUInt64:
  104.       begin
  105.         i64 := v;
  106.         Result := Int64Rec(i64).Lo;
  107.       end;
  108.     varString, varUString:
  109.       Result := StrToInt(v);
  110.     else
  111.       // will most likely cause an exception
  112.       Result := v;
  113.   end;
  114. end;
  115.  
  116. procedure _Assigned(var Value: Variant; Args: TJvInterpreterArgs);
  117. begin
  118.   Value := Assigned(V2O(Args.Values[0]));
  119. end;
  120.  
  121. procedure ObjectToElement(var Value: Variant; Args: TJvInterpreterArgs);
  122. begin
  123.   try
  124.     Value := IwbElement(Pointer(V2O(Args.Values[0])));
  125.   except
  126.   end;
  127. end;
  128.  
  129. procedure _FullPathToFilename(var Value: Variant; Args: TJvInterpreterArgs);
  130. begin
  131.   Value := FullPathToFilename(String(Args.Values[0]));
  132. end;
  133.  
  134. procedure EnableSkyrimSaveFormat(var Value: Variant; Args: TJvInterpreterArgs);
  135. begin
  136.   wbTestWrite := True;
  137.   wbForceNewHeader := True;
  138. end;
  139.  
  140. procedure GetRecordDefNames(var Value: Variant; Args: TJvInterpreterArgs);
  141. var
  142.   sl: TStrings;
  143.   i: integer;
  144. begin
  145.   sl := TStrings(V2O(Args.Values[0]));
  146.  
  147.   if not Assigned(sl) then
  148.     Exit;
  149.  
  150.   for i := Low(wbRecordDefs) to High(wbRecordDefs) do
  151.     with wbRecordDefs[i].rdeDef do
  152.       sl.Add(DefaultSignature + ' - ' + GetName);
  153. end;
  154.  
  155. procedure wbFilterStrings(var Value: Variant; Args: TJvInterpreterArgs);
  156. var
  157.   slIn, slOut: TStrings;
  158.   Filter: string;
  159.   i: integer;
  160. begin
  161.   slIn := TStrings(V2O(Args.Values[0]));
  162.   slOut := TStrings(V2O(Args.Values[1]));
  163.   if not Assigned(slIn) or not Assigned(slOut) then
  164.     Exit;
  165.   Filter := string(Args.Values[2]);
  166.   for i := 0 to Pred(slIn.Count) do
  167.     if Pos(Filter, slIn[i]) > 0 then
  168.       slOut.Add(slIn[i]);
  169. end;
  170.  
  171. procedure wbRemoveDuplicateStrings(var Value: Variant; Args: TJvInterpreterArgs);
  172. var
  173.   sl: TStringList;
  174.   i, j: integer;
  175. begin
  176.   sl := TStringList(V2O(Args.Values[0]));
  177.   for i := Pred(sl.Count) downto 0 do begin
  178.     sl.Find(sl[i], j);
  179.     if (j <> -1) and (j <> i) then
  180.       sl.Delete(i);
  181.   end;
  182. end;
  183.  
  184. procedure wbGetVersionNumber(var Value: Variant; Args: TJvInterpreterArgs);
  185. var
  186.   fileInfo   : PVSFIXEDFILEINFO;
  187.   verlen     : Cardinal;
  188.   rs         : TResourceStream;
  189.   m          : TMemoryStream;
  190.   resource   : HRSRC;
  191. begin
  192.   Value := 0;
  193.   resource := FindResource(HInstance, PWideChar(1), RT_VERSION);
  194.   if resource = 0 then
  195.     Exit;
  196.   m := TMemoryStream.Create;
  197.   try
  198.     rs := TResourceStream.CreateFromID(HInstance, 1, RT_VERSION);
  199.     try m.CopyFrom(rs, rs.Size); finally rs.Free; end;
  200.     m.Position := 0;
  201.     if not VerQueryValue(m.Memory, '\', Pointer(fileInfo), verlen) then
  202.       Exit;
  203.     Value := fileInfo.dwFileVersionMS shl  8 and $FF000000 +
  204.              fileInfo.dwFileVersionMS shl 16 and $00FF0000 +
  205.              fileInfo.dwFileVersionLS shr  8 and $0000FF00 +
  206.              fileInfo.dwFileVersionLS        and $000000FF;
  207.   finally
  208.     m.Free;
  209.   end;
  210. end;
  211.  
  212.  
  213. { TwbVector }
  214.  
  215. function wbVector2Var(const wbVector: TwbVector): Variant;
  216. var
  217.   Rec: ^TwbVector;
  218. begin
  219.   New(Rec);
  220.   Rec^ := wbVector;
  221.   Result := R2V(cTwbVector, Rec);
  222. end;
  223.  
  224. function Var2wbVector(const wbVector: Variant): TwbVector;
  225. begin
  226.   Result := TwbVector(V2R(wbVector)^);
  227. end;
  228.  
  229. procedure JvInterpreter_wbVector(var Value: Variant; Args: TJvInterpreterArgs);
  230. var
  231.   Rec: TwbVector;
  232. begin
  233.   Rec.x := Args.Values[0];
  234.   Rec.y := Args.Values[1];
  235.   Rec.z := Args.Values[2];
  236.   Value := wbVector2Var(Rec);
  237. end;
  238.  
  239.  
  240. { TwbGridCell }
  241.  
  242. function wbGridCell2Var(const wbGridCell: TwbGridCell): Variant;
  243. var
  244.   Rec: ^TwbGridCell;
  245. begin
  246.   New(Rec);
  247.   Rec^ := wbGridCell;
  248.   Result := R2V(cTwbGridCell, Rec);
  249. end;
  250.  
  251. function Var2wbGridCell(const wbGridCell: Variant): TwbGridCell;
  252. begin
  253.   Result := TwbGridCell(V2R(wbGridCell)^);
  254. end;
  255.  
  256. procedure JvInterpreter_wbGridCell(var Value: Variant; Args: TJvInterpreterArgs);
  257. var
  258.   Rec: TwbGridCell;
  259. begin
  260.   Rec.x := Args.Values[0];
  261.   Rec.y := Args.Values[1];
  262.   Value := wbGridCell2Var(Rec);
  263. end;
  264.  
  265.  
  266. { IwbElement }
  267.  
  268. procedure IwbElement_Name(var Value: Variant; Args: TJvInterpreterArgs);
  269. var
  270.   Element: IwbElement;
  271. begin
  272.   Value := '';
  273.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  274.     Value := Element.Name;
  275. end;
  276.  
  277. procedure IwbElement_ShortName(var Value: Variant; Args: TJvInterpreterArgs);
  278. var
  279.   Element: IwbElement;
  280. begin
  281.   Value := '';
  282.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  283.     Value := Element.ShortName;
  284. end;
  285.  
  286. procedure IwbElement_BaseName(var Value: Variant; Args: TJvInterpreterArgs);
  287. var
  288.   Element: IwbElement;
  289. begin
  290.   Value := '';
  291.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  292.     Value := Element.BaseName;
  293. end;
  294.  
  295. procedure IwbElement_DisplayName(var Value: Variant; Args: TJvInterpreterArgs);
  296. var
  297.   Element: IwbElement;
  298. begin
  299.   Value := '';
  300.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  301.     Value := Element.DisplayName;
  302. end;
  303.  
  304. function IntToEsState(anInt: Integer): TwbElementState;
  305. begin
  306.   case anInt of
  307.     0: Result := esModified;
  308.     1: Result := esInternalModified;
  309.     2: Result := esUnsaved;
  310.     3: Result := esSortKeyValid;
  311.     4: Result := esExtendedSortKeyValid;
  312.     5: Result := esHidden;
  313.     6: Result := esParentHidden;
  314.     7: Result := esParentHiddenChecked;
  315.     8: Result := esNotReachable;
  316.     9: Result := esReachable;
  317.     10: Result := esTagged;
  318.     11: Result := esDeciding;
  319.     12: Result := esNotSuitableToAddTo;
  320.   else
  321.     Result := esDummy;
  322.   end;
  323. end;
  324.  
  325. procedure IwbElement_ClearElementState(var Value: Variant; Args: TJvInterpreterArgs);
  326. var
  327.   Element : IwbElement;
  328.   eState  : TwbElementState;
  329. begin
  330.   Value := '';
  331.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then begin
  332.     try
  333.       eState := IntToEsState(Args.Values[1]);
  334.       Value := eState in Element.ElementStates;
  335.       Element.SetElementState(eState, True);
  336.     except
  337.  
  338.     end;
  339.   end;
  340. end;
  341.  
  342. procedure IwbElement_SetElementState(var Value: Variant; Args: TJvInterpreterArgs);
  343. var
  344.   Element : IwbElement;
  345.   eState  : TwbElementState;
  346. begin
  347.   Value := '';
  348.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then begin
  349.     try
  350.       eState := IntToEsState(Args.Values[1]);
  351.       Value := eState in Element.ElementStates;
  352.       Element.SetElementState(eState);
  353.     except
  354.  
  355.     end;
  356.   end;
  357. end;
  358.  
  359. procedure IwbElement_GetElementState(var Value: Variant; Args: TJvInterpreterArgs);
  360. var
  361.   Element : IwbElement;
  362.   eState  : TwbElementState;
  363. begin
  364.   Value := '';
  365.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then begin
  366.     try
  367.       eState := IntToEsState(Args.Values[1]);
  368.       Value := eState in Element.ElementStates;
  369.     except
  370.  
  371.     end;
  372.   end;
  373. end;
  374.  
  375. procedure IwbElement_Path(var Value: Variant; Args: TJvInterpreterArgs);
  376. var
  377.   Element: IwbElement;
  378. begin
  379.   Value := '';
  380.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  381.     Value := Element.Path;
  382. end;
  383.  
  384. procedure IwbElement_FullPath(var Value: Variant; Args: TJvInterpreterArgs);
  385. var
  386.   Element: IwbElement;
  387. begin
  388.   Value := '';
  389.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  390.     Value := Element.FullPath;
  391. end;
  392.  
  393. procedure IwbElement_PathName(var Value: Variant; Args: TJvInterpreterArgs);
  394. var
  395.   Element: IwbElement;
  396. begin
  397.   Value := '';
  398.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  399.     Value := Element.PathName;
  400. end;
  401.  
  402. procedure IwbElement_ElementType(var Value: Variant; Args: TJvInterpreterArgs);
  403. var
  404.   Element: IwbElement;
  405. begin
  406.   Value := -1;
  407.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  408.     Value := Element.ElementType;
  409. end;
  410.  
  411. procedure IwbElement_DefType(var Value: Variant; Args: TJvInterpreterArgs);
  412. var
  413.   Element: IwbElement;
  414. begin
  415.   Value := -1;
  416.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  417.     if Assigned(Element.ValueDef) then
  418.       Value := Element.ValueDef.DefType;
  419. end;
  420.  
  421. procedure IwbElement_EnumValues(var Value: Variant; Args: TJvInterpreterArgs);
  422. var
  423.   Element    : IwbElement;
  424.   NamedDef   : IwbNamedDef;
  425.   IntegerDef : IwbIntegerDef;
  426.   Enums      : IwbEnumDef;
  427.   i          : integer;
  428.   s          : string;
  429. begin
  430.   Value := '';
  431.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then begin
  432.     if Supports(Element.Def, IwbSubRecordDef) then
  433.       NamedDef := (Element.Def as IwbSubrecordDef).Value
  434.     else
  435.       NamedDef := Element.Def;
  436.  
  437.     if Supports(NamedDef, IwbIntegerDef, IntegerDef) and
  438.       Supports(IntegerDef.Formater[Element], IwbEnumDef, Enums) then begin
  439.  
  440.       for i := 0 to Pred(Enums.NameCount) do begin
  441.         if i > 0 then s := s + #13#10;
  442.         s := s + Enums.Names[i];
  443.       end;
  444.  
  445.       Value := s;
  446.     end;
  447.   end;
  448. end;
  449.  
  450. procedure IwbElement_FlagValues(var Value: Variant; Args: TJvInterpreterArgs);
  451. var
  452.   Element    : IwbElement;
  453.   NamedDef   : IwbNamedDef;
  454.   IntegerDef : IwbIntegerDef;
  455.   Flags      : IwbFlagsDef;
  456.   i          : integer;
  457.   s          : string;
  458. begin
  459.   Value := '';
  460.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then begin
  461.     if Supports(Element.Def, IwbSubRecordDef) then
  462.       NamedDef := (Element.Def as IwbSubrecordDef).Value
  463.     else
  464.       NamedDef := Element.Def;
  465.  
  466.     if Supports(NamedDef, IwbIntegerDef, IntegerDef) and
  467.       Supports(IntegerDef.Formater[Element], IwbFlagsDef, Flags) then begin
  468.  
  469.       for i := 0 to Pred(Flags.FlagCount) do begin
  470.         if i > 0 then s := s + #13#10;
  471.         s := s + Flags.Flags[i];
  472.       end;
  473.  
  474.       Value := s;
  475.     end;
  476.   end;
  477. end;
  478.  
  479. procedure IwbElement_IsInjected(var Value: Variant; Args: TJvInterpreterArgs);
  480. var
  481.   Element: IwbElement;
  482. begin
  483.   Value := false;
  484.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  485.     Value := Element.IsInjected;
  486. end;
  487.  
  488. procedure IwbElement_GetIsEditable(var Value: Variant; Args: TJvInterpreterArgs);
  489. var
  490.   Element: IwbElement;
  491. begin
  492.   Value := false;
  493.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  494.     Value := Element.IsEditable;
  495. end;
  496.  
  497. procedure IwbElement_SortKey(var Value: Variant; Args: TJvInterpreterArgs);
  498. var
  499.   Element: IwbElement;
  500. begin
  501.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  502.     Value := Element.Sortkey[Args.Values[1]];
  503. end;
  504.  
  505. procedure IwbElement_GetEditValue(var Value: Variant; Args: TJvInterpreterArgs);
  506. var
  507.   Element: IwbElement;
  508. begin
  509.   Value := '';
  510.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  511.     Value := Element.EditValue;
  512. end;
  513.  
  514. procedure IwbElement_SetEditValue(var Value: Variant; Args: TJvInterpreterArgs);
  515. var
  516.   Element: IwbElement;
  517. begin
  518.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  519.     Element.EditValue := string(Args.Values[1]);
  520. end;
  521.  
  522. procedure IwbElement_GetNativeValue(var Value: Variant; Args: TJvInterpreterArgs);
  523. var
  524.   Element: IwbElement;
  525. begin
  526.   Value := '';
  527.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  528.     Value := Element.NativeValue;
  529. end;
  530.  
  531. procedure IwbElement_SetNativeValue(var Value: Variant; Args: TJvInterpreterArgs);
  532. var
  533.   Element: IwbElement;
  534. begin
  535.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  536.     Element.NativeValue := Args.Values[1];
  537. end;
  538.  
  539. procedure IwbElement_Remove(var Value: Variant; Args: TJvInterpreterArgs);
  540. var
  541.   Element: IwbElement;
  542. begin
  543.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  544.     Element.Remove;
  545. end;
  546.  
  547. procedure IwbElement_GetFile(var Value: Variant; Args: TJvInterpreterArgs);
  548. var
  549.   Element: IwbElement;
  550. begin
  551.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  552.     Value := Element._File;
  553. end;
  554.  
  555. procedure IwbElement_GetContainer(var Value: Variant; Args: TJvInterpreterArgs);
  556. var
  557.   Element: IwbElement;
  558. begin
  559.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  560.     Value := Element.Container;
  561. end;
  562.  
  563. procedure IwbElement_ContainingMainRecord(var Value: Variant; Args: TJvInterpreterArgs);
  564. var
  565.   Element: IwbElement;
  566. begin
  567.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  568.     Value := Element.ContainingMainRecord;
  569. end;
  570.  
  571. procedure IwbElement_LinksTo(var Value: Variant; Args: TJvInterpreterArgs);
  572. var
  573.   Element: IwbElement;
  574. begin
  575.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  576.     Value := Element.LinksTo;
  577. end;
  578.  
  579. procedure IwbElement_Check(var Value: Variant; Args: TJvInterpreterArgs);
  580. var
  581.   Element: IwbElement;
  582. begin
  583.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  584.     Value := Element.Check;
  585. end;
  586.  
  587. procedure IwbElement_Assign(var Value: Variant; Args: TJvInterpreterArgs);
  588. var
  589.   Element, Element2: IwbElement;
  590. begin
  591.   Element2 := nil;
  592.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  593.     if (V2O(Args.Values[2]) = nil) or Supports(IInterface(Args.Values[2]), IwbElement, Element2) then
  594.       Value := Element.Assign(Args.Values[1], Element2, Args.Values[3]);
  595. end;
  596.  
  597. procedure IwbElement_Equals(var Value: Variant; Args: TJvInterpreterArgs);
  598. var
  599.   Element, Element2: IwbElement;
  600. begin
  601.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  602.     if Supports(IInterface(Args.Values[1]), IwbElement, Element2) then
  603.       Value := Element.Equals(Element2);
  604. end;
  605.  
  606. procedure IwbElement_CanContainFormIDs(var Value: Variant; Args: TJvInterpreterArgs);
  607. var
  608.   Element: IwbElement;
  609. begin
  610.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  611.     Value := Element.CanContainFormIDs;
  612. end;
  613.  
  614. procedure IwbElement_CanMoveUp(var Value: Variant; Args: TJvInterpreterArgs);
  615. var
  616.   Element: IwbElement;
  617. begin
  618.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  619.     Value := Element.CanMoveUp;
  620. end;
  621.  
  622. procedure IwbElement_CanMoveDown(var Value: Variant; Args: TJvInterpreterArgs);
  623. var
  624.   Element: IwbElement;
  625. begin
  626.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  627.     Value := Element.CanMoveDown;
  628. end;
  629.  
  630. procedure IwbElement_MoveUp(var Value: Variant; Args: TJvInterpreterArgs);
  631. var
  632.   Element: IwbElement;
  633. begin
  634.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  635.     Element.MoveUp;
  636. end;
  637.  
  638. procedure IwbElement_MoveDown(var Value: Variant; Args: TJvInterpreterArgs);
  639. var
  640.   Element: IwbElement;
  641. begin
  642.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  643.     Element.MoveDown;
  644. end;
  645.  
  646. procedure IwbElement_ReportRequiredMasters(var Value: Variant; Args: TJvInterpreterArgs);
  647. var
  648.   Element: IwbElement;
  649. begin
  650.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  651.     Element.ReportRequiredMasters(TStrings(V2O(Args.Values[1])), Args.Values[2], Args.Values[3]);
  652. end;
  653.  
  654. procedure IwbElement_BuildRef(var Value: Variant; Args: TJvInterpreterArgs);
  655. var
  656.   Element: IwbElement;
  657. begin
  658.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  659.     Element.BuildRef;
  660. end;
  661.  
  662. procedure _wbCopyElementToFile(var Value: Variant; Args: TJvInterpreterArgs);
  663. var
  664.   Element: IwbElement;
  665.   _File: IwbFile;
  666. begin
  667.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  668.     if Supports(IInterface(Args.Values[1]), IwbFile, _File) then
  669.       Value := wbCopyElementToFile(Element, _File, Args.Values[2], Args.Values[3], '', '', '');
  670. end;
  671.  
  672. procedure _wbCopyElementToFileWithPrefix(var Value: Variant; Args: TJvInterpreterArgs);
  673. var
  674.   Element: IwbElement;
  675.   _File: IwbFile;
  676. begin
  677.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  678.     if Supports(IInterface(Args.Values[1]), IwbFile, _File) then
  679.       Value := wbCopyElementToFile(Element, _File, Args.Values[2], Args.Values[3], Args.Values[4], Args.Values[5], Args.Values[6]);
  680. end;
  681.  
  682. procedure _wbCopyElementToRecord(var Value: Variant; Args: TJvInterpreterArgs);
  683. var
  684.   Element: IwbElement;
  685.   MainRecord: IwbMainRecord;
  686. begin
  687.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  688.     if Supports(IInterface(Args.Values[1]), IwbMainRecord, MainRecord) then
  689.       Value := wbCopyElementToRecord(Element, MainRecord, Args.Values[2], Args.Values[3]);
  690. end;
  691.  
  692.  
  693. { IwbContainer }
  694.  
  695. procedure IwbContainer_GetElementEditValues(var Value: Variant; Args: TJvInterpreterArgs);
  696. var
  697.   Container: IwbContainerElementRef;
  698. begin
  699.   Value := '';
  700.   if Supports(IInterface(Args.Values[0]), IwbContainerElementRef, Container) then
  701.     Value := Container.ElementEditValues[Args.Values[1]];
  702. end;
  703.  
  704. procedure IwbContainer_SetElementEditValues(var Value: Variant; Args: TJvInterpreterArgs);
  705. var
  706.   Container: IwbContainerElementRef;
  707. begin
  708.   if Supports(IInterface(Args.Values[0]), IwbContainerElementRef, Container) then
  709.     Container.ElementEditValues[Args.Values[1]] := Args.Values[2];
  710. end;
  711.  
  712. procedure IwbContainer_GetElementNativeValues(var Value: Variant; Args: TJvInterpreterArgs);
  713. var
  714.   Container: IwbContainerElementRef;
  715. begin
  716.   if Supports(IInterface(Args.Values[0]), IwbContainerElementRef, Container) then
  717.     Value := Container.ElementNativeValues[Args.Values[1]];
  718. end;
  719.  
  720. procedure IwbContainer_SetElementNativeValues(var Value: Variant; Args: TJvInterpreterArgs);
  721. var
  722.   Container: IwbContainerElementRef;
  723. begin
  724.   if Supports(IInterface(Args.Values[0]), IwbContainerElementRef, Container) then
  725.     Container.ElementNativeValues[Args.Values[1]] := Args.Values[2];
  726. end;
  727.  
  728. procedure IwbContainer_ElementByName(var Value: Variant; Args: TJvInterpreterArgs);
  729. var
  730.   Container: IwbContainerElementRef;
  731. begin
  732.   if Supports(IInterface(Args.Values[0]), IwbContainerElementRef, Container) then
  733.     Value := Container.ElementByName[Args.Values[1]];
  734. end;
  735.  
  736. procedure IwbContainer_ElementBySignature(var Value: Variant; Args: TJvInterpreterArgs);
  737. var
  738.   Container: IwbContainerElementRef;
  739.   Signature: TwbSignature;
  740. begin
  741.   if Supports(IInterface(Args.Values[0]), IwbContainerElementRef, Container) then begin
  742.     Signature := StrToSignature(Args.Values[1]);
  743.     Value := Container.ElementBySignature[Signature];
  744.   end;
  745. end;
  746.  
  747. procedure IwbContainer_ElementByPath(var Value: Variant; Args: TJvInterpreterArgs);
  748. var
  749.   Container: IwbContainerElementRef;
  750. begin
  751.   if Supports(IInterface(Args.Values[0]), IwbContainerElementRef, Container) then
  752.     Value := Container.ElementByPath[Args.Values[1]];
  753. end;
  754.  
  755. procedure IwbContainer_AdditionalElementCount(var Value: Variant; Args: TJvInterpreterArgs);
  756. var
  757.   Container: IwbContainerElementRef;
  758. begin
  759.   Value := 0;
  760.   if Supports(IInterface(Args.Values[0]), IwbContainerElementRef, Container) then
  761.     Value := Container.AdditionalElementCount;
  762. end;
  763.  
  764. procedure IwbContainer_ElementCount(var Value: Variant; Args: TJvInterpreterArgs);
  765. var
  766.   Container: IwbContainerElementRef;
  767. begin
  768.   Value := 0;
  769.   if Supports(IInterface(Args.Values[0]), IwbContainerElementRef, Container) then
  770.     Value := Container.ElementCount;
  771. end;
  772.  
  773. procedure IwbContainer_ElementByIndex(var Value: Variant; Args: TJvInterpreterArgs);
  774. var
  775.   Container: IwbContainerElementRef;
  776. begin
  777.   if Supports(IInterface(Args.Values[0]), IwbContainerElementRef, Container) then
  778.     Value := Container.Elements[Args.Values[1]];
  779. end;
  780.  
  781. procedure IwbContainer_ElementExists(var Value: Variant; Args: TJvInterpreterArgs);
  782. var
  783.   Container: IwbContainerElementRef;
  784. begin
  785.   if Supports(IInterface(Args.Values[0]), IwbContainerElementRef, Container) then
  786.     Value := Container.ElementExists[string(Args.Values[1])];
  787. end;
  788.  
  789. procedure IwbContainer_LastElement(var Value: Variant; Args: TJvInterpreterArgs);
  790. var
  791.   Container: IwbContainerElementRef;
  792. begin
  793.   if Supports(IInterface(Args.Values[0]), IwbContainerElementRef, Container) then
  794.     Value := Container.LastElement;
  795. end;
  796.  
  797. procedure IwbContainer_IndexOf(var Value: Variant; Args: TJvInterpreterArgs);
  798. var
  799.   Container: IwbContainerElementRef;
  800.   Element: IwbElement;
  801. begin
  802.   Value := -1;
  803.   if Supports(IInterface(Args.Values[0]), IwbContainerElementRef, Container) then
  804.     if Supports(IInterface(Args.Values[1]), IwbElement, Element) then
  805.       Value := Container.IndexOf(Element);
  806. end;
  807.  
  808. procedure IwbContainer_Add(var Value: Variant; Args: TJvInterpreterArgs);
  809. var
  810.   Container: IwbContainerElementRef;
  811. begin
  812.   if Supports(IInterface(Args.Values[0]), IwbContainerElementRef, Container) then
  813.     Value := Container.Add(Args.Values[1], Args.Values[2]);
  814. end;
  815.  
  816. procedure IwbContainer_AddElement(var Value: Variant; Args: TJvInterpreterArgs);
  817. var
  818.   Container: IwbContainerElementRef;
  819.   Element: IwbElement;
  820. begin
  821.   if Supports(IInterface(Args.Values[0]), IwbContainerElementRef, Container) then
  822.     if Supports(IInterface(Args.Values[1]), IwbElement, Element) then
  823.       Container.AddElement(Element);
  824. end;
  825.  
  826. procedure IwbContainer_InsertElement(var Value: Variant; Args: TJvInterpreterArgs);
  827. var
  828.   Container: IwbContainerElementRef;
  829.   Element: IwbElement;
  830. begin
  831.   if Supports(IInterface(Args.Values[0]), IwbContainerElementRef, Container) then
  832.     if Supports(IInterface(Args.Values[1]), IwbElement, Element) then
  833.       Container.InsertElement(integer(Args.Values[1]), Element);
  834. end;
  835.  
  836. procedure IwbContainer_RemoveElement(var Value: Variant; Args: TJvInterpreterArgs);
  837. var
  838.   Container: IwbContainerElementRef;
  839.   Element: IwbElement;
  840.   vtyp: integer;
  841. begin
  842.   if Supports(IInterface(Args.Values[0]), IwbContainerElementRef, Container) then begin
  843.     vtyp := VarType(Args.Values[1]);
  844.     case vtyp of
  845.       varInteger, varInt64, varWord, varLongWord, varShortInt:
  846.          Value := Container.RemoveElement(integer(Args.Values[1]), True);
  847.       varString, varUString:
  848.          Value := Container.RemoveElement(string(Args.Values[1]));
  849.     else
  850.       if Supports(IInterface(Args.Values[1]), IwbElement, Element) then
  851.         Value := Container.RemoveElement(Element, True);
  852.     end;
  853.   end;
  854. end;
  855.  
  856. procedure IwbContainer_RemoveByIndex(var Value: Variant; Args: TJvInterpreterArgs);
  857. var
  858.   Container: IwbContainerElementRef;
  859. begin
  860.   if Supports(IInterface(Args.Values[0]), IwbContainerElementRef, Container) then
  861.     Value := Container.RemoveElement(integer(Args.Values[1]), boolean(Args.Values[2]));
  862. end;
  863.  
  864. procedure IwbContainer_ReverseElements(var Value: Variant; Args: TJvInterpreterArgs);
  865. var
  866.   Container: IwbContainerElementRef;
  867. begin
  868.   if Supports(IInterface(Args.Values[0]), IwbContainerElementRef, Container) then
  869.     Container.ReverseElements;
  870. end;
  871.  
  872. procedure IwbContainer_ContainerStates(var Value: Variant; Args: TJvInterpreterArgs);
  873. var
  874.   Container: IwbContainerElementRef;
  875. begin
  876.   if Supports(IInterface(Args.Values[0]), IwbContainerElementRef, Container) then
  877.     Value := Byte(Container.ContainerStates);
  878. end;
  879.  
  880. procedure IwbContainer_IsSorted(var Value: Variant; Args: TJvInterpreterArgs);
  881. var
  882.   Container: IwbSortableContainer;
  883. begin
  884.   Value := False;
  885.   if Supports(IInterface(Args.Values[0]), IwbSortableContainer, Container) then
  886.     Value := Container.Sorted;
  887. end;
  888.  
  889.  
  890. //  GetChildRecords(c: IwbContainer; sig: string; var lst: TList);
  891. //  Input a container, a record signature, and a list.  Returns
  892. //  a list of all records in the container matching the input
  893. //  signature.
  894. procedure IwbContainer_GetChildRecords(var Value: Variant; Args: TJvInterpreterArgs);
  895. var
  896.   Container: IwbContainerElementRef;
  897.   Records: TDynMainRecords;
  898.   i, Count: Integer;
  899.   lst: TList;
  900. begin
  901.   if not Supports(IInterface(Args.Values[0]), IwbContainerElementRef, Container) then
  902.     exit;
  903.    
  904.   Records := nil;
  905.   Count := 0;
  906.   SetLength(Records, 4096);
  907.   FindRecords(Container, String(Args.Values[1]), Records, Count);
  908.   SetLength(Records, Count);
  909.   lst := TList(V2O(Args.Values[2]));
  910.   if Length(Records) <> 0 then
  911.     for i := Low(Records) to High(Records) do
  912.       lst.Add(Pointer(Records[i]));
  913. end;
  914.  
  915.  
  916. { IwbMainRecord }
  917.  
  918. procedure IwbMainRecord_Signature(var Value: Variant; Args: TJvInterpreterArgs);
  919. var
  920.   Element: IwbHasSignature;
  921. begin
  922.   Value := '';
  923.   if Supports(IInterface(Args.Values[0]), IwbHasSignature, Element) then
  924.     Value := string(Element.Signature);
  925. end;
  926.  
  927. procedure IwbMainRecord_FormID(var Value: Variant; Args: TJvInterpreterArgs);
  928. var
  929.   MainRecord: IwbMainRecord;
  930. begin
  931.   Value := 0;
  932.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  933.     Value := MainRecord.FormID;
  934. end;
  935.  
  936. procedure IwbMainRecord_EditorID(var Value: Variant; Args: TJvInterpreterArgs);
  937. var
  938.   MainRecord: IwbMainRecord;
  939. begin
  940.   Value := '';
  941.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  942.     Value := MainRecord.EditorID;
  943. end;
  944.  
  945. procedure IwbMainRecord_SetEditorID(var Value: Variant; Args: TJvInterpreterArgs);
  946. var
  947.   MainRecord: IwbMainRecord;
  948. begin
  949.   Value := '';
  950.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  951.     MainRecord.EditorID := Args.Values[1];
  952.     Value := MainRecord.EditorID;
  953. end;
  954.  
  955. procedure IwbMainRecord_FixedFormID(var Value: Variant; Args: TJvInterpreterArgs);
  956. var
  957.   MainRecord: IwbMainRecord;
  958. begin
  959.   Value := 0;
  960.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  961.     Value := MainRecord.FixedFormID;
  962. end;
  963.  
  964. procedure IwbMainRecord_GetLoadOrderFormID(var Value: Variant; Args: TJvInterpreterArgs);
  965. var
  966.   MainRecord: IwbMainRecord;
  967. begin
  968.   Value := 0;
  969.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  970.     Value := MainRecord.LoadOrderFormID;
  971. end;
  972.  
  973. procedure IwbMainRecord_SetLoadOrderFormID(var Value: Variant; Args: TJvInterpreterArgs);
  974. var
  975.   MainRecord: IwbMainRecord;
  976. begin
  977.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  978.     MainRecord.LoadOrderFormID := VarToCardinal(Args.Values[1]);
  979. end;
  980.  
  981. procedure IwbMainRecord_GetIsDeleted(var Value: Variant; Args: TJvInterpreterArgs);
  982. var
  983.   MainRecord: IwbMainRecord;
  984. begin
  985.   Value := false;
  986.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  987.     Value := MainRecord.IsDeleted;
  988. end;
  989.  
  990. procedure IwbMainRecord_SetIsDeleted(var Value: Variant; Args: TJvInterpreterArgs);
  991. var
  992.   MainRecord: IwbMainRecord;
  993. begin
  994.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  995.     MainRecord.IsDeleted := Args.Values[1];
  996. end;
  997.  
  998. procedure IwbMainRecord_GetIsInitiallyDisabled(var Value: Variant; Args: TJvInterpreterArgs);
  999. var
  1000.   MainRecord: IwbMainRecord;
  1001. begin
  1002.   Value := false;
  1003.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1004.     Value := MainRecord.IsInitiallyDisabled;
  1005. end;
  1006.  
  1007. procedure IwbMainRecord_SetIsInitiallyDisabled(var Value: Variant; Args: TJvInterpreterArgs);
  1008. var
  1009.   MainRecord: IwbMainRecord;
  1010. begin
  1011.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1012.     MainRecord.IsInitiallyDisabled := Args.Values[1];
  1013. end;
  1014.  
  1015. procedure IwbMainRecord_GetIsPersistent(var Value: Variant; Args: TJvInterpreterArgs);
  1016. var
  1017.   MainRecord: IwbMainRecord;
  1018. begin
  1019.   Value := false;
  1020.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1021.     Value := MainRecord.IsPersistent;
  1022. end;
  1023.  
  1024. procedure IwbMainRecord_SetIsPersistent(var Value: Variant; Args: TJvInterpreterArgs);
  1025. var
  1026.   MainRecord: IwbMainRecord;
  1027. begin
  1028.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1029.     MainRecord.IsPersistent := Args.Values[1];
  1030. end;
  1031.  
  1032. procedure IwbMainRecord_GetIsVisibleWhenDistant(var Value: Variant; Args: TJvInterpreterArgs);
  1033. var
  1034.   MainRecord: IwbMainRecord;
  1035. begin
  1036.   Value := false;
  1037.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1038.     Value := MainRecord.IsVisibleWhenDistant;
  1039. end;
  1040.  
  1041. procedure IwbMainRecord_SetIsVisibleWhenDistant(var Value: Variant; Args: TJvInterpreterArgs);
  1042. var
  1043.   MainRecord: IwbMainRecord;
  1044. begin
  1045.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1046.     MainRecord.IsVisibleWhenDistant := Args.Values[1];
  1047. end;
  1048.  
  1049. procedure IwbMainRecord_GetFormVersion(var Value: Variant; Args: TJvInterpreterArgs);
  1050. var
  1051.   MainRecord: IwbMainRecord;
  1052. begin
  1053.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1054.     Value := Cardinal(MainRecord.Version);
  1055. end;
  1056.  
  1057. procedure IwbMainRecord_SetFormVersion(var Value: Variant; Args: TJvInterpreterArgs);
  1058. var
  1059.   MainRecord: IwbMainRecord;
  1060. begin
  1061.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1062.     MainRecord.Version := Args.Values[1];
  1063. end;
  1064.  
  1065. procedure IwbMainRecord_OverrideCount(var Value: Variant; Args: TJvInterpreterArgs);
  1066. var
  1067.   MainRecord: IwbMainRecord;
  1068. begin
  1069.   Value := 0;
  1070.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1071.     Value := MainRecord.OverrideCount;
  1072. end;
  1073.  
  1074. procedure IwbMainRecord_OverrideByIndex(var Value: Variant; Args: TJvInterpreterArgs);
  1075. var
  1076.   MainRecord: IwbMainRecord;
  1077. begin
  1078.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1079.     Value := MainRecord.Overrides[Args.Values[1]];
  1080. end;
  1081.  
  1082. procedure IwbMainRecord_ReferencedByCount(var Value: Variant; Args: TJvInterpreterArgs);
  1083. var
  1084.   MainRecord: IwbMainRecord;
  1085. begin
  1086.   Value := 0;
  1087.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1088.     Value := MainRecord.ReferencedByCount;
  1089. end;
  1090.  
  1091. procedure IwbMainRecord_ReferencedByIndex(var Value: Variant; Args: TJvInterpreterArgs);
  1092. var
  1093.   MainRecord: IwbMainRecord;
  1094. begin
  1095.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1096.     Value := MainRecord.ReferencedBy[Args.Values[1]];
  1097. end;
  1098.  
  1099. procedure IwbMainRecord_BaseRecord(var Value: Variant; Args: TJvInterpreterArgs);
  1100. var
  1101.   MainRecord: IwbMainRecord;
  1102. begin
  1103.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1104.     Value := MainRecord.BaseRecord;
  1105. end;
  1106.  
  1107. procedure IwbMainRecord_BaseRecordID(var Value: Variant; Args: TJvInterpreterArgs);
  1108. var
  1109.   MainRecord: IwbMainRecord;
  1110. begin
  1111.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1112.     Value := MainRecord.BaseRecordID;
  1113. end;
  1114.  
  1115. procedure IwbMainRecord_UpdateRefs(var Value: Variant; Args: TJvInterpreterArgs);
  1116. var
  1117.   MainRecord: IwbMainRecord;
  1118. begin
  1119.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1120.     MainRecord.UpdateRefs;
  1121. end;
  1122.  
  1123. procedure IwbMainRecord_ChildGroup(var Value: Variant; Args: TJvInterpreterArgs);
  1124. var
  1125.   MainRecord: IwbMainRecord;
  1126. begin
  1127.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1128.     Value := MainRecord.ChildGroup;
  1129. end;
  1130.  
  1131. procedure IwbMainRecord_Master(var Value: Variant; Args: TJvInterpreterArgs);
  1132. var
  1133.   MainRecord: IwbMainRecord;
  1134. begin
  1135.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1136.     Value := MainRecord.Master;
  1137. end;
  1138.  
  1139. procedure IwbMainRecord_MasterOrSelf(var Value: Variant; Args: TJvInterpreterArgs);
  1140. var
  1141.   MainRecord: IwbMainRecord;
  1142. begin
  1143.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1144.     Value := MainRecord.MasterOrSelf;
  1145. end;
  1146.  
  1147. procedure IwbMainRecord_IsMaster(var Value: Variant; Args: TJvInterpreterArgs);
  1148. var
  1149.   MainRecord: IwbMainRecord;
  1150. begin
  1151.   Value := false;
  1152.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1153.     Value := MainRecord.IsMaster;
  1154. end;
  1155.  
  1156. procedure IwbMainRecord_IsWinningOverride(var Value: Variant; Args: TJvInterpreterArgs);
  1157. var
  1158.   MainRecord: IwbMainRecord;
  1159. begin
  1160.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1161.     Value := MainRecord.IsWinningOverride;
  1162. end;
  1163.  
  1164. procedure IwbMainRecord_WinningOverride(var Value: Variant; Args: TJvInterpreterArgs);
  1165. var
  1166.   MainRecord: IwbMainRecord;
  1167. begin
  1168.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1169.     Value := MainRecord.WinningOverride;
  1170. end;
  1171.  
  1172. procedure IwbMainRecord_HighestOverrideOrSelf(var Value: Variant; Args: TJvInterpreterArgs);
  1173. var
  1174.   MainRecord: IwbMainRecord;
  1175. begin
  1176.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1177.     Value := MainRecord.HighestOverrideOrSelf[Integer(Args.Values[1])];
  1178. end;
  1179.  
  1180. procedure IwbMainRecord_CompareExchangeFormID(var Value: Variant; Args: TJvInterpreterArgs);
  1181. var
  1182.   MainRecord: IwbMainRecord;
  1183. begin
  1184.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1185.     Value := MainRecord.CompareExchangeFormID(VarToCardinal(Args.Values[1]), VarToCardinal(Args.Values[2]));
  1186. end;
  1187.  
  1188. procedure IwbMainRecord_ChangeFormSignature(var Value: Variant; Args: TJvInterpreterArgs);
  1189. var
  1190.   MainRecord: IwbMainRecord;
  1191.   Signature: TwbSignature;
  1192. begin
  1193.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then begin
  1194.     Signature := StrToSignature(Args.Values[1]);
  1195.     MainRecord.ChangeFormSignature(Signature);
  1196.   end;
  1197. end;
  1198.  
  1199. procedure IwbMainRecord_GetPosition(var Value: Variant; Args: TJvInterpreterArgs);
  1200. var
  1201.   MainRecord: IwbMainRecord;
  1202.   Vec: TwbVector;
  1203. begin
  1204.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then begin
  1205.     MainRecord.GetPosition(Vec);
  1206.     Value := wbVector2Var(Vec);
  1207.   end;
  1208. end;
  1209.  
  1210. procedure IwbMainRecord_GetRotation(var Value: Variant; Args: TJvInterpreterArgs);
  1211. var
  1212.   MainRecord: IwbMainRecord;
  1213.   Vec: TwbVector;
  1214. begin
  1215.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then begin
  1216.     MainRecord.GetRotation(Vec);
  1217.     Value := wbVector2Var(Vec);
  1218.   end;
  1219. end;
  1220.  
  1221. procedure IwbMainRecord_GetGridCell(var Value: Variant; Args: TJvInterpreterArgs);
  1222. var
  1223.   MainRecord: IwbMainRecord;
  1224.   Rec: TwbGridCell;
  1225. begin
  1226.   if Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then begin
  1227.     MainRecord.GetGridCell(Rec);
  1228.     Value := wbGridCell2Var(Rec);
  1229.   end;
  1230. end;
  1231.  
  1232.  
  1233. { IwbGroupRecord }
  1234.  
  1235. procedure IwbGroupRecord_GroupType(var Value: Variant; Args: TJvInterpreterArgs);
  1236. var
  1237.   GroupRecord: IwbGroupRecord;
  1238. begin
  1239.   Value := -1;
  1240.   if Supports(IInterface(Args.Values[0]), IwbGroupRecord, GroupRecord) then
  1241.     Value := GroupRecord.GroupType;
  1242. end;
  1243.  
  1244. procedure IwbGroupRecord_GroupLabel(var Value: Variant; Args: TJvInterpreterArgs);
  1245. var
  1246.   GroupRecord: IwbGroupRecord;
  1247. begin
  1248.   Value := -1;
  1249.   if Supports(IInterface(Args.Values[0]), IwbGroupRecord, GroupRecord) then
  1250.     Value := GroupRecord.GroupLabel;
  1251. end;
  1252.  
  1253. procedure IwbGroupRecord_ChildrenOf(var Value: Variant; Args: TJvInterpreterArgs);
  1254. var
  1255.   GroupRecord: IwbGroupRecord;
  1256. begin
  1257.   if Supports(IInterface(Args.Values[0]), IwbGroupRecord, GroupRecord) then
  1258.     Value := GroupRecord.ChildrenOf;
  1259. end;
  1260.  
  1261. procedure IwbGroupRecord_MainRecordByEditorID(var Value: Variant; Args: TJvInterpreterArgs);
  1262. var
  1263.   GroupRecord: IwbGroupRecord;
  1264. begin
  1265.   if Supports(IInterface(Args.Values[0]), IwbGroupRecord, GroupRecord) then
  1266.     Value := GroupRecord. MainRecordByEditorID[string(Args.Values[1])];
  1267. end;
  1268.  
  1269. procedure IwbGroupRecord_FindChildGroup(var Value: Variant; Args: TJvInterpreterArgs);
  1270. var
  1271.   GroupRecord: IwbGroupRecord;
  1272.   MainRecord: IwbMainRecord;
  1273. begin
  1274.   if Supports(IInterface(Args.Values[0]), IwbGroupRecord, GroupRecord) then
  1275.     if Supports(IInterface(Args.Values[2]), IwbMainRecord, MainRecord) then
  1276.       Value := GroupRecord.FindChildGroup(Args.Values[1], MainRecord);
  1277. end;
  1278.  
  1279.  
  1280. { IwbFile }
  1281.  
  1282. procedure IwbFile_GetFileName(var Value: Variant; Args: TJvInterpreterArgs);
  1283. var
  1284.   _File: IwbFile;
  1285.   Element: IwbElement;
  1286. begin
  1287.   Value := '';
  1288.   if Supports(IInterface(Args.Values[0]), IwbFile, _File) then
  1289.     Value := _File.FileName
  1290.   else
  1291.   if Supports(IInterface(Args.Values[0]), IwbElement, Element) then
  1292.     if Assigned(Element._File) then
  1293.       Value := Element._File.FileName
  1294. end;
  1295.  
  1296. procedure IwbFile_GetLoadOrder(var Value: Variant; Args: TJvInterpreterArgs);
  1297. var
  1298.   _File: IwbFile;
  1299. begin
  1300.   Value := -1;
  1301.   if Supports(IInterface(Args.Values[0]), IwbFile, _File) then
  1302.     Value := _File.LoadOrder;
  1303. end;
  1304.  
  1305. procedure IwbFile_GetNewFormID(var Value: Variant; Args: TJvInterpreterArgs);
  1306. var
  1307.   _File: IwbFile;
  1308. begin
  1309.   Value := 0;
  1310.   if Supports(IInterface(Args.Values[0]), IwbFile, _File) then
  1311.     Value := _File.NewFormID;
  1312. end;
  1313.  
  1314. procedure IwbFile_GetIsESM(var Value: Variant; Args: TJvInterpreterArgs);
  1315. var
  1316.   _File: IwbFile;
  1317. begin
  1318.   if Supports(IInterface(Args.Values[0]), IwbFile, _File) then
  1319.     Value := _File.IsESM;
  1320. end;
  1321.  
  1322. procedure IwbFile_SetIsESM(var Value: Variant; Args: TJvInterpreterArgs);
  1323. var
  1324.   _File: IwbFile;
  1325. begin
  1326.   if Supports(IInterface(Args.Values[0]), IwbFile, _File) then
  1327.     _File.IsESM := Args.Values[1];
  1328. end;
  1329.  
  1330. procedure IwbFile_SortMasters(var Value: Variant; Args: TJvInterpreterArgs);
  1331. var
  1332.   _File: IwbFile;
  1333. begin
  1334.   if Supports(IInterface(Args.Values[0]), IwbFile, _File) then
  1335.     _File.SortMasters;
  1336. end;
  1337.  
  1338. procedure IwbFile_CleanMasters(var Value: Variant; Args: TJvInterpreterArgs);
  1339. var
  1340.   _File: IwbFile;
  1341. begin
  1342.   if Supports(IInterface(Args.Values[0]), IwbFile, _File) then
  1343.     _File.CleanMasters;
  1344. end;
  1345.  
  1346. procedure IwbFile_MasterCount(var Value: Variant; Args: TJvInterpreterArgs);
  1347. var
  1348.   _File: IwbFile;
  1349. begin
  1350.   Value := 0;
  1351.   if Supports(IInterface(Args.Values[0]), IwbFile, _File) then
  1352.     Value := _File.MasterCount;
  1353. end;
  1354.  
  1355. procedure IwbFile_MasterByIndex(var Value: Variant; Args: TJvInterpreterArgs);
  1356. var
  1357.   _File: IwbFile;
  1358. begin
  1359.   if Supports(IInterface(Args.Values[0]), IwbFile, _File) then
  1360.     if Args.Values[1] < _File.MasterCount then
  1361.       Value := _File.Masters[Args.Values[1]];
  1362. end;
  1363.  
  1364. procedure IwbFile_RecordCount(var Value: Variant; Args: TJvInterpreterArgs);
  1365. var
  1366.   _File: IwbFile;
  1367. begin
  1368.   Value := 0;
  1369.   if Supports(IInterface(Args.Values[0]), IwbFile, _File) then
  1370.     Value := _File.RecordCount;
  1371. end;
  1372.  
  1373. procedure IwbFile_RecordByIndex(var Value: Variant; Args: TJvInterpreterArgs);
  1374. var
  1375.   _File: IwbFile;
  1376. begin
  1377.   if Supports(IInterface(Args.Values[0]), IwbFile, _File) then
  1378.     if Args.Values[1] < _File.RecordCount then
  1379.       Value := _File.Records[Args.Values[1]];
  1380. end;
  1381.  
  1382. procedure IwbFile_GroupBySignature(var Value: Variant; Args: TJvInterpreterArgs);
  1383. var
  1384.   _File: IwbFile;
  1385. begin
  1386.   if Supports(IInterface(Args.Values[0]), IwbFile, _File) then
  1387.     Value := _File.GroupBySignature[StrToSignature(Args.Values[1])];
  1388. end;
  1389.  
  1390. procedure IwbFile_RecordByFormID(var Value: Variant; Args: TJvInterpreterArgs);
  1391. var
  1392.   _File: IwbFile;
  1393. begin
  1394.   if Supports(IInterface(Args.Values[0]), IwbFile, _File) then
  1395.     Value := _File.RecordByFormID[VarToCardinal(Args.Values[1]), Args.Values[2]];
  1396. end;
  1397.  
  1398. procedure IwbFile_RecordByEditorID(var Value: Variant; Args: TJvInterpreterArgs);
  1399. var
  1400.   _File: IwbFile;
  1401. begin
  1402.   if Supports(IInterface(Args.Values[0]), IwbFile, _File) then
  1403.     Value := _File.RecordByEditorID[string(Args.Values[1])];
  1404. end;
  1405.  
  1406. procedure IwbFile_AddMasterIfMissing(var Value: Variant; Args: TJvInterpreterArgs);
  1407. var
  1408.   _File: IwbFile;
  1409. begin
  1410.   if Supports(IInterface(Args.Values[0]), IwbFile, _File) then
  1411.     _File.AddMasterIfMissing(string(Args.Values[1]));
  1412. end;
  1413.  
  1414. procedure IwbFile_HasMaster(var Value: Variant; Args: TJvInterpreterArgs);
  1415. var
  1416.   _File: IwbFile;
  1417. begin
  1418.   if Supports(IInterface(Args.Values[0]), IwbFile, _File) then
  1419.     Value := _File.HasMaster(StrToSignature(Args.Values[1]));
  1420. end;
  1421.  
  1422. procedure IwbFile_HasGroup(var Value: Variant; Args: TJvInterpreterArgs);
  1423. var
  1424.   _File: IwbFile;
  1425. begin
  1426.   if Supports(IInterface(Args.Values[0]), IwbFile, _File) then
  1427.     Value := _File.HasGroup(StrToSignature(Args.Values[1]));
  1428. end;
  1429.  
  1430. procedure IwbFile_LoadOrderFormIDtoFileFormID(var Value: Variant; Args: TJvInterpreterArgs);
  1431. var
  1432.   _File: IwbFile;
  1433. begin
  1434.   if Supports(IInterface(Args.Values[0]), IwbFile, _File) then
  1435.     Value := _File.LoadOrderFormIDtoFileFormID(Args.Values[1]);
  1436. end;
  1437.  
  1438. procedure IwbFile_FileFormIDtoLoadOrderFormID(var Value: Variant; Args: TJvInterpreterArgs);
  1439. var
  1440.   _File: IwbFile;
  1441. begin
  1442.   if Supports(IInterface(Args.Values[0]), IwbFile, _File) then
  1443.     Value := _File.FileFormIDtoLoadOrderFormID(Args.Values[1]);
  1444. end;
  1445.  
  1446.  
  1447. { wbContainerHandler }
  1448.  
  1449. procedure IwbContainerHandler_ResourceContainerList(var Value: Variant; Args: TJvInterpreterArgs);
  1450. begin
  1451.   wbContainerHandler.ContainerList(TStrings(V2O(Args.Values[0])));
  1452. end;
  1453.  
  1454. procedure IwbContainerHandler_ResourceList(var Value: Variant; Args: TJvInterpreterArgs);
  1455. begin
  1456.   wbContainerHandler.ContainerResourceList(Args.Values[0], TStrings(V2O(Args.Values[1])));
  1457. end;
  1458.  
  1459. procedure IwbContainerHandler_ResourceExists(var Value: Variant; Args: TJvInterpreterArgs);
  1460. begin
  1461.   Value := wbContainerHandler.ResourceExists(Args.Values[0]);
  1462. end;
  1463.  
  1464. procedure IwbContainerHandler_ResourceCount(var Value: Variant; Args: TJvInterpreterArgs);
  1465. begin
  1466.   Value := wbContainerHandler.ResourceCount(Args.Values[0], TStrings(V2O(Args.Values[1])));
  1467. end;
  1468.  
  1469. procedure IwbContainerHandler_ResourceOpenData(var Value: Variant; Args: TJvInterpreterArgs);
  1470. var
  1471.   Res           : TDynResources;
  1472.   ResContainer  : string;
  1473.   i             : integer;
  1474. begin
  1475.   Res := wbContainerHandler.OpenResource(Args.Values[1]);
  1476.   if Length(Res) = 0 then
  1477.     Exit;
  1478.   ResContainer := string(Args.Values[0]);
  1479.   if ResContainer = '' then
  1480.     ResContainer := Res[High(Res)].Container.Name;
  1481.   for i := Low(Res) to High(Res) do
  1482.     if SameText(Res[i].Container.Name, ResContainer) then
  1483.       Value := Res[i].GetData;
  1484. end;
  1485.  
  1486. procedure IwbContainerHandler_ResourceCopy(var Value: Variant; Args: TJvInterpreterArgs);
  1487. begin
  1488.   wbContainerHandler.ResourceCopy(Args.Values[0], Args.Values[1], Args.Values[2]);
  1489. end;
  1490.  
  1491.  
  1492. { TwbFastStringList }
  1493.  
  1494. procedure TwbFastStringList_Create(var Value: Variant; Args: TJvInterpreterArgs);
  1495. begin
  1496.   Value := O2V(TwbFastStringList.Create);
  1497. end;
  1498.  
  1499.  
  1500. { Nif routines }
  1501.  
  1502. procedure NifUtils_NifBlockList(var Value: Variant; Args: TJvInterpreterArgs);
  1503. begin
  1504.   Value := NifBlockList(TBytes(Args.Values[0]), TStrings(V2O(Args.Values[1])));
  1505. end;
  1506.  
  1507. procedure NifUtils_NifTextureList(var Value: Variant; Args: TJvInterpreterArgs);
  1508. begin
  1509.   Value := NifTextures(TBytes(Args.Values[0]), TStrings(V2O(Args.Values[1])));
  1510. end;
  1511.  
  1512. procedure NifUtils_NifTextureListUVRange(var Value: Variant; Args: TJvInterpreterArgs);
  1513. begin
  1514.   Value := NifTexturesUVRange(TBytes(Args.Values[0]), Single(Args.Values[1]), TStrings(V2O(Args.Values[2])));
  1515. end;
  1516.  
  1517.  
  1518. { DDS routines }
  1519.  
  1520. procedure DDSUtils_wbDDSStreamToBitmap(var Value: Variant; Args: TJvInterpreterArgs);
  1521. begin
  1522.   Value := wbDDSStreamToBitmap(TStream(V2O(Args.Values[0])), TBitmap(V2O(Args.Values[1])));
  1523. end;
  1524.  
  1525. procedure DDSUtils_wbDDSDataToBitmap(var Value: Variant; Args: TJvInterpreterArgs);
  1526. begin
  1527.   Value := wbDDSDataToBitmap(TBytes(Args.Values[0]), TBitmap(V2O(Args.Values[1])));
  1528. end;
  1529.  
  1530.  
  1531. { Misc routines }
  1532.  
  1533. procedure Misc_wbFlipBitmap(var Value: Variant; Args: TJvInterpreterArgs);
  1534. begin
  1535.   wbFlipBitmap(TBitmap(V2O((Args.Values[0]))), Integer(Args.Values[1]));
  1536. end;
  1537.  
  1538. procedure Misc_wbAlphaBlend(var Value: Variant; Args: TJvInterpreterArgs);
  1539. begin
  1540.   Value := wbAlphaBlend(
  1541.     Args.Values[0], // DestDC
  1542.     Args.Values[1], // X
  1543.     Args.Values[2], // Y
  1544.     Args.Values[3], // Width
  1545.     Args.Values[4], // Height
  1546.     Args.Values[5], // SrcDC
  1547.     Args.Values[6], // SrcX
  1548.     Args.Values[7], // SrcY
  1549.     Args.Values[8], // SrcWidth
  1550.     Args.Values[9], // SrcHeight
  1551.     Args.Values[10] // Alpha
  1552.   );
  1553. end;
  1554.  
  1555. procedure Misc_wbPositionToGridCell(var Value: Variant; Args: TJvInterpreterArgs);
  1556. begin
  1557.   Value := wbGridCell2Var(wbPositionToGridCell(Var2wbVector(Args.Values[0])));
  1558. end;
  1559.  
  1560. procedure Misc_wbSubBlockFromGridCell(var Value: Variant; Args: TJvInterpreterArgs);
  1561. begin
  1562.   Value := wbGridCell2Var(wbSubBlockFromGridCell(Var2wbGridCell(Args.Values[0])));
  1563. end;
  1564.  
  1565. procedure Misc_wbBlockFromSubBlock(var Value: Variant; Args: TJvInterpreterArgs);
  1566. begin
  1567.   Value := wbGridCell2Var(wbBlockFromSubBlock(Var2wbGridCell(Args.Values[0])));
  1568. end;
  1569.  
  1570. procedure Misc_wbGridCellToGroupLabel(var Value: Variant; Args: TJvInterpreterArgs);
  1571. begin
  1572.   Value := wbGridCellToGroupLabel(Var2wbGridCell(Args.Values[0]));
  1573. end;
  1574.  
  1575. procedure Misc_wbIsInGridCell(var Value: Variant; Args: TJvInterpreterArgs);
  1576. begin
  1577.   Value := wbIsInGridCell(Var2wbVector(Args.Values[0]), Var2wbGridCell(Args.Values[1]));
  1578. end;
  1579.  
  1580. procedure Misc_wbCRC32Data(var Value: Variant; Args: TJvInterpreterArgs);
  1581. begin
  1582.   Value := wbCRC32Data(Args.Values[0]);
  1583. end;
  1584.  
  1585. procedure Misc_wbCRC32File(var Value: Variant; Args: TJvInterpreterArgs);
  1586. begin
  1587.   Value := wbCRC32File(string(Args.Values[0]));
  1588. end;
  1589.  
  1590. procedure Misc_wbSHA1Data(var Value: Variant; Args: TJvInterpreterArgs);
  1591. begin
  1592.   Value := wbSHA1Data(Args.Values[0]);
  1593. end;
  1594.  
  1595. procedure Misc_wbSHA1File(var Value: Variant; Args: TJvInterpreterArgs);
  1596. begin
  1597.   Value := wbSHA1File(string(Args.Values[0]));
  1598. end;
  1599.  
  1600. procedure Misc_wbMD5Data(var Value: Variant; Args: TJvInterpreterArgs);
  1601. begin
  1602.   Value := wbMD5Data(Args.Values[0]);
  1603. end;
  1604.  
  1605. procedure Misc_wbMD5File(var Value: Variant; Args: TJvInterpreterArgs);
  1606. begin
  1607.   Value := wbMD5File(string(Args.Values[0]));
  1608. end;
  1609.  
  1610. // find REFR records in child groups by base record signatures
  1611. // that are not deleted or disabled
  1612. procedure Misc_wbFindREFRsByBase(var Value: Variant; Args: TJvInterpreterArgs);
  1613. var
  1614.   MainRecord          : IwbMainRecord;
  1615.   REFRs               : TDynMainRecords;
  1616.   i, j, Count, Opt    : Integer;
  1617.   lst                 : TList;
  1618.   BaseSignatures      : string;
  1619. begin
  1620.   if not Supports(IInterface(Args.Values[0]), IwbMainRecord, MainRecord) then
  1621.     Exit;
  1622.  
  1623.   REFRs := nil;
  1624.   Count := 0;
  1625.   SetLength(REFRs, 4096);
  1626.   FindRecords(MainRecord.ChildGroup, 'REFR', REFRs, Count);
  1627.   for i := 0 to Pred(MainRecord.OverrideCount) do
  1628.     FindRecords(MainRecord.Overrides[i].ChildGroup, 'REFR', REFRs, Count);
  1629.   SetLength(REFRs, Count);
  1630.   // removing duplicates
  1631.   if Length(REFRs) > 1 then begin
  1632.     wbMergeSort(@REFRs[0], Length(REFRs), CompareElementsFormIDAndLoadOrder);
  1633.     j := 0;
  1634.     for i := Succ(Low(REFRs)) to High(REFRs) do begin
  1635.       if REFRs[j].LoadOrderFormID <> REFRs[i].LoadOrderFormID then
  1636.         Inc(j);
  1637.       if j <> i then
  1638.         REFRs[j] := REFRs[i];
  1639.     end;
  1640.     SetLength(REFRs, Succ(j));
  1641.   end;
  1642.  
  1643.   BaseSignatures := string(Args.Values[1]);
  1644.   Opt := Integer(Args.Values[2]);
  1645.   lst := TList(V2O(Args.Values[3]));
  1646.   if not Assigned(lst) then
  1647.     Exit;
  1648.  
  1649.   if Length(REFRs) <> 0 then
  1650.     for i := Low(REFRs) to High(REFRs) do
  1651.       if  not ((Opt and 1 <> 0) and REFRs[i].IsDeleted)
  1652.       and not ((Opt and 2 <> 0) and REFRs[i].IsInitiallyDisabled)
  1653.       and not ((Opt and 4 <> 0) and REFRs[i].ElementExists['XESP'])
  1654.       then
  1655.         if Assigned(REFRs[i].BaseRecord) and (Pos(REFRs[i].BaseRecord.Signature, BaseSignatures) <> 0) then
  1656.           lst.Add(Pointer(REFRs[i]));
  1657. end;
  1658.  
  1659. procedure Misc_wbNormalizeResourceName(var Value: Variant; Args: TJvInterpreterArgs);
  1660. begin
  1661.   Value := wbNormalizeResourceName(string(Args.Values[0]), Args.Values[1]);
  1662. end;
  1663.  
  1664. procedure Misc_wbStringListInString(var Value: Variant; Args: TJvInterpreterArgs);
  1665. var
  1666.   sl: TStringList;
  1667.   s: string;
  1668.   i: integer;
  1669. begin
  1670.   Value := -1;
  1671.   sl := TStringList(V2O(Args.Values[0]));
  1672.   if not Assigned(sl) then
  1673.     Exit;
  1674.   s := string(Args.Values[1]);
  1675.   for i := 0 to Pred(sl.Count) do
  1676.     if Pos(Lowercase(sl[i]), Lowercase(s)) > 0 then begin
  1677.       Value := i;
  1678.       Exit;
  1679.     end;
  1680. end;
  1681.  
  1682.  
  1683. procedure RegisterJvInterpreterAdapter(JvInterpreterAdapter: TJvInterpreterAdapter);
  1684. begin
  1685.   with JvInterpreterAdapter do begin
  1686.     AddExtUnit(cInterface);
  1687.     { TwbVector }
  1688.     AddRec(cInterface, cTwbVector, SizeOf(TwbVector), [RFD('x', 0, varSingle), RFD('y', 4, varSingle), RFD('z', 8, varSingle)], nil, nil, nil);
  1689.     AddFunction(cInterface, 'wbVector', JvInterpreter_wbVector, 3, [varEmpty, varEmpty, varEmpty], varRecord);
  1690.     { TwbGridCell }
  1691.     AddRec(cInterface, cTwbGridCell, SizeOf(TwbGridCell), [RFD('x', 0, varInteger), RFD('y', 4, varInteger)], nil, nil, nil);
  1692.     AddFunction(cInterface, 'wbGridCell', JvInterpreter_wbGridCell, 2, [varEmpty, varEmpty], varRecord);
  1693.  
  1694.     //AddIntfGet(IwbElement, 'Name', IwbElement_Name, 0, [VarEmpty], varEmpty);
  1695.     AddConst(cUnit, 'gmTES4', ord(gmTES4));
  1696.     AddConst(cUnit, 'gmTES5', ord(gmTES5));
  1697.     AddConst(cUnit, 'gmFO3', ord(gmFO3));
  1698.     AddConst(cUnit, 'gmFNV', ord(gmFNV));
  1699.  
  1700.     { TwbElementType }
  1701.     AddConst(cUnit, 'etFile', ord(etFile));
  1702.     AddConst(cUnit, 'etMainRecord', ord(etMainRecord));
  1703.     AddConst(cUnit, 'etGroupRecord', ord(etGroupRecord));
  1704.     AddConst(cUnit, 'etSubRecord', ord(etSubRecord));
  1705.     AddConst(cUnit, 'etSubRecordStruct', ord(etSubRecordStruct));
  1706.     AddConst(cUnit, 'etSubRecordArray', ord(etSubRecordArray));
  1707.     AddConst(cUnit, 'etSubRecordUnion', ord(etSubRecordUnion));
  1708.     AddConst(cUnit, 'etArray', ord(etArray));
  1709.     AddConst(cUnit, 'etStruct', ord(etStruct));
  1710.     AddConst(cUnit, 'etValue', ord(etValue));
  1711.     AddConst(cUnit, 'etFlag', ord(etFlag));
  1712.     AddConst(cUnit, 'etStringListTerminator', ord(etStringListTerminator));
  1713.     AddConst(cUnit, 'etUnion', ord(etUnion));
  1714.     AddConst(cUnit, 'etStructChapter', ord(etStructChapter));
  1715.  
  1716.     { TwbElementState }
  1717.     AddConst(cUnit, 'esModified', Ord(esModified));
  1718.     AddConst(cUnit, 'esInternalModified', Ord(esInternalModified));
  1719.     AddConst(cUnit, 'esUnsaved', Ord(esUnsaved));
  1720.     AddConst(cUnit, 'esSortKeyValid', Ord(esSortKeyValid));
  1721.     AddConst(cUnit, 'esExtendedSortKeyValid', Ord(esExtendedSortKeyValid));
  1722.     AddConst(cUnit, 'esHidden', Ord(esHidden));
  1723.     AddConst(cUnit, 'esParentHidden', Ord(esParentHidden));
  1724.     AddConst(cUnit, 'esParentHiddenChecked', Ord(esParentHiddenChecked));
  1725.     AddConst(cUnit, 'esNotReachable', Ord(esNotReachable));
  1726.     AddConst(cUnit, 'esReachable', Ord(esReachable));
  1727.     AddConst(cUnit, 'esTagged', Ord(esTagged));
  1728.     AddConst(cUnit, 'esDeciding', Ord(esDeciding));
  1729.     AddConst(cUnit, 'esNotSuitableToAddTo', Ord(esNotSuitableToAddTo));
  1730.  
  1731.     { TwbDefType }
  1732.     AddConst(cUnit, 'dtRecord', ord(dtRecord));
  1733.     AddConst(cUnit, 'dtSubRecord', ord(dtSubRecord));
  1734.     AddConst(cUnit, 'dtSubRecordArray', ord(dtSubRecordArray));
  1735.     AddConst(cUnit, 'dtSubRecordStruct', ord(dtSubRecordStruct));
  1736.     AddConst(cUnit, 'dtSubRecordUnion', ord(dtSubRecordUnion));
  1737.     AddConst(cUnit, 'dtString', ord(dtString));
  1738.     AddConst(cUnit, 'dtLString', ord(dtLString));
  1739.     AddConst(cUnit, 'dtLenString', ord(dtLenString));
  1740.     AddConst(cUnit, 'dtByteArray', ord(dtByteArray));
  1741.     AddConst(cUnit, 'dtInteger', ord(dtInteger));
  1742.     AddConst(cUnit, 'dtIntegerFormater', ord(dtIntegerFormater));
  1743.     AddConst(cUnit, 'dtFloat', ord(dtFloat));
  1744.     AddConst(cUnit, 'dtArray', ord(dtArray));
  1745.     AddConst(cUnit, 'dtStruct', ord(dtStruct));
  1746.     AddConst(cUnit, 'dtUnion', ord(dtUnion));
  1747.     AddConst(cUnit, 'dtEmpty', ord(dtEmpty));
  1748.     AddConst(cUnit, 'dtStructChapter', ord(dtStructChapter));
  1749.  
  1750.     { TConflictThis }
  1751.     AddConst(cUnit, 'ctUnknown', ord(ctUnknown));
  1752.     AddConst(cUnit, 'ctIgnored', ord(ctIgnored));
  1753.     AddConst(cUnit, 'ctNotDefined', ord(ctNotDefined));
  1754.     AddConst(cUnit, 'ctIdenticalToMaster', ord(ctIdenticalToMaster));
  1755.     AddConst(cUnit, 'ctOnlyOne', ord(ctOnlyOne));
  1756.     AddConst(cUnit, 'ctHiddenByModGroup', ord(ctHiddenByModGroup));
  1757.     AddConst(cUnit, 'ctMaster', ord(ctMaster));
  1758.     AddConst(cUnit, 'ctConflictBenign', ord(ctConflictBenign));
  1759.     AddConst(cUnit, 'ctOverride', ord(ctOverride));
  1760.     AddConst(cUnit, 'ctIdenticalToMasterWinsConflict', ord(ctIdenticalToMasterWinsConflict));
  1761.     AddConst(cUnit, 'ctConflictWins', ord(ctConflictWins));
  1762.     AddConst(cUnit, 'ctConflictLoses', ord(ctConflictLoses));
  1763.  
  1764.     { TConflictAll }
  1765.     AddConst(cUnit, 'caUnknown', ord(caUnknown));
  1766.     AddConst(cUnit, 'caOnlyOne', ord(caOnlyOne));
  1767.     AddConst(cUnit, 'caNoConflict', ord(caNoConflict));
  1768.     AddConst(cUnit, 'caConflictBenign', ord(caConflictBenign));
  1769.     AddConst(cUnit, 'caOverride', ord(caOverride));
  1770.     AddConst(cUnit, 'caConflict', ord(caConflict));
  1771.     AddConst(cUnit, 'caConflictCritical', ord(caConflictCritical));
  1772.  
  1773.     { TwbContainerState }
  1774.     AddConst(cUnit, 'csInit', ord(csInit));
  1775.     AddConst(cUnit, 'csInitOnce', ord(csInitOnce));
  1776.     AddConst(cUnit, 'csInitDone', ord(csInitDone));
  1777.     AddConst(cUnit, 'csInitializing', ord(csInitializing));
  1778.     AddConst(cUnit, 'csRefsBuild', ord(csRefsBuild));
  1779.     AddConst(cUnit, 'csAsCreatedEmpty', ord(csAsCreatedEmpty));
  1780.  
  1781.     {TGameResourceType}
  1782.     AddConst(cUnit, 'resMesh', ord(resMesh));
  1783.     AddConst(cUnit, 'resTexture', ord(resTexture));
  1784.     AddConst(cUnit, 'resSound', ord(resSound));
  1785.     AddConst(cUnit, 'resMusic', ord(resMusic));
  1786.  
  1787.  
  1788.     AddFunction(cUnit, 'Assigned', _Assigned, 1, [varEmpty], varEmpty);
  1789.     AddFunction(cUnit, 'ObjectToElement', ObjectToElement, 1, [varEmpty], varEmpty);
  1790.     AddFunction(cUnit, 'FullPathToFilename', _FullPathToFilename, 1, [varEmpty], varEmpty);
  1791.     AddFunction(cUnit, 'EnableSkyrimSaveFormat', EnableSkyrimSaveFormat, 0, [], varEmpty);
  1792.     AddFunction(cUnit, 'GetRecordDefNames', GetRecordDefNames, 1, [varEmpty], varEmpty);
  1793.     AddFunction(cUnit, 'wbFilterStrings', wbFilterStrings, 3, [varEmpty, varEmpty, varEmpty], varEmpty);
  1794.     AddFunction(cUnit, 'wbRemoveDuplicateStrings', wbRemoveDuplicateStrings, 1, [varEmpty], varEmpty);
  1795.     AddFunction(cUnit, 'wbVersionNumber', wbGetVersionNumber, 0, [], varEmpty);
  1796.  
  1797.     { IwbElement }
  1798.     AddFunction(cUnit, 'Name', IwbElement_Name, 1, [varEmpty], varEmpty);
  1799.     AddFunction(cUnit, 'ShortName', IwbElement_ShortName, 1, [varEmpty], varEmpty);
  1800.     AddFunction(cUnit, 'BaseName', IwbElement_BaseName, 1, [varEmpty], varEmpty);
  1801.     AddFunction(cUnit, 'DisplayName', IwbElement_DisplayName, 1, [varEmpty], varEmpty);
  1802.     AddFunction(cUnit, 'Path', IwbElement_Path, 1, [varEmpty], varEmpty);
  1803.     AddFunction(cUnit, 'FullPath', IwbElement_FullPath, 1, [varEmpty], varEmpty);
  1804.     AddFunction(cUnit, 'PathName', IwbElement_PathName, 1, [varEmpty], varEmpty);
  1805.     AddFunction(cUnit, 'ElementType', IwbElement_ElementType, 1, [varEmpty], varEmpty);
  1806.     AddFunction(cUnit, 'DefType', IwbElement_DefType, 1, [varEmpty], varEmpty);
  1807.     AddFunction(cUnit, 'EnumValues', IwbElement_EnumValues, 1, [varEmpty], varEmpty);
  1808.     AddFunction(cUnit, 'FlagValues', IwbElement_FlagValues, 1, [varEmpty], varEmpty);
  1809.     AddFunction(cUnit, 'SortKey', IwbElement_SortKey, 2, [varEmpty, varBoolean], varEmpty);
  1810.     AddFunction(cUnit, 'IsInjected', IwbElement_IsInjected, 1, [varEmpty], varEmpty);
  1811.     AddFunction(cUnit, 'IsEditable', IwbElement_GetIsEditable, 1, [varEmpty], varEmpty);
  1812.     AddFunction(cUnit, 'GetEditValue', IwbElement_GetEditValue, 1, [varEmpty], varEmpty);
  1813.     AddFunction(cUnit, 'SetEditValue', IwbElement_SetEditValue, 2, [varEmpty, varString], varEmpty);
  1814.     AddFunction(cUnit, 'GetNativeValue', IwbElement_GetNativeValue, 1, [varEmpty], varEmpty);
  1815.     AddFunction(cUnit, 'SetNativeValue', IwbElement_SetNativeValue, 2, [varEmpty, varEmpty], varEmpty);
  1816.     AddFunction(cUnit, 'Remove', IwbElement_Remove, 1, [varEmpty], varEmpty);
  1817.     AddFunction(cUnit, 'GetFile', IwbElement_GetFile, 1, [varEmpty], varEmpty);
  1818.     AddFunction(cUnit, 'GetContainer', IwbElement_GetContainer, 1, [varEmpty], varEmpty);
  1819.     AddFunction(cUnit, 'ContainingMainRecord', IwbElement_ContainingMainRecord, 1, [varEmpty], varEmpty);
  1820.     AddFunction(cUnit, 'LinksTo', IwbElement_LinksTo, 1, [varEmpty], varEmpty);
  1821.     AddFunction(cUnit, 'Check', IwbElement_Check, 1, [varEmpty], varEmpty);
  1822.     AddFunction(cUnit, 'ElementAssign', IwbElement_Assign, 4, [varEmpty, varEmpty, varEmpty, varBoolean], varEmpty);
  1823.     AddFunction(cUnit, 'Equals', IwbElement_Equals, 2, [varEmpty, varEmpty], varEmpty);
  1824.     AddFunction(cUnit, 'CanContainFormIDs', IwbElement_CanContainFormIDs, 1, [varEmpty], varEmpty);
  1825.     AddFunction(cUnit, 'CanMoveUp', IwbElement_CanMoveUp, 1, [varEmpty], varEmpty);
  1826.     AddFunction(cUnit, 'CanMoveDown', IwbElement_CanMoveDown, 1, [varEmpty], varEmpty);
  1827.     AddFunction(cUnit, 'MoveUp', IwbElement_MoveUp, 1, [varEmpty], varEmpty);
  1828.     AddFunction(cUnit, 'MoveDown', IwbElement_MoveDown, 1, [varEmpty], varEmpty);
  1829.     AddFunction(cUnit, 'wbCopyElementToFile', _wbCopyElementToFile, 4, [varEmpty, varEmpty, varBoolean, varBoolean], varEmpty);
  1830.     AddFunction(cUnit, 'wbCopyElementToFileWithPrefix', _wbCopyElementToFileWithPrefix, 7, [varEmpty, varEmpty, varBoolean, varBoolean, varEmpty, varEmpty, varEmpty], varEmpty);
  1831.     AddFunction(cUnit, 'wbCopyElementToRecord', _wbCopyElementToRecord, 4, [varEmpty, varEmpty, varBoolean, varBoolean], varEmpty);
  1832.     AddFunction(cUnit, 'ClearElementState', IwbElement_ClearElementState, 2, [varEmpty, varEmpty], varBoolean);
  1833.     AddFunction(cUnit, 'SetElementState', IwbElement_SetElementState, 2, [varEmpty, varEmpty], varBoolean);
  1834.     AddFunction(cUnit, 'GetElementState', IwbElement_GetElementState, 2, [varEmpty, varEmpty], varBoolean);
  1835.     AddFunction(cUnit, 'ReportRequiredMasters', IwbElement_ReportRequiredMasters, 4, [varEmpty, varEmpty, varEmpty, varEmpty], varEmpty);
  1836.     AddFunction(cUnit, 'BuildRef', IwbElement_BuildRef, 1, [varEmpty], varEmpty);
  1837.  
  1838.     { IwbContainer }
  1839.     AddFunction(cUnit, 'GetElementEditValues', IwbContainer_GetElementEditValues, 2, [varEmpty, varString], varEmpty);
  1840.     AddFunction(cUnit, 'SetElementEditValues', IwbContainer_SetElementEditValues, 3, [varEmpty, varString, varString], varEmpty);
  1841.     AddFunction(cUnit, 'GetElementNativeValues', IwbContainer_GetElementNativeValues, 2, [varEmpty, varString], varEmpty);
  1842.     AddFunction(cUnit, 'SetElementNativeValues', IwbContainer_SetElementNativeValues, 3, [varEmpty, varString, varEmpty], varEmpty);
  1843.     AddFunction(cUnit, 'ElementByName', IwbContainer_ElementByName, 2, [varEmpty, varString], varEmpty);
  1844.     AddFunction(cUnit, 'ElementBySignature', IwbContainer_ElementBySignature, 2, [varEmpty, varString], varEmpty);
  1845.     AddFunction(cUnit, 'ElementByPath', IwbContainer_ElementByPath, 2, [varEmpty, varString], varEmpty);
  1846.     AddFunction(cUnit, 'AdditionalElementCount', IwbContainer_AdditionalElementCount, 1, [varEmpty], varEmpty);
  1847.     AddFunction(cUnit, 'ElementCount', IwbContainer_ElementCount, 1, [varEmpty], varEmpty);
  1848.     AddFunction(cUnit, 'ElementByIndex', IwbContainer_ElementByIndex, 2, [varEmpty, varInteger], varEmpty);
  1849.     AddFunction(cUnit, 'ElementExists', IwbContainer_ElementExists, 2, [varEmpty, varString], varEmpty);
  1850.     AddFunction(cUnit, 'LastElement', IwbContainer_LastElement, 1, [varEmpty], varEmpty);
  1851.     AddFunction(cUnit, 'IndexOf', IwbContainer_IndexOf, 2, [varEmpty, varEmpty], varEmpty);
  1852.     AddFunction(cUnit, 'Add', IwbContainer_Add, 3, [varEmpty, varString, varBoolean], varEmpty);
  1853.     AddFunction(cUnit, 'AddElement', IwbContainer_AddElement, 2, [varEmpty, varEmpty], varEmpty);
  1854.     AddFunction(cUnit, 'InsertElement', IwbContainer_InsertElement, 3, [varEmpty, varInteger, varEmpty], varEmpty);
  1855.     AddFunction(cUnit, 'RemoveElement', IwbContainer_RemoveElement, 2, [varEmpty, varEmpty], varEmpty);
  1856.     AddFunction(cUnit, 'RemoveByIndex', IwbContainer_RemoveByIndex, 3, [varEmpty, varInteger, varBoolean], varEmpty);
  1857.     AddFunction(cUnit, 'ReverseElements', IwbContainer_ReverseElements, 1, [varEmpty], varEmpty);
  1858.     AddFunction(cUnit, 'ContainerStates', IwbContainer_ContainerStates, 1, [varEmpty], varEmpty);
  1859.     AddFunction(cUnit, 'IsSorted', IwbContainer_IsSorted, 1, [varEmpty], varEmpty);
  1860.     AddFunction(cUnit, 'GetChildRecords', IwbContainer_GetChildRecords, 3, [varEmpty, varEmpty, varEmpty], varEmpty);
  1861.  
  1862.     { IwbMainRecord }
  1863.     AddFunction(cUnit, 'Signature', IwbMainRecord_Signature, 1, [varEmpty], varEmpty);
  1864.     AddFunction(cUnit, 'FormID', IwbMainRecord_FormID, 1, [varEmpty], varEmpty);
  1865.     AddFunction(cUnit, 'EditorID', IwbMainRecord_EditorID, 1, [varEmpty], varEmpty);
  1866.     AddFunction(cUnit, 'SetEditorID', IwbMainRecord_SetEditorID, 2, [varEmpty, varEmpty], varEmpty);
  1867.     AddFunction(cUnit, 'FixedFormID', IwbMainRecord_FixedFormID, 1, [varEmpty], varEmpty);
  1868.     AddFunction(cUnit, 'GetLoadOrderFormID', IwbMainRecord_GetLoadOrderFormID, 1, [varEmpty], varEmpty);
  1869.     AddFunction(cUnit, 'SetLoadOrderFormID', IwbMainRecord_SetLoadOrderFormID, 2, [varEmpty, varEmpty], varEmpty);
  1870.     AddFunction(cUnit, 'GetIsDeleted', IwbMainRecord_GetIsDeleted, 1, [varEmpty], varEmpty);
  1871.     AddFunction(cUnit, 'SetIsDeleted', IwbMainRecord_SetIsDeleted, 2, [varEmpty, varBoolean], varEmpty);
  1872.     AddFunction(cUnit, 'GetIsInitiallyDisabled', IwbMainRecord_GetIsInitiallyDisabled, 1, [varEmpty], varEmpty);
  1873.     AddFunction(cUnit, 'SetIsInitiallyDisabled', IwbMainRecord_SetIsInitiallyDisabled, 2, [varEmpty, varBoolean], varEmpty);
  1874.     AddFunction(cUnit, 'GetIsPersistent', IwbMainRecord_GetIsPersistent, 1, [varEmpty], varEmpty);
  1875.     AddFunction(cUnit, 'SetIsPersistent', IwbMainRecord_SetIsPersistent, 2, [varEmpty, varBoolean], varEmpty);
  1876.     AddFunction(cUnit, 'GetIsVisibleWhenDistant', IwbMainRecord_GetIsVisibleWhenDistant, 1, [varEmpty], varEmpty);
  1877.     AddFunction(cUnit, 'SetIsVisibleWhenDistant', IwbMainRecord_SetIsVisibleWhenDistant, 2, [varEmpty, varBoolean], varEmpty);
  1878.     AddFunction(cUnit, 'GetFormVersion', IwbMainRecord_GetFormVersion, 1, [varEmpty], varEmpty);
  1879.     AddFunction(cUnit, 'SetFormVersion', IwbMainRecord_SetFormVersion, 2, [varEmpty, varInteger], varEmpty);
  1880.     AddFunction(cUnit, 'OverrideCount', IwbMainRecord_OverrideCount, 1, [varEmpty], varEmpty);
  1881.     AddFunction(cUnit, 'OverrideByIndex', IwbMainRecord_OverrideByIndex, 2, [varEmpty, varInteger], varEmpty);
  1882.     AddFunction(cUnit, 'ReferencedByCount', IwbMainRecord_ReferencedByCount, 1, [varEmpty], varEmpty);
  1883.     AddFunction(cUnit, 'ReferencedByIndex', IwbMainRecord_ReferencedByIndex, 2, [varEmpty, varInteger], varEmpty);
  1884.     AddFunction(cUnit, 'Master', IwbMainRecord_Master, 1, [varEmpty], varEmpty);
  1885.     AddFunction(cUnit, 'MasterOrSelf', IwbMainRecord_MasterOrSelf, 1, [varEmpty], varEmpty);
  1886.     AddFunction(cUnit, 'IsMaster', IwbMainRecord_IsMaster, 1, [varEmpty], varEmpty);
  1887.     AddFunction(cUnit, 'IsWinningOverride', IwbMainRecord_IsWinningOverride, 1, [varEmpty], varEmpty);
  1888.     AddFunction(cUnit, 'WinningOverride', IwbMainRecord_WinningOverride, 1, [varEmpty], varEmpty);
  1889.     AddFunction(cUnit, 'HighestOverrideOrSelf', IwbMainRecord_HighestOverrideOrSelf, 2, [varEmpty, varEmpty], varEmpty);
  1890.     AddFunction(cUnit, 'BaseRecord', IwbMainRecord_BaseRecord, 1, [varEmpty], varEmpty);
  1891.     AddFunction(cUnit, 'BaseRecordID', IwbMainRecord_BaseRecordID, 1, [varEmpty], varEmpty);
  1892.     AddFunction(cUnit, 'UpdateRefs', IwbMainRecord_UpdateRefs, 1, [varEmpty], varEmpty);
  1893.     AddFunction(cUnit, 'ChildGroup', IwbMainRecord_ChildGroup, 1, [varEmpty], varEmpty);
  1894.     AddFunction(cUnit, 'CompareExchangeFormID', IwbMainRecord_CompareExchangeFormID, 3, [varEmpty, varEmpty, varEmpty], varEmpty);
  1895.     AddFunction(cUnit, 'ChangeFormSignature', IwbMainRecord_ChangeFormSignature, 2, [varEmpty, varEmpty], varEmpty);
  1896.     AddFunction(cUnit, 'GetPosition', IwbMainRecord_GetPosition, 1, [varEmpty], varEmpty);
  1897.     AddFunction(cUnit, 'GetRotation', IwbMainRecord_GetRotation, 1, [varEmpty], varEmpty);
  1898.     AddFunction(cUnit, 'GetGridCell', IwbMainRecord_GetGridCell, 1, [varEmpty], varEmpty);
  1899.  
  1900.     { IwbGroupRecord }
  1901.     AddFunction(cUnit, 'GroupType', IwbGroupRecord_GroupType, 1, [varEmpty], varEmpty);
  1902.     AddFunction(cUnit, 'GroupLabel', IwbGroupRecord_GroupLabel, 1, [varEmpty], varEmpty);
  1903.     AddFunction(cUnit, 'ChildrenOf', IwbGroupRecord_ChildrenOf, 1, [varEmpty], varEmpty);
  1904.     AddFunction(cUnit, 'MainRecordByEditorID', IwbGroupRecord_MainRecordByEditorID, 2, [varEmpty], varEmpty);
  1905.     AddFunction(cUnit, 'FindChildGroup', IwbGroupRecord_FindChildGroup, 3, [varEmpty, varEmpty, varEmpty], varEmpty);
  1906.  
  1907.     { IwbFile }
  1908.     AddFunction(cUnit, 'GetFileName', IwbFile_GetFileName, 1, [varEmpty], varEmpty);
  1909.     AddFunction(cUnit, 'GetLoadOrder', IwbFile_GetLoadOrder, 1, [varEmpty], varEmpty);
  1910.     AddFunction(cUnit, 'GetNewFormID', IwbFile_GetNewFormID, 0, [varEmpty], varEmpty);
  1911.     AddFunction(cUnit, 'GetIsESM', IwbFile_GetIsESM, 1, [varEmpty], varEmpty);
  1912.     AddFunction(cUnit, 'SetIsESM', IwbFile_SetIsESM, 2, [varEmpty, varBoolean], varEmpty);
  1913.     AddFunction(cUnit, 'SortMasters', IwbFile_SortMasters, 1, [varEmpty], varEmpty);
  1914.     AddFunction(cUnit, 'CleanMasters', IwbFile_CleanMasters, 1, [varEmpty], varEmpty);
  1915.     AddFunction(cUnit, 'MasterCount', IwbFile_MasterCount, 1, [varEmpty], varEmpty);
  1916.     AddFunction(cUnit, 'MasterByIndex', IwbFile_MasterByIndex, 2, [varEmpty, varInteger], varEmpty);
  1917.     AddFunction(cUnit, 'RecordCount', IwbFile_RecordCount, 1, [varEmpty], varEmpty);
  1918.     AddFunction(cUnit, 'RecordByIndex', IwbFile_RecordByIndex, 2, [varEmpty, varInteger], varEmpty);
  1919.     AddFunction(cUnit, 'GroupBySignature', IwbFile_GroupBySignature, 2, [varEmpty, varString], varEmpty);
  1920.     AddFunction(cUnit, 'RecordByFormID', IwbFile_RecordByFormID, 3, [varEmpty, varInteger, varBoolean], varEmpty);
  1921.     AddFunction(cUnit, 'RecordByEditorID', IwbFile_RecordByEditorID, 2, [varEmpty, varString], varEmpty);
  1922.     AddFunction(cUnit, 'AddMasterIfMissing', IwbFile_AddMasterIfMissing, 2, [varEmpty, varString], varEmpty);
  1923.     AddFunction(cUnit, 'HasMaster', IwbFile_HasMaster, 2, [varEmpty, varString], varEmpty);
  1924.     AddFunction(cUnit, 'HasGroup', IwbFile_HasGroup, 2, [varEmpty, varString], varEmpty);
  1925.     AddFunction(cUnit, 'LoadOrderFormIDtoFileFormID', IwbFile_LoadOrderFormIDtoFileFormID, 2, [varEmpty, varEmpty], varEmpty);
  1926.     AddFunction(cUnit, 'FileFormIDtoLoadOrderFormID', IwbFile_FileFormIDtoLoadOrderFormID, 2, [varEmpty, varString], varEmpty);
  1927.  
  1928.     { IwbContainerHandler }
  1929.     AddFunction(cUnit, 'ResourceContainerList', IwbContainerHandler_ResourceContainerList, 1, [varEmpty], varEmpty);
  1930.     AddFunction(cUnit, 'ResourceExists', IwbContainerHandler_ResourceExists, 1, [varEmpty], varEmpty);
  1931.     AddFunction(cUnit, 'ResourceCount', IwbContainerHandler_ResourceCount, 2, [varEmpty, varEmpty], varEmpty);
  1932.     AddFunction(cUnit, 'ResourceList', IwbContainerHandler_ResourceList, 2, [varEmpty, varEmpty], varEmpty);
  1933.     AddFunction(cUnit, 'ResourceOpenData', IwbContainerHandler_ResourceOpenData, 2, [varEmpty, varEmpty], varEmpty);
  1934.     AddFunction(cUnit, 'ResourceCopy', IwbContainerHandler_ResourceCopy, 3, [varEmpty, varEmpty, varEmpty], varEmpty);
  1935.  
  1936.     { IwbFastStringList }
  1937.     AddClass('TwbFastStringList', TwbFastStringList, 'TwbFastStringList');
  1938.     AddGet(TwbFastStringList, 'Create', TwbFastStringList_Create, 0, [varEmpty], varEmpty);
  1939.  
  1940.     { Nif routines }
  1941.     AddFunction(cUnit, 'NifBlockList', NifUtils_NifBlockList, 2, [varEmpty, varEmpty], varEmpty);
  1942.     AddFunction(cUnit, 'NifTextureList', NifUtils_NifTextureList, 2, [varEmpty, varEmpty], varEmpty);
  1943.     AddFunction(cUnit, 'NifTextureListUVRange', NifUtils_NifTextureListUVRange, 3, [varEmpty, varEmpty, varEmpty], varEmpty);
  1944.  
  1945.     { DDS routines }
  1946.     AddFunction(cUnit, 'wbDDSStreamToBitmap', DDSUtils_wbDDSStreamToBitmap, 2, [varEmpty, varEmpty], varEmpty);
  1947.     AddFunction(cUnit, 'wbDDSDataToBitmap', DDSUtils_wbDDSDataToBitmap, 2, [varEmpty, varEmpty], varEmpty);
  1948.  
  1949.     { Misc routines }
  1950.     AddFunction(cUnit, 'wbFlipBitmap', Misc_wbFlipBitmap, 2, [varEmpty, varEmpty], varEmpty);
  1951.     AddFunction(cUnit, 'wbAlphaBlend', Misc_wbAlphaBlend, 11, [varEmpty, varEmpty, varEmpty, varEmpty, varEmpty, varEmpty, varEmpty, varEmpty, varEmpty, varEmpty, varEmpty], varEmpty);
  1952.     AddFunction(cUnit, 'wbPositionToGridCell', Misc_wbPositionToGridCell, 1, [varEmpty], varEmpty);
  1953.     AddFunction(cUnit, 'wbSubBlockFromGridCell', Misc_wbSubBlockFromGridCell, 1, [varEmpty], varEmpty);
  1954.     AddFunction(cUnit, 'wbBlockFromSubBlock', Misc_wbBlockFromSubBlock, 1, [varEmpty], varEmpty);
  1955.     AddFunction(cUnit, 'wbGridCellToGroupLabel', Misc_wbGridCellToGroupLabel, 1, [varEmpty], varEmpty);
  1956.     AddFunction(cUnit, 'wbIsInGridCell', Misc_wbIsInGridCell, 2, [varEmpty, varEmpty], varEmpty);
  1957.     AddFunction(cUnit, 'wbCRC32Data', Misc_wbCRC32Data, 1, [varEmpty], varEmpty);
  1958.     AddFunction(cUnit, 'wbCRC32File', Misc_wbCRC32File, 1, [varEmpty], varEmpty);
  1959.     AddFunction(cUnit, 'wbSHA1Data', Misc_wbSHA1Data, 1, [varEmpty], varEmpty);
  1960.     AddFunction(cUnit, 'wbSHA1File', Misc_wbSHA1File, 1, [varEmpty], varEmpty);
  1961.     AddFunction(cUnit, 'wbMD5Data', Misc_wbMD5Data, 1, [varEmpty], varEmpty);
  1962.     AddFunction(cUnit, 'wbMD5File', Misc_wbMD5File, 1, [varEmpty], varEmpty);
  1963.     AddFunction(cUnit, 'wbFindREFRsByBase', Misc_wbFindRefrsByBase, 4, [varEmpty, varEmpty, varEmpty, varEmpty], varEmpty);
  1964.     AddFunction(cUnit, 'wbNormalizeResourceName', Misc_wbNormalizeResourceName, 2, [varEmpty, varEmpty], varEmpty);
  1965.     AddFunction(cUnit, 'wbStringListInString', Misc_wbStringListInString, 2, [varEmpty, varEmpty], varEmpty);
  1966.   end;
  1967. end;
  1968.  
  1969. procedure Init;
  1970. begin
  1971.   RegisterJvInterpreterAdapter(GlobalJvInterpreterAdapter);
  1972.   JvInterpreterFm.RegisterJvInterpreterAdapter(GlobalJvInterpreterAdapter);
  1973.   JvInterpreter_System.RegisterJvInterpreterAdapter(GlobalJvInterpreterAdapter);
  1974.   JvInterpreter_SysUtils.RegisterJvInterpreterAdapter(GlobalJvInterpreterAdapter);
  1975.   JvInterpreter_Classes.RegisterJvInterpreterAdapter(GlobalJvInterpreterAdapter);
  1976.   JvInterpreter_Dialogs.RegisterJvInterpreterAdapter(GlobalJvInterpreterAdapter);
  1977.   JvInterpreter_Windows.RegisterJvInterpreterAdapter(GlobalJvInterpreterAdapter);
  1978.   JvInterpreter_Graphics.RegisterJvInterpreterAdapter(GlobalJvInterpreterAdapter);
  1979.   JvInterpreter_Controls.RegisterJvInterpreterAdapter(GlobalJvInterpreterAdapter);
  1980.   JvInterpreter_Buttons.RegisterJvInterpreterAdapter(GlobalJvInterpreterAdapter);
  1981.   JvInterpreter_StdCtrls.RegisterJvInterpreterAdapter(GlobalJvInterpreterAdapter);
  1982.   JvInterpreter_ComCtrls.RegisterJvInterpreterAdapter(GlobalJvInterpreterAdapter);
  1983.   JvInterpreter_ExtCtrls.RegisterJvInterpreterAdapter(GlobalJvInterpreterAdapter);
  1984.   JvInterpreter_Forms.RegisterJvInterpreterAdapter(GlobalJvInterpreterAdapter);
  1985.   JvInterpreter_Dialogs.RegisterJvInterpreterAdapter(GlobalJvInterpreterAdapter);
  1986.   JvInterpreter_Menus.RegisterJvInterpreterAdapter(GlobalJvInterpreterAdapter);
  1987.   //JvInterpreter_JvEditor.RegisterJvInterpreterAdapter(GlobalJvInterpreterAdapter);
  1988.   wbScriptAdapterMisc.RegisterJvInterpreterAdapter(GlobalJvInterpreterAdapter);
  1989. end;
  1990.  
  1991. initialization
  1992.   Init;
  1993.  
  1994. end.
Advertisement
Add Comment
Please, Sign In to add comment