usr/src/java/adr/org/opensolaris/os/adr/adrgen/CGenerator.java
author Stephen Talley <stephen.talley@oracle.com>
Wed, 14 Mar 2012 10:45:15 -0400
changeset 809 8a6fba4105d7
parent 717 7f7fc966a88f
permissions -rw-r--r--
7150175 radadrgen should generate rad module man pages 7150179 radadrgen should validate against original rng schema 7150184 radadrgen's output doesn't conform to docbook schema 7150189 adr schema should support documentation markup for union arms 7150226 radadrgen transforms should be internationalized 7150292 radadrgen -c should take a directory name, like -j 7150294 radadrgen command line usage should be broken into multiple synopses 7150352 radadrgen -o text should be revisited 7106700 radadrgen man page lacks documentation, -N, -m options
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
     1
/*
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
     2
 * CDDL HEADER START
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
     3
 *
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
     5
 * Common Development and Distribution License (the "License").
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
     6
 * You may not use this file except in compliance with the License.
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
     7
 *
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    11
 * and limitations under the License.
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    12
 *
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    18
 *
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    19
 * CDDL HEADER END
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    20
 */
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    21
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    22
/*
809
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
    23
 * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    24
 */
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    25
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    26
package org.opensolaris.os.adr.adrgen;
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    27
809
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
    28
import java.io.*;
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
    29
import java.util.*;
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    30
import org.opensolaris.os.adr.*;
809
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
    31
import org.opensolaris.os.adr.CLI.Option;
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
    32
