diff --git a/DataScraping/Reps/OpenCL-Docs b/DataScraping/Reps/OpenCL-Docs index 5cedd789..a7fe71a1 160000 --- a/DataScraping/Reps/OpenCL-Docs +++ b/DataScraping/Reps/OpenCL-Docs @@ -1 +1 @@ -Subproject commit 5cedd789a590dd52887399fbfb385bdbc533a995 +Subproject commit a7fe71a1d2ff59de6b6f394b0237772bf6141d2d diff --git a/DataScraping/XML/Dummy/ScrapXML.pas b/DataScraping/XML/Dummy/ScrapXML.pas index 3bfbe1f7..85c61b18 100644 --- a/DataScraping/XML/Dummy/ScrapXML.pas +++ b/DataScraping/XML/Dummy/ScrapXML.pas @@ -106,14 +106,14 @@ begin if tname=nil then raise nil; - var gr := GroupSource.FindOrMakeItem(tname); + var gr := GroupSource.FindOrMakeItem(tname, true); if gr<>nil then begin Result := new TypeRef(gr); exit; end; - var bt := BasicTypeSource.FindOrMakeItem(tname); + var bt := BasicTypeSource.FindOrMakeItem(tname, true); if bt<>nil then begin Result := new TypeRef(bt); @@ -184,7 +184,7 @@ function GroupSource.MakeNewItem: Group; .ToArray ); - Result := new Group(new GroupName('', nil, self.Name), |BasicTypeSource.FindOrMakeItem('enum_base')|, enums); + Result := new Group(new GroupName('', nil, self.Name), |BasicTypeSource.FindOrMakeItem('enum_base', false)|, enums); end; {$endregion Group} diff --git a/DataScraping/XML/ItemSources.pas b/DataScraping/XML/ItemSources.pas index e775c048..3dc30b8e 100644 --- a/DataScraping/XML/ItemSources.pas +++ b/DataScraping/XML/ItemSources.pas @@ -9,19 +9,9 @@ interface uses NamedItems; type - ItemSource = abstract class - where TSelf: ItemSource; - where TSourceName: class, IEquatable; - where TItem: class; - private _name: TSourceName; - private ready := default(TItem); - private static all_sources := new Dictionary; - - public static procedure PrintAllNames := all_sources.Keys.PrintLines; + ItemSourceHelpers = static class - static constructor; - - protected static function MakeName(api, s, api_beg: string; allow_nil, skip_invalid: boolean; api_underscore_sep: boolean?; known_suffixes: HashSet; params suffix_formats: array of string): TFullName; + public static function MakeName(api, s, api_beg: string; allow_nil, skip_invalid: boolean; api_underscore_sep: boolean?; known_suffixes: HashSet; params suffix_formats: array of string): TFullName; where TFullName: ApiVendorLName; begin Result := nil; @@ -50,6 +40,20 @@ interface Result := TFullName(ctor.Invoke(new object[](api, s, api_beg, api_underscore_sep, extract_suffix))); end; + end; + + ItemSource = abstract class + where TSelf: ItemSource; + where TSourceName: class, IEquatable; + where TItem: class; + private _name: TSourceName; + private ready := default(TItem); + private static all_sources := new Dictionary; + + public static procedure PrintAllNames := all_sources.Keys.PrintLines; + + static constructor; + protected constructor(name: TSourceName); begin self._name := name; @@ -101,11 +105,24 @@ interface end; - public static function FindOrMakeItem(name: TSourceName): TItem; + public static function FindOrMakeItem(name: TSourceName; allow_nil: boolean; reason: string := nil): TItem; begin - Result := nil; - if name=nil then exit; + if reason<>nil then + reason := '; Reason: '+reason; + + if name=nil then + begin + if not allow_nil then + raise new InvalidOperationException($'Requested {TypeToTypeName(typeof(TItem))} for a nil name{reason}'); + Result := nil; + exit; + end; + Result := all_sources.Get(name)?.GetItem; + if Result<>nil then exit; + if not allow_nil then + raise new InvalidOperationException($'Returned a nil {TypeToTypeName(typeof(TItem))} for name [{name}]{reason}'); + end; protected function MakeNewItem: TItem; abstract; diff --git a/DataScraping/XML/OpenCL/ScrapXML.pas b/DataScraping/XML/OpenCL/ScrapXML.pas index da0202c1..bd573ddc 100644 --- a/DataScraping/XML/OpenCL/ScrapXML.pas +++ b/DataScraping/XML/OpenCL/ScrapXML.pas @@ -62,7 +62,7 @@ private val_s: string; public static function MakeName(s: string; allow_nil, skip_invalid: boolean) := - inherited MakeName&(api, s, api, allow_nil, skip_invalid, true, VendorSuffixSource.known_suffixes, '*_E'); + ItemSourceHelpers.MakeName&(api, s, api, allow_nil, skip_invalid, true, VendorSuffixSource.known_suffixes, '*_E'); /// CL_FLT_MAX and stuff private static external_enum_names := new HashSet; @@ -182,7 +182,7 @@ private definitions := new List; public static function MakeName(s: string; allow_nil, skip_invalid: boolean) := - inherited MakeName&(api, s, api, allow_nil, skip_invalid, true, VendorSuffixSource.known_suffixes, '*_e'); + ItemSourceHelpers.MakeName&(api, s, api, allow_nil, skip_invalid, true, VendorSuffixSource.known_suffixes, '*_e'); private constructor(gr_name: GroupName; org_name, etype: string); begin @@ -268,7 +268,7 @@ private is_ptr_hungry: boolean; public static function MakeName(s: string; allow_nil, skip_invalid: boolean) := - inherited MakeName&(api, s, api, allow_nil, skip_invalid, nil, VendorSuffixSource.known_suffixes, '*_e','*E'); + ItemSourceHelpers.MakeName&(api, s, api, allow_nil, skip_invalid, nil, VendorSuffixSource.known_suffixes, '*_e','*E'); public constructor(name: IdClassName; base_t: string; is_ptr_hungry: boolean); begin @@ -289,7 +289,7 @@ private member_ns: array of XmlNode; public static function MakeName(s: string; allow_nil, skip_invalid: boolean) := - inherited MakeName&(api, s, api, allow_nil, skip_invalid, true, VendorSuffixSource.known_suffixes, '*_e'); + ItemSourceHelpers.MakeName&(api, s, api, allow_nil, skip_invalid, true, VendorSuffixSource.known_suffixes, '*_e'); public constructor(n: XmlNode); begin @@ -309,7 +309,7 @@ private par_ns: array of XmlNode; public static function MakeName(s: string; allow_nil, skip_invalid: boolean) := - inherited MakeName&(api, s, api, allow_nil, skip_invalid, true, VendorSuffixSource.known_suffixes); + ItemSourceHelpers.MakeName&(api, s, api, allow_nil, skip_invalid, true, VendorSuffixSource.known_suffixes); public constructor(n: XmlNode); begin @@ -333,7 +333,7 @@ private par_ns: array of XmlNode; public static function MakeName(s: string; allow_nil, skip_invalid: boolean) := - inherited MakeName&(api, s, api, allow_nil, skip_invalid, false, VendorSuffixSource.known_suffixes, '*E'); + ItemSourceHelpers.MakeName&(api, s, api, allow_nil, skip_invalid, false, VendorSuffixSource.known_suffixes, '*E'); public constructor(name: FuncName; entry_point_name: string; par_ns: sequence of XmlNode); begin @@ -423,6 +423,49 @@ {$region Extension} + ExtensionHelpers = static class + + public static function MakeName(s: string; allow_nil, skip_invalid: boolean) := + ItemSourceHelpers.MakeName&(api, s, api, allow_nil, skip_invalid, true, VendorSuffixSource.known_suffixes, 'e_*','E_*'); + + private static function MakeFeatureOrExtensionName(s: string): (FeatureName, ExtensionName); + begin + var f := FeatureSource.MakeName(s, true, true); + Result := (f, if f<>nil then nil else ExtensionHelpers.MakeName(s, true, true)); + end; + + end; + + ExtensionDepOptionSource = sealed class + private core_dep: FeatureName; + private ext_deps: array of ExtensionName; + + public constructor(deps_s: string); + begin + self.core_dep := nil; + var ext_deps_l := new List; + + foreach var dep_s in deps_s.Split('+') do + begin + var (f,e) := ExtensionHelpers.MakeFeatureOrExtensionName(dep_s); + + if f<>nil then + begin + if core_dep<>nil then + raise new System.NotImplementedException; + core_dep := f; + end; + + if e<>nil then + ext_deps_l += e; + + end; + + self.ext_deps := ext_deps_l.ToArray; + end; + + end; + ExtensionSource = sealed class(ItemSource) private ext_str: string; private rns: sequence of XmlNode; @@ -430,20 +473,12 @@ private revision: string; private provisional: boolean; - private core_dep: FeatureName; - private ext_deps: array of ExtensionName; + private dep_options: array of ExtensionDepOptionSource; private obsolete_by: (FeatureName, ExtensionName); private promoted_to: (FeatureName, ExtensionName); - public static function MakeName(s: string; allow_nil, skip_invalid: boolean) := - inherited MakeName&(api, s, api, allow_nil, skip_invalid, true, VendorSuffixSource.known_suffixes, 'e_*','E_*'); - - private static function MakeFeatureOrExtensionName(s: string): (FeatureName, ExtensionName); - begin - var f := FeatureSource.MakeName(s, true, true); - Result := (f, if f<>nil then nil else ExtensionSource.MakeName(s, true, true)); - end; + public static function MakeName(s: string; allow_nil, skip_invalid: boolean) := ExtensionHelpers.MakeName(s, allow_nil, skip_invalid); public constructor(name: ExtensionName; ext_str: string; rns: sequence of XmlNode; revision, provisional, deps, obsolete_by, promoted_to: string); begin @@ -462,36 +497,18 @@ self.provisional := true; end; - if ext_str='cl_khr_gl_depth_images' then - begin - ext_str := ext_str; - end; - - self.core_dep := nil; if string.IsNullOrEmpty(deps) then - ext_deps := System.Array.Empty& else + self.dep_options := System.Array.Empty& else begin - var ext_deps_l := new List; - foreach var dep in deps.Split('+') do - begin - var (f,e) := MakeFeatureOrExtensionName(dep); - - if f<>nil then - begin - if core_dep<>nil then - raise new System.NotImplementedException; - core_dep := f; - end; - - if e<>nil then - ext_deps_l += e; - - end; - self.ext_deps := ext_deps_l.ToArray; + if '()'.Any(ch->deps.Contains(ch)) then + // Need more complex parsing + // Prob. convert to DNF after parsing, when it becomes needed + raise new NotImplementedException; + self.dep_options := deps.Split(',').ConvertAll(deps_opt->new ExtensionDepOptionSource(deps_opt)); end; - self.obsolete_by := MakeFeatureOrExtensionName(obsolete_by); - self.promoted_to := MakeFeatureOrExtensionName(promoted_to); + self.obsolete_by := ExtensionHelpers.MakeFeatureOrExtensionName(obsolete_by); + self.promoted_to := ExtensionHelpers.MakeFeatureOrExtensionName(promoted_to); end; @@ -583,7 +600,7 @@ function EnumSource.MakeNewItem: Enum; else raise new System.NotImplementedException(v); end; end else - if EnumSource.FindOrMakeItem(EnumSource.MakeName(val_str, true, false)) is Enum(var old_e) then + if EnumSource.FindOrMakeItem(EnumSource.MakeName(val_str, true, false), true) is Enum(var old_e) then val := old_e.Value else raise new MessageException($'ERROR: Could not parse value [{val_str}] of {self}'); end; @@ -773,7 +790,7 @@ function GroupSource.MakeNewItem: Group; var ename := enum_n['name']; if ename in EnumSource.external_enum_names then continue; - var e := EnumSource.FindOrMakeItem(EnumSource.MakeName(ename,false,false)); + var e := EnumSource.FindOrMakeItem(EnumSource.MakeName(ename,false,false), false); if not new_enums.Add(e) then Otp($'WARNING: {e} was added twice in the same RN') else if e not in node_by_enum then @@ -815,7 +832,7 @@ function GroupSource.MakeNewItem: Group; end else if sz_s.IsInteger then sz := new ParArrSizeConst(sz_s.ToInteger) else - if EnumSource.FindOrMakeItem(EnumSource.MakeName(sz_s,true,false)) is Enum(var old_e) then + if EnumSource.FindOrMakeItem(EnumSource.MakeName(sz_s,true,false), true) is Enum(var old_e) then sz := new ParArrSizeConst(old_e.Value) else raise new System.FormatException(sz_s); end else @@ -869,9 +886,8 @@ function GroupSource.MakeNewItem: Group; else begin - var old_e := EnumSource.FindOrMakeItem(EnumSource.MakeName(terminate_s,false,false)); - if old_e=nil then raise nil; - term_by.Add(old_e, e); + var terminate_e := EnumSource.FindOrMakeItem(EnumSource.MakeName(terminate_s,false,false), false); + term_by.Add(terminate_e, e); end; end; @@ -939,7 +955,7 @@ function StructSource.MakeNewItem: Struct; var text_end := $'[{static_len_enum_name}]'; if not text.EndsWith(text_end) then raise new System.InvalidOperationException; text := text.RemoveEnd(text_end); - len := new ParArrSizeConst(EnumSource.FindOrMakeItem(EnumSource.MakeName(static_len_enum_name, false, false)).Value); + len := new ParArrSizeConst(EnumSource.FindOrMakeItem(EnumSource.MakeName(static_len_enum_name, false, false), false).Value); end else len := ParArrSizeNotArray.Instance; @@ -1017,8 +1033,7 @@ function FuncSource.MakeNewItem: Func; Result := new Func(self.Name, self.entry_point_name, pars, nil); - var err_code_gr := GroupSource.FindOrMakeItem(GroupSource.MakeName('cl_error_code',false,false)); - if err_code_gr=nil then raise nil; + var err_code_gr := GroupSource.FindOrMakeItem(GroupSource.MakeName('cl_error_code',false,false), false); var have_err_ret := pars.Any(par->par.ParType.TypeObj = err_code_gr); @@ -1101,7 +1116,7 @@ function FuncSource.MakeNewItem: Func; func_n.TryDiscardAttrib('requires'); var name := func_n['name']; - Result.funcs += FuncSource.FindOrMakeItem(FuncSource.MakeName(name, false, false)); + Result.funcs += FuncSource.FindOrMakeItem(FuncSource.MakeName(name, false, false), false); end; {$endregion func} @@ -1157,11 +1172,13 @@ function ExtensionSource.MakeNewItem := self.revision, self.provisional, - FeatureSource.FindOrMakeItem(self.core_dep), - self.ext_deps.ConvertAll(ExtensionSource.FindOrMakeItem), + self.dep_options.ConvertAll(dep_opt->new ExtensionDepOption( + FeatureSource.FindOrMakeItem(dep_opt.core_dep, true), + dep_opt.ext_deps.ConvertAll(name->ExtensionSource.FindOrMakeItem(name, false)) + )), - (FeatureSource.FindOrMakeItem(self.obsolete_by[0]), ExtensionSource.FindOrMakeItem(self.obsolete_by[1])), - (FeatureSource.FindOrMakeItem(self.promoted_to[0]), ExtensionSource.FindOrMakeItem(self.promoted_to[1])) + (FeatureSource.FindOrMakeItem(self.obsolete_by[0], true), ExtensionSource.FindOrMakeItem(self.obsolete_by[1], true)), + (FeatureSource.FindOrMakeItem(self.promoted_to[0], true), ExtensionSource.FindOrMakeItem(self.promoted_to[1], true)) ); diff --git a/DataScraping/XML/OpenCL/funcs.bin b/DataScraping/XML/OpenCL/funcs.bin index 3cbb9ac2..fc573999 100644 Binary files a/DataScraping/XML/OpenCL/funcs.bin and b/DataScraping/XML/OpenCL/funcs.bin differ diff --git a/DataScraping/XML/OpenGL/ScrapXML.pas b/DataScraping/XML/OpenGL/ScrapXML.pas index 5a92cbfc..6d3c82b6 100644 --- a/DataScraping/XML/OpenGL/ScrapXML.pas +++ b/DataScraping/XML/OpenGL/ScrapXML.pas @@ -88,7 +88,7 @@ begin if name='__GLXextFuncPtr' then name := name.TrimStart('_'); - Result := inherited MakeName&(api, name, api, allow_nil, skip_invalid, false, VendorSuffixSource.known_suffixes, '*E','e*'); + Result := ItemSourceHelpers.MakeName&(api, name, api, allow_nil, skip_invalid, false, VendorSuffixSource.known_suffixes, '*E','e*'); end; public constructor(api, name, text: string); @@ -187,7 +187,7 @@ name := name.Substring(api_sep_ind+2); end; - Result := inherited MakeName&(api, name, '', false, false, false, VendorSuffixSource.known_suffixes, '*E'); + Result := ItemSourceHelpers.MakeName&(api, name, '', false, false, false, VendorSuffixSource.known_suffixes, '*E'); end; public static procedure Register(api,name: string; is_bitfield: boolean; ename: EnumName); @@ -229,7 +229,7 @@ if (context_api='wgl') and l_name.StartsWith('ERROR') then api_beg := ''; - Result := inherited MakeName&(own_api, l_name, api_beg, for_lookup, false, api_beg<>'', VendorSuffixSource.known_suffixes, '*_E'); + Result := ItemSourceHelpers.MakeName&(own_api, l_name, api_beg, for_lookup, false, api_beg<>'', VendorSuffixSource.known_suffixes, '*_E'); if Result=nil then exit; if not for_lookup then exit; @@ -237,7 +237,7 @@ if own_api in |'gles1', 'gles2', 'glsc2'| then begin - Result := inherited MakeName&('gl', l_name, api_beg, for_lookup, false, api_beg<>'', VendorSuffixSource.known_suffixes, '*_E'); + Result := ItemSourceHelpers.MakeName&('gl', l_name, api_beg, for_lookup, false, api_beg<>'', VendorSuffixSource.known_suffixes, '*_E'); end; end; @@ -330,7 +330,7 @@ public static extra_defined := new HashSet; public static function MakeName(api, name: string; skip_invalid: boolean) := if (name=nil) or name.StartsWith('_') then nil else - inherited MakeName&(api, name, '', false, skip_invalid, false, VendorSuffixSource.known_suffixes); + ItemSourceHelpers.MakeName&(api, name, '', false, skip_invalid, false, VendorSuffixSource.known_suffixes); public static function UseAs(name: IdClassName; t: string): IdClassSource; begin @@ -421,7 +421,7 @@ api := 'gdi'; end; - Result := inherited MakeName&(api, name, api_beg, false, false, false, VendorSuffixSource.known_suffixes, '*E'); + Result := ItemSourceHelpers.MakeName&(api, name, api_beg, false, false, false, VendorSuffixSource.known_suffixes, '*E'); end; private constructor(api: string; n: XmlNode); begin @@ -554,7 +554,7 @@ RequiredListSource = record private add: RequiredListSource; public static function MakeName(own_api, name, context_api: string; allow_nil: boolean) := - inherited MakeName&(own_api, name, context_api, allow_nil, false, true, VendorSuffixSource.known_suffixes, 'e_*','E_*'); + ItemSourceHelpers.MakeName&(own_api, name, context_api, allow_nil, false, true, VendorSuffixSource.known_suffixes, 'e_*','E_*'); public static procedure InitAll(file_api: string; extensions_n: XmlNode) := foreach var extension_n in extensions_n.SubNodes['extension'] do @@ -642,14 +642,14 @@ function VendorSuffixSource.MakeNewItem := begin var bt := default(BasicType); - var cl := IdClassSource.FindOrMakeItem(IdClassSource.MakeName(api, tname, true)); - var d := DelegateSource.FindOrMakeItem(DelegateSource.MakeName(api, tname, true, true)); + var cl := IdClassSource.FindOrMakeItem(IdClassSource.MakeName(api, tname, true), true); + var d := DelegateSource.FindOrMakeItem(DelegateSource.MakeName(api, tname, true, true), true); if (cl<>nil) and (cl.Name not in IdClassSource.extra_defined) then raise new InvalidOperationException; case Ord(cl<>nil)+Ord(d<>nil) of - 0: bt := BasicTypeSource.FindOrMakeItem(tname); + 0: bt := BasicTypeSource.FindOrMakeItem(tname, true); end; if bt<>nil then Result := new TypeRef(bt) else @@ -675,7 +675,7 @@ function DelegateSource.MakeNewItem: Delegate; .Trim ; - var pars := |new ParData(nil, new TypeRef(BasicTypeSource.FindOrMakeItem('void')), 0, System.Array.Empty&, ParArrSizeNotArray.Instance, nil)|; + var pars := |new ParData(nil, new TypeRef(BasicTypeSource.FindOrMakeItem('void', false)), 0, System.Array.Empty&, ParArrSizeNotArray.Instance, nil)|; if params_s in |'','void'| then begin @@ -717,13 +717,13 @@ function GroupSource.MakeNewItem: Group; begin var castable_to := new List(castable_to_names.Count); foreach var tname in castable_to_names do - castable_to += BasicTypeSource.FindOrMakeItem(tname); + castable_to += BasicTypeSource.FindOrMakeItem(tname, false); var possible_bitfield := new HashSet; var enums := new List(enum_names.Count); foreach var ename in enum_names.Keys do begin - var e := EnumSource.FindOrMakeItem(ename); + var e := EnumSource.FindOrMakeItem(ename, false); if e.Value<>0 then possible_bitfield += enum_names[ename]; @@ -765,9 +765,7 @@ function EnumSource.MakeNewItem: Enum; if alias_s<>nil then begin - var old_e := EnumSource.FindOrMakeItem(EnumSource.MakeName(nil, alias_s, self.Name.ApiName, true)); - if old_e=nil then - raise nil; + var old_e := EnumSource.FindOrMakeItem(EnumSource.MakeName(nil, alias_s, self.Name.ApiName, true), false); if old_e.Value <> val then raise new InvalidOperationException; var TODO := 0; //TODO Use enum name end to extract VendorName @@ -785,7 +783,7 @@ function IdClassSource.MakeNewItem: IdClass; var castable_to := new List(castable_to_names.Count); foreach var tname in self.castable_to_names do - castable_to += BasicTypeSource.FindOrMakeItem(tname); + castable_to += BasicTypeSource.FindOrMakeItem(tname, false); Result := new IdClass(name, castable_to.ToArray); end; @@ -990,9 +988,7 @@ function FuncSource.MakeNewItem: Func; end; - var alias := FuncSource.FindOrMakeItem(self.alias_name); - if (alias_name<>nil) <> (alias<>nil) then - raise new InvalidOperationException(self.ToString); + var alias := FuncSource.FindOrMakeItem(self.alias_name, alias_name=nil); Result := new Func(self.Name, self.entry_point_name, pars, alias); end; @@ -1007,15 +1003,13 @@ function RequiredListSource.MakeNewItem: RequiredList; foreach var n in self.enum_names do begin - var e := EnumSource.FindOrMakeItem(n); - if e=nil then raise new InvalidOperationException(n.ToString); + var e := EnumSource.FindOrMakeItem(n, false); Result.enums += e; end; foreach var n in self.func_names do begin - var f := FuncSource.FindOrMakeItem(n); - if f=nil then raise new InvalidOperationException(n.ToString); + var f := FuncSource.FindOrMakeItem(n, false); Result.funcs += f; end; @@ -1067,8 +1061,7 @@ function ExtensionSource.MakeNewItem := self.ext_str, self.add.MakeNewItem, nil, false, - default(Feature), - System.Array.Empty&, + System.Array.Empty&, (default(Feature), default(Extension)), (default(Feature), default(Extension)) diff --git a/DataScraping/XML/OpenGL/funcs.bin b/DataScraping/XML/OpenGL/funcs.bin index a59ea1d5..7a097003 100644 Binary files a/DataScraping/XML/OpenGL/funcs.bin and b/DataScraping/XML/OpenGL/funcs.bin differ diff --git a/DataScraping/XML/XMLItems.pas b/DataScraping/XML/XMLItems.pas index 06c280a6..e9c52ba2 100644 --- a/DataScraping/XML/XMLItems.pas +++ b/DataScraping/XML/XMLItems.pas @@ -1154,6 +1154,19 @@ RequiredList = record end; + Extension = class; + ExtensionDepOption = record + private core_dep: Feature; + private ext_deps: array of Extension; + + public constructor(core_dep: Feature; ext_deps: array of Extension); + begin + self.core_dep := core_dep; + self.ext_deps := ext_deps; + end; + + end; + Extension = sealed class(NamedItem) private ext_str: string; private add: RequiredList; @@ -1161,8 +1174,7 @@ RequiredList = record private revision: string; private provisional: boolean; - private core_dep: Feature; - private ext_deps: array of Extension; + private dep_options: array of ExtensionDepOption; private obsolete_by: (Feature, Extension); private promoted_to: (Feature, Extension); @@ -1177,8 +1189,7 @@ RequiredList = record name: ExtensionName; ext_str: string; add: RequiredList; revision: string; provisional: boolean; - core_dep: Feature; - ext_deps: array of Extension; + dep_options: array of ExtensionDepOption; obsolete_by: (Feature, Extension); promoted_to: (Feature, Extension) ); @@ -1188,8 +1199,7 @@ RequiredList = record self.add := add; self.revision := revision; self.provisional := provisional; - self.core_dep := core_dep; - self.ext_deps := ext_deps; + self.dep_options := dep_options; self.obsolete_by := obsolete_by; self.promoted_to := promoted_to; end; @@ -1204,8 +1214,12 @@ RequiredList = record bw.WriteNullable(self.revision, bw.Write); bw.Write(self.provisional); - bw.WriteBinIndexOrNil(self.core_dep); - bw.WriteBinIndexArr( Extension.DistillAllUnique(self.ext_deps) ); + bw.Write(self.dep_options.Length); + foreach var dep_opt in self.dep_options do + begin + bw.WriteBinIndexOrNil(dep_opt.core_dep); + bw.WriteBinIndexArr( Extension.DistillAllUnique(dep_opt.ext_deps) ); + end; bw.WriteAnyBinIndexOrNil(self.obsolete_by); bw.WriteAnyBinIndexOrNil(self.promoted_to); diff --git a/Modules.Packed/OpenCL.pas b/Modules.Packed/OpenCL.pas index beca2836..6dd406aa 100644 --- a/Modules.Packed/OpenCL.pas +++ b/Modules.Packed/OpenCL.pas @@ -14342,8 +14342,21 @@ cl_queue_family_properties = record end; + /// id: cl_khr_extended_versioning + /// version: 1.0.0 + /// promoted to: cl 3.0 + clExtendedVersioningKHR = static class + public const ExtensionString = 'cl_khr_extended_versioning'; + end; + /// id: cl_ext_cxx_for_opencl - /// version: 0.0.0 + /// version: 1.0.0 + /// dependency option 1 + /// - core dependency: cl 3.0 + /// dependency option 2 + /// - core dependency: cl 2.0 + /// - ext dependencies: + ///-- - cl_khr_extended_versioning (clExtendedVersioningKHR) clCxxForOpenclEXT = static class public const ExtensionString = 'cl_ext_cxx_for_opencl'; end; @@ -14353,7 +14366,7 @@ cl_queue_family_properties = record {$endif DEBUG} [PCUNotRestore] /// id: cl_ext_device_fission - /// version: 0.0.0 + /// version: 1.0.0 clDeviceFissionEXT = sealed partial class public constructor(pl: cl_platform_id); private constructor := raise new System.NotSupportedException; @@ -14427,30 +14440,21 @@ cl_queue_family_properties = record end; /// id: cl_ext_float_atomics - /// version: 0.0.0 + /// version: 1.0.0 + /// dependency option 1 + /// - core dependency: cl 2.0 + /// dependency option 2 + /// - core dependency: cl 3.0 clFloatAtomicsEXT = static class public const ExtensionString = 'cl_ext_float_atomics'; end; - /// id: cl_ext_image_from_buffer - /// version: 0.0.0 - /// core dependency: cl 3.0 - clImageFromBufferEXT = static class - public const ExtensionString = 'cl_ext_image_from_buffer'; - end; - - /// id: cl_ext_image_raw10_raw12 - /// version: 0.0.0 - clImageRaw10Raw12EXT = static class - public const ExtensionString = 'cl_ext_image_raw10_raw12'; - end; - {$ifndef DEBUG} [System.Security.SuppressUnmanagedCodeSecurity] {$endif DEBUG} [PCUNotRestore] /// id: cl_ext_image_requirements_info - /// version: 0.0.0 + /// version: 0.5.0 /// core dependency: cl 3.0 clImageRequirementsInfoEXT = sealed partial class public constructor(pl: cl_platform_id); @@ -14566,12 +14570,28 @@ cl_queue_family_properties = record end; + /// id: cl_ext_image_from_buffer + /// version: 1.0.0 + /// core dependency: cl 3.0 + /// ext dependencies: + /// - cl_ext_image_requirements_info (clImageRequirementsInfoEXT) + clImageFromBufferEXT = static class + public const ExtensionString = 'cl_ext_image_from_buffer'; + end; + + /// id: cl_ext_image_raw10_raw12 + /// version: 1.0.0 + /// core dependency: cl 1.2 + clImageRaw10Raw12EXT = static class + public const ExtensionString = 'cl_ext_image_raw10_raw12'; + end; + {$ifndef DEBUG} [System.Security.SuppressUnmanagedCodeSecurity] {$endif DEBUG} [PCUNotRestore] /// id: cl_ext_migrate_memobject - /// version: 0.0.0 + /// version: 1.0.0 clMigrateMemobjectEXT = sealed partial class public constructor(pl: cl_platform_id); private constructor := raise new System.NotSupportedException; @@ -18330,13 +18350,6 @@ cl_queue_family_properties = record public const ExtensionString = 'cl_khr_extended_bit_ops'; end; - /// id: cl_khr_extended_versioning - /// version: 1.0.0 - /// promoted to: cl 3.0 - clExtendedVersioningKHR = static class - public const ExtensionString = 'cl_khr_extended_versioning'; - end; - {$ifndef DEBUG} [System.Security.SuppressUnmanagedCodeSecurity] {$endif DEBUG} diff --git a/Packing/Descriptions/OpenCL.predoc b/Packing/Descriptions/OpenCL.predoc index 931e4deb..d379dbf4 100644 --- a/Packing/Descriptions/OpenCL.predoc +++ b/Packing/Descriptions/OpenCL.predoc @@ -14330,8 +14330,21 @@ type end; + /// id: cl_khr_extended_versioning + /// version: 1.0.0 + /// promoted to: cl 3.0 + clExtendedVersioningKHR = static class + public const ExtensionString = 'cl_khr_extended_versioning'; + end; + /// id: cl_ext_cxx_for_opencl - /// version: 0.0.0 + /// version: 1.0.0 + /// dependency option 1 + /// - core dependency: cl 3.0 + /// dependency option 2 + /// - core dependency: cl 2.0 + /// - ext dependencies: + ///-- - cl_khr_extended_versioning (clExtendedVersioningKHR) clCxxForOpenclEXT = static class public const ExtensionString = 'cl_ext_cxx_for_opencl'; end; @@ -14341,7 +14354,7 @@ type {$endif DEBUG} [PCUNotRestore] /// id: cl_ext_device_fission - /// version: 0.0.0 + /// version: 1.0.0 clDeviceFissionEXT = sealed partial class public constructor(pl: cl_platform_id); private constructor := raise new System.NotSupportedException; @@ -14415,30 +14428,21 @@ type end; /// id: cl_ext_float_atomics - /// version: 0.0.0 + /// version: 1.0.0 + /// dependency option 1 + /// - core dependency: cl 2.0 + /// dependency option 2 + /// - core dependency: cl 3.0 clFloatAtomicsEXT = static class public const ExtensionString = 'cl_ext_float_atomics'; end; - /// id: cl_ext_image_from_buffer - /// version: 0.0.0 - /// core dependency: cl 3.0 - clImageFromBufferEXT = static class - public const ExtensionString = 'cl_ext_image_from_buffer'; - end; - - /// id: cl_ext_image_raw10_raw12 - /// version: 0.0.0 - clImageRaw10Raw12EXT = static class - public const ExtensionString = 'cl_ext_image_raw10_raw12'; - end; - {$ifndef DEBUG} [System.Security.SuppressUnmanagedCodeSecurity] {$endif DEBUG} [PCUNotRestore] /// id: cl_ext_image_requirements_info - /// version: 0.0.0 + /// version: 0.5.0 /// core dependency: cl 3.0 clImageRequirementsInfoEXT = sealed partial class public constructor(pl: cl_platform_id); @@ -14554,12 +14558,28 @@ type end; + /// id: cl_ext_image_from_buffer + /// version: 1.0.0 + /// core dependency: cl 3.0 + /// ext dependencies: + /// - cl_ext_image_requirements_info (clImageRequirementsInfoEXT) + clImageFromBufferEXT = static class + public const ExtensionString = 'cl_ext_image_from_buffer'; + end; + + /// id: cl_ext_image_raw10_raw12 + /// version: 1.0.0 + /// core dependency: cl 1.2 + clImageRaw10Raw12EXT = static class + public const ExtensionString = 'cl_ext_image_raw10_raw12'; + end; + {$ifndef DEBUG} [System.Security.SuppressUnmanagedCodeSecurity] {$endif DEBUG} [PCUNotRestore] /// id: cl_ext_migrate_memobject - /// version: 0.0.0 + /// version: 1.0.0 clMigrateMemobjectEXT = sealed partial class public constructor(pl: cl_platform_id); private constructor := raise new System.NotSupportedException; @@ -18318,13 +18338,6 @@ type public const ExtensionString = 'cl_khr_extended_bit_ops'; end; - /// id: cl_khr_extended_versioning - /// version: 1.0.0 - /// promoted to: cl 3.0 - clExtendedVersioningKHR = static class - public const ExtensionString = 'cl_khr_extended_versioning'; - end; - {$ifndef DEBUG} [System.Security.SuppressUnmanagedCodeSecurity] {$endif DEBUG} diff --git a/Packing/Template/LowLvl/CodeContainerItems.pas b/Packing/Template/LowLvl/CodeContainerItems.pas index e38ff11c..4d724fec 100644 --- a/Packing/Template/LowLvl/CodeContainerItems.pas +++ b/Packing/Template/LowLvl/CodeContainerItems.pas @@ -2458,6 +2458,18 @@ impl_wr += class_type; {$region Extension} + ExtensionDepOption = record + private core_dep_ind: integer? + private ext_dep_inds: array of integer; + + public constructor(br: BinReader); + begin + self.core_dep_ind := br.ReadIndexOrNil; + self.ext_dep_inds := br.ReadInt32Arr; + end; + + end; + FeatureOrExtensionIndex = record public f_ind := default(integer?); public e_ind := default(integer?); @@ -2479,8 +2491,7 @@ FeatureOrExtensionIndex = record private revision: string; private provisional: boolean; - private core_dep_ind: integer? - private ext_dep_inds: array of integer; + private dep_options: array of ExtensionDepOption; private obsolete_by: FeatureOrExtensionIndex; private promoted_to: FeatureOrExtensionIndex; @@ -2497,8 +2508,7 @@ FeatureOrExtensionIndex = record Result.revision := br.ReadOrNil(br->br.ReadString); Result.provisional := br.ReadBoolean; - Result.core_dep_ind := br.ReadIndexOrNil; - Result.ext_dep_inds := br.ReadInt32Arr; + Result.dep_options := br.ReadArr(br->new ExtensionDepOption(br)); Result.obsolete_by := new FeatureOrExtensionIndex(br); Result.promoted_to := new FeatureOrExtensionIndex(br); @@ -2512,11 +2522,13 @@ FeatureOrExtensionIndex = record public property RevisionStr: string read revision; public property IsProvisional: boolean read provisional; - public function HasCoreDependency := core_dep_ind<>nil; - public function CoreDependency := Feature.ByIndex(core_dep_ind.Value); + public property DepOptionCount: integer read dep_options.Length; - public function HasExtDependencies := ext_dep_inds.Length<>0; - public function ExtDependencies := Extension.MakeLazySeq(ext_dep_inds).ToSeq; + public function HasCoreDependency(i: integer) := dep_options[i].core_dep_ind<>nil; + public function CoreDependency(i: integer) := Feature.ByIndex(dep_options[i].core_dep_ind.Value); + + public function HasExtDependencies(i: integer) := dep_options[i].ext_dep_inds.Length<>0; + public function ExtDependencies(i: integer) := Extension.MakeLazySeq(dep_options[i].ext_dep_inds).ToSeq; public property ObsoletedBy: FeatureOrExtensionIndex read obsolete_by; public property PromotedTo: FeatureOrExtensionIndex read promoted_to; @@ -2545,8 +2557,9 @@ FeatureOrExtensionIndex = record if not ApiManager.ShouldKeep(api) then exit; Extension.written_c += 1; - foreach var dep in ExtDependencies do - dep.Save; + for var dep_opt_i := 0 to DepOptionCount-1 do + foreach var dep in ExtDependencies(dep_opt_i) do + dep.Save; var any_funcs := add.Funcs.Any; @@ -2585,81 +2598,137 @@ FeatureOrExtensionIndex = record intr_wr += ' [PCUNotRestore]'#10; end; - intr_wr += ' /// id: '; - intr_wr += self.ExtensionString; - intr_wr += #10; - - if (self.RevisionStr<>nil) or (self.IsProvisional) then + {$region description} begin - intr_wr += ' /// version: '; - if self.RevisionStr<>nil then + var curr_tab := ''; + + var descr_block := (body: Action)-> + begin + var old_tab := curr_tab; + var own_tab := if curr_tab='' then ' -' else '--'+curr_tab; + curr_tab := own_tab; + + body(); + + if curr_tab <> own_tab then + raise new InvalidOperationException; + curr_tab := old_tab; + end; + //TODO #3197 + var descr_line := procedure(body: Action)-> + begin + var wr := intr_wr; + + wr += ' ///'; + wr += curr_tab; + wr += ' '; + + body(wr); + + wr += #10; + end; + + {$region id} + + descr_line(wr-> + begin + wr += 'id: '; + wr += self.ExtensionString; + end); + + {$endregion id} + + {$region version} + + if (self.RevisionStr<>nil) or (self.IsProvisional) then descr_line(wr-> begin - intr_wr += self.RevisionStr; + wr += 'version: '; + if self.RevisionStr<>nil then + begin + wr += self.RevisionStr; + if self.IsProvisional then + wr += ' (provisional)'; + end else if self.IsProvisional then - intr_wr += ' (provisional)'; - end else - if self.IsProvisional then - intr_wr += 'provisional'; - intr_wr += #10; - end; - - var write_feature := procedure(wr: Writer; f: Feature)-> - begin - wr += f.Name.SourceAPI; - wr += ' '; - wr += f.Name.Major; - wr += '.'; - wr += f.Name.Minor; - end; - if self.HasCoreDependency then - begin - intr_wr += ' /// core dependency: '; - write_feature(intr_wr, self.CoreDependency); - intr_wr += #10; - end; - - var write_ext := procedure(wr: Writer; e: Extension)-> - begin - wr += e.ExtensionString; - wr += ' ('; - wr += e.MakeWriteableName; - wr += ')'; - end; - if self.HasExtDependencies then - begin - intr_wr += ' /// ext dependencies:'#10; - foreach var e in self.ExtDependencies do + wr += 'provisional'; + end); + + {$endregion version} + + {$region feature/extension references} + + var write_feature := procedure(wr: Writer; f: Feature)-> begin - intr_wr += ' /// - '; - write_ext(intr_wr, e); - intr_wr += #10; + wr += f.Name.SourceAPI; + wr += ' '; + wr += f.Name.Major; + wr += '.'; + wr += f.Name.Minor; + end; + var write_ext := procedure(wr: Writer; e: Extension)-> + begin + wr += e.ExtensionString; + wr += ' ('; + wr += e.MakeWriteableName; + wr += ')'; end; - end; - - var write_foe := procedure(wr: Writer; foe: FeatureOrExtensionIndex; header: string)-> - begin - if foe.f_ind<>nil then + var write_dep_opt := procedure(opt_i: integer)-> begin - wr += ' /// '; - wr += header; - wr += ': '; - write_feature(wr, Feature.ByIndex(foe.f_ind.Value)); - wr += #10; + + if self.HasCoreDependency(opt_i) then descr_line(wr-> + begin + wr += 'core dependency: '; + write_feature(wr, self.CoreDependency(opt_i)); + end); + + if self.HasExtDependencies(opt_i) then + begin + descr_line(wr->(wr += 'ext dependencies:')); + descr_block(()-> + foreach var e in self.ExtDependencies(opt_i) do + descr_line(wr->write_ext(wr, e)) + ); + end; + end; - if foe.e_ind<>nil then + case self.DepOptionCount of + 0: ; + 1: write_dep_opt(0); + else + for var opt_i := 0 to self.DepOptionCount-1 do + begin + descr_line(wr->(wr += $'dependency option {opt_i+1}')); + descr_block(()->write_dep_opt(opt_i)); + end; + end; + + var write_foe := procedure(foe: FeatureOrExtensionIndex; header: string)-> begin - wr += ' /// '; - wr += header; - wr += ': '; - write_ext(wr, Extension.ByIndex(foe.e_ind.Value)); - wr += #10; + + if foe.f_ind<>nil then descr_line(wr-> + begin + wr += header; + wr += ': '; + write_feature(wr, Feature.ByIndex(foe.f_ind.Value)); + end); + + if foe.e_ind<>nil then descr_line(wr-> + begin + wr += header; + wr += ': '; + write_ext(wr, Extension.ByIndex(foe.e_ind.Value)); + end); + end; + write_foe(self.ObsoletedBy, 'obsoleted by'); + write_foe(self.PromotedTo, 'promoted to'); + + {$endregion feature/extension references} end; - write_foe(intr_wr, self.ObsoletedBy, 'obsoleted by'); - write_foe(intr_wr, self.PromotedTo, 'promoted to'); + {$endregion description} intr_wr += ' '; intr_wr += display_name; diff --git a/Packing/Template/LowLvl/OpenCL/Extension.Interface.template b/Packing/Template/LowLvl/OpenCL/Extension.Interface.template index f23b0bbc..fe674eca 100644 --- a/Packing/Template/LowLvl/OpenCL/Extension.Interface.template +++ b/Packing/Template/LowLvl/OpenCL/Extension.Interface.template @@ -686,8 +686,21 @@ end; + /// id: cl_khr_extended_versioning + /// version: 1.0.0 + /// promoted to: cl 3.0 + clExtendedVersioningKHR = static class + public const ExtensionString = 'cl_khr_extended_versioning'; + end; + /// id: cl_ext_cxx_for_opencl - /// version: 0.0.0 + /// version: 1.0.0 + /// dependency option 1 + /// - core dependency: cl 3.0 + /// dependency option 2 + /// - core dependency: cl 2.0 + /// - ext dependencies: + ///-- - cl_khr_extended_versioning (clExtendedVersioningKHR) clCxxForOpenclEXT = static class public const ExtensionString = 'cl_ext_cxx_for_opencl'; end; @@ -697,7 +710,7 @@ {$endif DEBUG} [PCUNotRestore] /// id: cl_ext_device_fission - /// version: 0.0.0 + /// version: 1.0.0 clDeviceFissionEXT = sealed partial class public constructor(pl: cl_platform_id); private constructor := raise new System.NotSupportedException; @@ -771,30 +784,21 @@ end; /// id: cl_ext_float_atomics - /// version: 0.0.0 + /// version: 1.0.0 + /// dependency option 1 + /// - core dependency: cl 2.0 + /// dependency option 2 + /// - core dependency: cl 3.0 clFloatAtomicsEXT = static class public const ExtensionString = 'cl_ext_float_atomics'; end; - /// id: cl_ext_image_from_buffer - /// version: 0.0.0 - /// core dependency: cl 3.0 - clImageFromBufferEXT = static class - public const ExtensionString = 'cl_ext_image_from_buffer'; - end; - - /// id: cl_ext_image_raw10_raw12 - /// version: 0.0.0 - clImageRaw10Raw12EXT = static class - public const ExtensionString = 'cl_ext_image_raw10_raw12'; - end; - {$ifndef DEBUG} [System.Security.SuppressUnmanagedCodeSecurity] {$endif DEBUG} [PCUNotRestore] /// id: cl_ext_image_requirements_info - /// version: 0.0.0 + /// version: 0.5.0 /// core dependency: cl 3.0 clImageRequirementsInfoEXT = sealed partial class public constructor(pl: cl_platform_id); @@ -910,12 +914,28 @@ end; + /// id: cl_ext_image_from_buffer + /// version: 1.0.0 + /// core dependency: cl 3.0 + /// ext dependencies: + /// - cl_ext_image_requirements_info (clImageRequirementsInfoEXT) + clImageFromBufferEXT = static class + public const ExtensionString = 'cl_ext_image_from_buffer'; + end; + + /// id: cl_ext_image_raw10_raw12 + /// version: 1.0.0 + /// core dependency: cl 1.2 + clImageRaw10Raw12EXT = static class + public const ExtensionString = 'cl_ext_image_raw10_raw12'; + end; + {$ifndef DEBUG} [System.Security.SuppressUnmanagedCodeSecurity] {$endif DEBUG} [PCUNotRestore] /// id: cl_ext_migrate_memobject - /// version: 0.0.0 + /// version: 1.0.0 clMigrateMemobjectEXT = sealed partial class public constructor(pl: cl_platform_id); private constructor := raise new System.NotSupportedException; @@ -4674,13 +4694,6 @@ public const ExtensionString = 'cl_khr_extended_bit_ops'; end; - /// id: cl_khr_extended_versioning - /// version: 1.0.0 - /// promoted to: cl 3.0 - clExtendedVersioningKHR = static class - public const ExtensionString = 'cl_khr_extended_versioning'; - end; - {$ifndef DEBUG} [System.Security.SuppressUnmanagedCodeSecurity] {$endif DEBUG}