Skip to content

Commit c363dcd

Browse files
committed
Modify upstream's object.pl script to output D code, apply diff
1 parent 8d6caf1 commit c363dcd

File tree

2 files changed

+1507
-93
lines changed

2 files changed

+1507
-93
lines changed

scripts/objects.pl

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
#! /usr/bin/env perl
2+
#
3+
# Script to generate module `deimos.openssl.object_mac`
4+
#
5+
# Upstream uses a script to generate `<openssl/object_mac.h>`.
6+
# Instead of porting the header, we can simply modify this script
7+
# to output D code. This script was first copied from openssl-3.0.3 tag,
8+
# then modified. If it needs updating, check git history for required changes.
9+
#
10+
# Since the object definitions are just values, versioning for old versions
11+
# is not required. Hence one can just update the definitions on a new release
12+
# using the following commands (assuming CWD is the root of this repository):
13+
# ````
14+
# export OSSL_COPYRIGHT_YEAR=2022 # Or later
15+
# perl -I $PTOR/util/perl/ scripts/objects.pl \
16+
# $PTOR/crypto/objects.txt $PTOR/crypto/obj_mac.num \
17+
# > source/deimos/openssl/obj_mac.d
18+
# ```
19+
# Where $PTOR is the 'path to OpenSSL repository'.
20+
#
221
# Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
322
#
423
# Licensed under the Apache License 2.0 (the "License"). You may not use
@@ -136,25 +155,25 @@
136155
}
137156

138157
print <<"EOF";
139-
/*
158+
/**
159+
* Bindings for `<openssl/obj_mac.h>`
160+
*
140161
* WARNING: do not edit!
141-
* Generated by crypto/objects/objects.pl
162+
* Generated by `scripts/objects.pl`, copied and modified from the upstream
163+
* script `crypto/objects/objects.pl`.
142164
*
143165
* Copyright 2000-$YEAR The OpenSSL Project Authors. All Rights Reserved.
144166
* Licensed under the Apache License 2.0 (the "License"). You may not use
145167
* this file except in compliance with the License. You can obtain a copy
146168
* in the file LICENSE in the source distribution or at
147169
* https://www.openssl.org/source/license.html
148170
*/
171+
module deimos.openssl.obj_mac;
149172
150-
#ifndef OPENSSL_OBJ_MAC_H
151-
# define OPENSSL_OBJ_MAC_H
152-
# pragma once
153-
154-
#define SN_undef "UNDEF"
155-
#define LN_undef "undefined"
156-
#define NID_undef 0
157-
#define OBJ_undef 0L
173+
enum SN_undef = "UNDEF";
174+
enum LN_undef = "undefined";
175+
enum NID_undef = 0;
176+
enum OBJ_undef = "0L";
158177
EOF
159178

160179
sub expand
@@ -170,17 +189,12 @@ sub expand
170189
{
171190
$Cname=$ordern{$_};
172191
print "\n";
173-
print expand("#define SN_$Cname\t\t\"$sn{$Cname}\"\n") if $sn{$Cname} ne "";
174-
print expand("#define LN_$Cname\t\t\"$ln{$Cname}\"\n") if $ln{$Cname} ne "";
175-
print expand("#define NID_$Cname\t\t$nid{$Cname}\n") if $nid{$Cname} ne "";
176-
print expand("#define OBJ_$Cname\t\t$obj{$Cname}\n") if $obj{$Cname} ne "";
192+
print expand("enum SN_$Cname = \"$sn{$Cname}\";\n") if $sn{$Cname} ne "";
193+
print expand("enum LN_$Cname = \"$ln{$Cname}\";\n") if $ln{$Cname} ne "";
194+
print expand("enum NID_$Cname = $nid{$Cname};\n") if $nid{$Cname} ne "";
195+
print expand("enum OBJ_$Cname = \"$obj{$Cname}\";\n") if $obj{$Cname} ne "";
177196
}
178197

179-
print <<EOF;
180-
181-
#endif /* OPENSSL_OBJ_MAC_H */
182-
EOF
183-
184198
sub process_oid
185199
{
186200
local($oid)=@_;

0 commit comments

Comments
 (0)