import org.opensolaris.os.adr.Type.*;
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    33
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    34
public class CGenerator {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    35
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    36
    private static final String DOMAIN = "C";
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    37
    private static final String NULLSTR = "NULL";
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    38
467
53ca54066b26 14979 type decorators for fun and profit
David Powell <David.Powell@sun.com>
parents: 461
diff changeset
    39
    private static void setTargetName(Type t, String name) {
53ca54066b26 14979 type decorators for fun and profit
David Powell <David.Powell@sun.com>
parents: 461
diff changeset
    40
	t.setAuxData(DOMAIN, name);
53ca54066b26 14979 type decorators for fun and profit
David Powell <David.Powell@sun.com>
parents: 461
diff changeset
    41
    }
53ca54066b26 14979 type decorators for fun and profit
David Powell <David.Powell@sun.com>
parents: 461
diff changeset
    42
53ca54066b26 14979 type decorators for fun and profit
David Powell <David.Powell@sun.com>
parents: 461
diff changeset
    43
    private static String getTargetName(Type t) {
53ca54066b26 14979 type decorators for fun and profit
David Powell <David.Powell@sun.com>
parents: 461
diff changeset
    44
	return (String)t.getAuxData(DOMAIN);
53ca54066b26 14979 type decorators for fun and profit
David Powell <David.Powell@sun.com>
parents: 461
diff changeset
    45
    }
53ca54066b26 14979 type decorators for fun and profit
David Powell <David.Powell@sun.com>
parents: 461
diff changeset
    46
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    47
    private static String toBoolean(boolean b) {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    48
	return b ? "B_TRUE" : "B_FALSE";
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    49
    }
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    50
564
f0779ed38052 17004 - separate read/write error semantics for properties.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 556
diff changeset
    51
    private static String toErrorPtr(Type error) {
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    52
	if (error == null)
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    53
	    return NULLSTR;
467
53ca54066b26 14979 type decorators for fun and profit
David Powell <David.Powell@sun.com>
parents: 461
diff changeset
    54
	return String.format("&t_%s", getTargetName(error));
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    55
    }
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    56
628
9c2bcc10515e Bug 17664 - ADRGEN-1: Interface comparison, versioning validation
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 575
diff changeset
    57
    static String toStabilityStr(Stability s) {
556
4db6c449f366 16806 INT-6: Add support for interface stability/commitment
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 540
diff changeset
    58
	switch (s) {
4db6c449f366 16806 INT-6: Add support for interface stability/commitment
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 540
diff changeset
    59
	    case PRIVATE:
4db6c449f366 16806 INT-6: Add support for interface stability/commitment
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 540
diff changeset
    60
		return "s_private";
4db6c449f366 16806 INT-6: Add support for interface stability/commitment
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 540
diff changeset
    61
	    case UNCOMMITTED:
4db6c449f366 16806 INT-6: Add support for interface stability/commitment
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 540
diff changeset
    62
		return "s_uncommitted";
4db6c449f366 16806 INT-6: Add support for interface stability/commitment
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 540
diff changeset
    63
	    case COMMITTED:
4db6c449f366 16806 INT-6: Add support for interface stability/commitment
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 540
diff changeset
    64
		return "s_committed";
4db6c449f366 16806 INT-6: Add support for interface stability/commitment
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 540
diff changeset
    65
	    default:
4db6c449f366 16806 INT-6: Add support for interface stability/commitment
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 540
diff changeset
    66
		throw new AssertionError("Invalid Stability: " + s);
4db6c449f366 16806 INT-6: Add support for interface stability/commitment
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 540
diff changeset
    67
	}
4db6c449f366 16806 INT-6: Add support for interface stability/commitment
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 540
diff changeset
    68
    }
4db6c449f366 16806 INT-6: Add support for interface stability/commitment
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 540
diff changeset
    69
628
9c2bcc10515e Bug 17664 - ADRGEN-1: Interface comparison, versioning validation
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 575
diff changeset
    70
    static void generateVersions(PrintStream impl, API api) {
9c2bcc10515e Bug 17664 - ADRGEN-1: Interface comparison, versioning validation
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 575
diff changeset
    71
	APIVersion v = api.getVersionByStability(Stability.PRIVATE);
9c2bcc10515e Bug 17664 - ADRGEN-1: Interface comparison, versioning validation
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 575
diff changeset
    72
	impl.format("    { { %s, %d, %d },", toStabilityStr(Stability.PRIVATE),
677
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 653
diff changeset
    73
	    v.getMajor(), v.getMinor());
628
9c2bcc10515e Bug 17664 - ADRGEN-1: Interface comparison, versioning validation
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 575
diff changeset
    74
	v = api.getVersionByStability(Stability.UNCOMMITTED);
9c2bcc10515e Bug 17664 - ADRGEN-1: Interface comparison, versioning validation
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 575
diff changeset
    75
	impl.format(" { %s, %d, %d },", toStabilityStr(Stability.UNCOMMITTED),
677
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 653
diff changeset
    76
	    v.getMajor(), v.getMinor());
628
9c2bcc10515e Bug 17664 - ADRGEN-1: Interface comparison, versioning validation
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 575
diff changeset
    77
	v = api.getVersionByStability(Stability.COMMITTED);
9c2bcc10515e Bug 17664 - ADRGEN-1: Interface comparison, versioning validation
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 575
diff changeset
    78
	impl.format(" { %s, %d, %d } },\n", toStabilityStr(Stability.COMMITTED),
677
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 653
diff changeset
    79
	    v.getMajor(), v.getMinor());
628
9c2bcc10515e Bug 17664 - ADRGEN-1: Interface comparison, versioning validation
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 575
diff changeset
    80
    }
9c2bcc10515e Bug 17664 - ADRGEN-1: Interface comparison, versioning validation
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 575
diff changeset
    81
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    82
    static void generateComplex(PrintStream header, PrintStream impl,
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    83
	Type.ComplexType t) {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    84
467
53ca54066b26 14979 type decorators for fun and profit
David Powell <David.Powell@sun.com>
parents: 461
diff changeset
    85
	String tn = getTargetName(t);
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    86
	String fn = "t_fields_" + tn;
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    87
461
c88c8113c01d 3840 sharemgr does not recognize new shares added via cli
David Powell <David.Powell@sun.com>
parents: 391
diff changeset
    88
	impl.format("static typefield_t %s[] = {\n", fn);
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    89
	List<Field> fields = t.getAllFields();
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    90
	for (Field f : fields)
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    91
	    impl.format("    { \"%s\", &t_%s, %s },\n", f.getName(),
467
53ca54066b26 14979 type decorators for fun and profit
David Powell <David.Powell@sun.com>
parents: 461
diff changeset
    92
		getTargetName(f.getType()), toBoolean(f.isOptional()));
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    93
	impl.format("};\n");
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    94
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    95
	header.format("extern type_t t_%s;\n", tn);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    96
	impl.format(
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    97
	    "type_t t_%s = { dt_struct, \"%s\", %d, { .t_fields = %s } };\n",
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    98
	    tn, t.getName() == null ? "(anon)" : t.getName(),
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    99
	    fields.size(), fn);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   100
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   101
	impl.println();
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   102
    }
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   103
709
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   104
    static void generateUnion(PrintStream header, PrintStream impl,
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   105
	Type.UnionType t) {
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   106
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   107
	String tn = getTargetName(t);
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   108
	String dn = getTargetName(t.getDiscType());
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   109
	String fn = "t_arms_" + tn;
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   110
	boolean bool = t.getDiscType() == Type.getType(StdType.BOOLEAN);
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   111
	Arm defaultarm = t.getDefault();
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   112
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   113
	impl.format("static unionarm_t %s[] = {\n", fn);
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   114
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   115
	if (defaultarm != null) {
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   116
		impl.format("    { NULL, &t_%s, %s },\n",
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   117
		    getTargetName(defaultarm.getType()),
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   118
		    toBoolean(defaultarm.isOptional()));
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   119
	} else {
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   120
		impl.format("    { NULL, NULL, B_FALSE },\n");
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   121
	}
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   122
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   123
	if (bool) {
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   124
	    for (Arm a : t.getArms())
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   125
		impl.format("    { &d_%s, &t_%s, %s },\n",
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   126
		    (Boolean)a.getDiscValue() ? "true" : "false",
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   127
		    getTargetName(a.getType()), toBoolean(a.isOptional()));
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   128
	} else {
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   129
	    for (Arm a : t.getArms())
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   130
		impl.format("    { &e_%s_%s, &t_%s, %s },\n",
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   131
		    dn, ((Type.EnumValue)a.getDiscValue()).getName(),
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   132
		    getTargetName(a.getType()), toBoolean(a.isOptional()));
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   133
	}
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   134
	impl.format("};\n");
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   135
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   136
	header.format("extern type_t t_%s;\n", tn);
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   137
	impl.format(
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   138
	    "type_t t_%s = { dt_union, \"%s\", %d, \n" +
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   139
	    "    { .t_union = { &t_%s, %s } }\n" +
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   140
	    "};\n", tn, t.getName(), t.getArms().size(), dn, fn);
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   141
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   142
	impl.println();
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   143
    }
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   144
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   145
    static void generateArray(PrintStream header, PrintStream impl,
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   146
	Type.ArrayType t) {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   147
467
53ca54066b26 14979 type decorators for fun and profit
David Powell <David.Powell@sun.com>
parents: 461
diff changeset
   148
	String tn = getTargetName(t);
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   149
	header.format("extern type_t t_%s;\n", tn);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   150
	impl.format(
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   151
	    "type_t t_%s = { dt_array, \"%s\", 0, { .t_array = &t_%s } };\n",
467
53ca54066b26 14979 type decorators for fun and profit
David Powell <David.Powell@sun.com>
parents: 461
diff changeset
   152
	    tn, "(array)", getTargetName(t.getType()));
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   153
	impl.println();
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   154
    }
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   155
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   156
    static void generateEnum(PrintStream header, PrintStream impl,
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   157
	Type.EnumType t) {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   158
467
53ca54066b26 14979 type decorators for fun and profit
David Powell <David.Powell@sun.com>
parents: 461
diff changeset
   159
	String tn = getTargetName(t);
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   160
	String fn = "t_values_" + tn;
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   161
461
c88c8113c01d 3840 sharemgr does not recognize new shares added via cli
David Powell <David.Powell@sun.com>
parents: 391
diff changeset
   162
	impl.format("static enumval_t %s[] = {\n", fn);
681
e3ebf98ba2fd 18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents: 677
diff changeset
   163
e3ebf98ba2fd 18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents: 677
diff changeset
   164
	Type.EnumValue fallback = t.getFallback();
e3ebf98ba2fd 18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents: 677
diff changeset
   165
	List<Type.EnumValue> vlist = t.getValues();
e3ebf98ba2fd 18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents: 677
diff changeset
   166
e3ebf98ba2fd 18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents: 677
diff changeset
   167
	if (fallback != null) {
e3ebf98ba2fd 18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents: 677
diff changeset
   168
	    vlist = new LinkedList<Type.EnumValue>(vlist);
e3ebf98ba2fd 18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents: 677
diff changeset
   169
	    vlist.add(0, fallback);
e3ebf98ba2fd 18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents: 677
diff changeset
   170
	} else {
e3ebf98ba2fd 18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents: 677
diff changeset
   171
	    impl.format("    { NULL, %d, NULL },\n", 0);
e3ebf98ba2fd 18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents: 677
diff changeset
   172
	}
e3ebf98ba2fd 18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents: 677
diff changeset
   173
e3ebf98ba2fd 18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents: 677
diff changeset
   174
	for (Type.EnumValue v : vlist)
488
431cb33a5a4c 15744 adrgen should generate constants for enumeration values
David Powell <david.e.powell@oracle.com>
parents: 467
diff changeset
   175
	    impl.format("    { \"%s\", %d, &e_%s_%s },\n",
556
4db6c449f366 16806 INT-6: Add support for interface stability/commitment
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 540
diff changeset
   176
		v.getName(), v.getValue(), tn, v.getName());
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   177
	impl.format("};\n");
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   178
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   179
	header.format("extern type_t t_%s;\n", tn);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   180
	impl.format(
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   181
	    "type_t t_%s = { dt_enum, \"%s\", %d, { .t_enum = %s } };\n",
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   182
	    tn, t.getName(), t.getValues().size(), fn);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   183
	impl.println();
488
431cb33a5a4c 15744 adrgen should generate constants for enumeration values
David Powell <david.e.powell@oracle.com>
parents: 467
diff changeset
   184
681
e3ebf98ba2fd 18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents: 677
diff changeset
   185
	int i = fallback == null ? 1 : 0;
e3ebf98ba2fd 18035 enumeration fallback values
David Powell <david.e.powell@oracle.com>
parents: 677
diff changeset
   186
	for (Type.EnumValue v : vlist) {
488
431cb33a5a4c 15744 adrgen should generate constants for enumeration values
David Powell <david.e.powell@oracle.com>
parents: 467
diff changeset
   187
	    String en = String.format("e_%s_%s", tn, v.getName());
431cb33a5a4c 15744 adrgen should generate constants for enumeration values
David Powell <david.e.powell@oracle.com>
parents: 467
diff changeset
   188
	    header.format("extern data_t %s;\n", en);
431cb33a5a4c 15744 adrgen should generate constants for enumeration values
David Powell <david.e.powell@oracle.com>
parents: 467
diff changeset
   189
	    impl.format(
556
4db6c449f366 16806 INT-6: Add support for interface stability/commitment
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 540
diff changeset
   190
		"data_t %s = { &t_%s, 0, 0, 0, 0, { .integer = %d } };\n",
488
431cb33a5a4c 15744 adrgen should generate constants for enumeration values
David Powell <david.e.powell@oracle.com>
parents: 467
diff changeset
   191
		en, tn, i++);
431cb33a5a4c 15744 adrgen should generate constants for enumeration values
David Powell <david.e.powell@oracle.com>
parents: 467
diff changeset
   192
	}
431cb33a5a4c 15744 adrgen should generate constants for enumeration values
David Powell <david.e.powell@oracle.com>
parents: 467
diff changeset
   193
	impl.println();
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   194
    }
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   195
809
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   196
    static void generate(ADRGen p, String outDir, boolean server, boolean stubs,
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   197
	boolean common) throws FileNotFoundException {
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   198
653
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   199
	Interface iface = p.iface_;
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   200
	String header_name = "api_" + p.basename_ + ".h";
809
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   201
	PrintStream o_header = new PrintStream(new File(outDir, header_name));
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   202
	PrintStream o_impl = new PrintStream(
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   203
	    new File(outDir, "api_" + p.basename_ + "_impl.c"));
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   204
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   205
	for (Type.BuiltinType t : Type.BUILTINS.values())
467
53ca54066b26 14979 type decorators for fun and profit
David Powell <David.Powell@sun.com>
parents: 461
diff changeset
   206
	    setTargetName(t, t.getType().toString().toLowerCase());
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   207
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   208
	for (Type.ArrayType t : Type.BUILTIN_ARRAYS.values())
467
53ca54066b26 14979 type decorators for fun and profit
David Powell <David.Powell@sun.com>
parents: 461
diff changeset
   209
	    setTargetName(t, "array_" + getTargetName(t.getType()));
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   210
653
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   211
	for (Type.ComplexType t : iface.getTypes())
467
53ca54066b26 14979 type decorators for fun and profit
David Powell <David.Powell@sun.com>
parents: 461
diff changeset
   212
	    setTargetName(t, "_" + t.getName());
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   213
709
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   214
	for (Type.UnionType t : iface.getUnions())
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   215
	    setTargetName(t, "_" + t.getName());
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   216
653
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   217
	for (Type.EnumType t : iface.getEnums())
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   218
	    setTargetName(t, "_" + t.getName());
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   219
653
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   220
	for (Type.ArrayType t : iface.getArrays())
467
53ca54066b26 14979 type decorators for fun and profit
David Powell <David.Powell@sun.com>
parents: 461
diff changeset
   221
	    setTargetName(t, "array_" + getTargetName(t.getType()));
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   222
516
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   223
	o_header.format("#include <rad/adr.h>\n\n");
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   224
	o_header.format("#include <rad/adr_object.h>\n\n");
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   225
	if (server)
540
2a0d274b1469 16571 move all content module interfaces into rad_modapi.h
David Powell <david.e.powell@oracle.com>
parents: 516
diff changeset
   226
	    o_header.format("#include <rad/rad_modapi.h>\n");
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   227
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   228
	o_impl.format("#include \"" + header_name + "\"\n\n");
717
7f7fc966a88f 18481 More rigorous module build
David Powell <david.e.powell@oracle.com>
parents: 709
diff changeset
   229
	o_impl.format("/* LINTLIBRARY */\n\n");
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   230
	o_impl.format("#define\tCOUNT(x)\t(sizeof (x) / sizeof (x[0]))\n\n");
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   231
653
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   232
	for (Type t : iface.getAll()) {
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   233
	    if (t instanceof Type.ComplexType) {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   234
		generateComplex(o_header, o_impl, (Type.ComplexType)t);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   235
	    } else if (t instanceof Type.ArrayType) {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   236
		generateArray(o_header, o_impl, (Type.ArrayType)t);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   237
	    } else if (t instanceof Type.EnumType) {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   238
		generateEnum(o_header, o_impl, (Type.EnumType)t);
709
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   239
	    } else if (t instanceof Type.UnionType) {
6d87dfa365c0 18333 discriminated unions
David Powell <david.e.powell@oracle.com>
parents: 699
diff changeset
   240
		generateUnion(o_header, o_impl, (Type.UnionType)t);
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   241
	    }
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   242
	}
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   243
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   244
	/* All server routines, used when generating stubs */
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   245
	List<String> invokers = new LinkedList<String>();
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   246
	List<String> readers = new LinkedList<String>();
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   247
	List<String> writers = new LinkedList<String>();
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   248
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   249
	/*
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   250
	 * API naming conventions
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   251
	 *
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   252
	 * Functions:
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   253
	 * api_name_read_aname
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   254
	 * api_name_write_aname
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   255
	 * api_name_invoke_mname
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   256
	 *
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   257
	 * Types:
575
e5ca78dfe938 17085 add component prefixes to adr's method/attribute
David Powell <david.e.powell@oracle.com>
parents: 573
diff changeset
   258
	 * adr_attribute_t api_name_attribute_aname
e5ca78dfe938 17085 add component prefixes to adr's method/attribute
David Powell <david.e.powell@oracle.com>
parents: 573
diff changeset
   259
	 * adr_attribute_t *api_name_attributes[]
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   260
	 *
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   261
	 * parameter_t api_name_params_mname[]
575
e5ca78dfe938 17085 add component prefixes to adr's method/attribute
David Powell <david.e.powell@oracle.com>
parents: 573
diff changeset
   262
	 * adr_method_t api_name_method_mname
e5ca78dfe938 17085 add component prefixes to adr's method/attribute
David Powell <david.e.powell@oracle.com>
parents: 573
diff changeset
   263
	 * adr_method_t *api_name_methods[]
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   264
	 *
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   265
	 * (Below isn't an array of pointers, no api_name_event_ename)
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   266
	 * eventtype_t api_name_events[]
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   267
	 *
653
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   268
	 * Parents:
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   269
	 * adr_object_t *api_name_parents[];
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   270
	 *
575
e5ca78dfe938 17085 add component prefixes to adr's method/attribute
David Powell <david.e.powell@oracle.com>
parents: 573
diff changeset
   271
	 * adr_object_t api_name
e5ca78dfe938 17085 add component prefixes to adr's method/attribute
David Powell <david.e.powell@oracle.com>
parents: 573
diff changeset
   272
	 * rad_object_t api_name_svr
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   273
	 */
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   274
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   275
	/* XXX: need to require api/feature names be "tame". */
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   276
	/* XXX: Should keep readers/writers/invokers sorted */
809
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   277
	for (API api : iface.getAPIs().values()) {
516
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   278
	    List<String> myinvokers = new LinkedList<String>();
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   279
	    List<String> myreaders = new LinkedList<String>();
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   280
	    List<String> mywriters = new LinkedList<String>();
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   281
	    /*
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   282
	     * First, define attributes
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   283
	     */
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   284
	    List<String> myprops = new LinkedList<String>();
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   285
	    for (Property prop : api.getAllProps().values()) {
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   286
		String writefunc = NULLSTR;
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   287
		String readfunc = writefunc;
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   288
		boolean mine = common ? prop.getAPI() == api : true;
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   289
		String apiname = mine ? api.getName() : prop.getAPI().getName();
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   290
516
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   291
		if (server && prop.isWritable()) {
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   292
		    writefunc = String.format("api_%s_write_%s",
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   293
			apiname, prop.getName());
516
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   294
		    mywriters.add(writefunc);
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   295
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   296
		    if (mine) {
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   297
			o_header.format("attr_write_f %s;\n", writefunc);
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   298
			writers.add(writefunc);
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   299
			writefunc = "&" + writefunc;
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   300
		    }
516
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   301
		} else {
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   302
		    mywriters.add(null);
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   303
		}
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   304
516
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   305
		if (server && prop.isReadable()) {
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   306
		    readfunc = String.format("api_%s_read_%s",
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   307
			apiname, prop.getName());
516
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   308
		    myreaders.add(readfunc);
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   309
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   310
		    if (mine) {
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   311
			o_header.format("attr_read_f %s;\n", readfunc);
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   312
			readers.add(readfunc);
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   313
			readfunc = "&" + readfunc;
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   314
		    }
516
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   315
		} else {
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   316
		    myreaders.add(null);
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   317
		}
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   318
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   319
		if (mine) {
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   320
		    o_impl.format(
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   321
			"static adr_attribute_t api_%s_attribute_%s = {\n",
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   322
			apiname, prop.getName());
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   323
		    o_impl.format("    \"%s\", %s, &t_%s, %s,\n" +
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   324
			"    %s, %s, %s, %s\n",
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   325
			prop.getName(),
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   326
			toStabilityStr(prop.getStability()),
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   327
			getTargetName(prop.getType()),
699
34ec90cc612c adrgen5 - documentation generator
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 681
diff changeset
   328
			toErrorPtr(prop.getReadErrorType()),
34ec90cc612c adrgen5 - documentation generator
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 681
diff changeset
   329
			toErrorPtr(prop.getWriteErrorType()),
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   330
			toBoolean(prop.isOptional()),
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   331
			toBoolean(prop.isReadable()),
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   332
			toBoolean(prop.isWritable()));
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   333
		    o_impl.format("};\n\n");
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   334
		}
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   335
		myprops.add(String.format("api_%s_attribute_%s",
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   336
		    apiname, prop.getName()));
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   337
	    }
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   338
516
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   339
	    if (server && mywriters.size() > 0) {
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   340
		o_impl.format("static attr_write_t api_%s_write[] = {\n",
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   341
		    api.getName());
516
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   342
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   343
		for (String writer : mywriters) {
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   344
		    if (writer == null)
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   345
			o_impl.format("    NULL,\n");
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   346
		    else
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   347
			o_impl.format("    &%s,\n", writer);
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   348
		}
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   349
		o_impl.format("};\n");
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   350
	    }
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   351
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   352
	    if (server && myreaders.size() > 0) {
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   353
		o_impl.format("static attr_read_t api_%s_read[] = {\n",
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   354
		    api.getName());
516
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   355
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   356
		for (String reader : myreaders) {
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   357
		    if (reader == null)
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   358
			o_impl.format("    NULL,\n");
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   359
		    else
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   360
			o_impl.format("    &%s,\n", reader);
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   361
		}
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   362
		o_impl.format("};\n");
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   363
	    }
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   364
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   365
	    String nattributes = "0";
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   366
	    String attributes = NULLSTR;
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   367
	    if (myprops.size() > 0) {
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   368
		attributes = String.format("api_%s_attributes", api.getName());
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   369
		nattributes = String.format("COUNT(%s)", attributes);
575
e5ca78dfe938 17085 add component prefixes to adr's method/attribute
David Powell <david.e.powell@oracle.com>
parents: 573
diff changeset
   370
		o_impl.format("static adr_attribute_t *%s[] = {\n", attributes);
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   371
		for (String prop : myprops)
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   372
		    o_impl.format("    &%s,\n", prop);
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   373
		o_impl.format("};\n\n");
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   374
	    }
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   375
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   376
	    /*
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   377
	     * Second define methods
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   378
	     */
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   379
	    List<String> mymethods = new LinkedList<String>();
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   380
	    for (Method method : api.getAllMethods().values()) {
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   381
		boolean mine = common ? method.getAPI() == api : true;
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   382
		String apiname = mine ? api.getName() :
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   383
		    method.getAPI().getName();
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   384
		String mfunc = String.format("api_%s_invoke_%s",
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   385
		    apiname, method.getName());
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   386
		myinvokers.add(mfunc);
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   387
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   388
		if (mine) {
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   389
		    if (server)
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   390
			o_header.format("meth_invoke_f %s;\n", mfunc);
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   391
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   392
		    String paramname = NULLSTR;
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   393
		    if (method.getArguments().size() > 0) {
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   394
			paramname = String.format("api_%s_params_%s",
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   395
			    apiname, method.getName());
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   396
			o_impl.format("static adr_parameter_t %s[] = {\n",
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   397
			    paramname);
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   398
			for (Argument arg : method.getArguments())
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   399
			    o_impl.format("    { \"%s\", &t_%s, %s },\n",
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   400
				arg.getName(), getTargetName(arg.getType()),
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   401
				toBoolean(arg.isOptional()));
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   402
			o_impl.format("};\n");
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   403
		    }
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   404
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   405
		    o_impl.format("static adr_method_t api_%s_method_%s = {\n",
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   406
			apiname, method.getName());
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   407
		    o_impl.format(
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   408
			"    \"%s\", %s, %d, &t_%s, %s,\n    %s, %s\n",
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   409
			method.getName(),
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   410
			toStabilityStr(method.getStability()),
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   411
			method.getArguments().size(),
699
34ec90cc612c adrgen5 - documentation generator
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 681
diff changeset
   412
			getTargetName(method.getResult().getType()),
34ec90cc612c adrgen5 - documentation generator
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 681
diff changeset
   413
			toErrorPtr(method.getErrorType()),
34ec90cc612c adrgen5 - documentation generator
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 681
diff changeset
   414
			toBoolean(method.getResult().isOptional()), paramname);
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   415
		    o_impl.format("};\n\n");
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   416
		    invokers.add(mfunc);
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   417
		}
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   418
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   419
		mymethods.add(String.format("api_%s_method_%s",
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   420
		    apiname, method.getName()));
516
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   421
	    }
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   422
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   423
	    if (server && myinvokers.size() > 0) {
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   424
		o_impl.format("static meth_invoke_t api_%s_invoke[] = {\n",
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   425
		    api.getName());
516
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   426
		for (String invoker : myinvokers)
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   427
		    o_impl.format("    &%s,\n", invoker);
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   428
		o_impl.format("};\n");
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   429
	    }
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   430
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   431
	    String nmethods = "0";
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   432
	    String methods = NULLSTR;
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   433
	    if (mymethods.size() > 0) {
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   434
		methods = String.format("api_%s_methods", api.getName());
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   435
		nmethods = String.format("COUNT(%s)", methods);
575
e5ca78dfe938 17085 add component prefixes to adr's method/attribute
David Powell <david.e.powell@oracle.com>
parents: 573
diff changeset
   436
		o_impl.format("static adr_method_t *%s[] = {\n", methods);
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   437
		for (String method : mymethods)
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   438
		    o_impl.format("    &%s,\n", method);
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   439
		o_impl.format("};\n\n");
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   440
	    }
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   441
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   442
	    /*
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   443
	     * Third define events
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   444
	     */
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   445
	    String nevents = "0";
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   446
	    String events = NULLSTR;
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   447
	    if (api.getAllEvents().size() > 0) {
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   448
		events = String.format("api_%s_events", api.getName());
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   449
		nevents = String.format("COUNT(%s)", events);
516
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   450
		o_impl.format("static adr_event_t %s[] = {\n", events);
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   451
		for (Event event : api.getAllEvents().values())
556
4db6c449f366 16806 INT-6: Add support for interface stability/commitment
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 540
diff changeset
   452
		    o_impl.format("    { \"%s\", %s, &t_%s },\n",
4db6c449f366 16806 INT-6: Add support for interface stability/commitment
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 540
diff changeset
   453
			event.getName(),
628
9c2bcc10515e Bug 17664 - ADRGEN-1: Interface comparison, versioning validation
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 575
diff changeset
   454
			toStabilityStr(event.getStability()),
556
4db6c449f366 16806 INT-6: Add support for interface stability/commitment
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 540
diff changeset
   455
			getTargetName(event.getType()));
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   456
		o_impl.format("};\n\n");
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   457
	    }
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   458
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   459
	    /*
653
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   460
	     * Fourth define parents
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   461
	     */
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   462
	    String nparents = "0";
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   463
	    String parents = NULLSTR;
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   464
	    if (api.getParents().size() > 0) {
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   465
		parents = String.format("api_%s_parents", api.getName());
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   466
		nparents = String.format("COUNT(%s)", parents);
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   467
		o_impl.format("static adr_object_t *%s[] = {\n", parents);
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   468
		for (API papi : api.getParents())
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   469
		    o_impl.format("    &api_%s,\n", papi.getName());
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   470
		o_impl.format("};\n\n");
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   471
	    }
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   472
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   473
	    /*
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   474
	     * Last, define api
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   475
	     */
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   476
	    o_header.format("extern adr_object_t api_%s;\n", api.getName());
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   477
	    o_impl.format("adr_object_t api_%s = {\n", api.getName());
653
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   478
	    o_impl.format("    \"%s\",\n", iface.getName());
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   479
	    o_impl.format("    \"%s\",\n", api.getName());
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   480
	    generateVersions(o_impl, api);
653
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   481
	    o_impl.format("    %s,\n", nattributes);
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   482
	    o_impl.format("    %s,\n", nmethods);
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   483
	    o_impl.format("    %s,\n", nevents);
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   484
	    o_impl.format("    %s,\n", nparents);
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   485
	    o_impl.format("    %s,\n", attributes);
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   486
	    o_impl.format("    %s,\n", methods);
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   487
	    o_impl.format("    %s,\n", events);
24acc3da862b 17874 Augment rad protocol to communicate inherited API versions
David Powell <david.e.powell@oracle.com>
parents: 652
diff changeset
   488
	    o_impl.format("    %s\n", parents);
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   489
	    o_impl.format("};\n\n");
516
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   490
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   491
	    if (server) {
575
e5ca78dfe938 17085 add component prefixes to adr's method/attribute
David Powell <david.e.powell@oracle.com>
parents: 573
diff changeset
   492
		o_header.format("extern rad_object_t api_%s_svr;\n",
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   493
		    api.getName());
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   494
		o_impl.format("rad_object_t api_%s_svr = {\n", api.getName());
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   495
		o_impl.format("    &api_%s,\n", api.getName());
573
f0add9469f92 17058 support removing objects
David Powell <david.e.powell@oracle.com>
parents: 564
diff changeset
   496
		if (myinvokers.size() > 0)
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   497
		    o_impl.format("    api_%s_invoke,\n", api.getName());
516
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   498
		else
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   499
		    o_impl.format("    NULL,\n");
573
f0add9469f92 17058 support removing objects
David Powell <david.e.powell@oracle.com>
parents: 564
diff changeset
   500
		if (mywriters.size() > 0)
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   501
		    o_impl.format("    api_%s_write,\n", api.getName());
516
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   502
		else
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   503
		    o_impl.format("    NULL,\n");
573
f0add9469f92 17058 support removing objects
David Powell <david.e.powell@oracle.com>
parents: 564
diff changeset
   504
		if (myreaders.size() > 0)
650
265ab927a268 17810 need way to deregister stale dynamic objects
David Powell <david.e.powell@oracle.com>
parents: 628
diff changeset
   505
		    o_impl.format("    api_%s_read\n", api.getName());
516
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   506
		else
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   507
		    o_impl.format("    NULL\n");
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   508
		o_impl.format("};\n\n");
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   509
	    }
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   510
	}
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   511
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   512
	if (!stubs)
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   513
	    return;
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   514
809
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   515
	PrintStream o_stubs = new PrintStream(
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   516
	    new File(outDir, "api_" + p.basename_ + "_stubs.c"));
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   517
	o_stubs.format("#include <stdio.h>\n");
516
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   518
	o_stubs.format("#include <rad/adr.h>\n\n");
96029ce1545c 16312 generate, use numerical handles for server objects
David Powell <david.e.powell@oracle.com>
parents: 488
diff changeset
   519
	o_stubs.format("#include <rad/adr_object.h>\n\n");
540
2a0d274b1469 16571 move all content module interfaces into rad_modapi.h
David Powell <david.e.powell@oracle.com>
parents: 516
diff changeset
   520
	o_stubs.format("#include <rad/rad_modapi.h>\n");
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   521
	o_stubs.format("#include \"api_%s.h\"\n\n", p.basename_);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   522
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   523
	for (String reader : readers) {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   524
	    o_stubs.format("conerr_t\n");
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   525
	    o_stubs.format(
575
e5ca78dfe938 17085 add component prefixes to adr's method/attribute
David Powell <david.e.powell@oracle.com>
parents: 573
diff changeset
   526
		"%s(rad_instance_t *inst, adr_attribute_t *attr,\n", reader);
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   527
	    o_stubs.format("    data_t **data, data_t **error)\n");
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   528
	    o_stubs.format("{\n");
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   529
	    o_stubs.format(
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   530
		"\t(void) fprintf(stderr, \"NOT IMPLEMENTED: %s\\n\");\n",
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   531
		reader);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   532
	    o_stubs.format("\treturn (ce_system);\n");
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   533
	    o_stubs.format("}\n\n");
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   534
	}
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   535
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   536
	for (String writer : writers) {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   537
	    o_stubs.format("conerr_t\n");
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   538
	    o_stubs.format(
575
e5ca78dfe938 17085 add component prefixes to adr's method/attribute
David Powell <david.e.powell@oracle.com>
parents: 573
diff changeset
   539
		"%s(rad_instance_t *inst, adr_attribute_t *attr,\n", writer);
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   540
	    o_stubs.format("    data_t *data, data_t **error)\n");
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   541
	    o_stubs.format("{\n");
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   542
	    o_stubs.format(
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   543
		"\t(void) fprintf(stderr, \"NOT IMPLEMENTED: %s\\n\");\n",
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   544
		writer);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   545
	    o_stubs.format("\treturn (ce_system);\n");
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   546
	    o_stubs.format("}\n\n");
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   547
	}
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   548
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   549
	for (String invoker : invokers) {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   550
	    o_stubs.format("conerr_t\n");
575
e5ca78dfe938 17085 add component prefixes to adr's method/attribute
David Powell <david.e.powell@oracle.com>
parents: 573
diff changeset
   551
	    o_stubs.format("%s(rad_instance_t *inst, adr_method_t *meth,\n",
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   552
		invoker);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   553
	    o_stubs.format(
699
34ec90cc612c adrgen5 - documentation generator
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 681
diff changeset
   554
		"    data_t **ret, data_t **args, int count, " +
34ec90cc612c adrgen5 - documentation generator
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 681
diff changeset
   555
		"data_t **error)\n");
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   556
	    o_stubs.format("{\n");
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   557
	    o_stubs.format(
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   558
		"\t(void) fprintf(stderr, \"NOT IMPLEMENTED: %s\\n\");\n",
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   559
		invoker);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   560
	    o_stubs.format("\treturn (ce_system);\n");
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   561
	    o_stubs.format("}\n\n");
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   562
	}
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   563
    }
809
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   564
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   565
    /**
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   566
     * Performs intrinsic validation of the given spec file, then generates C
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   567
     * definitions.  Note: this method does NOT validate against a schema.
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   568
     *
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   569
     * Usage: java ... -d <dir> [-N] [-r [-m] [-s]] <spec.xml>
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   570
     */
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   571
    public static void main(String[] args) {
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   572
	CLI cli = new CLI(CGenerator.class);
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   573
	Map<Character, CLI.Option> opts = new HashMap<Character, CLI.Option>();
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   574
	int operands = cli.getOptions(args, "d:Nrms", opts);
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   575
	if (operands == args.length) {
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   576
	    cli.die(2, "spec file not specified");
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   577
	}
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   578
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   579
	File file = new File(args[operands]);
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   580
	CLI.Option d = opts.get('d');
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   581
	if (d == null) {
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   582
	    cli.die(2, "directory not specified");
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   583
	}
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   584
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   585
	String outDir = d.getArg();
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   586
	boolean check_nullable = opts.get('N') == null;
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   587
	boolean generate_server = opts.get('r') != null;
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   588
	boolean generate_common = opts.get('m') != null;
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   589
	boolean generate_cstubs = opts.get('s') != null;
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   590
	try {
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   591
	    ADRGen adr = new ADRGen(file, check_nullable);
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   592
	    CGenerator.generate(adr, outDir, generate_server, generate_cstubs,
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   593
		generate_common);
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   594
	} catch (ParseException e) {
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   595
	    cli.die(1, "error parsing file %s: %s", file,
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   596
		e.getLocalizedMessage());
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   597
	} catch (FileNotFoundException e) {
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   598
	    cli.die(1, "error parsing file %s: %s", file,
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   599
		e.getLocalizedMessage());
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   600
	}
8a6fba4105d7 7150175 radadrgen should generate rad module man pages
Stephen Talley <stephen.talley@oracle.com>
parents: 717
diff changeset
   601
    }
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   602
}