Compare commits
41
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
698b9e0371 | ||
|
|
a33cba8cef | ||
|
|
8808a38a2e | ||
|
|
76adc60ac3 | ||
|
|
3275d36d80 | ||
|
|
17cec63877 | ||
|
|
5f39d9a466 | ||
|
|
363a82e6a8 | ||
|
|
598e91a092 | ||
|
|
e313f9b3a0 | ||
|
|
ee13526af5 | ||
|
|
58e340b36c | ||
|
|
f5787c6225 | ||
|
|
4dc0e38c99 | ||
|
|
1131c3042f | ||
|
|
71c90857ed | ||
|
|
7e5c20ea92 | ||
|
|
891589683f | ||
|
|
94b2dde59c | ||
|
|
b8275218a8 | ||
|
|
b4458bbe79 | ||
|
|
2dcfaedae2 | ||
|
|
ae8d48481a | ||
|
|
f049631f70 | ||
|
|
217dd34edf | ||
|
|
bda4c94ed7 | ||
|
|
b2dd22cc84 | ||
|
|
004235d0c2 | ||
|
|
803323549e | ||
|
|
754ae304fa | ||
|
|
78916d9b4d | ||
|
|
bad745c9b9 | ||
|
|
da91e9735c | ||
|
|
758a45089e | ||
|
|
3df1d1ccce | ||
|
|
f125079519 | ||
|
|
7be54f3fec | ||
|
|
b72eea6fac | ||
|
|
9ca98fc4ce | ||
|
|
c56ed86391 | ||
|
|
2b46efb15f |
+1
-1
@@ -339,7 +339,7 @@ if(NOT SCL_IS_SUBBUILD)
|
||||
# $make package #
|
||||
###############################################################################
|
||||
|
||||
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "STEP Class Library")
|
||||
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "STEPcode")
|
||||
SET(CPACK_SET_DESTDIR "ON")
|
||||
|
||||
SET(CPACK_PACKAGE_VERSION_MAJOR ${SCL_VERSION_MAJOR})
|
||||
|
||||
@@ -2,7 +2,7 @@ Modifications to the original NIST code are (C)opyright by their
|
||||
respective authors. Unless otherwise specified, they are copyright
|
||||
on the date those changes were committed to whichever repository
|
||||
they were committed to first (i.e. BRL-CAD on SourceForge.net,
|
||||
mpictor/StepClassLibrary on github, etc).
|
||||
mpictor/StepClassLibrary or stepcode/stepcode on github).
|
||||
|
||||
Modifications which were first commited to the repository on github
|
||||
are licensed under the 3-clause BSD license below. Changes committed
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
Recent changes are recorded in the publicly available repository:
|
||||
https://github.com/mpictor/StepClassLibrary
|
||||
http://github.com/stepcode/stepcode
|
||||
|
||||
This repo was moved and renamed in May 2012. Previously, it was at
|
||||
http://github.com/mpictor/StepClassLibrary
|
||||
|
||||
Some are duplicates of changes recorded in the BRL-CAD repo:
|
||||
http://brlcad.svn.sourceforge.net/viewvc/brlcad/brlcad/trunk/src/other/step/?view=log
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
INSTALL
|
||||
|
||||
This file is contains installation instructions for the
|
||||
STEP Class Library.
|
||||
This file is contains installation instructions for STEPcode.
|
||||
|
||||
These installation requires that you have the following software
|
||||
available:
|
||||
|
||||
@@ -1,4 +1,18 @@
|
||||
STEP Class Library ------ http://github.com/mpictor/StepClassLibrary
|
||||
STEPcode ------ http://github.com/stepcode/stepcode
|
||||
************************************************************************
|
||||
Release 0.6 (May, 2012)
|
||||
|
||||
New since v0.5:
|
||||
* Renamed from STEP Class Library to STEPcode, moved to github.com/stepcode/stepcode
|
||||
* Advances in [Python](http://github.com/stepcode/stepcode/wiki/python-generator) support (#185)
|
||||
* ABI versioning
|
||||
* Implement memory manager with reporting of memory that isn't freed,
|
||||
fix many memory leaks (#148, #160, #162, #168)
|
||||
* MSVC fixes (> 128 nested if...else - #152), etc
|
||||
* Add AP219, AP238, PDM schema, AP203a1, syntax highlighting files
|
||||
* Improvements to CMake files, mostly from Cliff @ BRL-CAD (#143, #163, #181)
|
||||
* Allow runtime bounds for aggregates (discovered with AP209e2) (#166)
|
||||
* fedex_plus fprintf's can be traced with -DSCL_TRACE_FPRINTF=ON (#176)
|
||||
************************************************************************
|
||||
Release 0.5 (Feb 23, 2012)
|
||||
|
||||
@@ -28,7 +42,7 @@ New since v0.3:
|
||||
* Enums and entities are allowed to have the same names
|
||||
(affected ap242,210e3,209)
|
||||
* Remove the SCLP23 macro
|
||||
http://github.com/mpictor/StepClassLibrary/wiki/changelog-v0.4
|
||||
http://github.com/stepcode/stepcode/wiki/changelog-v0.4
|
||||
************************************************************************
|
||||
|
||||
Release 0.3 (Oct 29, 2011)
|
||||
@@ -58,10 +72,10 @@ What's new since v0.1?
|
||||
* Add BNF files, schemas, and CAX-IF Part 21 files
|
||||
|
||||
For a detailed list of changes, see
|
||||
https://github.com/mpictor/StepClassLibrary/wiki/changelog-v0.2
|
||||
https://github.com/stepcode/stepcode/wiki/changelog-v0.2
|
||||
|
||||
For a list of closed issues, see
|
||||
https://github.com/mpictor/StepClassLibrary/issues?state=closed&milestone=2
|
||||
https://github.com/stepcode/stepcode/issues?state=closed&milestone=2
|
||||
|
||||
************************************************************************
|
||||
|
||||
@@ -84,10 +98,10 @@ What's new since the SCL 3.2 release in 1998?
|
||||
parser debug output to a specified range of lines in the schema.
|
||||
|
||||
For a detailed list of changes, see
|
||||
https://github.com/mpictor/StepClassLibrary/wiki/changelog-v0.1
|
||||
https://github.com/stepcode/stepcode/wiki/changelog-v0.1
|
||||
|
||||
For a list of closed issues, see
|
||||
https://github.com/mpictor/StepClassLibrary/issues?state=closed&milestone=1
|
||||
https://github.com/stepcode/stepcode/issues?state=closed&milestone=1
|
||||
|
||||
Pre-BRL-CAD changes:
|
||||
* Patches from http://www.statik.tu-cottbus.de/fileadmin/project_dth/scl/
|
||||
|
||||
@@ -1,32 +1,34 @@
|
||||
***********************************************************************
|
||||
Step Class Library v0.5 -- http://github.com/mpictor/StepClassLibrary
|
||||
STEPcode v0.6 -- http://github.com/stepcode/stepcode
|
||||
|
||||
* What is SCL? SCL reads ISO10303-11 EXPRESS schemas and generates
|
||||
* What is STEPcode? SC reads ISO10303-11 EXPRESS schemas and generates
|
||||
C++ source code that can read and write Part 21 files conforming
|
||||
to that schema. In addition to C++, v0.5 includes experimental
|
||||
to that schema. In addition to C++, SC includes experimental
|
||||
support for Python.
|
||||
|
||||
* SCL is packaged along with some other tools. See
|
||||
"THE NIST STEP TOOLSET", below. In particular, Data Probe
|
||||
requires InterViews, an obsolete UI toolkit. I (mpictor) have not
|
||||
had luck building the data probe with it. It may be more productive
|
||||
to replace InterViews with a modern toolkit such as Qt. I
|
||||
expect that this would be non-trivial.
|
||||
|
||||
* Much of the work to update SCL has been done by the developers of
|
||||
BRL-CAD, and SCL was originally created at NIST in the 90's.
|
||||
* Renamed in April/May 2012: SC was formerly known as STEP Class
|
||||
Libraries, SCL for short. It was renamed because the name wasn't
|
||||
accurate: the class libraries make up only a part of the code.
|
||||
|
||||
* Much of the work to update SC has been done by the developers of
|
||||
BRL-CAD, and SC (then STEP Class Library) was originally created at
|
||||
NIST in the 90's.
|
||||
|
||||
* For information on changes version-by-version, see the NEWS file
|
||||
|
||||
* Build system uses only CMake now: configure, Makefile, and all
|
||||
autotools files have been removed, as has mkProbe.
|
||||
|
||||
* Building and testing SCL - see the INSTALL file
|
||||
|
||||
* For more details on the libraries and executables, see the wiki:
|
||||
http://github.com/stepcode/stepcode/wiki/About-STEPcode
|
||||
|
||||
* For license details, see the COPYING file. Summary: 3-clause BSD.
|
||||
|
||||
***********************************************************************
|
||||
|
||||
***********************************************************************
|
||||
CODING STANDARDS
|
||||
|
||||
SCL's source has been reformatted with astyle. When making changes, try
|
||||
SC's source has been reformatted with astyle. When making changes, try
|
||||
to match the current formatting. The main points are:
|
||||
|
||||
- compact (java-style) brackets:
|
||||
@@ -52,542 +54,4 @@ Download astyle from http://sourceforge.net/projects/astyle/files/astyle/
|
||||
|
||||
***********************************************************************
|
||||
|
||||
|
||||
***********************************************************************
|
||||
Notes/TODO items specific to the STEP libraries as included in BRL-CAD:
|
||||
|
||||
* Original build system has been replaced with Makefile.am and
|
||||
configure.ac files in the style of BRL-CAD's autotools build
|
||||
system.
|
||||
|
||||
* Changes have been made to src/express to get it compiling with
|
||||
the output of different versions of lex/flex/bison. These
|
||||
changes are not yet tested in terms of impact on functionality
|
||||
and should be a starting point for any debugging of EXPRESS
|
||||
parsing issues.
|
||||
|
||||
* Of the original test code, only p21read has been incorporated into
|
||||
the new build system, but they are still present in src/test
|
||||
|
||||
* Express and exppp header files have been relocated to subdirectories
|
||||
in include. The names of the library files being built have been
|
||||
altered, and clstepcore and cleditor now build as separate libraries.
|
||||
|
||||
* Numerous minor changes have been made, mostly including stdlib
|
||||
and other required files.
|
||||
|
||||
***********************************************************************
|
||||
|
||||
|
||||
=====================================================
|
||||
Much has changed since README.scl was written.
|
||||
However, it is reproduced in its entirety below.
|
||||
=====================================================
|
||||
|
||||
README.scl (top level README) February 1998
|
||||
|
||||
THE NIST STEP TOOLSET
|
||||
=====================
|
||||
|
||||
Included in this release of the NIST STEP Toolset are
|
||||
|
||||
STEP Class Library (SCL)
|
||||
fedex_plus
|
||||
fedex_idl
|
||||
fedex_os
|
||||
Data Probe application
|
||||
Part 21 Reader application
|
||||
mkProbe script
|
||||
NIST EXPRESS Toolkit
|
||||
NIST EXPRESS Pretty Printing Toolkit
|
||||
|
||||
The focus of our work since our last release has been on developing a
|
||||
reference implementation of the binding of EXPRESS to C++ and IDL as
|
||||
specified by STEP's Parts 23 and 26 respectively. To this we have
|
||||
added a persistence capability (based on the ObjectStore OODB from
|
||||
Object Design, Inc) and a distribution capability (based on Orbix by
|
||||
Iona Technologies, Ltd). We also experimented with the Open OODB from
|
||||
Texas Instruments and with DSOM from IBM.
|
||||
|
||||
The STEP Class Library (SCL) and fedex_plus are used to build
|
||||
STEP-related applications in C++. They support STEP Parts 21 (the
|
||||
exchange file format), 22 (the functional specification of STEP's
|
||||
Standard Data Access Interface, SDAI), 23 (the C++ binding to SDAI),
|
||||
and 26 (the IDL interface to SDAI). fedex_plus is an application of
|
||||
the NIST EXPRESS Toolkit (based on STEP Part 11) which generates a C++
|
||||
class library representation of an EXPRESS schema based on STEP's Part
|
||||
23. The generated classes work with the STEP Class Library. The NIST
|
||||
EXPRESS Pretty Printing Toolkit is used to format and output EXPRESS.
|
||||
fedex_os is used to generate software (in addition to fedex_plus)
|
||||
needed to use SCL with the ObjectStore OODB. fedex_idl translates
|
||||
EXPRESS to the Interface Definition Language (according to Part 26)
|
||||
for use with Orbix.
|
||||
|
||||
The Data Probe software and mkProbe script are used to generate
|
||||
schema-specific class libraries (a.k.a. "Schema Class Library"), Data
|
||||
Probe editors, and Part 21 file readers. mkProbe generates a C++
|
||||
library representing a schema (using fedex_plus) and links the schema
|
||||
library with other libraries of the SCL and Data Probe to create a
|
||||
schema specific editor, known as a Data Probe. The Data Probe is a
|
||||
graphical editor for STEP data; it is used to browse and edit data
|
||||
instances of the objects in an EXPRESS model. It may also be used to
|
||||
visually browse the objects contained in the EXPRESS schema itself.
|
||||
Data Probes are X Windows-based and use the InterViews Toolkit from
|
||||
Stanford University.
|
||||
|
||||
The Data Probe source code was designed with reusability in mind. The
|
||||
runtime-code uses three class libraries: the STEP Class Library
|
||||
(developed at NIST), the InterViews Toolkit (user interface
|
||||
developer's toolkit from Stanford), and a standard C++ Class Library.
|
||||
The NIST STEP Class Library is divided into component libraries
|
||||
including STEP Core, Editor, Utilities, Data Access Interface,
|
||||
Interviews extensions, and Probe. The STEP Core, Editor, and Utils
|
||||
libraries can be used without the user interface libraries (Interviews
|
||||
extensions and Probe) for applications needing to represent the
|
||||
EXPRESS data structures. At this point the Data Access Interface is a
|
||||
partial implementation of SDAI's Session schema.
|
||||
|
||||
Dependencies between these modules have been minimized so that an
|
||||
executable program, the Data Probe, can be easily reconfigured to
|
||||
support different conceptual schemas.
|
||||
|
||||
We have experimented with replacing the Interviews-based interface
|
||||
with a tcl interface with good success; however, it is not in our work
|
||||
plan to complete. If anyone is interested in extending the toolkit
|
||||
with a more modern interface, we would be glad to discuss it with you.
|
||||
|
||||
The Part 21 Reader was originally developed to test whether a Schema
|
||||
Class built and linked without problems. It is also useful for
|
||||
checking Part 21 files. It displays the error messages from the STEP
|
||||
Class Library as a file is read.
|
||||
|
||||
|
||||
SYSTEM REQUIREMENTS
|
||||
===================
|
||||
|
||||
Depending on how you want to use the toolkit, additional pieces of
|
||||
software will need to be available on your local system:
|
||||
|
||||
- UNIX SunOS 4.1.x or Solaris 5.x operating system.
|
||||
At NIST, the SCL including the Data Probe has been built on
|
||||
SunOS workstations. The SCL without the Data Probe has been
|
||||
built on Solaris. (We did not build the InterViews Library
|
||||
on Solaris.) NOTE: earlier versions of the SCL 2.1 without
|
||||
the Data Probe had been ported to AIX, HP, linux, and Windows NT.
|
||||
|
||||
- a C++ compiler -- cfront version 2.1 or higher
|
||||
|
||||
NOTE: The current SCL release has been built with SUN C/C++,
|
||||
and GNU's gcc/g++ compilers. Earlier versions of the SCL were
|
||||
built using CenterLine on SunOS and CSet++ on AIX.
|
||||
|
||||
If you successfully port the current version to other
|
||||
compilers and/or operating systems (and are willing to share)
|
||||
please contact us (stepcl@cme.nist.gov) so that we can point
|
||||
others to it.
|
||||
|
||||
- The NIST EXPRESS Toolkit -- available from NIST
|
||||
Included in this release; also available as:
|
||||
ftp.cme.nist.gov:pub/step/npttools/exptk.tar.Z
|
||||
|
||||
- The NIST EXPRESS Pretty Printer -- available from NIST
|
||||
Included in this release; also available as:
|
||||
ftp.cme.nist.gov:pub/step/npttools/exppp.tar.Z
|
||||
|
||||
The following components are optional:
|
||||
|
||||
- Version 3.1 of the InterViews Toolkit from Stanford.
|
||||
ftp://interviews.stanford.edu:pub/3.1.tar.Z
|
||||
|
||||
NOTE: InterViews is only needed for the Data Probe portion of
|
||||
the toolkit. The STEP Class Library without the Data Probe
|
||||
and InterViews has been built on more platforms than with these
|
||||
components.
|
||||
|
||||
- Orbix version 2.0. Available from Iona Technologies:
|
||||
http://www.iona.com
|
||||
|
||||
- Object Store version 4. Available from Object Design Inc.:
|
||||
http://www.odi.com.
|
||||
|
||||
|
||||
INSTALLATION INSTRUCTIONS
|
||||
=========================
|
||||
|
||||
Refer to the file INSTALL.
|
||||
|
||||
In the instructions below, you will see references to the directory
|
||||
<ARCH_DIR>. This directory name should be interpreted as the directory
|
||||
which is named to reflect your compiler and/or system architecture
|
||||
when installing the SCL using configure: i.e. "arch.centerline" or
|
||||
"arch-gnu.solaris"
|
||||
|
||||
|
||||
CREATING A NEW SCHEMA CLASS LIBRARY AND/OR DATA PROBE
|
||||
=====================================================
|
||||
|
||||
The <ARCH_DIR>/bin/mkProbe script automates the process of building
|
||||
new Schema Class Libraries and Data Probe executables. When run with
|
||||
the -l option only the Schema Class Library will be created. See man
|
||||
page in ~scl/man.
|
||||
|
||||
Examples
|
||||
|
||||
Input command line output (name and location)
|
||||
----------------------------------------------------
|
||||
mkProbe part41.exp pt41 ./pt41/dp_pt41
|
||||
|
||||
mkProbe -i part101.exp dp ~scl/<ARCH_DIR>/Probes/dp/dp_dp
|
||||
|
||||
mkProbe -l example.exp example ./example/libCexample.a
|
||||
|
||||
mkProbe -p example.exp example ./example/p21read_example
|
||||
|
||||
|
||||
CONTENTS
|
||||
========
|
||||
|
||||
This directory contains the following files and subdirectories.
|
||||
|
||||
This software release includes all the NIST software needed for
|
||||
creating new versions of the Data Probe program. Two example schemas
|
||||
are included in the data directory.
|
||||
|
||||
INSTALL - File discussing installation of SCL.
|
||||
|
||||
README.scl - This file.
|
||||
|
||||
src/test/README - README discussing SCL coding examples under src/test/
|
||||
|
||||
disclaim.txt - NIST disclaimer for this distribution.
|
||||
|
||||
build-apps.txt - Discusses how to build applications using the STEP
|
||||
Class Library.
|
||||
|
||||
whatsnew.3-1.txt- Discusses new features in the STEP Class Library and
|
||||
Data Probe 3.1 release.
|
||||
|
||||
whatsnew.2-1.txt- This was the `whatsnew' file released with SCL 2.1.
|
||||
Most of the information is still relevant.
|
||||
|
||||
configure - Script used to install the SCL.
|
||||
|
||||
configure.in - File used to create the configure script using gnu's
|
||||
autoconf software.
|
||||
|
||||
configure.files_notes.txt - Discusses various files used by the
|
||||
configure script.
|
||||
|
||||
Makefile - Contains a default rule to build SCL using the
|
||||
configure installation script.
|
||||
|
||||
<ARCH_DIR>/bin/mkProbe - Script used to generate a new Schema Class Library
|
||||
and/or Data Probe executable.
|
||||
(see CREATING A NEW SCHEMA CLASS LIBRARY AND/OR DATA PROBE)
|
||||
|
||||
config/ - Directory containing various templates needed by the
|
||||
configure installation script.
|
||||
|
||||
config/examples/ - Directory containing examples of using configure to
|
||||
install SCL.
|
||||
|
||||
arch_template/ - Directory containing templates used by configure to
|
||||
create an architecture specific SCL installation.
|
||||
|
||||
src/ - Source code files for the C++ libraries included in this
|
||||
release.
|
||||
|
||||
src/cl* - Directories containing the source code for the C++
|
||||
libraries in the STEP Class Library. These
|
||||
libraries are documented in the VTS Design document
|
||||
(see DOCUMENTATION below). They are as follows:
|
||||
|
||||
src/clutils - utilities needed by the other libraries.
|
||||
|
||||
src/clstepcore - "core" classes representing EXPRESS types
|
||||
and dictionary info.
|
||||
|
||||
src/cldai - classes for a partial implementation of the
|
||||
Session schema of STEP's Standard Data
|
||||
Access Interface (STEP Part 23).
|
||||
|
||||
src/cleditor - classes for managing data instances and
|
||||
exchange files.
|
||||
|
||||
src/clivfasd - customizations to the Interviews class
|
||||
library.
|
||||
|
||||
src/clprobe-ui - user interface classes for the Data Probe.
|
||||
|
||||
src/clSchemas - Contain subdirectories with schema specific source
|
||||
code generated by the mkProbe script.
|
||||
|
||||
src/express - Directory containing the EXPRESS Toolkit.
|
||||
|
||||
src/exppp - Directory containing EXPRESS Pretty Printer Toolkit.
|
||||
|
||||
src/test - Directory containing example STEP Class Library
|
||||
applications.
|
||||
|
||||
src/fedex_plus - Directory containing source code and makefile for
|
||||
fedex_plus, fedex_idl, fedex_os
|
||||
|
||||
<ARCH_DIR>
|
||||
|
||||
- <ARCH_DIR> is the installer-supplied name of the
|
||||
directory which is created when you run configure to
|
||||
install SCL. (See the file INSTALL for more
|
||||
information.) This directory contains computer
|
||||
architecture-specific files. Additional arch dirs
|
||||
may be created to support multiple platforms or C++
|
||||
compilers which all refer to the same source
|
||||
code under src/. The arch dir contains the subdirectories
|
||||
ofiles, bin, lib, and Probes.
|
||||
|
||||
<ARCH_DIR>/ofiles/ - Directory containing object (.o) files for SCL.
|
||||
|
||||
<ARCH_DIR>/ofiles/sdaiOrbix - Directory containing IDL files and
|
||||
Makefile needed to build and use SCL with Orbix.
|
||||
|
||||
<ARCH_DIR>/lib/ - Directory containing library (.a) files for SCL.
|
||||
|
||||
<ARCH_DIR>/Probes/ - The <ARCH_DIR>/Probes directory will contain
|
||||
directories for versions of the Schema Class Library
|
||||
and Data Probe generated using the mkProbe script
|
||||
with the -i option.
|
||||
|
||||
<ARCH_DIR>/bin/ - The fedex, fedex_plus, fedex_idl, and fedex_os,
|
||||
exppp, and symlink executables and mkProbe,
|
||||
sclbuild, and setup-arch scripts are placed in this
|
||||
directory during installation.
|
||||
|
||||
data/ - Directory containing sample EXPRESS files to use to
|
||||
create SCL applications such as the Data Probe or
|
||||
Part 21 Reader. Also contains data for some of the
|
||||
examples.
|
||||
|
||||
bin/ - Directory containing various scripts.
|
||||
|
||||
man/ - Directory containing man pages for the software in
|
||||
the release. You may look at the man page by
|
||||
issuing the command: nroff -man <manpagefile> or by
|
||||
adding this directory to your MANPATH.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
========
|
||||
|
||||
Example of creating a Data Probe
|
||||
--------------------------------
|
||||
|
||||
To create a new version of the Data Probe run the script mkProbe. For
|
||||
example, to create a Data Probe based on the "example_schema" EXPRESS
|
||||
schema included in this release, issue the following command in a
|
||||
directory from which you would like a subdirectory containing the new
|
||||
Data Probe to be created:
|
||||
|
||||
% mkProbe ~scl/data/example/example.exp example
|
||||
|
||||
This command creates a new version of the Data Probe in the file:
|
||||
|
||||
% ./example/dp_example
|
||||
|
||||
(It also creates subdirectory example/ if it does not exist already.)
|
||||
|
||||
|
||||
Examples of using the STEP Class Library
|
||||
----------------------------------------
|
||||
|
||||
To use the Schema Class Library source code (without the Data Probe
|
||||
software) refer to the examples in the directory src/test.
|
||||
|
||||
Example of a Part 21 file reader
|
||||
--------------------------------
|
||||
|
||||
To create a file reader based on STEP's Part 21 format use the mkProbe
|
||||
script with the -p option.
|
||||
|
||||
% mkProbe -p ~scl/data/example/example.exp example
|
||||
|
||||
The executable p21read_example is created. Run it as follows:
|
||||
|
||||
% p21read_example your_part_21_file
|
||||
|
||||
This program reads a file the name of which is supplied as an
|
||||
argument to the program. Any errors encountered when reading the file
|
||||
are reported to standard output. A summary of the file is also
|
||||
reported. The file is then written back out to a file the name of
|
||||
which may be supplied as the second argument to the program. If no
|
||||
name is given, "file.out" is used.
|
||||
|
||||
|
||||
FOR MORE INFORMATION
|
||||
====================
|
||||
|
||||
SCL HOME PAGE
|
||||
-------------
|
||||
|
||||
The SCL home page is located on the world wide web at,
|
||||
|
||||
http://www.nist.gov/scl
|
||||
|
||||
The SCL home page will provide important, up-to-date information on
|
||||
the status of the SCL, new developments and fixes, links to related
|
||||
software and projects, and may eventually contain an FAQ sheet.
|
||||
|
||||
SCL DOCUMENTATION
|
||||
-----------------
|
||||
|
||||
Documentation can be accessed from the SCL world wide web home page
|
||||
located at http://www.nist.gov/scl
|
||||
The following files (in postscript format) are particularly relevant:
|
||||
|
||||
Design of a C++ Software Library for Implementing EXPRESS: The NIST
|
||||
STEP Class Library
|
||||
|
||||
Data Probe User's Guide
|
||||
|
||||
Data Probe: A Tool for EXPRESS-based Data
|
||||
|
||||
Architecture for the Validation Testing System Software
|
||||
|
||||
Validation Testing System Software Reusable Software Component Design
|
||||
|
||||
Diagrams of basic SCL data structures
|
||||
|
||||
|
||||
ISO DOCUMENTATION
|
||||
-----------------
|
||||
|
||||
Copies of the International Standard documents (including STEP Part 11
|
||||
the EXPRESS Language Reference Manual, Part 21 the STEP Exchange File
|
||||
Format, Part 22 STEP's Standard Data Access Interface, and Part 23 the
|
||||
C++ language binding to SDAI) can be ordered from the ISO
|
||||
International Organization of Standardization or your national
|
||||
body. The United States distribution is managed by the US Product Data
|
||||
Exchange Association at:
|
||||
|
||||
U.S. Product Data Association (USPro)
|
||||
Trident Research Center, Suite 204
|
||||
5300 International Blvd.
|
||||
N. Charleston, SC 29418
|
||||
|
||||
http://www.uspro.scra.org
|
||||
uspro@scra.org
|
||||
Ph: 803-760-3327
|
||||
FAX: 803-760-3349
|
||||
|
||||
MAILING LIST
|
||||
------------
|
||||
|
||||
Announcements of new releases or bug fixes will also be sent to the
|
||||
mailing list scl@cme.nist.gov. To be added to the scl mailing list
|
||||
send a request to majordomo@cme.nist.gov. Include in the body of the
|
||||
message:
|
||||
|
||||
subscribe scl
|
||||
|
||||
For additional help, include in the body of the message:
|
||||
|
||||
help
|
||||
|
||||
If you use a signature within your email, end your majordomo
|
||||
command sequence with the word "end". For example,
|
||||
|
||||
subscribe scl
|
||||
end
|
||||
|
||||
|
||||
REPORTING PROBLEMS AND SUGGESTIONS
|
||||
==================================
|
||||
|
||||
We would like feedback on all parts of the software. Please let us
|
||||
know if you
|
||||
|
||||
- have problems following the instructions in the README file,
|
||||
- have problems installing the software,
|
||||
- have problems compiling your own valid EXPRESS schema, or
|
||||
- have suggestions for improvements to the software.
|
||||
- really like the software :)
|
||||
|
||||
Send your comments to
|
||||
|
||||
stepcl@cme.nist.gov
|
||||
|
||||
(For users of version 2, note the new mailing address of "stepcl...".)
|
||||
|
||||
Questions about availability or accessing the software should be
|
||||
directed to the SOLIS administrator
|
||||
|
||||
Gaylen Rinaudot
|
||||
npt-info@cme.nist.gov
|
||||
301-975-3386
|
||||
|
||||
ACKNOWLEDGMENTS
|
||||
===============
|
||||
|
||||
The STEP Class Library (SCL) was developed by the Manufacturing
|
||||
Systems Integration Division at the National Institute of Standards
|
||||
and Technology (http://www.mel/nist.gov/msid) to support testing of
|
||||
the Standard for the Exchange of Product Model Data (a.k.a STEP) and
|
||||
validation of STEP's emerging implementation specifications. Funding
|
||||
for the project has come from the U.S. Department of Commerce, and the
|
||||
Department of Defense agencies including the Office of the Defense
|
||||
CALS (Continuous Acquisition and Life-Cycle Support) Executive and the
|
||||
Defense Advanced Research Projects Agency (DARPA). Recent
|
||||
enhancements were sponsored by the National Industrial Information
|
||||
Infrastructure Consortium (NIIIP) (http://www.niiip.org) and the NAMT
|
||||
Framework project
|
||||
(http://www.mel.nist.gov/msid/projs/97projs/framewrk.htm) of NIST's
|
||||
Systems Integration for Manufacturing Applications (SIMA) program
|
||||
(http://www.mel.nist.gov/msid/sima/sima.htm).
|
||||
|
||||
LICENSING RESTRICTIONS and DISCLAIMERS
|
||||
======================================
|
||||
|
||||
This software was produced by the National Institute of Standards and
|
||||
Technology (NIST), an agency of the U.S. government, and by statute
|
||||
is not subject to copyright in the United States. Recipients of this
|
||||
software assume all responsibility associated with its operation,
|
||||
modification, maintenance, and subsequent re-distribution.
|
||||
|
||||
There is no warranty for the NIST STEP Toolkit.
|
||||
If the NIST STEP Toolkit is modified by someone else and passed on,
|
||||
NIST wants the Toolkit's recipients to know that what they have is not
|
||||
what NIST originally distributed.
|
||||
|
||||
Distribution Rights
|
||||
1. Anyone may copy and distribute verbatim copies of the NIST STEP Toolkit
|
||||
source code as received in any medium.
|
||||
|
||||
2. Anyone may modify their copy or copies of the NIST STEP Toolkit source
|
||||
code or any portion of it, and copy and distribute such modifications
|
||||
provided that all modifications are clearly associated with the entity
|
||||
that performs the modifications.
|
||||
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!DISCLAIMERS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
Names of companies and products are provided in order to adequately
|
||||
specify procedures and equipment used. In no case does such
|
||||
identification imply recommendation or endorsement by the National
|
||||
Institute of Standards and Technology, nor does it imply that the
|
||||
products are necessarily the best available for the purpose.
|
||||
|
||||
NO WARRANTY
|
||||
===========
|
||||
|
||||
NIST PROVIDES ABSOLUTELY NO WARRANTY. THE NIST STEP TOOLKIT
|
||||
IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS
|
||||
WITH YOU. SHOULD ANY PORTION OF THE NIST STEP TOOLKIT PROVE DEFECTIVE,
|
||||
YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
|
||||
|
||||
IN NO EVENT WILL NIST BE LIABLE FOR DAMAGES, INCLUDING ANY LOST
|
||||
PROFITS, LOST MONIES, OR OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL
|
||||
DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE (INCLUDING BUT NOT
|
||||
LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE, OR LOSSES
|
||||
SUSTAINED BY THIRD PARTIES, OR A FAILURE OF THE PROGRAM TO OPERATE
|
||||
WITH PROGRAMS NOT DISTRIBUTED BY NIST) THE PROGRAMS, EVEN IF YOU HAVE
|
||||
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY
|
||||
ANY OTHER PARTY.
|
||||
For more info, see the wiki.
|
||||
+1
-1
@@ -1 +1 @@
|
||||
0.5
|
||||
0.6
|
||||
|
||||
+116
-54
@@ -1,75 +1,137 @@
|
||||
# Will need windows logic someday, even though it doesn't work yet, so go ahead
|
||||
# and add the DLL_DEFINE macro
|
||||
|
||||
MACRO(DLL_DEFINE libname)
|
||||
IF(MSVC)
|
||||
STRING(REGEX REPLACE "lib" "" LOWERCORE "${libname}")
|
||||
STRING(TOUPPER ${LOWERCORE} UPPER_CORE)
|
||||
add_definitions("-D${UPPER_CORE}_EXPORT_DLL")
|
||||
ENDIF(MSVC)
|
||||
ENDMACRO()
|
||||
# set compile definitions for dll exports on windows
|
||||
MACRO(DEFINE_DLL_EXPORTS libname)
|
||||
IF( MSVC OR BORLAND )
|
||||
if( ${libname} MATCHES "sdai_.*" )
|
||||
set( export "SCL_SCHEMA_DLL_EXPORTS" )
|
||||
else()
|
||||
STRING(REGEX REPLACE "lib" "" shortname "${libname}")
|
||||
STRING(REGEX REPLACE "step" "" LOWERCORE "${shortname}")
|
||||
STRING(TOUPPER ${LOWERCORE} UPPER_CORE)
|
||||
set( export "SCL_${UPPER_CORE}_DLL_EXPORTS" )
|
||||
endif()
|
||||
get_target_property(defs ${libname} COMPILE_DEFINITIONS )
|
||||
if( defs ) #if no properties, ${defs} will be defs-NOTFOUND which CMake interprets as false
|
||||
set( defs "${defs};${export}")
|
||||
else( defs )
|
||||
set( defs "${export}")
|
||||
endif( defs )
|
||||
set_target_properties(${libname} PROPERTIES COMPILE_DEFINITIONS "${defs}" )
|
||||
ENDIF( MSVC OR BORLAND )
|
||||
ENDMACRO(DEFINE_DLL_EXPORTS libname)
|
||||
|
||||
# set compile definitions for dll imports on windows
|
||||
MACRO( DEFINE_DLL_IMPORTS tgt libs )
|
||||
IF( MSVC OR BORLAND )
|
||||
get_target_property(defs ${tgt} COMPILE_DEFINITIONS )
|
||||
if( NOT defs ) #if no properties, ${defs} will be defs-NOTFOUND which CMake interprets as false
|
||||
set( defs "")
|
||||
endif( NOT defs )
|
||||
foreach( lib ${libs} )
|
||||
STRING(REGEX REPLACE "lib" "" shortname "${lib}")
|
||||
STRING(REGEX REPLACE "step" "" LOWERCORE "${shortname}")
|
||||
STRING(TOUPPER ${LOWERCORE} UPPER_CORE)
|
||||
list( APPEND defs "SCL_${UPPER_CORE}_DLL_IMPORTS" )
|
||||
endforeach( lib ${libs} )
|
||||
if( DEFINED defs )
|
||||
if( defs )
|
||||
set_target_properties( ${tgt} PROPERTIES COMPILE_DEFINITIONS "${defs}" )
|
||||
endif( defs )
|
||||
endif( DEFINED defs )
|
||||
ENDIF( MSVC OR BORLAND )
|
||||
ENDMACRO( DEFINE_DLL_IMPORTS tgt libs )
|
||||
|
||||
#EXCLUDE_OR_INSTALL(target destination ARGV3)
|
||||
# installs ${target} in ${destination} unless testing is enabled AND ${arg_3} == "TESTABLE",
|
||||
# in which case the EXCLUDE_FROM_ALL property is set for testing.
|
||||
# EXCLUDE_FROM_ALL cannot be set on targets that are to be installed,
|
||||
# so either test the target or install it - but not both
|
||||
MACRO(EXCLUDE_OR_INSTALL target dest arg_3 )
|
||||
if( NOT ( ( SCL_ENABLE_TESTING ) AND ( "${arg_3}" STREQUAL "TESTABLE" ) ) )
|
||||
INSTALL(TARGETS ${target} DESTINATION ${dest})
|
||||
else( NOT ( ( SCL_ENABLE_TESTING ) AND ( "${arg_3}" STREQUAL "TESTABLE" ) ) )
|
||||
set_target_properties( ${target} PROPERTIES EXCLUDE_FROM_ALL ON )
|
||||
endif( NOT ( ( SCL_ENABLE_TESTING ) AND ( "${arg_3}" STREQUAL "TESTABLE" ) ) )
|
||||
ENDMACRO(EXCLUDE_OR_INSTALL target dest arg_3 )
|
||||
|
||||
#SCL_ADDEXEC( execname "source files" "linked libs" ["TESTABLE"] ["MSVC flag" ...])
|
||||
# optional 4th argument of "TESTABLE", passed to EXCLUDE_OR_INSTALL macro
|
||||
# optional args can also be used by MSVC-specific code, but it looks like these two uses
|
||||
# will not conflict because the MSVC args must contain "STRICT"
|
||||
MACRO(SCL_ADDEXEC execname srcs libs)
|
||||
STRING(REGEX REPLACE " " ";" srcslist "${srcs}")
|
||||
STRING(REGEX REPLACE " " ";" libslist "${libs}")
|
||||
add_executable(${execname} ${srcslist})
|
||||
target_link_libraries(${execname} ${libslist})
|
||||
INSTALL(TARGETS ${execname} DESTINATION bin)
|
||||
# Enable extra compiler flags if local executables and/or global options dictate
|
||||
SET(LOCAL_COMPILE_FLAGS "")
|
||||
FOREACH(extraarg ${ARGN})
|
||||
IF(${extraarg} MATCHES "STRICT" AND SCL-ENABLE_STRICT)
|
||||
SET(LOCAL_COMPILE_FLAGS "${LOCAL_COMPILE_FLAGS} ${STRICT_FLAGS}")
|
||||
ENDIF(${extraarg} MATCHES "STRICT" AND SCL-ENABLE_STRICT)
|
||||
ENDFOREACH(extraarg ${ARGN})
|
||||
IF(LOCAL_COMPILE_FLAGS)
|
||||
SET_TARGET_PROPERTIES(${execname} PROPERTIES COMPILE_FLAGS ${LOCAL_COMPILE_FLAGS})
|
||||
ENDIF(LOCAL_COMPILE_FLAGS)
|
||||
STRING(REGEX REPLACE " " ";" srcslist "${srcs}")
|
||||
STRING(REGEX REPLACE " " ";" libslist "${libs}")
|
||||
add_executable(${execname} ${srcslist})
|
||||
target_link_libraries(${execname} ${libslist})
|
||||
DEFINE_DLL_IMPORTS(${execname} "${libslist}") #add import definitions for all libs that the executable is linked to
|
||||
EXCLUDE_OR_INSTALL( ${execname} "bin" "${ARGV3}" )
|
||||
# Enable extra compiler flags if local executables and/or global options dictate
|
||||
SET(LOCAL_COMPILE_FLAGS "")
|
||||
FOREACH(extraarg ${ARGN})
|
||||
IF(${extraarg} MATCHES "STRICT" AND SCL-ENABLE_STRICT)
|
||||
SET(LOCAL_COMPILE_FLAGS "${LOCAL_COMPILE_FLAGS} ${STRICT_FLAGS}")
|
||||
ENDIF(${extraarg} MATCHES "STRICT" AND SCL-ENABLE_STRICT)
|
||||
ENDFOREACH(extraarg ${ARGN})
|
||||
IF(LOCAL_COMPILE_FLAGS)
|
||||
SET_TARGET_PROPERTIES(${execname} PROPERTIES COMPILE_FLAGS ${LOCAL_COMPILE_FLAGS})
|
||||
ENDIF(LOCAL_COMPILE_FLAGS)
|
||||
ENDMACRO(SCL_ADDEXEC execname srcs libs)
|
||||
|
||||
#SCL_ADDLIB( libname "source files" "linked libs" ["TESTABLE"] ["MSVC flag" ...])
|
||||
# optional 4th argument of "TESTABLE", passed to EXCLUDE_OR_INSTALL macro
|
||||
# optional args can also be used by MSVC-specific code, but it looks like these two uses
|
||||
# will not conflict because the MSVC args must contain "STRICT"
|
||||
MACRO(SCL_ADDLIB libname srcs libs)
|
||||
STRING(REGEX REPLACE " " ";" srcslist "${srcs}")
|
||||
STRING(REGEX REPLACE " " ";" libslist1 "${libs}")
|
||||
STRING(REGEX REPLACE "-framework;" "-framework " libslist "${libslist1}")
|
||||
DLL_DEFINE(${libname})
|
||||
IF(SCL_BUILD_SHARED_LIBS)
|
||||
add_library(${libname} SHARED ${srcslist})
|
||||
if(NOT ${libs} MATCHES "NONE")
|
||||
target_link_libraries(${libname} ${libslist})
|
||||
endif(NOT ${libs} MATCHES "NONE")
|
||||
SET_TARGET_PROPERTIES(${libname} PROPERTIES VERSION ${SCL_ABI_VERSION} SOVERSION ${SCL_ABI_SOVERSION} )
|
||||
INSTALL(TARGETS ${libname} DESTINATION lib)
|
||||
add_library(${libname} SHARED ${srcslist})
|
||||
DEFINE_DLL_EXPORTS(${libname})
|
||||
if(NOT ${libs} MATCHES "NONE")
|
||||
target_link_libraries(${libname} ${libslist})
|
||||
DEFINE_DLL_IMPORTS(${libname} "${libslist}" )
|
||||
endif(NOT ${libs} MATCHES "NONE")
|
||||
SET_TARGET_PROPERTIES(${libname} PROPERTIES VERSION ${SCL_ABI_VERSION} SOVERSION ${SCL_ABI_SOVERSION} )
|
||||
EXCLUDE_OR_INSTALL( ${libname} "lib" "${ARGV3}" )
|
||||
if(APPLE)
|
||||
set_target_properties(${libname} PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
|
||||
endif(APPLE)
|
||||
ENDIF(SCL_BUILD_SHARED_LIBS)
|
||||
IF(SCL_BUILD_STATIC_LIBS AND NOT MSVC)
|
||||
add_library(${libname}-static STATIC ${srcslist})
|
||||
if(NOT ${libs} MATCHES "NONE")
|
||||
target_link_libraries(${libname}-static ${libslist})
|
||||
endif(NOT ${libs} MATCHES "NONE")
|
||||
IF(NOT WIN32)
|
||||
SET_TARGET_PROPERTIES(${libname}-static PROPERTIES OUTPUT_NAME "${libname}")
|
||||
ENDIF(NOT WIN32)
|
||||
IF(WIN32)
|
||||
# We need the lib prefix on win32, so add it even if our add_library
|
||||
# wrapper function has removed it due to the target name - see
|
||||
# http://www.cmake.org/Wiki/CMake_FAQ#How_do_I_make_my_shared_and_static_libraries_have_the_same_root_name.2C_but_different_suffixes.3F
|
||||
SET_TARGET_PROPERTIES(${libname}-static PROPERTIES PREFIX "lib")
|
||||
ENDIF(WIN32)
|
||||
INSTALL(TARGETS ${libname}-static DESTINATION lib)
|
||||
add_library(${libname}-static STATIC ${srcslist})
|
||||
DEFINE_DLL_EXPORTS(${libname}-static)
|
||||
if(NOT ${libs} MATCHES "NONE")
|
||||
target_link_libraries(${libname}-static "${libslist}")
|
||||
DEFINE_DLL_IMPORTS(${libname}-static ${libslist} )
|
||||
endif(NOT ${libs} MATCHES "NONE")
|
||||
IF(NOT WIN32)
|
||||
SET_TARGET_PROPERTIES(${libname}-static PROPERTIES OUTPUT_NAME "${libname}")
|
||||
ENDIF(NOT WIN32)
|
||||
IF(WIN32)
|
||||
# We need the lib prefix on win32, so add it even if our add_library
|
||||
# wrapper function has removed it due to the target name - see
|
||||
# http://www.cmake.org/Wiki/CMake_FAQ#How_do_I_make_my_shared_and_static_libraries_have_the_same_root_name.2C_but_different_suffixes.3F
|
||||
SET_TARGET_PROPERTIES(${libname}-static PROPERTIES PREFIX "lib")
|
||||
ENDIF(WIN32)
|
||||
EXCLUDE_OR_INSTALL( ${libname}-static "lib" "${ARGV3}" )
|
||||
if(APPLE)
|
||||
set_target_properties(${libname}-static PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
|
||||
endif(APPLE)
|
||||
ENDIF(SCL_BUILD_STATIC_LIBS AND NOT MSVC)
|
||||
# Enable extra compiler flags if local libraries and/or global options dictate
|
||||
SET(LOCAL_COMPILE_FLAGS "")
|
||||
FOREACH(extraarg ${ARGN})
|
||||
IF(${extraarg} MATCHES "STRICT" AND SCL-ENABLE_STRICT)
|
||||
SET(LOCAL_COMPILE_FLAGS "${LOCAL_COMPILE_FLAGS} ${STRICT_FLAGS}")
|
||||
ENDIF(${extraarg} MATCHES "STRICT" AND SCL-ENABLE_STRICT)
|
||||
IF(${extraarg} MATCHES "STRICT" AND SCL-ENABLE_STRICT)
|
||||
SET(LOCAL_COMPILE_FLAGS "${LOCAL_COMPILE_FLAGS} ${STRICT_FLAGS}")
|
||||
ENDIF(${extraarg} MATCHES "STRICT" AND SCL-ENABLE_STRICT)
|
||||
ENDFOREACH(extraarg ${ARGN})
|
||||
IF(LOCAL_COMPILE_FLAGS)
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
SET_TARGET_PROPERTIES(${libname} PROPERTIES COMPILE_FLAGS ${LOCAL_COMPILE_FLAGS})
|
||||
ENDIF(BUILD_SHARED_LIBS)
|
||||
IF(BUILD_STATIC_LIBS AND NOT MSVC)
|
||||
SET_TARGET_PROPERTIES(${libname}-static PROPERTIES COMPILE_FLAGS ${LOCAL_COMPILE_FLAGS})
|
||||
ENDIF(BUILD_STATIC_LIBS AND NOT MSVC)
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
SET_TARGET_PROPERTIES(${libname} PROPERTIES COMPILE_FLAGS ${LOCAL_COMPILE_FLAGS})
|
||||
ENDIF(BUILD_SHARED_LIBS)
|
||||
IF(BUILD_STATIC_LIBS AND NOT MSVC)
|
||||
SET_TARGET_PROPERTIES(${libname}-static PROPERTIES COMPILE_FLAGS ${LOCAL_COMPILE_FLAGS})
|
||||
ENDIF(BUILD_STATIC_LIBS AND NOT MSVC)
|
||||
ENDIF(LOCAL_COMPILE_FLAGS)
|
||||
ENDMACRO(SCL_ADDLIB libname srcs libs)
|
||||
|
||||
+5
-30
@@ -1,12 +1,3 @@
|
||||
|
||||
#this sets a property so that the target doesn't get built by 'make' or 'make all'
|
||||
#useful when testing generation of schema code/compiling schem libs/etc
|
||||
FUNCTION( TESTABLE_TARGET target )
|
||||
if(SCL_ENABLE_TESTING)
|
||||
set_target_properties( ${target} PROPERTIES EXCLUDE_FROM_ALL ON )
|
||||
endif()
|
||||
ENDFUNCTION( TESTABLE_TARGET )
|
||||
|
||||
# To build one or more schemas, configure with
|
||||
# 'cmake -DSCL_BUILD_SCHEMAS="path/to/schema.exp;path/to/schema2.exp"
|
||||
|
||||
@@ -63,24 +54,11 @@ FUNCTION(BUILD_A_SCHEMA SCHEMA_FILE)
|
||||
WORKING_DIRECTORY ${SCHEMA_OUTPUT_DIR}
|
||||
COMMENT "Running fedex_plus for ${SCHEMA_SHORT_NAME}..."
|
||||
VERBATIM )
|
||||
if(MSVC OR BORLAND)
|
||||
add_definitions( -DSCL_SCHEMA_DLL_EXPORTS )
|
||||
add_definitions( -DSCL_BASE_DLL_IMPORTS )
|
||||
add_definitions( -DSCL_EXPRESS_DLL_IMPORTS )
|
||||
add_definitions( -DSCL_UTILS_DLL_IMPORTS )
|
||||
add_definitions( -DSCL_DAI_DLL_IMPORTS )
|
||||
add_definitions( -DSCL_CORE_DLL_IMPORTS )
|
||||
add_definitions( -DSCL_EDITOR_DLL_IMPORTS )
|
||||
endif()
|
||||
add_library( ${PROJECT_NAME} SHARED ${FEDEX_OUT} )
|
||||
target_link_libraries(${PROJECT_NAME} stepdai stepcore express stepeditor steputils base )
|
||||
# if testing is enabled, "TESTABLE" sets property EXCLUDE_FROM_ALL and prevents installation
|
||||
SCL_ADDLIB( ${PROJECT_NAME} "${FEDEX_OUT}" "stepdai stepcore express stepeditor steputils base" "TESTABLE" )
|
||||
add_dependencies( ${PROJECT_NAME} generate_cpp_${SCHEMA_SHORT_NAME} )
|
||||
set_target_properties( ${PROJECT_NAME} PROPERTIES COMPILE_FLAGS
|
||||
${${PROJECT_NAME}_COMPILE_FLAGS} )
|
||||
if(APPLE)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
|
||||
endif(APPLE)
|
||||
TESTABLE_TARGET( ${PROJECT_NAME} )
|
||||
|
||||
add_test( NAME generate_cpp_${SCHEMA_SHORT_NAME}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
@@ -98,19 +76,16 @@ FUNCTION(BUILD_A_SCHEMA SCHEMA_FILE)
|
||||
set_tests_properties( build_cpp_${PROJECT_NAME} PROPERTIES DEPENDS generate_cpp_${SCHEMA_SHORT_NAME} LABELS cpp_schema_build )
|
||||
|
||||
if(MSVC OR BORLAND)
|
||||
add_executable( p21read_${PROJECT_NAME} ${SCL_SOURCE_DIR}/src/test/p21read/p21read.cc ${SCL_SOURCE_DIR}/src/fedex_plus/xgetopt.cc )
|
||||
else()
|
||||
add_executable( p21read_${PROJECT_NAME} ${SCL_SOURCE_DIR}/src/test/p21read/p21read.cc )
|
||||
set( WIN_EXTRA_SRCS ${SCL_SOURCE_DIR}/src/fedex_plus/xgetopt.cc )
|
||||
endif()
|
||||
SCL_ADDEXEC( p21read_${PROJECT_NAME} "${SCL_SOURCE_DIR}/src/test/p21read/p21read.cc ${WIN_EXTRA_SRCS}" "${PROJECT_NAME}" "TESTABLE" )
|
||||
add_dependencies( p21read_${PROJECT_NAME} version_string )
|
||||
target_link_libraries( p21read_${PROJECT_NAME} ${PROJECT_NAME} )
|
||||
set_target_properties( p21read_${PROJECT_NAME} PROPERTIES COMPILE_FLAGS
|
||||
${${PROJECT_NAME}_COMPILE_FLAGS} )
|
||||
TESTABLE_TARGET( p21read_${PROJECT_NAME} )
|
||||
|
||||
#find all part 21 files in schema dir, add a test for each one
|
||||
get_filename_component( SCHEMA_DIR ${SCHEMA_FILE} PATH )
|
||||
file( GLOB_RECURSE P21_FILES ${SCHEMA_DIR}/*.stp ${SCHEMA_DIR}/*.step ${SCHEMA_DIR}/*.p21 )
|
||||
file( GLOB_RECURSE P21_FILES ${SCHEMA_DIR}/*.stp ${SCHEMA_DIR}/*.step ${SCHEMA_DIR}/*.p21 ${SCHEMA_DIR}/*.ifc )
|
||||
foreach( TEST_FILE ${P21_FILES} )
|
||||
get_filename_component( FNAME ${TEST_FILE} NAME_WE )
|
||||
add_test( NAME read_write_cpp_${SCHEMA_SHORT_NAME}_${FNAME}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -37,7 +37,7 @@ PROJECT_NUMBER = 3.2
|
||||
# for a project that appears at the top of each page and should give viewer
|
||||
# a quick idea about the purpose of the project. Keep the description short.
|
||||
|
||||
PROJECT_BRIEF = "STEP Class Library"
|
||||
PROJECT_BRIEF = "STEPcode"
|
||||
|
||||
# With the PROJECT_LOGO tag one can specify an logo or icon that is
|
||||
# included in the documentation. The maximum height of the logo should not
|
||||
|
||||
+2
-2
@@ -68,7 +68,7 @@
|
||||
<qtHelp collectionFile="./doc/helpcollection.qhc"
|
||||
projectFile="./doc/helpcollection.qhcp"
|
||||
storage="./doc/qch" copyAction="copy">
|
||||
<title>StepClassLibrary</title>
|
||||
<title>STEPcode</title>
|
||||
<startPage>qthelp://com.github.mpictor/doc/index.html</startPage>
|
||||
<!-- See http://doc.trolltech.com/assistant-custom-help-viewer.html for more
|
||||
settings in the <assistant> section. -->
|
||||
@@ -100,7 +100,7 @@
|
||||
-->
|
||||
<project>
|
||||
<!-- The name of the project -->
|
||||
<name>StepClassLibrary</name>
|
||||
<name>STEPcode</name>
|
||||
<!-- The version number of the documentation -->
|
||||
<version>0.2</version>
|
||||
<!-- Whether to build version specific documentation for the projects or not.
|
||||
|
||||
@@ -47,16 +47,16 @@ $mathjax
|
||||
<!-- add module list -->
|
||||
<div id="navrow0" class="tabs">
|
||||
<ul class="tablist">
|
||||
<li><a href="../../doc.StepClassLibrary/doxygen-html/index.html"><span>Main</span></a></li>
|
||||
<li><a href="../../doc.StepClassLibrary.CLDAI/doxygen-html/index.html"><span>CLDAI</span></a></li>
|
||||
<li><a href="../../doc.StepClassLibrary.CLEditor/doxygen-html/index.html"><span>CLEditor</span></a></li>
|
||||
<li><a href="../../doc.StepClassLibrary.CLProbe-ui/doxygen-html/index.html"><span>CLProbe-ui</span></a></li>
|
||||
<li><a href="../../doc.StepClassLibrary.CLStepCore/doxygen-html/index.html"><span>CLStepCore</span></a></li>
|
||||
<li><a href="../../doc.StepClassLibrary.CLUtils/doxygen-html/index.html"><span>CLUtils</span></a></li>
|
||||
<li><a href="../../doc.StepClassLibrary.ExPPP/doxygen-html/index.html"><span>ExPPP</span></a></li>
|
||||
<li><a href="../../doc.StepClassLibrary.Express/doxygen-html/index.html"><span>Express</span></a></li>
|
||||
<li><a href="../../doc.StepClassLibrary.Fedex-Plus/doxygen-html/index.html"><span>Fedex-Plus</span></a></li>
|
||||
<li><a href="../../doc.StepClassLibrary.Tests/doxygen-html/index.html"><span>Tests</span></a></li>
|
||||
<li><a href="../../doc.STEPcode/doxygen-html/index.html"><span>Main</span></a></li>
|
||||
<li><a href="../../doc.STEPcode.CLDAI/doxygen-html/index.html"><span>CLDAI</span></a></li>
|
||||
<li><a href="../../doc.STEPcode.CLEditor/doxygen-html/index.html"><span>CLEditor</span></a></li>
|
||||
<li><a href="../../doc.STEPcode.CLProbe-ui/doxygen-html/index.html"><span>CLProbe-ui</span></a></li>
|
||||
<li><a href="../../doc.STEPcode.CLStepCore/doxygen-html/index.html"><span>CLStepCore</span></a></li>
|
||||
<li><a href="../../doc.STEPcode.CLUtils/doxygen-html/index.html"><span>CLUtils</span></a></li>
|
||||
<li><a href="../../doc.STEPcode.ExPPP/doxygen-html/index.html"><span>ExPPP</span></a></li>
|
||||
<li><a href="../../doc.STEPcode.Express/doxygen-html/index.html"><span>Express</span></a></li>
|
||||
<li><a href="../../doc.STEPcode.Fedex-Plus/doxygen-html/index.html"><span>Fedex-Plus</span></a></li>
|
||||
<li><a href="../../doc.STEPcode.Tests/doxygen-html/index.html"><span>Tests</span></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- end module list -->
|
||||
|
||||
@@ -132,6 +132,13 @@ struct Scope_ {
|
||||
#define SCOPEdo_entities(s,t,de) DICTdo_type_init(s->symbol_table,&de,OBJ_ENTITY); { \
|
||||
Entity t; \
|
||||
while (0 != (t = (Entity)DICTdo(&de))) {
|
||||
#define SCOPEdo_functions(s,t,de) DICTdo_type_init(s->symbol_table,&de,OBJ_FUNCTION); { \
|
||||
Entity t; \
|
||||
while (0 != (t = (Entity)DICTdo(&de))) {
|
||||
#define SCOPEdo_rules(s,t,de) DICTdo_type_init(s->symbol_table,&de,OBJ_RULE); { \
|
||||
Entity t; \
|
||||
while (0 != (t = (Entity)DICTdo(&de))) {
|
||||
|
||||
#define SCOPEod }}
|
||||
|
||||
/***********************/
|
||||
@@ -143,5 +150,9 @@ extern SCL_EXPRESS_EXPORT void SCOPE_get_entities PROTO( ( Scope, Linked_Lis
|
||||
extern SCL_EXPRESS_EXPORT Linked_List SCOPEget_entities PROTO( ( Scope ) );
|
||||
extern SCL_EXPRESS_EXPORT Linked_List SCOPEget_entities_superclass_order PROTO( ( Scope ) );
|
||||
extern SCL_EXPRESS_EXPORT Generic SCOPEfind PROTO( ( Scope, char *, int ) );
|
||||
extern SCL_EXPRESS_EXPORT void SCOPE_get_functions PROTO( ( Scope, Linked_List ) );
|
||||
extern SCL_EXPRESS_EXPORT Linked_List SCOPEget_functions PROTO( ( Scope ) );
|
||||
extern SCL_EXPRESS_EXPORT void SCOPE_get_rules PROTO( ( Scope, Linked_List ) );
|
||||
extern SCL_EXPRESS_EXPORT Linked_List SCOPEget_rules PROTO( ( Scope ) );
|
||||
|
||||
#endif /* SCOPE_H */
|
||||
|
||||
@@ -8,9 +8,9 @@ set(LIBSTEPDAI_SRCS
|
||||
sdaiEntity_extent_set.cc
|
||||
sdaiModel_contents.cc
|
||||
sdaiModel_contents_list.cc
|
||||
sdaiEnum.cc
|
||||
sdaiString.cc
|
||||
sdaiBinary.cc
|
||||
sdaiEnum.cc
|
||||
sdaiString.cc
|
||||
sdaiBinary.cc
|
||||
)
|
||||
|
||||
SET(LIBSTEPDAI_PRIVATE_HDRS
|
||||
@@ -23,17 +23,11 @@ SET(LIBSTEPDAI_PRIVATE_HDRS
|
||||
sdaiObject.h
|
||||
sdaiSession_instance.h
|
||||
StrUtil.hh
|
||||
sdaiEnum.h
|
||||
sdaiString.h
|
||||
sdaiBinary.h
|
||||
sdaiEnum.h
|
||||
sdaiString.h
|
||||
sdaiBinary.h
|
||||
)
|
||||
|
||||
IF(MSVC OR BORLAND)
|
||||
add_definitions( -DSCL_DAI_DLL_EXPORTS )
|
||||
add_definitions( -DSCL_BASE_DLL_IMPORTS )
|
||||
add_definitions( -DSCL_UTILS_DLL_IMPORTS )
|
||||
ENDIF()
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${SCL_SOURCE_DIR}/src/base
|
||||
@@ -42,9 +36,3 @@ include_directories(
|
||||
)
|
||||
|
||||
SCL_ADDLIB(stepdai "${LIBSTEPDAI_SRCS}" "steputils base")
|
||||
|
||||
if(APPLE)
|
||||
if(SCL_BUILD_SHARED_LIBS)
|
||||
set_target_properties(stepdai PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
|
||||
endif(SCL_BUILD_SHARED_LIBS)
|
||||
endif(APPLE)
|
||||
|
||||
@@ -41,18 +41,4 @@ include_directories(
|
||||
${SCL_SOURCE_DIR}/src/clutils
|
||||
)
|
||||
|
||||
if(MSVC OR BORLAND)
|
||||
add_definitions( -DSCL_EDITOR_DLL_EXPORTS )
|
||||
add_definitions( -DSCL_BASE_DLL_IMPORTS )
|
||||
add_definitions( -DSCL_CORE_DLL_IMPORTS )
|
||||
add_definitions( -DSCL_DAI_DLL_IMPORTS )
|
||||
add_definitions( -DSCL_UTILS_DLL_IMPORTS )
|
||||
endif()
|
||||
|
||||
SCL_ADDLIB(stepeditor "${LIBSTEPEDITOR_SRCS}" "stepcore stepdai steputils base")
|
||||
|
||||
if(APPLE)
|
||||
if(SCL_BUILD_SHARED_LIBS)
|
||||
set_target_properties(stepeditor PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
|
||||
endif(SCL_BUILD_SHARED_LIBS)
|
||||
endif(APPLE)
|
||||
|
||||
@@ -28,31 +28,23 @@ set(LIBSTEPCORE_SRCS
|
||||
)
|
||||
|
||||
if(MINGW)
|
||||
set(LIBDEPEND_SRCS
|
||||
${SCL_SOURCE_DIR}/src/cleditor/instmgr.cc
|
||||
${SCL_SOURCE_DIR}/src/cleditor/mgrnode.cc
|
||||
${SCL_SOURCE_DIR}/src/cleditor/dispnode.cc
|
||||
${SCL_SOURCE_DIR}/src/cleditor/mgrnodearray.cc
|
||||
${SCL_SOURCE_DIR}/src/cleditor/needFunc.cc
|
||||
)
|
||||
set(LIBDEPEND_SRCS
|
||||
${SCL_SOURCE_DIR}/src/cleditor/instmgr.cc
|
||||
${SCL_SOURCE_DIR}/src/cleditor/mgrnode.cc
|
||||
${SCL_SOURCE_DIR}/src/cleditor/dispnode.cc
|
||||
${SCL_SOURCE_DIR}/src/cleditor/mgrnodearray.cc
|
||||
${SCL_SOURCE_DIR}/src/cleditor/needFunc.cc
|
||||
)
|
||||
endif(MINGW)
|
||||
|
||||
if(MSVC OR BORLAND)
|
||||
set(LIBDEPEND_SRCS
|
||||
${SCL_SOURCE_DIR}/src/cleditor/instmgr.cc
|
||||
${SCL_SOURCE_DIR}/src/cleditor/mgrnode.cc
|
||||
${SCL_SOURCE_DIR}/src/cleditor/dispnode.cc
|
||||
${SCL_SOURCE_DIR}/src/cleditor/mgrnodearray.cc
|
||||
${SCL_SOURCE_DIR}/src/cleditor/needFunc.cc
|
||||
)
|
||||
endif()
|
||||
|
||||
if(MSVC OR BORLAND)
|
||||
add_definitions( -DSCL_CORE_DLL_EXPORTS )
|
||||
add_definitions( -DSCL_BASE_DLL_IMPORTS )
|
||||
add_definitions( -DSCL_EXPRESS_DLL_IMPORTS )
|
||||
add_definitions( -DSCL_UTILS_DLL_IMPORTS )
|
||||
add_definitions( -DSCL_DAI_DLL_IMPORTS )
|
||||
set(LIBDEPEND_SRCS
|
||||
${SCL_SOURCE_DIR}/src/cleditor/instmgr.cc
|
||||
${SCL_SOURCE_DIR}/src/cleditor/mgrnode.cc
|
||||
${SCL_SOURCE_DIR}/src/cleditor/dispnode.cc
|
||||
${SCL_SOURCE_DIR}/src/cleditor/mgrnodearray.cc
|
||||
${SCL_SOURCE_DIR}/src/cleditor/needFunc.cc
|
||||
)
|
||||
endif()
|
||||
|
||||
SET(LIBSTEPCORE_PRIVATE_HDRS
|
||||
@@ -86,8 +78,3 @@ include_directories(
|
||||
)
|
||||
|
||||
SCL_ADDLIB(stepcore "${LIBSTEPCORE_SRCS} ${LIBDEPEND_SRCS}" "express steputils stepdai base")
|
||||
if(APPLE)
|
||||
if(SCL_BUILD_SHARED_LIBS)
|
||||
set_target_properties(stepcore PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
|
||||
endif(SCL_BUILD_SHARED_LIBS)
|
||||
endif(APPLE)
|
||||
|
||||
@@ -790,7 +790,6 @@ int STEPattribute::is_null() const {
|
||||
return ( *( ptr.S ) == S_STRING_NULL );
|
||||
|
||||
case BINARY_TYPE:
|
||||
ptr.b->clear();
|
||||
return ptr.b->empty();
|
||||
|
||||
case AGGREGATE_TYPE:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <sdai.h>
|
||||
#include "scl_memmgr.h"
|
||||
|
||||
const char * SCLversion = "STEP Class Library, github.com/mpictor/StepClassLibrary";
|
||||
const char * SCLversion = "STEPcode, github.com/stepcode/stepcode";
|
||||
|
||||
const SDAI_Integer SDAI_INT_NULL = LONG_MAX;
|
||||
const SDAI_Real SDAI_REAL_NULL = FLT_MIN;
|
||||
|
||||
@@ -28,23 +28,8 @@ include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
if (MSVC OR BORLAND)
|
||||
add_definitions( -DSCL_BASE_DLL_IMPORTS )
|
||||
add_definitions( -DSCL_UTILS_DLL_EXPORTS )
|
||||
endif()
|
||||
|
||||
SCL_ADDLIB(steputils "${LIBSTEPUTILS_SRCS}" "base")
|
||||
|
||||
IF(MINGW)
|
||||
IF(MINGW OR MSVC OR BORLAND)
|
||||
TARGET_LINK_LIBRARIES(steputils shlwapi.lib)
|
||||
ENDIF(MINGW)
|
||||
|
||||
IF(MSVC OR BORLAND)
|
||||
TARGET_LINK_LIBRARIES(steputils shlwapi.lib)
|
||||
ENDIF()
|
||||
|
||||
if(APPLE)
|
||||
if(SCL_BUILD_SHARED_LIBS)
|
||||
set_target_properties(steputils PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
|
||||
endif(SCL_BUILD_SHARED_LIBS)
|
||||
endif(APPLE)
|
||||
|
||||
@@ -10,17 +10,12 @@ set(LIBEXPPP_SOURCES
|
||||
include_directories(
|
||||
${SCL_SOURCE_DIR}/include
|
||||
${SCL_SOURCE_DIR}/include/exppp
|
||||
${SCL_SOURCE_DIR}/src/base
|
||||
${SCL_SOURCE_DIR}/src/base
|
||||
)
|
||||
|
||||
if(MSVC OR BORLAND)
|
||||
add_definitions( -DSCL_EXPPP_DLL_EXPORTS )
|
||||
add_definitions( -DSCL_EXPRESS_DLL_IMPORTS )
|
||||
add_definitions( -DSCL_BASE_DLL_IMPORTS )
|
||||
endif()
|
||||
|
||||
if(BORLAND)
|
||||
add_definitions( -D__STDC__ )
|
||||
add_definitions( -D__STDC__ )
|
||||
endif()
|
||||
|
||||
SCL_ADDLIB(libexppp "${LIBEXPPP_SOURCES}" "express base")
|
||||
@@ -30,8 +25,3 @@ endif(SCL_BUILD_SHARED_LIBS)
|
||||
|
||||
#SCL_ADDEXEC(exppp "${EXPPP_SOURCES}" "libexppp express")
|
||||
|
||||
if(APPLE)
|
||||
if(SCL_BUILD_SHARED_LIBS)
|
||||
set_target_properties(libexppp PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
|
||||
endif(SCL_BUILD_SHARED_LIBS)
|
||||
endif(APPLE)
|
||||
|
||||
@@ -80,21 +80,9 @@ add_definitions( -DYY_NO_UNISTD_H )
|
||||
endif()
|
||||
|
||||
if(BORLAND)
|
||||
add_definitions( -D__STDC__ )
|
||||
add_definitions( -DSCL_BASE_DLL_IMPORTS )
|
||||
add_definitions( -D__STDC__ )
|
||||
endif()
|
||||
|
||||
SCL_ADDLIB(express "${EXPRESS_SOURCES}" "base")
|
||||
|
||||
if(APPLE)
|
||||
if(SCL_BUILD_SHARED_LIBS)
|
||||
set_target_properties(express PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
|
||||
endif(SCL_BUILD_SHARED_LIBS)
|
||||
endif(APPLE)
|
||||
|
||||
SCL_ADDEXEC("check-express" "${CHECK_EXPRESS_SOURCES} ${CHECK_EXPRESS_EXTRA_SOURCES}" express)
|
||||
|
||||
if(MSVC OR BORLAND)
|
||||
set_target_properties(express PROPERTIES COMPILE_DEFINITIONS SCL_EXPRESS_DLL_EXPORTS)
|
||||
set_target_properties("check-express" PROPERTIES COMPILE_DEFINITIONS SCL_EXPRESS_DLL_IMPORTS)
|
||||
endif()
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ char EXPRESSgetopt_options[256] = "Bbd:e:i:w:p:u:l:nrvz";
|
||||
int no_need_to_work = 0; /* TRUE if we can exit gracefully without doing any work */
|
||||
|
||||
void print_fedex_version( void ) {
|
||||
fprintf( stderr, "Build info for %s: %s\nhttp://github.com/mpictor/StepClassLibrary\n", EXPRESSprogram_name, scl_version() );
|
||||
fprintf( stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode\n", EXPRESSprogram_name, scl_version() );
|
||||
no_need_to_work = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,49 @@ void SCOPE_get_entities( Scope scope, Linked_List result ) {
|
||||
}
|
||||
}
|
||||
|
||||
/** SCOPE_get_functions
|
||||
* \sa SCOPEget_functions
|
||||
*/
|
||||
void SCOPE_get_functions( Scope scope, Linked_List result ) {
|
||||
DictionaryEntry de;
|
||||
Generic x;
|
||||
|
||||
DICTdo_type_init( scope->symbol_table, &de, OBJ_FUNCTION );
|
||||
while( 0 != ( x = DICTdo( &de ) ) ) {
|
||||
LISTadd_last( result, x );
|
||||
}
|
||||
}
|
||||
/** SCOPE_get_functions
|
||||
* \sa SCOPEget_functions
|
||||
*/
|
||||
Linked_List SCOPEget_functions( Scope scope ) {
|
||||
Linked_List result = LISTcreate();
|
||||
SCOPE_get_functions( scope, result );
|
||||
return( result );
|
||||
}
|
||||
|
||||
/** SCOPE_get_rules
|
||||
* \sa SCOPEget_rules
|
||||
*/
|
||||
void SCOPE_get_rules( Scope scope, Linked_List result ) {
|
||||
DictionaryEntry de;
|
||||
Generic x;
|
||||
|
||||
DICTdo_type_init( scope->symbol_table, &de, OBJ_RULE );
|
||||
while( 0 != ( x = DICTdo( &de ) ) ) {
|
||||
LISTadd_last( result, x );
|
||||
}
|
||||
}
|
||||
/** SCOPE_get_functions
|
||||
* \sa SCOPEget_functions
|
||||
*/
|
||||
Linked_List SCOPEget_rules( Scope scope ) {
|
||||
Linked_List result = LISTcreate();
|
||||
SCOPE_get_rules( scope, result );
|
||||
return( result );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
** \param scope scope to examine
|
||||
** \return entities defined locally
|
||||
|
||||
@@ -29,12 +29,7 @@ include_directories(
|
||||
)
|
||||
|
||||
IF(MSVC OR BORLAND)
|
||||
set(fedex_plus_EXTRA_SOURCES
|
||||
xgetopt.cc
|
||||
)
|
||||
add_definitions( -DSCL_EXPRESS_DLL_IMPORTS )
|
||||
add_definitions( -DSCL_EXPPP_DLL_IMPORTS )
|
||||
add_definitions( -DSCL_BASE_DLL_IMPORTS )
|
||||
set(fedex_plus_EXTRA_SOURCES xgetopt.cc )
|
||||
ENDIF()
|
||||
|
||||
IF ("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
|
||||
|
||||
@@ -1950,7 +1950,7 @@ void AGGRprint_init( FILES* files, const Type t, const char* var_name, const cha
|
||||
ClassName( t->superscope->symbol.name ), aggr_name );
|
||||
fprintf( files->helpers, "inline SDAI_Integer getBound1_%s__%s( SDAI_Application_instance* this_ptr ) {\n",
|
||||
ClassName( t->superscope->symbol.name ), aggr_name );
|
||||
fprintf( files->helpers, " return ( (%s *) this_ptr)->%s_();\n};\n",
|
||||
fprintf( files->helpers, " return ( (%s *) this_ptr)->%s_();\n}\n",
|
||||
ClassName( t->superscope->symbol.name ), TYPEget_body( t )->lower->e.op2->symbol.name );
|
||||
}
|
||||
}
|
||||
@@ -1969,7 +1969,7 @@ void AGGRprint_init( FILES* files, const Type t, const char* var_name, const cha
|
||||
ClassName( t->superscope->symbol.name ), aggr_name );
|
||||
fprintf( files->helpers, "inline SDAI_Integer getBound2_%s__%s( SDAI_Application_instance* this_ptr ) {\n",
|
||||
ClassName( t->superscope->symbol.name ), aggr_name );
|
||||
fprintf( files->helpers, " return ( (%s *) this_ptr)->%s_();\n};\n",
|
||||
fprintf( files->helpers, " return ( (%s *) this_ptr)->%s_();\n}\n",
|
||||
ClassName( t->superscope->symbol.name ), TYPEget_body( t )->upper->e.op2->symbol.name );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +103,8 @@ FILE * FILEcreate( const char * );
|
||||
void FILEclose( FILE * );
|
||||
const char * ClassName( const char * );
|
||||
const char * ENTITYget_classname( Entity );
|
||||
void FUNCPrint( Function, FILES *, Schema );
|
||||
void RULEPrint( Rule, FILES *, Schema );
|
||||
void ENTITYPrint( Entity, FILES *, Schema );
|
||||
const char * StrToConstant( const char * );
|
||||
void TYPEselect_print( Type, FILES *, Schema );
|
||||
|
||||
@@ -4,7 +4,7 @@ include_directories(
|
||||
${SCL_SOURCE_DIR}/include
|
||||
${SCL_SOURCE_DIR}/include/exppp
|
||||
${SCL_SOURCE_DIR}/include/express
|
||||
${SCL_SOURCE_DIR}/src/base
|
||||
${SCL_SOURCE_DIR}/src/base
|
||||
${SCL_SOURCE_DIR}/src/fedex_plus
|
||||
)
|
||||
|
||||
@@ -14,9 +14,6 @@ IF(MSVC)
|
||||
set(fedex_plus_MSVC_SOURCES
|
||||
${SCL_SOURCE_DIR}/src/fedex_plus/xgetopt.cc
|
||||
)
|
||||
add_definitions( -DSCL_BASE_DLL_IMPORTS )
|
||||
add_definitions( -DSCL_EXPRESS_DLL_IMPORTS )
|
||||
add_definitions( -DSCL_EXPPP_DLL_IMPORTS )
|
||||
ENDIF(MSVC)
|
||||
|
||||
set(fedex_python_SOURCES
|
||||
|
||||
@@ -1,19 +1,28 @@
|
||||
# This file was generated by fedex_python. You probably don't want to edit
|
||||
# it since your modifications will be lost if fedex_plus is used to
|
||||
# regenerate it.
|
||||
import sys
|
||||
|
||||
from SCL.SCLBase import *
|
||||
from SCL.SimpleDataTypes import *
|
||||
from SCL.ConstructedDataTypes import *
|
||||
from SCL.AggregationDataTypes import *
|
||||
from SCL.TypeChecker import check_type
|
||||
from SCL.Expr import *
|
||||
maths_number = NUMBER
|
||||
# SELECT TYPE atom_based_value_
|
||||
if (not 'maths_number' in globals().keys()):
|
||||
maths_number = 'maths_number'
|
||||
if (not 'atom_based_tuple' in globals().keys()):
|
||||
atom_based_tuple = 'atom_based_tuple'
|
||||
from SCL.Builtin import *
|
||||
from SCL.Rules import *
|
||||
|
||||
schema_name = 'gcc_incomplete_type'
|
||||
|
||||
schema_scope = sys.modules[__name__]
|
||||
|
||||
# Defined datatype maths_number
|
||||
class maths_number(NUMBER):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
# SELECT TYPE atom_based_value
|
||||
atom_based_value = SELECT(
|
||||
'maths_number',
|
||||
'atom_based_tuple')
|
||||
atom_based_tuple = LIST(0,None,'atom_based_value')
|
||||
'atom_based_tuple',
|
||||
scope = schema_scope)
|
||||
atom_based_tuple = LIST(0,None,'atom_based_value', scope = schema_scope)
|
||||
|
||||
@@ -1,22 +1,31 @@
|
||||
# This file was generated by fedex_python. You probably don't want to edit
|
||||
# it since your modifications will be lost if fedex_plus is used to
|
||||
# regenerate it.
|
||||
import sys
|
||||
|
||||
from SCL.SCLBase import *
|
||||
from SCL.SimpleDataTypes import *
|
||||
from SCL.ConstructedDataTypes import *
|
||||
from SCL.AggregationDataTypes import *
|
||||
from SCL.TypeChecker import check_type
|
||||
from SCL.Expr import *
|
||||
common_datum_list = LIST(1,None,'datum_reference_element')
|
||||
label = STRING
|
||||
# SELECT TYPE datum_or_common_datum_
|
||||
if (not 'common_datum_list' in globals().keys()):
|
||||
common_datum_list = 'common_datum_list'
|
||||
if (not 'datum' in globals().keys()):
|
||||
datum = 'datum'
|
||||
from SCL.Builtin import *
|
||||
from SCL.Rules import *
|
||||
|
||||
schema_name = 'index_attribute'
|
||||
|
||||
schema_scope = sys.modules[__name__]
|
||||
|
||||
common_datum_list = LIST(1,None,'datum_reference_element', scope = schema_scope)
|
||||
# Defined datatype label
|
||||
class label(STRING):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
# SELECT TYPE datum_or_common_datum
|
||||
datum_or_common_datum = SELECT(
|
||||
'common_datum_list',
|
||||
'datum')
|
||||
'datum',
|
||||
scope = schema_scope)
|
||||
|
||||
####################
|
||||
# ENTITY shape_aspect #
|
||||
@@ -25,7 +34,7 @@ class shape_aspect(BaseEntityClass):
|
||||
'''Entity shape_aspect definition.
|
||||
|
||||
:param name
|
||||
:type name:STRING
|
||||
:type name:label
|
||||
|
||||
:param of_shape
|
||||
:type of_shape:product_definition_shape
|
||||
@@ -42,8 +51,8 @@ class shape_aspect(BaseEntityClass):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument name is mantatory and can not be set to None')
|
||||
if not check_type(value,STRING):
|
||||
self._name = STRING(value)
|
||||
if not check_type(value,label):
|
||||
self._name = label(value)
|
||||
else:
|
||||
self._name = value
|
||||
return property(**locals())
|
||||
@@ -61,6 +70,13 @@ class shape_aspect(BaseEntityClass):
|
||||
else:
|
||||
self._of_shape = value
|
||||
return property(**locals())
|
||||
def wr1(self):
|
||||
eval_wr1_wr = (SIZEOF(USEDIN(self,'INDEX_ATTRIBUTE.' + 'ID_ATTRIBUTE.IDENTIFIED_ITEM')) <= 1)
|
||||
if not eval_wr1_wr:
|
||||
raise AssertionError('Rule wr1 violated')
|
||||
else:
|
||||
return eval_wr1_wr
|
||||
|
||||
|
||||
####################
|
||||
# ENTITY general_datum_reference #
|
||||
@@ -71,8 +87,8 @@ class general_datum_reference(shape_aspect):
|
||||
:param base
|
||||
:type base:datum_or_common_datum
|
||||
'''
|
||||
def __init__( self , shape_aspect__name , shape_aspect__of_shape , base, ):
|
||||
shape_aspect.__init__(self , shape_aspect__name , shape_aspect__of_shape , )
|
||||
def __init__( self , inherited0__name , inherited1__of_shape , base, ):
|
||||
shape_aspect.__init__(self , inherited0__name , inherited1__of_shape , )
|
||||
self.base = base
|
||||
|
||||
@apply
|
||||
@@ -88,6 +104,13 @@ class general_datum_reference(shape_aspect):
|
||||
else:
|
||||
self._base = value
|
||||
return property(**locals())
|
||||
def wr1(self):
|
||||
eval_wr1_wr = (( not ('INDEX_ATTRIBUTE.COMMON_DATUM_LIST' == TYPEOF(self.base))) or (self.self.shape_aspect.self.of_shape == self.base[1].self.shape_aspect.self.of_shape))
|
||||
if not eval_wr1_wr:
|
||||
raise AssertionError('Rule wr1 violated')
|
||||
else:
|
||||
return eval_wr1_wr
|
||||
|
||||
|
||||
####################
|
||||
# ENTITY product_definition_shape #
|
||||
@@ -104,8 +127,8 @@ class product_definition_shape(BaseEntityClass):
|
||||
class datum_reference_element(general_datum_reference):
|
||||
'''Entity datum_reference_element definition.
|
||||
'''
|
||||
def __init__( self , general_datum_reference__base , ):
|
||||
general_datum_reference.__init__(self , general_datum_reference__base , )
|
||||
def __init__( self , inherited0__name , inherited1__of_shape , inherited2__base , ):
|
||||
general_datum_reference.__init__(self , inherited0__name , inherited1__of_shape , inherited2__base , )
|
||||
|
||||
####################
|
||||
# ENTITY datum #
|
||||
@@ -113,5 +136,5 @@ class datum_reference_element(general_datum_reference):
|
||||
class datum(shape_aspect):
|
||||
'''Entity datum definition.
|
||||
'''
|
||||
def __init__( self , shape_aspect__name , shape_aspect__of_shape , ):
|
||||
shape_aspect.__init__(self , shape_aspect__name , shape_aspect__of_shape , )
|
||||
def __init__( self , inherited0__name , inherited1__of_shape , ):
|
||||
shape_aspect.__init__(self , inherited0__name , inherited1__of_shape , )
|
||||
|
||||
@@ -1,32 +1,71 @@
|
||||
# This file was generated by fedex_python. You probably don't want to edit
|
||||
# it since your modifications will be lost if fedex_plus is used to
|
||||
# regenerate it.
|
||||
import sys
|
||||
|
||||
from SCL.SCLBase import *
|
||||
from SCL.SimpleDataTypes import *
|
||||
from SCL.ConstructedDataTypes import *
|
||||
from SCL.AggregationDataTypes import *
|
||||
from SCL.TypeChecker import check_type
|
||||
from SCL.Expr import *
|
||||
text = STRING
|
||||
representation_context = STRING
|
||||
identifier = STRING
|
||||
shape_definition = STRING
|
||||
transformation = STRING
|
||||
representation_item = STRING
|
||||
characterized_product_definition = STRING
|
||||
# SELECT TYPE characterized_definition_
|
||||
if (not 'characterized_object' in globals().keys()):
|
||||
characterized_object = 'characterized_object'
|
||||
if (not 'characterized_product_definition' in globals().keys()):
|
||||
characterized_product_definition = 'characterized_product_definition'
|
||||
if (not 'shape_definition' in globals().keys()):
|
||||
shape_definition = 'shape_definition'
|
||||
from SCL.Builtin import *
|
||||
from SCL.Rules import *
|
||||
|
||||
schema_name = 'multiple_rep'
|
||||
|
||||
schema_scope = sys.modules[__name__]
|
||||
|
||||
# Defined datatype text
|
||||
class text(STRING):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
# Defined datatype representation_context
|
||||
class representation_context(STRING):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
# Defined datatype identifier
|
||||
class identifier(STRING):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
# Defined datatype shape_definition
|
||||
class shape_definition(STRING):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
# Defined datatype transformation
|
||||
class transformation(STRING):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
# Defined datatype representation_item
|
||||
class representation_item(STRING):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
# Defined datatype characterized_product_definition
|
||||
class characterized_product_definition(STRING):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
# SELECT TYPE characterized_definition
|
||||
characterized_definition = SELECT(
|
||||
'characterized_object',
|
||||
'characterized_product_definition',
|
||||
'shape_definition')
|
||||
label = STRING
|
||||
characterized_object = STRING
|
||||
'shape_definition',
|
||||
scope = schema_scope)
|
||||
# Defined datatype label
|
||||
class label(STRING):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
# Defined datatype characterized_object
|
||||
class characterized_object(STRING):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
|
||||
####################
|
||||
# ENTITY representation_relationship #
|
||||
@@ -35,7 +74,7 @@ class representation_relationship(BaseEntityClass):
|
||||
'''Entity representation_relationship definition.
|
||||
|
||||
:param name
|
||||
:type name:STRING
|
||||
:type name:label
|
||||
|
||||
:param rep_1
|
||||
:type rep_1:representation
|
||||
@@ -56,8 +95,8 @@ class representation_relationship(BaseEntityClass):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument name is mantatory and can not be set to None')
|
||||
if not check_type(value,STRING):
|
||||
self._name = STRING(value)
|
||||
if not check_type(value,label):
|
||||
self._name = label(value)
|
||||
else:
|
||||
self._name = value
|
||||
return property(**locals())
|
||||
@@ -96,8 +135,15 @@ class representation_relationship(BaseEntityClass):
|
||||
class shape_representation_relationship(representation_relationship):
|
||||
'''Entity shape_representation_relationship definition.
|
||||
'''
|
||||
def __init__( self , representation_relationship__name , representation_relationship__rep_1 , representation_relationship__rep_2 , ):
|
||||
representation_relationship.__init__(self , representation_relationship__name , representation_relationship__rep_1 , representation_relationship__rep_2 , )
|
||||
def __init__( self , inherited0__name , inherited1__rep_1 , inherited2__rep_2 , ):
|
||||
representation_relationship.__init__(self , inherited0__name , inherited1__rep_1 , inherited2__rep_2 , )
|
||||
def wr1(self):
|
||||
eval_wr1_wr = ('MULTIPLE_REP.SHAPE_REPRESENTATION' == (TYPEOF(self.self.representation_relationship.self.rep_1) + TYPEOF(self.self.representation_relationship.self.rep_2)))
|
||||
if not eval_wr1_wr:
|
||||
raise AssertionError('Rule wr1 violated')
|
||||
else:
|
||||
return eval_wr1_wr
|
||||
|
||||
|
||||
####################
|
||||
# ENTITY representation #
|
||||
@@ -106,13 +152,13 @@ class representation(BaseEntityClass):
|
||||
'''Entity representation definition.
|
||||
|
||||
:param name
|
||||
:type name:STRING
|
||||
:type name:label
|
||||
|
||||
:param items
|
||||
:type items:SET(1,None,'STRING')
|
||||
:type items:SET(1,None,'STRING', scope = schema_scope)
|
||||
|
||||
:param context_of_items
|
||||
:type context_of_items:STRING
|
||||
:type context_of_items:representation_context
|
||||
'''
|
||||
def __init__( self , name,items,context_of_items, ):
|
||||
self.name = name
|
||||
@@ -127,8 +173,8 @@ class representation(BaseEntityClass):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument name is mantatory and can not be set to None')
|
||||
if not check_type(value,STRING):
|
||||
self._name = STRING(value)
|
||||
if not check_type(value,label):
|
||||
self._name = label(value)
|
||||
else:
|
||||
self._name = value
|
||||
return property(**locals())
|
||||
@@ -141,7 +187,7 @@ class representation(BaseEntityClass):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument items is mantatory and can not be set to None')
|
||||
if not check_type(value,SET(1,None,'STRING')):
|
||||
if not check_type(value,SET(1,None,'STRING', scope = schema_scope)):
|
||||
self._items = SET(value)
|
||||
else:
|
||||
self._items = value
|
||||
@@ -155,11 +201,25 @@ class representation(BaseEntityClass):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument context_of_items is mantatory and can not be set to None')
|
||||
if not check_type(value,STRING):
|
||||
self._context_of_items = STRING(value)
|
||||
if not check_type(value,representation_context):
|
||||
self._context_of_items = representation_context(value)
|
||||
else:
|
||||
self._context_of_items = value
|
||||
return property(**locals())
|
||||
def wr1(self):
|
||||
eval_wr1_wr = (SIZEOF(USEDIN(self,'MULTIPLE_REP.' + 'ID_ATTRIBUTE.IDENTIFIED_ITEM')) <= 1)
|
||||
if not eval_wr1_wr:
|
||||
raise AssertionError('Rule wr1 violated')
|
||||
else:
|
||||
return eval_wr1_wr
|
||||
|
||||
def wr2(self):
|
||||
eval_wr2_wr = (SIZEOF(USEDIN(self,'MULTIPLE_REP.' + 'DESCRIPTION_ATTRIBUTE.DESCRIBED_ITEM')) <= 1)
|
||||
if not eval_wr2_wr:
|
||||
raise AssertionError('Rule wr2 violated')
|
||||
else:
|
||||
return eval_wr2_wr
|
||||
|
||||
|
||||
####################
|
||||
# ENTITY property_definition #
|
||||
@@ -168,7 +228,7 @@ class property_definition(BaseEntityClass):
|
||||
'''Entity property_definition definition.
|
||||
|
||||
:param name
|
||||
:type name:STRING
|
||||
:type name:label
|
||||
|
||||
:param definition
|
||||
:type definition:characterized_definition
|
||||
@@ -185,8 +245,8 @@ class property_definition(BaseEntityClass):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument name is mantatory and can not be set to None')
|
||||
if not check_type(value,STRING):
|
||||
self._name = STRING(value)
|
||||
if not check_type(value,label):
|
||||
self._name = label(value)
|
||||
else:
|
||||
self._name = value
|
||||
return property(**locals())
|
||||
@@ -204,6 +264,13 @@ class property_definition(BaseEntityClass):
|
||||
else:
|
||||
self._definition = value
|
||||
return property(**locals())
|
||||
def wr1(self):
|
||||
eval_wr1_wr = (SIZEOF(USEDIN(self,'MULTIPLE_REP.' + 'ID_ATTRIBUTE.IDENTIFIED_ITEM')) <= 1)
|
||||
if not eval_wr1_wr:
|
||||
raise AssertionError('Rule wr1 violated')
|
||||
else:
|
||||
return eval_wr1_wr
|
||||
|
||||
|
||||
####################
|
||||
# ENTITY context_dependent_shape_representation #
|
||||
@@ -230,6 +297,20 @@ class context_dependent_shape_representation(BaseEntityClass):
|
||||
else:
|
||||
self._representation_relation = value
|
||||
return property(**locals())
|
||||
def wr2(self):
|
||||
eval_wr2_wr = (SIZEOF(USEDIN(self,'MULTIPLE_REP.' + 'DESCRIPTION_ATTRIBUTE.DESCRIBED_ITEM')) <= 1)
|
||||
if not eval_wr2_wr:
|
||||
raise AssertionError('Rule wr2 violated')
|
||||
else:
|
||||
return eval_wr2_wr
|
||||
|
||||
def wr3(self):
|
||||
eval_wr3_wr = (SIZEOF(USEDIN(self,'MULTIPLE_REP.' + 'NAME_ATTRIBUTE.NAMED_ITEM')) <= 1)
|
||||
if not eval_wr3_wr:
|
||||
raise AssertionError('Rule wr3 violated')
|
||||
else:
|
||||
return eval_wr3_wr
|
||||
|
||||
|
||||
####################
|
||||
# ENTITY definitional_representation_relationship #
|
||||
@@ -237,8 +318,8 @@ class context_dependent_shape_representation(BaseEntityClass):
|
||||
class definitional_representation_relationship(representation_relationship):
|
||||
'''Entity definitional_representation_relationship definition.
|
||||
'''
|
||||
def __init__( self , representation_relationship__name , representation_relationship__rep_1 , representation_relationship__rep_2 , ):
|
||||
representation_relationship.__init__(self , representation_relationship__name , representation_relationship__rep_1 , representation_relationship__rep_2 , )
|
||||
def __init__( self , inherited0__name , inherited1__rep_1 , inherited2__rep_2 , ):
|
||||
representation_relationship.__init__(self , inherited0__name , inherited1__rep_1 , inherited2__rep_2 , )
|
||||
|
||||
####################
|
||||
# ENTITY component_2d_location #
|
||||
@@ -249,16 +330,24 @@ class component_2d_location(context_dependent_shape_representation,shape_represe
|
||||
:param context_dependent_shape_representation_representation_relation
|
||||
:type context_dependent_shape_representation_representation_relation:component_2d_location
|
||||
'''
|
||||
def __init__( self , context_dependent_shape_representation__representation_relation , ):
|
||||
context_dependent_shape_representation.__init__(self , context_dependent_shape_representation__representation_relation , )
|
||||
shape_representation_relationship.__init__(self , )
|
||||
definitional_representation_relationship.__init__(self , )
|
||||
def __init__( self , inherited0__representation_relation , inherited1__name , inherited2__rep_1 , inherited3__rep_2 , inherited4__name , inherited5__rep_1 , inherited6__rep_2 , ):
|
||||
context_dependent_shape_representation.__init__(self , inherited0__representation_relation , )
|
||||
shape_representation_relationship.__init__(self , inherited1__name , inherited2__rep_1 , inherited3__rep_2 , )
|
||||
definitional_representation_relationship.__init__(self , inherited4__name , inherited5__rep_1 , inherited6__rep_2 , )
|
||||
|
||||
@apply
|
||||
def context_dependent_shape_representation_representation_relation():
|
||||
def fget( self ):
|
||||
return EvalDerivedAttribute(self,'''SELF''')
|
||||
attribute_eval = self
|
||||
return attribute_eval
|
||||
def fset( self, value ):
|
||||
# DERIVED argument
|
||||
raise AssertionError('Argument context_dependent_shape_representation_representation_relation is DERIVED. It is computed and can not be set to any value')
|
||||
return property(**locals())
|
||||
def wr1(self):
|
||||
eval_wr1_wr = (self.self.representation_relationship.self.name == 'component 2d location')
|
||||
if not eval_wr1_wr:
|
||||
raise AssertionError('Rule wr1 violated')
|
||||
else:
|
||||
return eval_wr1_wr
|
||||
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
# This file was generated by fedex_python. You probably don't want to edit
|
||||
# it since your modifications will be lost if fedex_plus is used to
|
||||
# regenerate it.
|
||||
import sys
|
||||
|
||||
from SCL.SCLBase import *
|
||||
from SCL.SimpleDataTypes import *
|
||||
from SCL.ConstructedDataTypes import *
|
||||
from SCL.AggregationDataTypes import *
|
||||
from SCL.TypeChecker import check_type
|
||||
from SCL.Expr import *
|
||||
from SCL.Builtin import *
|
||||
from SCL.Rules import *
|
||||
|
||||
schema_name = 'test_array'
|
||||
|
||||
schema_scope = sys.modules[__name__]
|
||||
|
||||
|
||||
####################
|
||||
# ENTITY point #
|
||||
@@ -15,7 +23,7 @@ class point(BaseEntityClass):
|
||||
'''Entity point definition.
|
||||
|
||||
:param coords
|
||||
:type coords:ARRAY(1,3,'REAL')
|
||||
:type coords:ARRAY(1,3,'REAL', scope = schema_scope)
|
||||
'''
|
||||
def __init__( self , coords, ):
|
||||
self.coords = coords
|
||||
@@ -28,7 +36,7 @@ class point(BaseEntityClass):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument coords is mantatory and can not be set to None')
|
||||
if not check_type(value,ARRAY(1,3,'REAL')):
|
||||
if not check_type(value,ARRAY(1,3,'REAL', scope = schema_scope)):
|
||||
self._coords = ARRAY(value)
|
||||
else:
|
||||
self._coords = value
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
# This file was generated by fedex_python. You probably don't want to edit
|
||||
# it since your modifications will be lost if fedex_plus is used to
|
||||
# regenerate it.
|
||||
import sys
|
||||
|
||||
from SCL.SCLBase import *
|
||||
from SCL.SimpleDataTypes import *
|
||||
from SCL.ConstructedDataTypes import *
|
||||
from SCL.AggregationDataTypes import *
|
||||
from SCL.TypeChecker import check_type
|
||||
from SCL.Builtin import *
|
||||
from SCL.Rules import *
|
||||
|
||||
schema_name = 'test_array_of_array_of_simple_types'
|
||||
|
||||
schema_scope = sys.modules[__name__]
|
||||
|
||||
|
||||
####################
|
||||
# ENTITY transformation #
|
||||
####################
|
||||
class transformation(BaseEntityClass):
|
||||
'''Entity transformation definition.
|
||||
|
||||
:param rotation
|
||||
:type rotation:ARRAY(1,3,ARRAY(1,3,'REAL', scope = schema_scope))
|
||||
'''
|
||||
def __init__( self , rotation, ):
|
||||
self.rotation = rotation
|
||||
|
||||
@apply
|
||||
def rotation():
|
||||
def fget( self ):
|
||||
return self._rotation
|
||||
def fset( self, value ):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument rotation is mantatory and can not be set to None')
|
||||
if not check_type(value,ARRAY(1,3,ARRAY(1,3,'REAL', scope = schema_scope))):
|
||||
self._rotation = ARRAY(value)
|
||||
else:
|
||||
self._rotation = value
|
||||
return property(**locals())
|
||||
@@ -1,12 +1,20 @@
|
||||
# This file was generated by fedex_python. You probably don't want to edit
|
||||
# it since your modifications will be lost if fedex_plus is used to
|
||||
# regenerate it.
|
||||
import sys
|
||||
|
||||
from SCL.SCLBase import *
|
||||
from SCL.SimpleDataTypes import *
|
||||
from SCL.ConstructedDataTypes import *
|
||||
from SCL.AggregationDataTypes import *
|
||||
from SCL.TypeChecker import check_type
|
||||
from SCL.Expr import *
|
||||
from SCL.Builtin import *
|
||||
from SCL.Rules import *
|
||||
|
||||
schema_name = 'test_array_of_simple_types'
|
||||
|
||||
schema_scope = sys.modules[__name__]
|
||||
|
||||
|
||||
####################
|
||||
# ENTITY point #
|
||||
@@ -15,13 +23,13 @@ class point(BaseEntityClass):
|
||||
'''Entity point definition.
|
||||
|
||||
:param arr_real
|
||||
:type arr_real:ARRAY(1,3,'REAL')
|
||||
:type arr_real:ARRAY(1,3,'REAL', scope = schema_scope)
|
||||
|
||||
:param arr_string
|
||||
:type arr_string:ARRAY(1,3,'STRING')
|
||||
:type arr_string:ARRAY(1,3,'STRING', scope = schema_scope)
|
||||
|
||||
:param arr_integer
|
||||
:type arr_integer:ARRAY(1,None,'INTEGER')
|
||||
:type arr_integer:ARRAY(1,None,'INTEGER', scope = schema_scope)
|
||||
'''
|
||||
def __init__( self , arr_real,arr_string,arr_integer, ):
|
||||
self.arr_real = arr_real
|
||||
@@ -36,7 +44,7 @@ class point(BaseEntityClass):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument arr_real is mantatory and can not be set to None')
|
||||
if not check_type(value,ARRAY(1,3,'REAL')):
|
||||
if not check_type(value,ARRAY(1,3,'REAL', scope = schema_scope)):
|
||||
self._arr_real = ARRAY(value)
|
||||
else:
|
||||
self._arr_real = value
|
||||
@@ -50,7 +58,7 @@ class point(BaseEntityClass):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument arr_string is mantatory and can not be set to None')
|
||||
if not check_type(value,ARRAY(1,3,'STRING')):
|
||||
if not check_type(value,ARRAY(1,3,'STRING', scope = schema_scope)):
|
||||
self._arr_string = ARRAY(value)
|
||||
else:
|
||||
self._arr_string = value
|
||||
@@ -64,7 +72,7 @@ class point(BaseEntityClass):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument arr_integer is mantatory and can not be set to None')
|
||||
if not check_type(value,ARRAY(1,None,'INTEGER')):
|
||||
if not check_type(value,ARRAY(1,None,'INTEGER', scope = schema_scope)):
|
||||
self._arr_integer = ARRAY(value)
|
||||
else:
|
||||
self._arr_integer = value
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
# This file was generated by fedex_python. You probably don't want to edit
|
||||
# it since your modifications will be lost if fedex_plus is used to
|
||||
# regenerate it.
|
||||
import sys
|
||||
|
||||
from SCL.SCLBase import *
|
||||
from SCL.SimpleDataTypes import *
|
||||
from SCL.ConstructedDataTypes import *
|
||||
from SCL.AggregationDataTypes import *
|
||||
from SCL.TypeChecker import check_type
|
||||
from SCL.Expr import *
|
||||
from SCL.Builtin import *
|
||||
from SCL.Rules import *
|
||||
|
||||
schema_name = 'test_derived_attribute'
|
||||
|
||||
schema_scope = sys.modules[__name__]
|
||||
|
||||
|
||||
####################
|
||||
# ENTITY vector #
|
||||
@@ -88,7 +96,8 @@ class circle(BaseEntityClass):
|
||||
@apply
|
||||
def area():
|
||||
def fget( self ):
|
||||
return EvalDerivedAttribute(self,'''PI * (radius ** 2)''')
|
||||
attribute_eval = ( PI * (self.radius ** 2))
|
||||
return attribute_eval
|
||||
def fset( self, value ):
|
||||
# DERIVED argument
|
||||
raise AssertionError('Argument area is DERIVED. It is computed and can not be set to any value')
|
||||
@@ -97,7 +106,8 @@ class circle(BaseEntityClass):
|
||||
@apply
|
||||
def perimeter():
|
||||
def fget( self ):
|
||||
return EvalDerivedAttribute(self,'''2 * PI * radius''')
|
||||
attribute_eval = ((2 * PI ) * self.radius)
|
||||
return attribute_eval
|
||||
def fset( self, value ):
|
||||
# DERIVED argument
|
||||
raise AssertionError('Argument perimeter is DERIVED. It is computed and can not be set to any value')
|
||||
|
||||
@@ -0,0 +1,322 @@
|
||||
# This file was generated by fedex_python. You probably don't want to edit
|
||||
# it since your modifications will be lost if fedex_plus is used to
|
||||
# regenerate it.
|
||||
import sys
|
||||
|
||||
from SCL.SCLBase import *
|
||||
from SCL.SimpleDataTypes import *
|
||||
from SCL.ConstructedDataTypes import *
|
||||
from SCL.AggregationDataTypes import *
|
||||
from SCL.TypeChecker import check_type
|
||||
from SCL.Builtin import *
|
||||
from SCL.Rules import *
|
||||
|
||||
schema_name = 'test_entity_where_rule'
|
||||
|
||||
schema_scope = sys.modules[__name__]
|
||||
|
||||
# Defined datatype label
|
||||
class label(STRING):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
|
||||
####################
|
||||
# ENTITY unit_vector #
|
||||
####################
|
||||
class unit_vector(BaseEntityClass):
|
||||
'''Entity unit_vector definition.
|
||||
|
||||
:param a
|
||||
:type a:REAL
|
||||
|
||||
:param b
|
||||
:type b:REAL
|
||||
|
||||
:param c
|
||||
:type c:REAL
|
||||
'''
|
||||
def __init__( self , a,b,c, ):
|
||||
self.a = a
|
||||
self.b = b
|
||||
self.c = c
|
||||
|
||||
@apply
|
||||
def a():
|
||||
def fget( self ):
|
||||
return self._a
|
||||
def fset( self, value ):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument a is mantatory and can not be set to None')
|
||||
if not check_type(value,REAL):
|
||||
self._a = REAL(value)
|
||||
else:
|
||||
self._a = value
|
||||
return property(**locals())
|
||||
|
||||
@apply
|
||||
def b():
|
||||
def fget( self ):
|
||||
return self._b
|
||||
def fset( self, value ):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument b is mantatory and can not be set to None')
|
||||
if not check_type(value,REAL):
|
||||
self._b = REAL(value)
|
||||
else:
|
||||
self._b = value
|
||||
return property(**locals())
|
||||
|
||||
@apply
|
||||
def c():
|
||||
def fget( self ):
|
||||
return self._c
|
||||
def fset( self, value ):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument c is mantatory and can not be set to None')
|
||||
if not check_type(value,REAL):
|
||||
self._c = REAL(value)
|
||||
else:
|
||||
self._c = value
|
||||
return property(**locals())
|
||||
def length_1(self):
|
||||
eval_length_1_wr = ((((self.a ** 2) + (self.b ** 2)) + (self.c ** 2)) == 1)
|
||||
if not eval_length_1_wr:
|
||||
raise AssertionError('Rule length_1 violated')
|
||||
else:
|
||||
return eval_length_1_wr
|
||||
|
||||
|
||||
####################
|
||||
# ENTITY address #
|
||||
####################
|
||||
class address(BaseEntityClass):
|
||||
'''Entity address definition.
|
||||
|
||||
:param internal_location
|
||||
:type internal_location:label
|
||||
|
||||
:param street_number
|
||||
:type street_number:label
|
||||
|
||||
:param street
|
||||
:type street:label
|
||||
|
||||
:param postal_box
|
||||
:type postal_box:label
|
||||
|
||||
:param town
|
||||
:type town:label
|
||||
|
||||
:param region
|
||||
:type region:label
|
||||
|
||||
:param postal_code
|
||||
:type postal_code:label
|
||||
|
||||
:param country
|
||||
:type country:label
|
||||
|
||||
:param facsimile_number
|
||||
:type facsimile_number:label
|
||||
|
||||
:param telephone_number
|
||||
:type telephone_number:label
|
||||
|
||||
:param electronic_mail_address
|
||||
:type electronic_mail_address:label
|
||||
|
||||
:param telex_number
|
||||
:type telex_number:label
|
||||
'''
|
||||
def __init__( self , internal_location,street_number,street,postal_box,town,region,postal_code,country,facsimile_number,telephone_number,electronic_mail_address,telex_number, ):
|
||||
self.internal_location = internal_location
|
||||
self.street_number = street_number
|
||||
self.street = street
|
||||
self.postal_box = postal_box
|
||||
self.town = town
|
||||
self.region = region
|
||||
self.postal_code = postal_code
|
||||
self.country = country
|
||||
self.facsimile_number = facsimile_number
|
||||
self.telephone_number = telephone_number
|
||||
self.electronic_mail_address = electronic_mail_address
|
||||
self.telex_number = telex_number
|
||||
|
||||
@apply
|
||||
def internal_location():
|
||||
def fget( self ):
|
||||
return self._internal_location
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,label):
|
||||
self._internal_location = label(value)
|
||||
else:
|
||||
self._internal_location = value
|
||||
else:
|
||||
self._internal_location = value
|
||||
return property(**locals())
|
||||
|
||||
@apply
|
||||
def street_number():
|
||||
def fget( self ):
|
||||
return self._street_number
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,label):
|
||||
self._street_number = label(value)
|
||||
else:
|
||||
self._street_number = value
|
||||
else:
|
||||
self._street_number = value
|
||||
return property(**locals())
|
||||
|
||||
@apply
|
||||
def street():
|
||||
def fget( self ):
|
||||
return self._street
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,label):
|
||||
self._street = label(value)
|
||||
else:
|
||||
self._street = value
|
||||
else:
|
||||
self._street = value
|
||||
return property(**locals())
|
||||
|
||||
@apply
|
||||
def postal_box():
|
||||
def fget( self ):
|
||||
return self._postal_box
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,label):
|
||||
self._postal_box = label(value)
|
||||
else:
|
||||
self._postal_box = value
|
||||
else:
|
||||
self._postal_box = value
|
||||
return property(**locals())
|
||||
|
||||
@apply
|
||||
def town():
|
||||
def fget( self ):
|
||||
return self._town
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,label):
|
||||
self._town = label(value)
|
||||
else:
|
||||
self._town = value
|
||||
else:
|
||||
self._town = value
|
||||
return property(**locals())
|
||||
|
||||
@apply
|
||||
def region():
|
||||
def fget( self ):
|
||||
return self._region
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,label):
|
||||
self._region = label(value)
|
||||
else:
|
||||
self._region = value
|
||||
else:
|
||||
self._region = value
|
||||
return property(**locals())
|
||||
|
||||
@apply
|
||||
def postal_code():
|
||||
def fget( self ):
|
||||
return self._postal_code
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,label):
|
||||
self._postal_code = label(value)
|
||||
else:
|
||||
self._postal_code = value
|
||||
else:
|
||||
self._postal_code = value
|
||||
return property(**locals())
|
||||
|
||||
@apply
|
||||
def country():
|
||||
def fget( self ):
|
||||
return self._country
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,label):
|
||||
self._country = label(value)
|
||||
else:
|
||||
self._country = value
|
||||
else:
|
||||
self._country = value
|
||||
return property(**locals())
|
||||
|
||||
@apply
|
||||
def facsimile_number():
|
||||
def fget( self ):
|
||||
return self._facsimile_number
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,label):
|
||||
self._facsimile_number = label(value)
|
||||
else:
|
||||
self._facsimile_number = value
|
||||
else:
|
||||
self._facsimile_number = value
|
||||
return property(**locals())
|
||||
|
||||
@apply
|
||||
def telephone_number():
|
||||
def fget( self ):
|
||||
return self._telephone_number
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,label):
|
||||
self._telephone_number = label(value)
|
||||
else:
|
||||
self._telephone_number = value
|
||||
else:
|
||||
self._telephone_number = value
|
||||
return property(**locals())
|
||||
|
||||
@apply
|
||||
def electronic_mail_address():
|
||||
def fget( self ):
|
||||
return self._electronic_mail_address
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,label):
|
||||
self._electronic_mail_address = label(value)
|
||||
else:
|
||||
self._electronic_mail_address = value
|
||||
else:
|
||||
self._electronic_mail_address = value
|
||||
return property(**locals())
|
||||
|
||||
@apply
|
||||
def telex_number():
|
||||
def fget( self ):
|
||||
return self._telex_number
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,label):
|
||||
self._telex_number = label(value)
|
||||
else:
|
||||
self._telex_number = value
|
||||
else:
|
||||
self._telex_number = value
|
||||
return property(**locals())
|
||||
def wr1(self):
|
||||
eval_wr1_wr = (((((((((((EXISTS(self.internal_location) or EXISTS(self.street_number)) or EXISTS(self.street)) or EXISTS(self.postal_box)) or EXISTS(self.town)) or EXISTS(self.region)) or EXISTS(self.postal_code)) or EXISTS(self.country)) or EXISTS(self.facsimile_number)) or EXISTS(self.telephone_number)) or EXISTS(self.electronic_mail_address)) or EXISTS(self.telex_number))
|
||||
if not eval_wr1_wr:
|
||||
raise AssertionError('Rule wr1 violated')
|
||||
else:
|
||||
return eval_wr1_wr
|
||||
|
||||
@@ -1,22 +1,26 @@
|
||||
# This file was generated by fedex_python. You probably don't want to edit
|
||||
# it since your modifications will be lost if fedex_plus is used to
|
||||
# regenerate it.
|
||||
import sys
|
||||
|
||||
from SCL.SCLBase import *
|
||||
from SCL.SimpleDataTypes import *
|
||||
from SCL.ConstructedDataTypes import *
|
||||
from SCL.AggregationDataTypes import *
|
||||
from SCL.TypeChecker import check_type
|
||||
from SCL.Expr import *
|
||||
from SCL.Builtin import *
|
||||
from SCL.Rules import *
|
||||
|
||||
schema_name = 'test_enum_entity_name'
|
||||
|
||||
schema_scope = sys.modules[__name__]
|
||||
|
||||
|
||||
# ENUMERATION TYPE simple_datum_reference_modifier
|
||||
if (not 'line' in globals().keys()):
|
||||
line = 'line'
|
||||
if (not 'translation' in globals().keys()):
|
||||
translation = 'translation'
|
||||
simple_datum_reference_modifier = ENUMERATION(
|
||||
'line',
|
||||
'translation',
|
||||
)
|
||||
scope = schema_scope)
|
||||
|
||||
####################
|
||||
# ENTITY line #
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
# This file was generated by fedex_python. You probably don't want to edit
|
||||
# it since your modifications will be lost if fedex_plus is used to
|
||||
# regenerate it.
|
||||
import sys
|
||||
|
||||
from SCL.SCLBase import *
|
||||
from SCL.SimpleDataTypes import *
|
||||
from SCL.ConstructedDataTypes import *
|
||||
from SCL.AggregationDataTypes import *
|
||||
from SCL.TypeChecker import check_type
|
||||
from SCL.Expr import *
|
||||
from SCL.Builtin import *
|
||||
from SCL.Rules import *
|
||||
|
||||
schema_name = 'test_enums_same_name'
|
||||
|
||||
schema_scope = sys.modules[__name__]
|
||||
|
||||
|
||||
# ENUMERATION TYPE hair_color
|
||||
if (not 'bald' in globals().keys()):
|
||||
bald = 'bald'
|
||||
if (not 'red' in globals().keys()):
|
||||
red = 'red'
|
||||
hair_color = ENUMERATION(
|
||||
'bald',
|
||||
'red',
|
||||
)
|
||||
scope = schema_scope)
|
||||
|
||||
# ENUMERATION TYPE favorite_color
|
||||
if (not 'clear' in globals().keys()):
|
||||
clear = 'clear'
|
||||
if (not 'red' in globals().keys()):
|
||||
red = 'red'
|
||||
favorite_color = ENUMERATION(
|
||||
'clear',
|
||||
'red',
|
||||
)
|
||||
scope = schema_scope)
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
# This file was generated by fedex_python. You probably don't want to edit
|
||||
# it since your modifications will be lost if fedex_plus is used to
|
||||
# regenerate it.
|
||||
import sys
|
||||
|
||||
from SCL.SCLBase import *
|
||||
from SCL.SimpleDataTypes import *
|
||||
from SCL.ConstructedDataTypes import *
|
||||
from SCL.AggregationDataTypes import *
|
||||
from SCL.TypeChecker import check_type
|
||||
from SCL.Builtin import *
|
||||
from SCL.Rules import *
|
||||
|
||||
schema_name = 'test_function'
|
||||
|
||||
schema_scope = sys.modules[__name__]
|
||||
|
||||
|
||||
####################
|
||||
# ENTITY dummy #
|
||||
####################
|
||||
class dummy(BaseEntityClass):
|
||||
'''Entity dummy definition.
|
||||
'''
|
||||
# This class does not define any attribute.
|
||||
pass
|
||||
|
||||
####################
|
||||
# FUNCTION add #
|
||||
####################
|
||||
def add(r1,r2,):
|
||||
'''
|
||||
:param r1
|
||||
:type r1:REAL
|
||||
:param r2
|
||||
:type r2:REAL
|
||||
'''
|
||||
result = r1 + r2
|
||||
return result
|
||||
|
||||
####################
|
||||
# FUNCTION pow_n #
|
||||
####################
|
||||
def pow_n(r1,n,):
|
||||
'''
|
||||
:param r1
|
||||
:type r1:REAL
|
||||
:param n
|
||||
:type n:INTEGER
|
||||
'''
|
||||
if (n == 0):
|
||||
return 1
|
||||
else:
|
||||
result = r1
|
||||
for i in range(1,n,1):
|
||||
result = result * r1
|
||||
return result
|
||||
|
||||
####################
|
||||
# FUNCTION case_1 #
|
||||
####################
|
||||
def case_1(a,):
|
||||
'''
|
||||
:param a
|
||||
:type a:INTEGER
|
||||
'''
|
||||
case_selector = a
|
||||
if case_selector == 1:
|
||||
x = SIN(a)
|
||||
elif case_selector == 2:
|
||||
x = EXP(a)
|
||||
elif case_selector == 3:
|
||||
x = SQRT(a)
|
||||
elif case_selector == 4:
|
||||
x = LOG(a)
|
||||
elif case_selector == 5:
|
||||
x = LOG(a)
|
||||
else:
|
||||
x = 0
|
||||
return x
|
||||
@@ -1,23 +1,40 @@
|
||||
# This file was generated by fedex_python. You probably don't want to edit
|
||||
# it since your modifications will be lost if fedex_plus is used to
|
||||
# regenerate it.
|
||||
import sys
|
||||
|
||||
from SCL.SCLBase import *
|
||||
from SCL.SimpleDataTypes import *
|
||||
from SCL.ConstructedDataTypes import *
|
||||
from SCL.AggregationDataTypes import *
|
||||
from SCL.TypeChecker import check_type
|
||||
from SCL.Expr import *
|
||||
# SELECT TYPE classification_item_
|
||||
if (not 'person_and_organization_address' in globals().keys()):
|
||||
person_and_organization_address = 'person_and_organization_address'
|
||||
if (not 'address' in globals().keys()):
|
||||
address = 'address'
|
||||
from SCL.Builtin import *
|
||||
from SCL.Rules import *
|
||||
|
||||
schema_name = 'test_multiple_inheritance'
|
||||
|
||||
schema_scope = sys.modules[__name__]
|
||||
|
||||
# SELECT TYPE classification_item
|
||||
classification_item = SELECT(
|
||||
'person_and_organization_address',
|
||||
'address')
|
||||
text = STRING
|
||||
identifier = STRING
|
||||
label = STRING
|
||||
'address',
|
||||
scope = schema_scope)
|
||||
# Defined datatype text
|
||||
class text(STRING):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
# Defined datatype identifier
|
||||
class identifier(STRING):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
# Defined datatype label
|
||||
class label(STRING):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
|
||||
####################
|
||||
# ENTITY address #
|
||||
@@ -26,40 +43,40 @@ class address(BaseEntityClass):
|
||||
'''Entity address definition.
|
||||
|
||||
:param internal_location
|
||||
:type internal_location:STRING
|
||||
:type internal_location:label
|
||||
|
||||
:param street_number
|
||||
:type street_number:STRING
|
||||
:type street_number:label
|
||||
|
||||
:param street
|
||||
:type street:STRING
|
||||
:type street:label
|
||||
|
||||
:param postal_box
|
||||
:type postal_box:STRING
|
||||
:type postal_box:label
|
||||
|
||||
:param town
|
||||
:type town:STRING
|
||||
:type town:label
|
||||
|
||||
:param region
|
||||
:type region:STRING
|
||||
:type region:label
|
||||
|
||||
:param postal_code
|
||||
:type postal_code:STRING
|
||||
:type postal_code:label
|
||||
|
||||
:param country
|
||||
:type country:STRING
|
||||
:type country:label
|
||||
|
||||
:param facsimile_number
|
||||
:type facsimile_number:STRING
|
||||
:type facsimile_number:label
|
||||
|
||||
:param telephone_number
|
||||
:type telephone_number:STRING
|
||||
:type telephone_number:label
|
||||
|
||||
:param electronic_mail_address
|
||||
:type electronic_mail_address:STRING
|
||||
:type electronic_mail_address:label
|
||||
|
||||
:param telex_number
|
||||
:type telex_number:STRING
|
||||
:type telex_number:label
|
||||
'''
|
||||
def __init__( self , internal_location,street_number,street,postal_box,town,region,postal_code,country,facsimile_number,telephone_number,electronic_mail_address,telex_number, ):
|
||||
self.internal_location = internal_location
|
||||
@@ -81,8 +98,10 @@ class address(BaseEntityClass):
|
||||
return self._internal_location
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,STRING):
|
||||
self._internal_location = STRING(value)
|
||||
if not check_type(value,label):
|
||||
self._internal_location = label(value)
|
||||
else:
|
||||
self._internal_location = value
|
||||
else:
|
||||
self._internal_location = value
|
||||
return property(**locals())
|
||||
@@ -93,8 +112,10 @@ class address(BaseEntityClass):
|
||||
return self._street_number
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,STRING):
|
||||
self._street_number = STRING(value)
|
||||
if not check_type(value,label):
|
||||
self._street_number = label(value)
|
||||
else:
|
||||
self._street_number = value
|
||||
else:
|
||||
self._street_number = value
|
||||
return property(**locals())
|
||||
@@ -105,8 +126,10 @@ class address(BaseEntityClass):
|
||||
return self._street
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,STRING):
|
||||
self._street = STRING(value)
|
||||
if not check_type(value,label):
|
||||
self._street = label(value)
|
||||
else:
|
||||
self._street = value
|
||||
else:
|
||||
self._street = value
|
||||
return property(**locals())
|
||||
@@ -117,8 +140,10 @@ class address(BaseEntityClass):
|
||||
return self._postal_box
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,STRING):
|
||||
self._postal_box = STRING(value)
|
||||
if not check_type(value,label):
|
||||
self._postal_box = label(value)
|
||||
else:
|
||||
self._postal_box = value
|
||||
else:
|
||||
self._postal_box = value
|
||||
return property(**locals())
|
||||
@@ -129,8 +154,10 @@ class address(BaseEntityClass):
|
||||
return self._town
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,STRING):
|
||||
self._town = STRING(value)
|
||||
if not check_type(value,label):
|
||||
self._town = label(value)
|
||||
else:
|
||||
self._town = value
|
||||
else:
|
||||
self._town = value
|
||||
return property(**locals())
|
||||
@@ -141,8 +168,10 @@ class address(BaseEntityClass):
|
||||
return self._region
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,STRING):
|
||||
self._region = STRING(value)
|
||||
if not check_type(value,label):
|
||||
self._region = label(value)
|
||||
else:
|
||||
self._region = value
|
||||
else:
|
||||
self._region = value
|
||||
return property(**locals())
|
||||
@@ -153,8 +182,10 @@ class address(BaseEntityClass):
|
||||
return self._postal_code
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,STRING):
|
||||
self._postal_code = STRING(value)
|
||||
if not check_type(value,label):
|
||||
self._postal_code = label(value)
|
||||
else:
|
||||
self._postal_code = value
|
||||
else:
|
||||
self._postal_code = value
|
||||
return property(**locals())
|
||||
@@ -165,8 +196,10 @@ class address(BaseEntityClass):
|
||||
return self._country
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,STRING):
|
||||
self._country = STRING(value)
|
||||
if not check_type(value,label):
|
||||
self._country = label(value)
|
||||
else:
|
||||
self._country = value
|
||||
else:
|
||||
self._country = value
|
||||
return property(**locals())
|
||||
@@ -177,8 +210,10 @@ class address(BaseEntityClass):
|
||||
return self._facsimile_number
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,STRING):
|
||||
self._facsimile_number = STRING(value)
|
||||
if not check_type(value,label):
|
||||
self._facsimile_number = label(value)
|
||||
else:
|
||||
self._facsimile_number = value
|
||||
else:
|
||||
self._facsimile_number = value
|
||||
return property(**locals())
|
||||
@@ -189,8 +224,10 @@ class address(BaseEntityClass):
|
||||
return self._telephone_number
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,STRING):
|
||||
self._telephone_number = STRING(value)
|
||||
if not check_type(value,label):
|
||||
self._telephone_number = label(value)
|
||||
else:
|
||||
self._telephone_number = value
|
||||
else:
|
||||
self._telephone_number = value
|
||||
return property(**locals())
|
||||
@@ -201,8 +238,10 @@ class address(BaseEntityClass):
|
||||
return self._electronic_mail_address
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,STRING):
|
||||
self._electronic_mail_address = STRING(value)
|
||||
if not check_type(value,label):
|
||||
self._electronic_mail_address = label(value)
|
||||
else:
|
||||
self._electronic_mail_address = value
|
||||
else:
|
||||
self._electronic_mail_address = value
|
||||
return property(**locals())
|
||||
@@ -213,8 +252,10 @@ class address(BaseEntityClass):
|
||||
return self._telex_number
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,STRING):
|
||||
self._telex_number = STRING(value)
|
||||
if not check_type(value,label):
|
||||
self._telex_number = label(value)
|
||||
else:
|
||||
self._telex_number = value
|
||||
else:
|
||||
self._telex_number = value
|
||||
return property(**locals())
|
||||
@@ -226,13 +267,13 @@ class personal_address(address):
|
||||
'''Entity personal_address definition.
|
||||
|
||||
:param people
|
||||
:type people:SET(1,None,'person')
|
||||
:type people:SET(1,None,'person', scope = schema_scope)
|
||||
|
||||
:param description
|
||||
:type description:STRING
|
||||
:type description:text
|
||||
'''
|
||||
def __init__( self , address__internal_location , address__street_number , address__street , address__postal_box , address__town , address__region , address__postal_code , address__country , address__facsimile_number , address__telephone_number , address__electronic_mail_address , address__telex_number , people,description, ):
|
||||
address.__init__(self , address__internal_location , address__street_number , address__street , address__postal_box , address__town , address__region , address__postal_code , address__country , address__facsimile_number , address__telephone_number , address__electronic_mail_address , address__telex_number , )
|
||||
def __init__( self , inherited0__internal_location , inherited1__street_number , inherited2__street , inherited3__postal_box , inherited4__town , inherited5__region , inherited6__postal_code , inherited7__country , inherited8__facsimile_number , inherited9__telephone_number , inherited10__electronic_mail_address , inherited11__telex_number , people,description, ):
|
||||
address.__init__(self , inherited0__internal_location , inherited1__street_number , inherited2__street , inherited3__postal_box , inherited4__town , inherited5__region , inherited6__postal_code , inherited7__country , inherited8__facsimile_number , inherited9__telephone_number , inherited10__electronic_mail_address , inherited11__telex_number , )
|
||||
self.people = people
|
||||
self.description = description
|
||||
|
||||
@@ -244,7 +285,7 @@ class personal_address(address):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument people is mantatory and can not be set to None')
|
||||
if not check_type(value,SET(1,None,'person')):
|
||||
if not check_type(value,SET(1,None,'person', scope = schema_scope)):
|
||||
self._people = SET(value)
|
||||
else:
|
||||
self._people = value
|
||||
@@ -256,8 +297,10 @@ class personal_address(address):
|
||||
return self._description
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,STRING):
|
||||
self._description = STRING(value)
|
||||
if not check_type(value,text):
|
||||
self._description = text(value)
|
||||
else:
|
||||
self._description = value
|
||||
else:
|
||||
self._description = value
|
||||
return property(**locals())
|
||||
@@ -269,13 +312,13 @@ class organizational_address(address):
|
||||
'''Entity organizational_address definition.
|
||||
|
||||
:param organizations
|
||||
:type organizations:SET(1,None,'organization')
|
||||
:type organizations:SET(1,None,'organization', scope = schema_scope)
|
||||
|
||||
:param description
|
||||
:type description:STRING
|
||||
:type description:text
|
||||
'''
|
||||
def __init__( self , address__internal_location , address__street_number , address__street , address__postal_box , address__town , address__region , address__postal_code , address__country , address__facsimile_number , address__telephone_number , address__electronic_mail_address , address__telex_number , organizations,description, ):
|
||||
address.__init__(self , address__internal_location , address__street_number , address__street , address__postal_box , address__town , address__region , address__postal_code , address__country , address__facsimile_number , address__telephone_number , address__electronic_mail_address , address__telex_number , )
|
||||
def __init__( self , inherited0__internal_location , inherited1__street_number , inherited2__street , inherited3__postal_box , inherited4__town , inherited5__region , inherited6__postal_code , inherited7__country , inherited8__facsimile_number , inherited9__telephone_number , inherited10__electronic_mail_address , inherited11__telex_number , organizations,description, ):
|
||||
address.__init__(self , inherited0__internal_location , inherited1__street_number , inherited2__street , inherited3__postal_box , inherited4__town , inherited5__region , inherited6__postal_code , inherited7__country , inherited8__facsimile_number , inherited9__telephone_number , inherited10__electronic_mail_address , inherited11__telex_number , )
|
||||
self.organizations = organizations
|
||||
self.description = description
|
||||
|
||||
@@ -287,7 +330,7 @@ class organizational_address(address):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument organizations is mantatory and can not be set to None')
|
||||
if not check_type(value,SET(1,None,'organization')):
|
||||
if not check_type(value,SET(1,None,'organization', scope = schema_scope)):
|
||||
self._organizations = SET(value)
|
||||
else:
|
||||
self._organizations = value
|
||||
@@ -299,8 +342,10 @@ class organizational_address(address):
|
||||
return self._description
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,STRING):
|
||||
self._description = STRING(value)
|
||||
if not check_type(value,text):
|
||||
self._description = text(value)
|
||||
else:
|
||||
self._description = value
|
||||
else:
|
||||
self._description = value
|
||||
return property(**locals())
|
||||
@@ -312,22 +357,22 @@ class person(BaseEntityClass):
|
||||
'''Entity person definition.
|
||||
|
||||
:param id
|
||||
:type id:STRING
|
||||
:type id:identifier
|
||||
|
||||
:param last_name
|
||||
:type last_name:STRING
|
||||
:type last_name:label
|
||||
|
||||
:param first_name
|
||||
:type first_name:STRING
|
||||
:type first_name:label
|
||||
|
||||
:param middle_names
|
||||
:type middle_names:LIST(1,None,'STRING')
|
||||
:type middle_names:LIST(1,None,'STRING', scope = schema_scope)
|
||||
|
||||
:param prefix_titles
|
||||
:type prefix_titles:LIST(1,None,'STRING')
|
||||
:type prefix_titles:LIST(1,None,'STRING', scope = schema_scope)
|
||||
|
||||
:param suffix_titles
|
||||
:type suffix_titles:LIST(1,None,'STRING')
|
||||
:type suffix_titles:LIST(1,None,'STRING', scope = schema_scope)
|
||||
'''
|
||||
def __init__( self , id,last_name,first_name,middle_names,prefix_titles,suffix_titles, ):
|
||||
self.id = id
|
||||
@@ -345,8 +390,8 @@ class person(BaseEntityClass):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument id is mantatory and can not be set to None')
|
||||
if not check_type(value,STRING):
|
||||
self._id = STRING(value)
|
||||
if not check_type(value,identifier):
|
||||
self._id = identifier(value)
|
||||
else:
|
||||
self._id = value
|
||||
return property(**locals())
|
||||
@@ -357,8 +402,10 @@ class person(BaseEntityClass):
|
||||
return self._last_name
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,STRING):
|
||||
self._last_name = STRING(value)
|
||||
if not check_type(value,label):
|
||||
self._last_name = label(value)
|
||||
else:
|
||||
self._last_name = value
|
||||
else:
|
||||
self._last_name = value
|
||||
return property(**locals())
|
||||
@@ -369,8 +416,10 @@ class person(BaseEntityClass):
|
||||
return self._first_name
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,STRING):
|
||||
self._first_name = STRING(value)
|
||||
if not check_type(value,label):
|
||||
self._first_name = label(value)
|
||||
else:
|
||||
self._first_name = value
|
||||
else:
|
||||
self._first_name = value
|
||||
return property(**locals())
|
||||
@@ -381,8 +430,10 @@ class person(BaseEntityClass):
|
||||
return self._middle_names
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,LIST(1,None,'STRING')):
|
||||
if not check_type(value,LIST(1,None,'STRING', scope = schema_scope)):
|
||||
self._middle_names = LIST(value)
|
||||
else:
|
||||
self._middle_names = value
|
||||
else:
|
||||
self._middle_names = value
|
||||
return property(**locals())
|
||||
@@ -393,8 +444,10 @@ class person(BaseEntityClass):
|
||||
return self._prefix_titles
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,LIST(1,None,'STRING')):
|
||||
if not check_type(value,LIST(1,None,'STRING', scope = schema_scope)):
|
||||
self._prefix_titles = LIST(value)
|
||||
else:
|
||||
self._prefix_titles = value
|
||||
else:
|
||||
self._prefix_titles = value
|
||||
return property(**locals())
|
||||
@@ -405,11 +458,20 @@ class person(BaseEntityClass):
|
||||
return self._suffix_titles
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,LIST(1,None,'STRING')):
|
||||
if not check_type(value,LIST(1,None,'STRING', scope = schema_scope)):
|
||||
self._suffix_titles = LIST(value)
|
||||
else:
|
||||
self._suffix_titles = value
|
||||
else:
|
||||
self._suffix_titles = value
|
||||
return property(**locals())
|
||||
def wr1(self):
|
||||
eval_wr1_wr = (EXISTS(self.last_name) or EXISTS(self.first_name))
|
||||
if not eval_wr1_wr:
|
||||
raise AssertionError('Rule wr1 violated')
|
||||
else:
|
||||
return eval_wr1_wr
|
||||
|
||||
|
||||
####################
|
||||
# ENTITY organization #
|
||||
@@ -418,13 +480,13 @@ class organization(BaseEntityClass):
|
||||
'''Entity organization definition.
|
||||
|
||||
:param id
|
||||
:type id:STRING
|
||||
:type id:identifier
|
||||
|
||||
:param name
|
||||
:type name:STRING
|
||||
:type name:label
|
||||
|
||||
:param description
|
||||
:type description:STRING
|
||||
:type description:text
|
||||
'''
|
||||
def __init__( self , id,name,description, ):
|
||||
self.id = id
|
||||
@@ -437,8 +499,10 @@ class organization(BaseEntityClass):
|
||||
return self._id
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,STRING):
|
||||
self._id = STRING(value)
|
||||
if not check_type(value,identifier):
|
||||
self._id = identifier(value)
|
||||
else:
|
||||
self._id = value
|
||||
else:
|
||||
self._id = value
|
||||
return property(**locals())
|
||||
@@ -451,8 +515,8 @@ class organization(BaseEntityClass):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument name is mantatory and can not be set to None')
|
||||
if not check_type(value,STRING):
|
||||
self._name = STRING(value)
|
||||
if not check_type(value,label):
|
||||
self._name = label(value)
|
||||
else:
|
||||
self._name = value
|
||||
return property(**locals())
|
||||
@@ -463,8 +527,10 @@ class organization(BaseEntityClass):
|
||||
return self._description
|
||||
def fset( self, value ):
|
||||
if value != None: # OPTIONAL attribute
|
||||
if not check_type(value,STRING):
|
||||
self._description = STRING(value)
|
||||
if not check_type(value,text):
|
||||
self._description = text(value)
|
||||
else:
|
||||
self._description = value
|
||||
else:
|
||||
self._description = value
|
||||
return property(**locals())
|
||||
@@ -476,14 +542,14 @@ class person_and_organization_address(organizational_address,personal_address):
|
||||
'''Entity person_and_organization_address definition.
|
||||
|
||||
:param organizational_address_organizations
|
||||
:type organizational_address_organizations:SET(1,1,'organization')
|
||||
:type organizational_address_organizations:SET(1,1,'organization', scope = schema_scope)
|
||||
|
||||
:param personal_address_people
|
||||
:type personal_address_people:SET(1,1,'person')
|
||||
:type personal_address_people:SET(1,1,'person', scope = schema_scope)
|
||||
'''
|
||||
def __init__( self , organizational_address__organizations , organizational_address__description , personal_address__people , personal_address__description , organizational_address_organizations,personal_address_people, ):
|
||||
organizational_address.__init__(self , organizational_address__organizations , organizational_address__description , )
|
||||
personal_address.__init__(self , personal_address__people , personal_address__description , )
|
||||
def __init__( self , inherited0__internal_location , inherited1__street_number , inherited2__street , inherited3__postal_box , inherited4__town , inherited5__region , inherited6__postal_code , inherited7__country , inherited8__facsimile_number , inherited9__telephone_number , inherited10__electronic_mail_address , inherited11__telex_number , inherited12__organizations , inherited13__description , inherited14__internal_location , inherited15__street_number , inherited16__street , inherited17__postal_box , inherited18__town , inherited19__region , inherited20__postal_code , inherited21__country , inherited22__facsimile_number , inherited23__telephone_number , inherited24__electronic_mail_address , inherited25__telex_number , inherited26__people , inherited27__description , organizational_address_organizations,personal_address_people, ):
|
||||
organizational_address.__init__(self , inherited0__internal_location , inherited1__street_number , inherited2__street , inherited3__postal_box , inherited4__town , inherited5__region , inherited6__postal_code , inherited7__country , inherited8__facsimile_number , inherited9__telephone_number , inherited10__electronic_mail_address , inherited11__telex_number , inherited12__organizations , inherited13__description , )
|
||||
personal_address.__init__(self , inherited14__internal_location , inherited15__street_number , inherited16__street , inherited17__postal_box , inherited18__town , inherited19__region , inherited20__postal_code , inherited21__country , inherited22__facsimile_number , inherited23__telephone_number , inherited24__electronic_mail_address , inherited25__telex_number , inherited26__people , inherited27__description , )
|
||||
self.organizational_address_organizations = organizational_address_organizations
|
||||
self.personal_address_people = personal_address_people
|
||||
|
||||
@@ -495,7 +561,7 @@ class person_and_organization_address(organizational_address,personal_address):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument organizational_address_organizations is mantatory and can not be set to None')
|
||||
if not check_type(value,SET(1,1,'organization')):
|
||||
if not check_type(value,SET(1,1,'organization', scope = schema_scope)):
|
||||
self._organizational_address_organizations = SET(value)
|
||||
else:
|
||||
self._organizational_address_organizations = value
|
||||
@@ -509,7 +575,7 @@ class person_and_organization_address(organizational_address,personal_address):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument personal_address_people is mantatory and can not be set to None')
|
||||
if not check_type(value,SET(1,1,'person')):
|
||||
if not check_type(value,SET(1,1,'person', scope = schema_scope)):
|
||||
self._personal_address_people = SET(value)
|
||||
else:
|
||||
self._personal_address_people = value
|
||||
|
||||
@@ -1,14 +1,35 @@
|
||||
# This file was generated by fedex_python. You probably don't want to edit
|
||||
# it since your modifications will be lost if fedex_plus is used to
|
||||
# regenerate it.
|
||||
import sys
|
||||
|
||||
from SCL.SCLBase import *
|
||||
from SCL.SimpleDataTypes import *
|
||||
from SCL.ConstructedDataTypes import *
|
||||
from SCL.AggregationDataTypes import *
|
||||
from SCL.TypeChecker import check_type
|
||||
from SCL.Expr import *
|
||||
measure = REAL
|
||||
type2 = INTEGER
|
||||
from SCL.Builtin import *
|
||||
from SCL.Rules import *
|
||||
|
||||
schema_name = 'test_named_type'
|
||||
|
||||
schema_scope = sys.modules[__name__]
|
||||
|
||||
# Defined datatype measure
|
||||
class measure(REAL):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
# Defined datatype type2
|
||||
class type2(INTEGER):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
# Defined datatype type3
|
||||
class type3(type2):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
|
||||
####################
|
||||
# ENTITY line #
|
||||
@@ -17,10 +38,18 @@ class line(BaseEntityClass):
|
||||
'''Entity line definition.
|
||||
|
||||
:param line_length
|
||||
:type line_length:REAL
|
||||
:type line_length:measure
|
||||
|
||||
:param other_param
|
||||
:type other_param:type3
|
||||
|
||||
:param and_another
|
||||
:type and_another:REAL
|
||||
'''
|
||||
def __init__( self , line_length, ):
|
||||
def __init__( self , line_length,other_param,and_another, ):
|
||||
self.line_length = line_length
|
||||
self.other_param = other_param
|
||||
self.and_another = and_another
|
||||
|
||||
@apply
|
||||
def line_length():
|
||||
@@ -30,8 +59,36 @@ class line(BaseEntityClass):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument line_length is mantatory and can not be set to None')
|
||||
if not check_type(value,REAL):
|
||||
self._line_length = REAL(value)
|
||||
if not check_type(value,measure):
|
||||
self._line_length = measure(value)
|
||||
else:
|
||||
self._line_length = value
|
||||
return property(**locals())
|
||||
|
||||
@apply
|
||||
def other_param():
|
||||
def fget( self ):
|
||||
return self._other_param
|
||||
def fset( self, value ):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument other_param is mantatory and can not be set to None')
|
||||
if not check_type(value,type3):
|
||||
self._other_param = type3(value)
|
||||
else:
|
||||
self._other_param = value
|
||||
return property(**locals())
|
||||
|
||||
@apply
|
||||
def and_another():
|
||||
def fget( self ):
|
||||
return self._and_another
|
||||
def fset( self, value ):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument and_another is mantatory and can not be set to None')
|
||||
if not check_type(value,REAL):
|
||||
self._and_another = REAL(value)
|
||||
else:
|
||||
self._and_another = value
|
||||
return property(**locals())
|
||||
|
||||
@@ -1,36 +1,35 @@
|
||||
# This file was generated by fedex_python. You probably don't want to edit
|
||||
# it since your modifications will be lost if fedex_plus is used to
|
||||
# regenerate it.
|
||||
import sys
|
||||
|
||||
from SCL.SCLBase import *
|
||||
from SCL.SimpleDataTypes import *
|
||||
from SCL.ConstructedDataTypes import *
|
||||
from SCL.AggregationDataTypes import *
|
||||
from SCL.TypeChecker import check_type
|
||||
from SCL.Expr import *
|
||||
# SELECT TYPE permanent_attachment_
|
||||
if (not 'glue' in globals().keys()):
|
||||
glue = 'glue'
|
||||
if (not 'weld' in globals().keys()):
|
||||
weld = 'weld'
|
||||
from SCL.Builtin import *
|
||||
from SCL.Rules import *
|
||||
|
||||
schema_name = 'test_select_data_type'
|
||||
|
||||
schema_scope = sys.modules[__name__]
|
||||
|
||||
# SELECT TYPE permanent_attachment
|
||||
permanent_attachment = SELECT(
|
||||
'glue',
|
||||
'weld')
|
||||
# SELECT TYPE temporary_attachment_
|
||||
if (not 'nail' in globals().keys()):
|
||||
nail = 'nail'
|
||||
if (not 'screw' in globals().keys()):
|
||||
screw = 'screw'
|
||||
'weld',
|
||||
scope = schema_scope)
|
||||
# SELECT TYPE temporary_attachment
|
||||
temporary_attachment = SELECT(
|
||||
'nail',
|
||||
'screw')
|
||||
# SELECT TYPE attachment_method_
|
||||
if (not 'permanent_attachment' in globals().keys()):
|
||||
permanent_attachment = 'permanent_attachment'
|
||||
if (not 'temporary_attachment' in globals().keys()):
|
||||
temporary_attachment = 'temporary_attachment'
|
||||
'screw',
|
||||
scope = schema_scope)
|
||||
# SELECT TYPE attachment_method
|
||||
attachment_method = SELECT(
|
||||
'permanent_attachment',
|
||||
'temporary_attachment')
|
||||
'temporary_attachment',
|
||||
scope = schema_scope)
|
||||
|
||||
####################
|
||||
# ENTITY weld #
|
||||
|
||||
@@ -1,15 +1,35 @@
|
||||
# This file was generated by fedex_python. You probably don't want to edit
|
||||
# it since your modifications will be lost if fedex_plus is used to
|
||||
# regenerate it.
|
||||
import sys
|
||||
|
||||
from SCL.SCLBase import *
|
||||
from SCL.SimpleDataTypes import *
|
||||
from SCL.ConstructedDataTypes import *
|
||||
from SCL.AggregationDataTypes import *
|
||||
from SCL.TypeChecker import check_type
|
||||
from SCL.Expr import *
|
||||
length_measure = REAL
|
||||
label = STRING
|
||||
point = REAL
|
||||
from SCL.Builtin import *
|
||||
from SCL.Rules import *
|
||||
|
||||
schema_name = 'test_single_inheritance'
|
||||
|
||||
schema_scope = sys.modules[__name__]
|
||||
|
||||
# Defined datatype length_measure
|
||||
class length_measure(REAL):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
# Defined datatype label
|
||||
class label(STRING):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
# Defined datatype point
|
||||
class point(REAL):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
|
||||
####################
|
||||
# ENTITY shape #
|
||||
@@ -18,7 +38,7 @@ class shape(BaseEntityClass):
|
||||
'''Entity shape definition.
|
||||
|
||||
:param item_name
|
||||
:type item_name:STRING
|
||||
:type item_name:label
|
||||
|
||||
:param number_of_sides
|
||||
:type number_of_sides:INTEGER
|
||||
@@ -35,8 +55,8 @@ class shape(BaseEntityClass):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument item_name is mantatory and can not be set to None')
|
||||
if not check_type(value,STRING):
|
||||
self._item_name = STRING(value)
|
||||
if not check_type(value,label):
|
||||
self._item_name = label(value)
|
||||
else:
|
||||
self._item_name = value
|
||||
return property(**locals())
|
||||
@@ -62,13 +82,13 @@ class rectangle(shape):
|
||||
'''Entity rectangle definition.
|
||||
|
||||
:param height
|
||||
:type height:REAL
|
||||
:type height:length_measure
|
||||
|
||||
:param width
|
||||
:type width:REAL
|
||||
:type width:length_measure
|
||||
'''
|
||||
def __init__( self , shape__item_name , shape__number_of_sides , height,width, ):
|
||||
shape.__init__(self , shape__item_name , shape__number_of_sides , )
|
||||
def __init__( self , inherited0__item_name , inherited1__number_of_sides , height,width, ):
|
||||
shape.__init__(self , inherited0__item_name , inherited1__number_of_sides , )
|
||||
self.height = height
|
||||
self.width = width
|
||||
|
||||
@@ -80,8 +100,8 @@ class rectangle(shape):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument height is mantatory and can not be set to None')
|
||||
if not check_type(value,REAL):
|
||||
self._height = REAL(value)
|
||||
if not check_type(value,length_measure):
|
||||
self._height = length_measure(value)
|
||||
else:
|
||||
self._height = value
|
||||
return property(**locals())
|
||||
@@ -94,8 +114,8 @@ class rectangle(shape):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument width is mantatory and can not be set to None')
|
||||
if not check_type(value,REAL):
|
||||
self._width = REAL(value)
|
||||
if not check_type(value,length_measure):
|
||||
self._width = length_measure(value)
|
||||
else:
|
||||
self._width = value
|
||||
return property(**locals())
|
||||
|
||||
@@ -1,15 +1,35 @@
|
||||
# This file was generated by fedex_python. You probably don't want to edit
|
||||
# it since your modifications will be lost if fedex_plus is used to
|
||||
# regenerate it.
|
||||
import sys
|
||||
|
||||
from SCL.SCLBase import *
|
||||
from SCL.SimpleDataTypes import *
|
||||
from SCL.ConstructedDataTypes import *
|
||||
from SCL.AggregationDataTypes import *
|
||||
from SCL.TypeChecker import check_type
|
||||
from SCL.Expr import *
|
||||
length_measure = REAL
|
||||
label = STRING
|
||||
point = REAL
|
||||
from SCL.Builtin import *
|
||||
from SCL.Rules import *
|
||||
|
||||
schema_name = 'test_single_inheritance_multi_level'
|
||||
|
||||
schema_scope = sys.modules[__name__]
|
||||
|
||||
# Defined datatype length_measure
|
||||
class length_measure(REAL):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
# Defined datatype label
|
||||
class label(STRING):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
# Defined datatype point
|
||||
class point(REAL):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
|
||||
|
||||
####################
|
||||
# ENTITY shape #
|
||||
@@ -18,7 +38,7 @@ class shape(BaseEntityClass):
|
||||
'''Entity shape definition.
|
||||
|
||||
:param item_name
|
||||
:type item_name:STRING
|
||||
:type item_name:label
|
||||
|
||||
:param number_of_sides
|
||||
:type number_of_sides:INTEGER
|
||||
@@ -35,8 +55,8 @@ class shape(BaseEntityClass):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument item_name is mantatory and can not be set to None')
|
||||
if not check_type(value,STRING):
|
||||
self._item_name = STRING(value)
|
||||
if not check_type(value,label):
|
||||
self._item_name = label(value)
|
||||
else:
|
||||
self._item_name = value
|
||||
return property(**locals())
|
||||
@@ -61,8 +81,8 @@ class shape(BaseEntityClass):
|
||||
class subshape(shape):
|
||||
'''Entity subshape definition.
|
||||
'''
|
||||
def __init__( self , shape__item_name , shape__number_of_sides , ):
|
||||
shape.__init__(self , shape__item_name , shape__number_of_sides , )
|
||||
def __init__( self , inherited0__item_name , inherited1__number_of_sides , ):
|
||||
shape.__init__(self , inherited0__item_name , inherited1__number_of_sides , )
|
||||
|
||||
####################
|
||||
# ENTITY rectangle #
|
||||
@@ -71,13 +91,13 @@ class rectangle(subshape):
|
||||
'''Entity rectangle definition.
|
||||
|
||||
:param height
|
||||
:type height:REAL
|
||||
:type height:length_measure
|
||||
|
||||
:param width
|
||||
:type width:REAL
|
||||
:type width:length_measure
|
||||
'''
|
||||
def __init__( self , height,width, ):
|
||||
subshape.__init__(self , )
|
||||
def __init__( self , inherited0__item_name , inherited1__number_of_sides , height,width, ):
|
||||
subshape.__init__(self , inherited0__item_name , inherited1__number_of_sides , )
|
||||
self.height = height
|
||||
self.width = width
|
||||
|
||||
@@ -89,8 +109,8 @@ class rectangle(subshape):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument height is mantatory and can not be set to None')
|
||||
if not check_type(value,REAL):
|
||||
self._height = REAL(value)
|
||||
if not check_type(value,length_measure):
|
||||
self._height = length_measure(value)
|
||||
else:
|
||||
self._height = value
|
||||
return property(**locals())
|
||||
@@ -103,8 +123,8 @@ class rectangle(subshape):
|
||||
# Mandatory argument
|
||||
if value==None:
|
||||
raise AssertionError('Argument width is mantatory and can not be set to None')
|
||||
if not check_type(value,REAL):
|
||||
self._width = REAL(value)
|
||||
if not check_type(value,length_measure):
|
||||
self._width = length_measure(value)
|
||||
else:
|
||||
self._width = value
|
||||
return property(**locals())
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
# This file was generated by fedex_python. You probably don't want to edit
|
||||
# it since your modifications will be lost if fedex_plus is used to
|
||||
# regenerate it.
|
||||
import sys
|
||||
|
||||
from SCL.SCLBase import *
|
||||
from SCL.SimpleDataTypes import *
|
||||
from SCL.ConstructedDataTypes import *
|
||||
from SCL.AggregationDataTypes import *
|
||||
from SCL.TypeChecker import check_type
|
||||
from SCL.Builtin import *
|
||||
from SCL.Rules import *
|
||||
|
||||
schema_name = 'test_where_rule'
|
||||
|
||||
schema_scope = sys.modules[__name__]
|
||||
|
||||
# Defined datatype month
|
||||
class month(INTEGER):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
self.unnamed_wr_0()
|
||||
self.unnamed_wr_1()
|
||||
|
||||
def unnamed_wr_0(self):
|
||||
eval_unnamed_wr_0 = (self <= 12)
|
||||
if not eval_unnamed_wr_0:
|
||||
raise AssertionError('Rule unnamed_wr_0 violated')
|
||||
else:
|
||||
return eval_unnamed_wr_0
|
||||
|
||||
def unnamed_wr_1(self):
|
||||
eval_unnamed_wr_1 = (self >= 1)
|
||||
if not eval_unnamed_wr_1:
|
||||
raise AssertionError('Rule unnamed_wr_1 violated')
|
||||
else:
|
||||
return eval_unnamed_wr_1
|
||||
|
||||
# Defined datatype positive
|
||||
class positive(INTEGER):
|
||||
def __init__(self,*kargs):
|
||||
pass
|
||||
self.notnegative()
|
||||
|
||||
def notnegative(self):
|
||||
eval_notnegative_wr = (self > 0)
|
||||
if not eval_notnegative_wr:
|
||||
raise AssertionError('Rule notnegative violated')
|
||||
else:
|
||||
return eval_notnegative_wr
|
||||
|
||||
@@ -30,7 +30,8 @@
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from SimpleDataTypes import *
|
||||
from TypeChecker import *
|
||||
from TypeChecker import check_type
|
||||
import BaseType
|
||||
|
||||
class BaseAggregate(object):
|
||||
""" A class that define common properties to ARRAY, LIST, SET and BAG.
|
||||
@@ -64,8 +65,11 @@ class BaseAggregate(object):
|
||||
# the index is
|
||||
list.__setitem__(self,index,value)
|
||||
|
||||
class ARRAY(object):
|
||||
"""An array data type has as its domain indexed, fixed-size collections of like elements. The lower
|
||||
class ARRAY(BaseType.Type, BaseType.Aggregate):
|
||||
"""
|
||||
EXPRESS definition:
|
||||
==================
|
||||
An array data type has as its domain indexed, fixed-size collections of like elements. The lower
|
||||
and upper bounds, which are integer-valued expressions, define the range of index values, and
|
||||
thus the size of each array collection.
|
||||
An array data type definition may optionally specify
|
||||
@@ -77,22 +81,57 @@ class ARRAY(object):
|
||||
in the array. These elements are indexed by subscripts from m to n, inclusive (see 12.6.1).
|
||||
NOTE 1 { The bounds may be positive, negative or zero, but may not be indeterminate (?) (see
|
||||
14.2).
|
||||
|
||||
Syntax:
|
||||
165 array_type = ARRAY bound_spec OF [ OPTIONAL ] [ UNIQUE ] base_type .
|
||||
176 bound_spec = '[' bound_1 ':' bound_2 ']' .
|
||||
174 bound_1 = numeric_expression .
|
||||
175 bound_2 = numeric_expression .
|
||||
171 base_type = aggregation_types | simple_types | named_types .
|
||||
Given that m is the lower bound and n is the upper bound, there are exactly n-m+1 elements
|
||||
in the array. These elements are indexed by subscripts from m to n, inclusive (see 12.6.1).
|
||||
NOTE 1 { The bounds may be positive, negative or zero, but may not be indeterminate (?) (see
|
||||
14.2).
|
||||
Rules and restrictions:
|
||||
a) Both expressions in the bound specication, bound_1 and bound_2, shall evaluate to
|
||||
integer values. Neither shall evaluate to the indeterminate (?) value.
|
||||
b) bound_1 gives the lower bound of the array. This shall be the lowest index which is
|
||||
valid for an array value of this data type.
|
||||
c) bound_2 gives the upper bound of the array. This shall be the highest index which is
|
||||
valid for an array value of this data type.
|
||||
d) bound_1 shall be less than or equal to bound_2.
|
||||
e) If the optional keyword is specied, an array value of this data type may have the
|
||||
indeterminate (?) value at one or more index positions.
|
||||
f) If the optional keyword is not specied, an array value of this data type shall not
|
||||
contain an indeterminate (?) value at any index position.
|
||||
g) If the unique keyword is specied, each element in an array value of this data type
|
||||
shall be dierent from (i.e., not instance equal to) every other element in the same array
|
||||
value.
|
||||
NOTE 2 : Both optional and unique may be specied in the same array data type definition.
|
||||
This does not preclude multiple indeterminate (?) values from occurring in a single array value.
|
||||
This is because comparisons between indeterminate (?) values result in unknown so the uniqueness
|
||||
constraint is not violated.
|
||||
EXAMPLE 27 : This example shows how a multi-dimensioned array is declared.
|
||||
sectors : ARRAY [ 1 : 10 ] OF -- first dimension
|
||||
ARRAY [ 11 : 14 ] OF -- second dimension
|
||||
UNIQUE something;
|
||||
The first array has 10 elements of data type ARRAY[11:14] OF UNIQUE something. There is
|
||||
a total of 40 elements of data type something in the attribute named sectors. Within each
|
||||
ARRAY[11:14], no duplicates may occur; however, the same something instance may occur in two
|
||||
different ARRAY[11:14] values within a single value for the attribute named sectors.
|
||||
|
||||
Python definition:
|
||||
==================
|
||||
@TODO
|
||||
"""
|
||||
def __init__( self , bound_1 , bound_2 , base_type , UNIQUE = False, OPTIONAL=False):
|
||||
def __init__( self , bound_1 , bound_2 , base_type , UNIQUE = False, OPTIONAL=False, scope = None):
|
||||
BaseType.Type.__init__(self, base_type, scope)
|
||||
if not type(bound_1)==int:
|
||||
raise TypeError("ARRAY lower bound must be an integer")
|
||||
if not type(bound_2)==int:
|
||||
raise TypeError("ARRAY upper bound must be an integer")
|
||||
if not (bound_1 <= bound_2):
|
||||
raise AssertionError("ARRAY lower bound must be less than or equal to upper bound")
|
||||
# the base type can be either a type or a string that defines a type
|
||||
if type(base_type)==str:
|
||||
if globals().has_key(base_type):
|
||||
self._base_type = globals()[base_type]
|
||||
else:
|
||||
raise TypeError("%s does not name a type"%base_type)
|
||||
else:
|
||||
self._base_type = base_type
|
||||
# set up class attributes
|
||||
self._bound_1 = bound_1
|
||||
self._bound_2 = bound_2
|
||||
@@ -108,6 +147,31 @@ class ARRAY(object):
|
||||
def bound_2(self):
|
||||
return self._bound_2
|
||||
|
||||
def get_hiindex(self):
|
||||
return INTEGER(self._bound_2)
|
||||
|
||||
def get_loindex(self):
|
||||
return INTEGER(self._bound_1)
|
||||
|
||||
def get_hibound(self):
|
||||
return INTEGER(self._bound_2)
|
||||
|
||||
def get_lobound(self):
|
||||
return INTEGER(self._bound_1)
|
||||
|
||||
def get_size(self):
|
||||
return INTEGER(self._bound_2 - self._bound_1 +1)
|
||||
|
||||
def get_value_unique(self):
|
||||
''' Return True if all items are different in the container, UNKNOWN if some items are
|
||||
indeterminate, or False otherwise'''
|
||||
if None in self._container:
|
||||
return Unknown
|
||||
if self.get_size()-len(set(self._container))>0: #some items are repeated
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def __getitem__(self, index):
|
||||
if index<self._bound_1:
|
||||
raise IndexError("ARRAY index out of bound (lower bound is %i, passed %i)"%(self._bound_1,index))
|
||||
@@ -126,21 +190,51 @@ class ARRAY(object):
|
||||
raise IndexError("ARRAY index out of bound (upper bound is %i, passed %i)"%(self._bound_2,index))
|
||||
else:
|
||||
# first check the type of the value
|
||||
check_type(value,self._base_type)
|
||||
check_type(value,self.get_type())
|
||||
# then check if the value is already in the array
|
||||
if self._unique:
|
||||
if value in self._container:
|
||||
raise AssertionError("UNIQUE keyword prevent inserting this instance.")
|
||||
raise AssertionError("UNIQUE keyword prevents inserting this instance.")
|
||||
self._container[index-self._bound_1] = value
|
||||
|
||||
class LIST(object):
|
||||
"""A list data type has as its domain sequences of like elements. The optional lower and upper
|
||||
class LIST(BaseType.Type, BaseType.Aggregate):
|
||||
"""
|
||||
EXPRESS definition:
|
||||
==================
|
||||
A list data type has as its domain sequences of like elements. The optional lower and upper
|
||||
bounds, which are integer-valued expressions, define the minimum and maximum number of
|
||||
elements that can be held in the collection defined by a list data type.
|
||||
A list data type
|
||||
definition may optionally specify that a list value cannot contain duplicate elements.
|
||||
|
||||
Syntax:
|
||||
237 list_type = LIST [ bound_spec ] OF [ UNIQUE ] base_type .
|
||||
176 bound_spec = '[' bound_1 ':' bound_2 ']' .
|
||||
174 bound_1 = numeric_expression .
|
||||
175 bound_2 = numeric_expression .
|
||||
171 base_type = aggregation_types | simple_types | named_types .
|
||||
Rules and restrictions:
|
||||
a) The bound_1 expression shall evaluate to an integer value greater than or equal to
|
||||
zero. It gives the lower bound, which is the minimum number of elements that can be in a
|
||||
list value of this data type. bound_1 shall not produce the indeterminate (?) value.
|
||||
b) The bound_2 expression shall evaluate to an integer value greater than or equal to
|
||||
bound_1, or an indeterminate (?) value. It gives the upper bound, which is the maximum
|
||||
number of elements that can be in a list value of this data type.
|
||||
If this value is indeterminate (?) the number of elements in a list value of this data type is
|
||||
not bounded from above.
|
||||
c) If the bound_spec is omitted, the limits are [0:?].
|
||||
d) If the unique keyword is specied, each element in a list value of this data type shall
|
||||
be dierent from (i.e., not instance equal to) every other element in the same list value.
|
||||
EXAMPLE 28 { This example denes a list of arrays. The list can contain zero to ten arrays. Each
|
||||
array of ten integers shall be dierent from all other arrays in a particular list.
|
||||
complex_list : LIST[0:10] OF UNIQUE ARRAY[1:10] OF INTEGER;
|
||||
|
||||
Python definition:
|
||||
==================
|
||||
@TODO
|
||||
"""
|
||||
def __init__( self , bound_1 , bound_2 , base_type , UNIQUE = False):
|
||||
def __init__( self , bound_1 , bound_2 , base_type , UNIQUE = False, scope = None):
|
||||
BaseType.Type.__init__(self, base_type, scope)
|
||||
if not type(bound_1)==int:
|
||||
raise TypeError("LIST lower bound must be an integer")
|
||||
# bound_2 can be set to None
|
||||
@@ -156,7 +250,6 @@ class LIST(object):
|
||||
# set up class attributes
|
||||
self._bound_1 = bound_1
|
||||
self._bound_2 = bound_2
|
||||
self._base_type = base_type
|
||||
self._unique = UNIQUE
|
||||
# preallocate list elements if bounds are both integers
|
||||
if not self._unbounded:
|
||||
@@ -171,6 +264,45 @@ class LIST(object):
|
||||
|
||||
def bound_2(self):
|
||||
return self._bound_2
|
||||
|
||||
def get_size(self):
|
||||
number_of_indeterminates = self._container.count(None)
|
||||
hiindex = len(self._container) - number_of_indeterminates
|
||||
return INTEGER(hiindex)
|
||||
|
||||
def get_hiindex(self):
|
||||
''' When V is a bag, list or set, the returned value is the actual number of elements in
|
||||
the aggregate value.'''
|
||||
number_of_indeterminates = self._container.count(None)
|
||||
hiindex = len(self._container) - number_of_indeterminates
|
||||
return INTEGER(hiindex)
|
||||
|
||||
def get_loindex(self):
|
||||
return INTEGER(1)
|
||||
|
||||
def get_hibound(self):
|
||||
hibound = self._bound_2
|
||||
if type(hibound)==int:
|
||||
return INTEGER(hibound)
|
||||
else:
|
||||
return hibound
|
||||
|
||||
def get_lobound(self):
|
||||
lobound = self._bound_1
|
||||
if type(lobound)==int:
|
||||
return INTEGER(lobound)
|
||||
else:
|
||||
return lobound
|
||||
|
||||
def get_value_unique(self):
|
||||
''' Return True if all items are different in the container, UNKNOWN if some items are
|
||||
indeterminate, or False otherwise'''
|
||||
if None in self._container:
|
||||
return Unknown
|
||||
if self.get_size()-len(set(self._container))>0: #some items are repeated
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def __getitem__(self, index):
|
||||
# case bounded
|
||||
@@ -203,7 +335,7 @@ class LIST(object):
|
||||
raise IndexError("ARRAY index out of bound (upper bound is %i, passed %i)"%(self._bound_2,index))
|
||||
else:
|
||||
# first check the type of the value
|
||||
check_type(value,self._base_type)
|
||||
check_type(value,self.get_type())
|
||||
# then check if the value is already in the array
|
||||
if self._unique:
|
||||
if value in self._container:
|
||||
@@ -216,7 +348,7 @@ class LIST(object):
|
||||
# if the _container list is of good size, just do like the bounded case
|
||||
if (index-self._bound_1<len(self._container)):
|
||||
# first check the type of the value
|
||||
check_type(value,self._base_type)
|
||||
check_type(value,self.get_type)
|
||||
# then check if the value is already in the array
|
||||
if self._unique:
|
||||
if value in self._container:
|
||||
@@ -229,37 +361,242 @@ class LIST(object):
|
||||
list_extension = delta_size*[None]
|
||||
self._container.extend(list_extension)
|
||||
# first check the type of the value
|
||||
check_type(value,self._base_type)
|
||||
check_type(value,self.get_type())
|
||||
# then check if the value is already in the array
|
||||
if self._unique:
|
||||
if value in self._container:
|
||||
raise AssertionError("UNIQUE keyword prevent inserting this instance.")
|
||||
self._container[index-self._bound_1] = value
|
||||
|
||||
class BAG(tuple, BaseAggregate):
|
||||
"""A bag data type has as its domain unordered collections of like elements. The optional lower
|
||||
and upper bounds, which are integer-valued expressions, dene the minimum and maximum
|
||||
number of elements that can be held in the collection dened by a bag data type.
|
||||
class BAG(BaseType.Type, BaseType.Aggregate):
|
||||
"""
|
||||
def __init__( self , bound1 , bound2 , base_type ):
|
||||
BaseAggregate.__init__( self , bound1 , bound2 , base_type )
|
||||
EXPRESS definition:
|
||||
==================
|
||||
A bag data type has as its domain unordered collections of like elements. The optional lower
|
||||
and upper bounds, which are integer-valued expressions, define the minimum and maximum
|
||||
number of elements that can be held in the collection dened by a bag data type.
|
||||
|
||||
Syntax:
|
||||
170 bag_type = BAG [ bound_spec ] OF base_type .
|
||||
176 bound_spec = '[' bound_1 ':' bound_2 ']' .
|
||||
174 bound_1 = numeric_expression .
|
||||
175 bound_2 = numeric_expression .
|
||||
171 base_type = aggregation_types | simple_types | named_types .
|
||||
|
||||
Rules and restrictions:
|
||||
a) The bound_1 expression shall evaluate to an integer value greater than or equal to
|
||||
zero. It gives the lower bound, which is the minimum number of elements that can be in a
|
||||
bag value of this data type. bound_1 shall not produce the indeterminate (?) value.
|
||||
b) The bound_2 expression shall evaluate to an integer value greater than or equal to
|
||||
bound_1, or an indeterminate (?) value. It gives the upper bound, which is the maximum
|
||||
number of elements that can be in a bag value of this data type.
|
||||
If this value is indeterminate (?) the number of elements in a bag value of this data type is
|
||||
not be bounded from above.
|
||||
c) If the bound_spec is omitted, the limits are [0:?].
|
||||
EXAMPLE 29 (This example defines an attribute as a bag of point (where point is a named data
|
||||
type assumed to have been declared elsewhere).
|
||||
a_bag_of_points : BAG OF point;
|
||||
The value of the attribute named a_bag_of_points can contain zero or more points. The same
|
||||
point instance may appear more than once in the value of a_bag_of_points.
|
||||
If the value is required to contain at least one element, the specification can provide a lower bound,
|
||||
as in:
|
||||
a_bag_of_points : BAG [1:?] OF point;
|
||||
The value of the attribute named a_bag_of_points now must contain at least one point.
|
||||
|
||||
Python definition:
|
||||
==================
|
||||
@TODO
|
||||
"""
|
||||
def __init__( self , bound_1 , bound_2 , base_type , scope = None):
|
||||
BaseType.Type.__init__(self, base_type, scope)
|
||||
if not type(bound_1)==int:
|
||||
raise TypeError("LIST lower bound must be an integer")
|
||||
# bound_2 can be set to None
|
||||
self._unbounded = False
|
||||
if bound_2 == None:
|
||||
self._unbounded = True
|
||||
elif not type(bound_2)==int:
|
||||
raise TypeError("LIST upper bound must be an integer")
|
||||
if not bound_1>=0:
|
||||
raise AssertionError("LIST lower bound must be greater of equal to 0")
|
||||
if (type(bound_2)==int and not (bound_1 <= bound_2)):
|
||||
raise AssertionError("ARRAY lower bound must be less than or equal to upper bound")
|
||||
# set up class attributes
|
||||
self._bound_1 = bound_1
|
||||
self._bound_2 = bound_2
|
||||
self._container = []
|
||||
|
||||
class SET(set, BaseAggregate):
|
||||
"""A set data type has as its domain unordered collections of like elements. The set data type is
|
||||
def bound_1(self):
|
||||
return self._bound_1
|
||||
|
||||
def bound_2(self):
|
||||
return self._bound_2
|
||||
|
||||
def add(self,value):
|
||||
'''
|
||||
Adds a value to the bag
|
||||
'''
|
||||
if self._unbounded:
|
||||
check_type(value,self.get_type())
|
||||
self._container.append(value)
|
||||
else:
|
||||
# first ensure that the bag is not full
|
||||
if len(self._container) == self._bound_2 - self._bound_1 + 1:
|
||||
raise AssertionError('BAG is full. Impossible to add any more item')
|
||||
else:
|
||||
check_type(value,self.get_type())
|
||||
self._container.append(value)
|
||||
|
||||
def get_size(self):
|
||||
''' When V is a bag, list or set, the returned value is the actual number of elements in
|
||||
the aggregate value.'''
|
||||
return INTEGER(len(self._container))
|
||||
|
||||
def get_hiindex(self):
|
||||
''' When V is a bag, list or set, the returned value is the actual number of elements in
|
||||
the aggregate value.'''
|
||||
return INTEGER(len(self._container))
|
||||
|
||||
def get_loindex(self):
|
||||
return INTEGER(1)
|
||||
|
||||
def get_hibound(self):
|
||||
hibound = self._bound_2
|
||||
if type(hibound)==int:
|
||||
return INTEGER(hibound)
|
||||
else:
|
||||
return hibound
|
||||
|
||||
def get_lobound(self):
|
||||
lobound = self._bound_1
|
||||
if type(lobound)==int:
|
||||
return INTEGER(lobound)
|
||||
else:
|
||||
return lobound
|
||||
def get_value_unique(self):
|
||||
''' Return True if all items are different in the container, UNKNOWN if some items are
|
||||
indeterminate, or False otherwise'''
|
||||
if None in self._container:
|
||||
return Unknown
|
||||
if self.get_size()-len(set(self._container))>0: #some items are repeated
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
class SET(BaseType.Type, BaseType.Aggregate):
|
||||
"""
|
||||
EXPRESS definition:
|
||||
==================
|
||||
A set data type has as its domain unordered collections of like elements. The set data type is
|
||||
a specialization of the bag data type. The optional lower and upper bounds, which are integer-
|
||||
valued expressions, dene the minimum and maximum number of elements that can be held in
|
||||
the collection dened by a set data type. The collection dened by set data type shall not
|
||||
contain two or more elements which are instance equal.
|
||||
Syntax:
|
||||
285 set_type = SET [ bound_spec ] OF base_type .
|
||||
176 bound_spec = '[' bound_1 ':' bound_2 ']' .
|
||||
174 bound_1 = numeric_expression .
|
||||
175 bound_2 = numeric_expression .
|
||||
171 base_type = aggregation_types | simple_types | named_types .
|
||||
Rules and restrictions:
|
||||
a) The bound_1 expression shall evaluate to an integer value greater than or equal to
|
||||
zero. It gives the lower bound, which is the minimum number of elements that can be in a
|
||||
set value of this data type. bound_1 shall not produce the indeterminate (?) value.
|
||||
b) The bound_2 expression shall evaluate to an integer value greater than or equal to
|
||||
bound_1, or an indeterminate (?) value. It gives the upper bound, which is the maximum
|
||||
number of elements that can be in a set value of this data type.
|
||||
If this value is indeterminate (?) the number of elements in a set value of this data type is
|
||||
not be bounded from above.
|
||||
c) If the bound_spec is omitted, the limits are [0:?].
|
||||
d) Each element in an occurrence of a set data type shall be dierent from (i.e., not
|
||||
instance equal to) every other element in the same set value.
|
||||
EXAMPLE 30 { This example denes an attribute as a set of points (a named data type assumed
|
||||
to have been declared elsewhere).
|
||||
a_set_of_points : SET OF point;
|
||||
The attribute named a_set_of_points can contain zero or more points. Each point instance (in
|
||||
the set value) is required to be dierent from every other point in the set.
|
||||
If the value is required to have no more than 15 points, the specication can provide an upper bound,
|
||||
as in:
|
||||
a_set_of_points : SET [0:15] OF point;
|
||||
The value of the attribute named a_set_of_points now may contain no more than 15 points.
|
||||
|
||||
Python definition:
|
||||
==================
|
||||
The difference with the BAG class is that the base container for SET is a set object.
|
||||
"""
|
||||
def __init__( self , bound1 , bound2 , base_type ):
|
||||
BaseAggregate.__init__( self , bound1 , bound2 , base_type )
|
||||
def __init__( self , bound_1 , bound_2 , base_type , scope = None):
|
||||
BaseType.Type.__init__(self, base_type, scope)
|
||||
if not type(bound_1)==int:
|
||||
raise TypeError("LIST lower bound must be an integer")
|
||||
# bound_2 can be set to None
|
||||
self._unbounded = False
|
||||
if bound_2 == None:
|
||||
self._unbounded = True
|
||||
elif not type(bound_2)==int:
|
||||
raise TypeError("LIST upper bound must be an integer")
|
||||
if not bound_1>=0:
|
||||
raise AssertionError("LIST lower bound must be greater of equal to 0")
|
||||
if (type(bound_2)==int and not (bound_1 <= bound_2)):
|
||||
raise AssertionError("ARRAY lower bound must be less than or equal to upper bound")
|
||||
# set up class attributes
|
||||
self._bound_1 = bound_1
|
||||
self._bound_2 = bound_2
|
||||
self._container = set()
|
||||
|
||||
if __name__=='__main__':
|
||||
# test ARRAY
|
||||
a = ARRAY(1,3,REAL)
|
||||
a[1] = REAL(3.)
|
||||
a[2] = REAL(-1.5)
|
||||
a[3] = REAL(4.)
|
||||
print a
|
||||
def bound_1(self):
|
||||
return self._bound_1
|
||||
|
||||
def bound_2(self):
|
||||
return self._bound_2
|
||||
|
||||
def add(self,value):
|
||||
'''
|
||||
Adds a value to the bag
|
||||
'''
|
||||
if self._unbounded:
|
||||
check_type(value,self.get_type())
|
||||
self._container.add(value)
|
||||
else:
|
||||
# first ensure that the bag is not full
|
||||
if len(self._container) == self._bound_2 - self._bound_1 + 1:
|
||||
if not value in self._container:
|
||||
raise AssertionError('SET is full. Impossible to add any more item')
|
||||
else:
|
||||
check_type(value,self.get_type())
|
||||
self._container.add(value)
|
||||
|
||||
def get_size(self):
|
||||
''' When V is a bag, list or set, the returned value is the actual number of elements in
|
||||
the aggregate value.'''
|
||||
return INTEGER(len(self._container))
|
||||
|
||||
def get_hiindex(self):
|
||||
''' When V is a bag, list or set, the returned value is the actual number of elements in
|
||||
the aggregate value.'''
|
||||
return INTEGER(len(self._container))
|
||||
|
||||
def get_loindex(self):
|
||||
return INTEGER(1)
|
||||
|
||||
def get_hibound(self):
|
||||
hibound = self._bound_2
|
||||
if type(hibound)==int:
|
||||
return INTEGER(hibound)
|
||||
else:
|
||||
return hibound
|
||||
|
||||
def get_lobound(self):
|
||||
lobound = self._bound_1
|
||||
if type(lobound)==int:
|
||||
return INTEGER(lobound)
|
||||
else:
|
||||
return lobound
|
||||
|
||||
def get_value_unique(self):
|
||||
''' Return True if all items are different in the container, UNKNOWN if some items are
|
||||
indeterminate, or False otherwise'''
|
||||
if None in self._container:
|
||||
return Unknown
|
||||
else:
|
||||
return True
|
||||
|
||||
@@ -29,43 +29,41 @@
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from math import *
|
||||
PI = pi #in EXPRESS, PI is uppercase
|
||||
|
||||
def EvalDerivedAttribute(class_instance, str_expr):
|
||||
class Type(object):
|
||||
'''
|
||||
This functions tries to evaluate EXPRESS math expr.
|
||||
For instance in the following example:
|
||||
==
|
||||
ENTITY circle;
|
||||
centre : point;
|
||||
radius : REAL;
|
||||
axis : vector;
|
||||
DERIVE
|
||||
area : REAL := PI*radius**2;
|
||||
perimeter : REAL := 2.0*PI*radius;
|
||||
|
||||
END_ENTITY;
|
||||
==
|
||||
The following string should be passed to EvalExpr:
|
||||
'PI*radius**2'
|
||||
A type can be defined from its name and scope
|
||||
Looking into the scope dict returns the python type class.
|
||||
This is the base class for aggregated data types or constructed data types
|
||||
'''
|
||||
# first, try to find class paramters
|
||||
# in the previous example, we should replace radius with self.radius before eval'ing expr
|
||||
props = []
|
||||
for prop in dir(class_instance):
|
||||
if not prop.startswith("_"): #means prop is an item that might be considered
|
||||
props.append(prop)
|
||||
for item in props:
|
||||
str_expr = str_expr.replace(item,"class_instance.%s"%item)
|
||||
# after that step, the expression should be:
|
||||
# PI*class_instance.radius*class_instance.radius
|
||||
# this can be evaluated with the eval function
|
||||
# CAREFUL: eval is known to be unsafe. This should be changed in the future
|
||||
# (using a parser, or simpy for instance)
|
||||
try:
|
||||
return eval(str_expr.lower())
|
||||
except:
|
||||
print 'Error evaluating expression'
|
||||
return None
|
||||
def __init__(self, typedef, scope):
|
||||
self._scope = scope
|
||||
self._typedef = typedef
|
||||
|
||||
def get_scope(self):
|
||||
return self._scope
|
||||
|
||||
def get_type(self):
|
||||
if type(self._typedef) == str:
|
||||
if self._scope == None:
|
||||
raise AssertionError('No scope defined for this type')
|
||||
elif vars(self._scope).has_key(self._typedef):
|
||||
return vars(self._scope)[self._typedef]
|
||||
else:
|
||||
raise TypeError("Type '%s' is not defined in given scope"%self._typedef)
|
||||
else:
|
||||
return self._typedef
|
||||
|
||||
class Aggregate:
|
||||
'''
|
||||
This is an abstract class. ARRAY, LIST, SET and BAG inherit from this class
|
||||
'''
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
scp = sys.modules[__name__]
|
||||
class line:
|
||||
pass
|
||||
new_type = Type('lie',scp)
|
||||
print new_type.get_type()
|
||||
|
||||
@@ -0,0 +1,716 @@
|
||||
# Copyright (c) 2011-2012, Thomas Paviot (tpaviot@gmail.com)
|
||||
# All rights reserved.
|
||||
|
||||
# This file is part of the StepClassLibrary (SCL).
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# Neither the name of the <ORGANIZATION> nor the names of its contributors may
|
||||
# be used to endorse or promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
__doc__ = "This module defines EXPRESS built in constants and functions"
|
||||
import math
|
||||
|
||||
from SimpleDataTypes import *
|
||||
from BaseType import Aggregate
|
||||
from AggregationDataTypes import *
|
||||
|
||||
SCL_float_epsilon = 1e-7
|
||||
# Builtin constants
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#14.1 CONST_E is a REAL constant representing the mathematical value e, the base of the natural
|
||||
#logarithm function (ln).
|
||||
CONST_E = REAL(math.pi)
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#14.2 Indeterminate
|
||||
#The indeterminate symbol (?) stands for an ambiguous value. It is compatible with all data
|
||||
#types.
|
||||
#NOTE - The most common use of indeterminate (?) is as the upper bound specication of a bag,
|
||||
#list or set. This usage represents the notion that the size of the aggregate value dened by the
|
||||
#aggregation data type is unbounded.
|
||||
# python note: indeterminate value is mapped to None in aggregate bounds
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#14.3 False
|
||||
#false is a logical constant representing the logical notion of falsehood. It is compatible with
|
||||
#the boolean and logical data types.
|
||||
FALSE = False
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#14.4 Pi
|
||||
#PI is a REAL constant representing the mathematical value , the ratio of a circle's circumference
|
||||
#to its diameter.
|
||||
PI = REAL(math.pi)
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#14.5 Self
|
||||
#SELF refers to the current entity instance or type value. self may appear within an entity
|
||||
#declaration, a type declaration or an entity constructor.
|
||||
#NOTE - sSELF is not a constant, but behaves as one in every context in which it can appear.
|
||||
# python note: SELF is not mapped to any constant, but is mapper to self
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#14.6 True
|
||||
#true is a logical constant representing the logical notion of truth. It is compatible with the
|
||||
#boolean and logical data types.
|
||||
TRUE = True
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#14.7 Unknown
|
||||
#unknown is a logical constant representing that there is insucient information available to
|
||||
#be able to evaluate a logical condition. It is compatible with the logical data type, but not
|
||||
#with the boolean data type.
|
||||
# @TODO: define UNKNOWN in python
|
||||
|
||||
#
|
||||
# Builtin Functions
|
||||
#15 Built-in functions
|
||||
#All functions (and mathematical operations in general) are assumed to evaluate to exact results.
|
||||
#The prototype for each of the built-in functions is given to show the type of the formal parameters
|
||||
#and the result.
|
||||
#
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.1 Abs - arithmetic function
|
||||
#FUNCTION ABS ( V:NUMBER ) : NUMBER;
|
||||
#The abs function returns the absolute value of a number.
|
||||
#Parameters : V is a number.
|
||||
#Result : The absolute value of V. The returned data type is identical to the data type of V.
|
||||
#EXAMPLE 125 { ABS ( -10 ) --> 10
|
||||
# Python definition:
|
||||
# ==================
|
||||
# ABS is mapped to python abs builtin function
|
||||
def ABS(V):
|
||||
if not isinstance(V,NUMBER):
|
||||
raise TypeError("ABS function takes a NUMBER parameter")
|
||||
return type(V)(abs(V))
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.2 ACos - arithmetic function
|
||||
#FUNCTION ACOS ( V:NUMBER ) : REAL;
|
||||
#The acos function returns the angle given a cosine value.
|
||||
#Parameters : V is a number which is the cosine of an angle.
|
||||
#Result : The angle in radians (0 result ) whose cosine is V.
|
||||
#Conditions : -1.0=<V<=1.0
|
||||
#EXAMPLE 126 { ACOS ( 0.3 ) --> 1.266103...
|
||||
# Python definition:
|
||||
# ==================
|
||||
# ACOS is mapped to python math.acos builtin function
|
||||
def ACOS(V):
|
||||
if not isinstance(V,NUMBER):
|
||||
raise TypeError("ACOS function takes a NUMBER parameter")
|
||||
return REAL(math.acos(V))
|
||||
|
||||
# it's the same for ASIN and ATAN
|
||||
def ASIN(V):
|
||||
if not isinstance(V,NUMBER):
|
||||
raise TypeError("ASIN function takes a NUMBER parameter")
|
||||
return REAL(math.asin(V))
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
# 15.3 ATan - arithmetic function
|
||||
#FUNCTION ATAN ( V1:NUMBER; V2:NUMBER ) : REAL;
|
||||
#The atan function returns the angle given a tangent value of V , where V is given by the
|
||||
#expression V = V1/V2.
|
||||
#Parameters :
|
||||
#a) V1 is a number.
|
||||
#b) V2 is a number.
|
||||
#Result : The angle in radians (-pi/2<=result<=pi/2) whose tangent is V. If V2 is zero, the result
|
||||
#is pi/2 or -pi/2 depending on the sign of V1.
|
||||
#Conditions : Both V1 and V2 shall not be zero.
|
||||
#EXAMPLE 128 { ATAN ( -5.5, 3.0 ) --> -1.071449...
|
||||
def ATAN(V1,V2):
|
||||
if not isinstance(V1,NUMBER) and not isinstance(V2,NUMBER):
|
||||
raise TypeError("ATAN function takes 2 NUMBER parameters")
|
||||
if V2 == 0:
|
||||
if V1>0:
|
||||
return REAL(math.pi/2)
|
||||
elif V1<0:
|
||||
return REAL(-math.pi/2)
|
||||
else:
|
||||
raise ValueError("ATAN parameters can be both equal to zero")
|
||||
else:
|
||||
return REAL(math.atan(float(V1)/float(V2)))
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.5 BLength - binary function
|
||||
#FUNCTION BLENGTH ( V:BINARY ) : INTEGER;
|
||||
#The blength function returns the number of bits in a binary.
|
||||
#Parameters : V is a binary value.
|
||||
#Result : The returned value is the actual number of bits in the binary value passed.
|
||||
#EXAMPLE 129
|
||||
#LOCAL
|
||||
#n : NUMBER;
|
||||
#x : BINARY := %01010010 ;
|
||||
#END_LOCAL;
|
||||
#...
|
||||
#n := BLENGTH ( x ); -- n is assigned the value 8
|
||||
def BLENGTH(V):
|
||||
if not isinstance(V,BINARY):
|
||||
raise TypeError("BLENGTH function takes one BINARY parameter")
|
||||
return INTEGER(len(V))
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.6 Cos - arithmetic function
|
||||
#FUNCTION COS ( V:NUMBER ) : REAL;
|
||||
#The cos function returns the cosine of an angle.
|
||||
#Parameters : V is a number which is an angle in radians.
|
||||
#Result : The cosine of V (-1.0<=result<=1.0).
|
||||
#EXAMPLE 130 { COS ( 0.5 ) --> 8.77582...E-1
|
||||
#
|
||||
#15.21 Sin - arithmetic function
|
||||
#FUNCTION SIN ( V:NUMBER ) : REAL;
|
||||
#The sin function returns the sine of an angle.
|
||||
#Parameters : V is a number representing an angle expressed in radians.
|
||||
#Result : The sine of V (-1.0 result 1.0).
|
||||
#EXAMPLE 144 { SIN ( PI ) --> 0.0
|
||||
#
|
||||
def COS(V):
|
||||
if not isinstance(V,NUMBER):
|
||||
raise TypeError("COS function takes a NUMBER parameter")
|
||||
return REAL(math.cos(V))
|
||||
def SIN(V):
|
||||
if not isinstance(V,NUMBER):
|
||||
raise TypeError("SIN function takes a NUMBER parameter")
|
||||
return REAL(math.sin(V))
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.7 Exists - general function
|
||||
#FUNCTION EXISTS ( V:GENERIC ) : BOOLEAN;
|
||||
#The exists function returns true if a value exists for the input parameter, or false if no value
|
||||
#exists for it. The exists function is useful for checking if values have been given to optional
|
||||
#attributes, or if variables have been initialized.
|
||||
#Parameters : V is an expression which results in any type.
|
||||
#Result : true or false depending on whether V has an actual or indeterminate (?) value.
|
||||
#EXAMPLE 131 { IF EXISTS ( a ) THEN ...
|
||||
def EXISTS(V):
|
||||
if V==None:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.8 Exp - arithmetic function
|
||||
#FUNCTION EXP ( V:NUMBER ) : REAL;
|
||||
#The exp function returns e (the base of the natural logarithm system) raised to the power V.
|
||||
#Parameters : V is a number.
|
||||
#Result : The value eV .
|
||||
#EXAMPLE 132 { EXP ( 10 ) --> 2.202646...E+4
|
||||
def EXP(V):
|
||||
if not isinstance(V,NUMBER):
|
||||
raise TypeError("EXP function takes a NUMBER parameter")
|
||||
return REAL(math.exp(V))
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.9 Format - general function
|
||||
#FUNCTION FORMAT(N:NUMBER; F:STRING):STRING;
|
||||
#The format returns a formatted string representation of a number.
|
||||
#Parameters :
|
||||
#a) N is a number (integer or real).
|
||||
#b) F is a string containing formatting commands.
|
||||
#Result : A string representation of N formatted according to F. Rounding is applied to the
|
||||
#string representation if necessary.
|
||||
#The formatting string contains special characters to indicate the appearance of the result. The
|
||||
#formatting string can be written in three ways:
|
||||
#a) The formatting string can give a symbolic description of the output representation.
|
||||
#b) The formatting string can give a picture description of the output representation.
|
||||
#c) When the formatting string is empty, a standard output representation is produced.
|
||||
# Table 20:
|
||||
#Number Format Display Comment
|
||||
#10 +7I ' +10' Zero suppression
|
||||
#10 +07I '+000010' Zeros not suppressed
|
||||
#10 10.3E ' 1.000E+01'
|
||||
#123.456789 8.2F ' 123.46'
|
||||
#123.456789 8.2E '1.23E+02'
|
||||
#123.456789 08.2E '0.12E+02' Preceding zero forced
|
||||
#9.876E123 8.2E '9.88E+123' Exponent part is 3 characters
|
||||
#and width ignored
|
||||
#32.777 6I ' 33' Rounded
|
||||
# Python definition
|
||||
# =================
|
||||
# python string formatting is obtained from the val function
|
||||
# @TODO: implement a safe eval or provide another implementation
|
||||
# that avoids unsafe eval python builtin function.
|
||||
def FORMAT(N,F):
|
||||
if not isinstance(N,NUMBER):
|
||||
raise TypeError("FORMAT function takes a NUMBER parameter")
|
||||
if not isinstance(F,STRING):
|
||||
raise TypeError("FORMAT function takes a NUMBER parameter")
|
||||
py_formatting = F.lower()
|
||||
string_to_evaluate = "'%"
|
||||
string_to_evaluate += "%s'"%py_formatting
|
||||
string_to_evaluate += "%"
|
||||
string_to_evaluate += "%s"%N
|
||||
result = eval(string_to_evaluate).upper()
|
||||
return STRING(result)
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.10 HiBound - arithmetic function
|
||||
#FUNCTION HIBOUND ( V:AGGREGATE OF GENERIC ) : INTEGER;
|
||||
#The hibound function returns the declared upper index of an array or the declared upper
|
||||
#bound of a bag, list or set.
|
||||
#Parameters : V is an aggregate value.
|
||||
#Result :
|
||||
#a) When V is an array the returned value is the declared upper index.
|
||||
#b) When V is a bag, list or set the returned value is the declared upper bound; if there
|
||||
#are no bounds declared or the upper bound is declared to be indeterminate (?) indeterminate
|
||||
#(?) is returned.
|
||||
#EXAMPLE 133 { Usage of hibound function on nested aggregate values.
|
||||
#LOCAL
|
||||
#a : ARRAY[-3:19] OF SET[2:4] OF LIST[0:?] OF INTEGER;
|
||||
#h1, h2, h3 : INTEGER;
|
||||
#END_LOCAL;
|
||||
#...
|
||||
#a[-3][1][1] := 2; -- places a value in the list
|
||||
#...
|
||||
#h1 := HIBOUND(a); -- =19 (upper bound of array)
|
||||
#h2 := HIBOUND(a[-3]); -- = 4 (upper bound of set)
|
||||
#h3 := HIBOUND(a[-3][1]); -- = ? (upper bound of list (unbounded))
|
||||
def HIBOUND(V):
|
||||
if not isinstance(V,Aggregate):
|
||||
raise TypeError("HIBOUND takes an aggregate of generic")
|
||||
return V.get_hibound()
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.11 HiIndex - arithmetic function
|
||||
#FUNCTION HIINDEX ( V:AGGREGATE OF GENERIC ) : INTEGER;
|
||||
#The hiindex function returns the upper index of an array or the number of elements in a bag,
|
||||
#list or set
|
||||
#Parameters : V is an aggregate value.
|
||||
#Result :
|
||||
#a) When V is an array, the returned value is the declared upper index.
|
||||
#b) When V is a bag, list or set, the returned value is the actual number of elements in
|
||||
#the aggregate value.
|
||||
#EXAMPLE 134 { Usage of hiindex function on nested aggregate values.
|
||||
#LOCAL
|
||||
#a : ARRAY[-3:19] OF SET[2:4] OF LIST[0:?] OF INTEGER;
|
||||
#h1, h2, h3 : INTEGER;
|
||||
#END_LOCAL;
|
||||
#a[-3][1][1] := 2; -- places a value in the list
|
||||
#h1 := HIINDEX(a); -- = 19 (upper bound of array)
|
||||
#h2 := HIINDEX(a[-3]); -- = 1 (size of set) -- this is invalid with respect
|
||||
#-- to the bounds on the SET
|
||||
#h3 := HIINDEX(a[-3][1]); -- = 1 (size of list)
|
||||
def HIINDEX(V):
|
||||
if not isinstance(V,Aggregate):
|
||||
raise TypeError("HIINDEX takes an aggregate of generic")
|
||||
return V.get_hiindex()
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.12 Length - string function
|
||||
#FUNCTION LENGTH ( V:STRING ) : INTEGER;
|
||||
#The length function returns the number of characters in a string.
|
||||
#Parameters : V is a string value.
|
||||
#Result : The returned value is the number of characters in the string and shall be greater than
|
||||
#or equal to zero.
|
||||
#EXAMPLE 135 - Usage of the length function.
|
||||
#LOCAL
|
||||
#n : NUMBER;
|
||||
#x1 : STRING := 'abc';
|
||||
#x2 : STRING := "000025FF000101B5;
|
||||
#END_LOCAL;
|
||||
#...
|
||||
#n := LENGTH ( x1 ); -- n is assigned the value 3
|
||||
#n := LENGTH ( x2 ); -- n is assigned the value 2
|
||||
def LENGTH(V):
|
||||
if not isinstance(V,STRING):
|
||||
raise TypeError("LENGTH take a STRING parameter")
|
||||
return INTEGER(len(V))
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.13 LoBound - arithmetic function
|
||||
#FUNCTION LOBOUND ( V:AGGREGATE OF GENERIC ) : INTEGER;
|
||||
#The lobound function returns the declared lower index of an array, or the declared lower
|
||||
#bound of a bag, list or set.
|
||||
#Parameters : V is an aggregate value.
|
||||
#Result :
|
||||
#a) When V is an array the returned value is the declared lower index.
|
||||
#b) When V is a bag, list or set the returned value is the declared lower bound; if no
|
||||
#lower bound is declared, zero (0) is returned.
|
||||
#EXAMPLE 136 { Usage of lobound function on nested aggregate values.
|
||||
#LOCAL
|
||||
#a : ARRAY[-3:19] OF SET[2:4] OF LIST[0:?] OF INTEGER;
|
||||
#h1, h2, h3 : INTEGER;
|
||||
#END_LOCAL;
|
||||
#...
|
||||
#h1 := LOBOUND(a); -- =-3 (lower index of array)
|
||||
#h2 := LOBOUND(a[-3]); -- = 2 (lower bound of set)
|
||||
#h3 := LOBOUND(a[-3][1]); -- = 0 (lower bound of list)
|
||||
def LOBOUND(V):
|
||||
if not isinstance(V,Aggregate):
|
||||
raise TypeError("HIBOUND takes an aggregate of generic")
|
||||
return V.get_lobound()
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.14 Log - arithmetic function
|
||||
#FUNCTION LOG ( V:NUMBER ) : REAL;
|
||||
#The log function returns the natural logarithm of a number.
|
||||
#Parameters : V is a number.
|
||||
#Result : A real number which is the natural logarithm of V.
|
||||
#Conditions : V > 0:0
|
||||
#EXAMPLE 137 { LOG ( 4.5 ) --> 1.504077...E0
|
||||
#15.15 Log2 - arithmetic function
|
||||
#FUNCTION LOG2 ( V:NUMBER ) : REAL;
|
||||
#The log2 function returns the base two logarithm of a number.
|
||||
#Parameters : V is a number.
|
||||
#Result : A real number which is the base two logarithm of V.
|
||||
#Conditions : V > 0:0
|
||||
#EXAMPLE 138 { LOG2 ( 8 ) --> 3.00...E0
|
||||
#15.16 Log10 - arithmetic function
|
||||
#FUNCTION LOG10 ( V:NUMBER ) : REAL;
|
||||
#The log10 function returns the base ten logarithm of a number.
|
||||
#Parameters : V is a number.
|
||||
#Result : A real number which is the base ten logarithm of V.
|
||||
#Conditions : V > 0:0
|
||||
#EXAMPLE 139 { LOG10 ( 10 ) --> 1.00...E0
|
||||
def LOG(V):
|
||||
if not isinstance(V,NUMBER):
|
||||
raise TypeError("LOG function takes a NUMBER parameter")
|
||||
return REAL(math.log(V))
|
||||
def LOG2(V):
|
||||
if not isinstance(V,NUMBER):
|
||||
raise TypeError("LOG2 function takes a NUMBER parameter")
|
||||
return REAL(math.log(V,2))
|
||||
def LOG10(V):
|
||||
if not isinstance(V,NUMBER):
|
||||
raise TypeError("LOG10 function takes a NUMBER parameter")
|
||||
return REAL(math.log10(V))
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.17 LoIndex - arithmetic function
|
||||
#FUNCTION LOINDEX ( V:AGGREGATE OF GENERIC ) : INTEGER;
|
||||
#The loindex function returns the lower index of an aggregate value.
|
||||
#Parameters : V is an aggregate value.
|
||||
#Result :
|
||||
#a) When V is an array the returned value is the declared lower index.
|
||||
#b) When V is a bag, list or set, the returned value is 1 (one).
|
||||
#EXAMPLE 140 { Usage of loindex function on nested aggregate values.
|
||||
#LOCAL
|
||||
#a : ARRAY[-3:19] OF SET[2:4] OF LIST[0:?] OF INTEGER;
|
||||
#h1, h2, h3 : INTEGER;
|
||||
#END_LOCAL;
|
||||
#...
|
||||
#h1 := LOINDEX(a); -- =-3 (lower bound of array)
|
||||
#h2 := LOINDEX(a[-3]); -- = 1 (for set)
|
||||
#h3 := LOINDEX(a[-3][1]); -- = 1 (for list)
|
||||
def LOINDEX(V):
|
||||
if not isinstance(V,Aggregate):
|
||||
raise TypeError("LOINDEX takes an aggregate of generic")
|
||||
return V.get_loindex()
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.18 NVL - null value function
|
||||
#FUNCTION NVL(V:GENERIC:GEN1; SUBSTITUTE:GENERIC:GEN1):GENERIC:GEN1;
|
||||
#The nvl function returns either the input value or an alternate value in the case where the input
|
||||
#has a indeterminate (?) value.
|
||||
#Parameters :
|
||||
#a) V is an expression which is of any type.
|
||||
#b) SUBSTITUTE is an expression which shall not evaluate to indeterminate (?).
|
||||
#Result : When V is not indeterminate (?) that value is returned. Otherwise, SUBSTITUTE is
|
||||
#returned.
|
||||
#EXAMPLE 141 { ENTITY unit_vector;
|
||||
#x, y : REAL;
|
||||
#z : OPTIONAL REAL;
|
||||
#WHERE
|
||||
#x**2 + y**2 + NVL(z, 0.0)**2 = 1.0;
|
||||
#END_ENTITY;
|
||||
#The nvl function is used to supply zero (0.0) as the value of Z when Z is indeterminate (?).
|
||||
def NVL(V,SUBSTITUTE):
|
||||
if V is not None:
|
||||
return V
|
||||
else:
|
||||
return SUBSTITUTE
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.19 Odd - arithmetic function
|
||||
#FUNCTION ODD ( V:INTEGER ) : LOGICAL;
|
||||
#The odd function returns true or false depending on whether a number is odd or even.
|
||||
#Parameters : V is an integer number.
|
||||
#Result : When V MOD 2 = 1 true is returned; otherwise false is returned.
|
||||
#Conditions : Zero is not odd.
|
||||
#EXAMPLE 142 { ODD ( 121 ) --> TRUE
|
||||
def ODD(V):
|
||||
if not isinstance(V,INTEGER):
|
||||
raise TypeError("ODD takes an INTEGER")
|
||||
if V%2 == 0:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.20 RolesOf - general function
|
||||
#FUNCTION ROLESOF ( V:GENERIC ) : SET OF STRING;
|
||||
#The rolesof function returns a set of strings containing the fully qualied names of the roles
|
||||
#played by the specied entity instance. A fully qualied name is dened to be the name of the
|
||||
#attribute qualied by the name of the schema and entity in which this attribute is declared (i.e.
|
||||
#'SCHEMA.ENTITY.ATTRIBUTE').
|
||||
#Parameters : V is any instance of an entity data type.
|
||||
#Result : A set of string values (in upper case) containing the fully qualied names of the
|
||||
#attributes of the entity instances which use the instance V.
|
||||
#When a named data type is use'd or reference'd, the schema and the name in that schema,
|
||||
#if renamed, are also returned. Since use statements may be chained, all the chained schema
|
||||
#names and the name in each schema are returned.
|
||||
#EXAMPLE 143 { This example shows that a point might be used as the centre of a circle. The
|
||||
#rolesof function determines what roles an entity instance actually plays.
|
||||
#SCHEMA that_schema;
|
||||
#ENTITY point;
|
||||
#x, y, z : REAL;
|
||||
#END_ENTITY;
|
||||
#ENTITY line;
|
||||
#start,
|
||||
#end : point;
|
||||
#END_ENTITY;
|
||||
#END_SCHEMA;
|
||||
#SCHEMA this_schema;
|
||||
#USE FROM that_schema (point,line);
|
||||
#CONSTANT
|
||||
#origin : point := point(0.0, 0.0, 0.0);
|
||||
#END_CONSTANT;
|
||||
#ENTITY circle;
|
||||
#centre : point;
|
||||
#axis : vector;
|
||||
#radius : REAL;
|
||||
#END_ENTITY;
|
||||
#...
|
||||
#LOCAL
|
||||
#p : point := point(1.0, 0.0, 0.0);
|
||||
#c : circle := circle(p, vector(1,1,1), 1.0);
|
||||
#l : line := line(p, origin);
|
||||
#END_LOCAL;
|
||||
#...
|
||||
#IF 'THIS_SCHEMA.CIRCLE.CENTRE' IN ROLESOF(p) THEN -- true
|
||||
#...
|
||||
#IF 'THIS_SCHEMA.LINE.START' IN ROLESOF(p) THEN -- true
|
||||
#...
|
||||
#IF 'THAT_SCHEMA.LINE.START' IN ROLESOF(p) THEN -- true
|
||||
#...
|
||||
#IF 'THIS_SCHEMA.LINE.END' IN ROLESOF(p) THEN -- false
|
||||
#
|
||||
# Python note:
|
||||
# @TODO: implement the ROLESOF function
|
||||
def ROLESOF(V):
|
||||
raise NotImplemented("Function ROLESOF not implemented")
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.22 SizeOf - aggregate function
|
||||
#FUNCTION SIZEOF ( V:AGGREGATE OF GENERIC ) : INTEGER;
|
||||
#The sizeof function returns the number of elements in an aggregate value.
|
||||
#Parameters : V is an aggregate value.
|
||||
#Result :
|
||||
#a) When V is an array the returned value is its declared number of elements in the
|
||||
#aggregation data type.
|
||||
#b) When V is a bag, list or set, the returned value is the actual number of elements in
|
||||
#the aggregate value.
|
||||
#EXAMPLE 145 { LOCAL
|
||||
#n : NUMBER;
|
||||
#y : ARRAY[2:5] OF b;
|
||||
#END_LOCAL;
|
||||
#...
|
||||
#n := SIZEOF (y); -- n is assigned the value 4
|
||||
def SIZEOF(V):
|
||||
if not isinstance(V,Aggregate):
|
||||
raise TypeError("SIZEOF takes an aggregate of generic")
|
||||
return V.get_size()
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.23 Sqrt - arithmetic function
|
||||
#FUNCTION SQRT ( V:NUMBER ) : REAL;
|
||||
#The sqrt function returns the non-negative square root of a number.
|
||||
#Parameters : V is any non-negative number.
|
||||
#Result : The non-negative square root of V.
|
||||
#Conditions : V 0:0
|
||||
#EXAMPLE 146 - SQRT ( 121 ) --> 11.0
|
||||
def SQRT(V):
|
||||
if not isinstance(V,NUMBER):
|
||||
raise TypeError("SQRT function takes a NUMBER parameter")
|
||||
if V<0.0:
|
||||
raise ValueError("SQRT takes a non-negative parameter")
|
||||
return REAL(math.sqrt(V))
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.24 Tan - arithmetic function
|
||||
#FUNCTION TAN ( V:NUMBER ) : REAL;
|
||||
#The tan function returns the tangent of of an angle.
|
||||
#Parameters : V is a number representing an angle expressed in radians.
|
||||
#Result : The tangent of the angle. If the angle is npi/2, where n is an odd integer, indeterminate
|
||||
#(?) is returned.
|
||||
#EXAMPLE 147 - TAN ( 0.0 ) --> 0.0
|
||||
def TAN(V):
|
||||
if not isinstance(V,NUMBER):
|
||||
raise TypeError("TAN function takes a NUMBER parameter")
|
||||
# check if angle is npi/2 where n is an odd integer
|
||||
a = V/(PI/2)
|
||||
if abs(a%2-1.) < SCL_float_epsilon :
|
||||
return None
|
||||
else:
|
||||
return REAL(math.tan(V))
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.25 TypeOf - general function
|
||||
#FUNCTION TYPEOF ( V:GENERIC ) : SET OF STRING;
|
||||
#The typeof function returns a set of strings that contains the names of all the data types
|
||||
#of which the parameter is a member. Except for the simple data types (binary, boolean,
|
||||
#integer, logical, number, real, and string) and the aggregation data types (array, bag,
|
||||
#list, set) these names are qualied by the name of the schema which contains the denition of
|
||||
#the type.
|
||||
#NOTE 1 { The primary purpose of this function is to check whether a given value (variable, at-
|
||||
#tribute value) can be used for a certain purpose, e.g. to ensure assignment compatibility between
|
||||
#two values. It may also be used if dierent subtypes or specializations of a given type have to be
|
||||
#treated dierently in some context.
|
||||
#Parameters : V is a value of any type.
|
||||
#Result : The contents of the returned set of string values are the names (in upper case) of all
|
||||
#types the value V is a member of. Such names are qualied by the name of the schema which
|
||||
#contains the denition of the type ('SCHEMA.TYPE') if it is neither a simple data type nor an
|
||||
#aggregation data type. It may be derived by the following algorithm (which is given here for
|
||||
#specification purposes rather than to prescribe any particular type of implementation)
|
||||
def TYPEOF(V):
|
||||
# Create the set to return
|
||||
v_types = set()
|
||||
# append the type of V to the set
|
||||
try: #it's a class
|
||||
to_add = V.__name__.upper()
|
||||
except AttributeError: #it's an instance, first retrieve the type
|
||||
to_add = type(V).__name__.upper()
|
||||
if not to_add in ['FLOAT','INT','AGGREGATE']:
|
||||
v_types.add(to_add)
|
||||
# recursively adds the base class names
|
||||
for base_type in type(V).__bases__:
|
||||
#print base_type
|
||||
if not base_type == object:
|
||||
v_types = v_types.union(TYPEOF(base_type))
|
||||
# finally, converts the v_types set to SET
|
||||
return v_types
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.26 UsedIn - general function
|
||||
#FUNCTION USEDIN ( T:GENERIC; R:STRING) : BAG OF GENERIC;
|
||||
#The usedin function returns each entity instance that uses a specied entity instance in a
|
||||
#specied role.
|
||||
def USEDIN(T,R):
|
||||
raise NotImplemented("USEDIN function not yet implemented.")
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.27 Value - arithmetic function
|
||||
#FUNCTION VALUE ( V:STRING ) : NUMBER;
|
||||
#The value function returns the numeric representation of a string.
|
||||
#Parameters : V is a string containing either a real or integer literal.
|
||||
#Result : A number corresponding to the string representation. If it is not possible to interpret
|
||||
#the string as either a real or integer literal, indeterminate (?) is returned.
|
||||
#EXAMPLE 151 { VALUE ( '1.234' ) --> 1.234 (REAL)
|
||||
#VALUE ( '20' ) --> 20 (INTEGER)
|
||||
#VALUE ( 'abc' ) --> ? null
|
||||
def VALUE(V):
|
||||
if not isinstance(V,STRING):
|
||||
raise TypeError("VALULE function takes a NUMBER parameter")
|
||||
# first try to instanciate an INTEGER from the string:
|
||||
try:
|
||||
return INTEGER(V)
|
||||
except:
|
||||
pass #not possible, try to cast to REAL
|
||||
try:
|
||||
return REAL(V)
|
||||
except:
|
||||
pass
|
||||
# else return None
|
||||
return None
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.28 Value in - membership function
|
||||
#FUNCTION VALUE_IN ( C:AGGREGATE OF GENERIC:GEN; V:GENERIC:GEN ) : LOGICAL;
|
||||
#The value in function returns a logical value depending on whether or not a particular value
|
||||
#is a member of an aggregation.
|
||||
#Parameters :
|
||||
#a) C is an aggregation of any type.
|
||||
#b) V is an expression which is assignment compatible with the base type of C.
|
||||
#Result :
|
||||
#a) If either V or C is indeterminate (?), unknown is returned.
|
||||
#b) If any element of C has a value equal to the value of V, true is returned.
|
||||
#c) If any element of C is indeterminate (?), unknown is returned.
|
||||
#d) Otherwise false is returned.
|
||||
#EXAMPLE 152 { The following test ensures that there is at least one point which is positioned at
|
||||
#the origin.
|
||||
#LOCAL
|
||||
#points : SET OF point;
|
||||
#END_LOCAL;
|
||||
#...
|
||||
#IF VALUE_IN(points, point(0.0, 0.0, 0.0)) THEN ...
|
||||
def VALUE_IN(C,V):
|
||||
if not isinstance(C,Aggregate):
|
||||
raise TypeError("VALUE_IN method takes an aggregate as first parameter")
|
||||
raise NotImplemented("VALUE_IN function not et implemented")
|
||||
|
||||
# EXPRESS definition:
|
||||
# ===================
|
||||
#15.29 Value unique - uniqueness function
|
||||
#FUNCTION VALUE UNIQUE ( V:AGGREGATE OF GENERIC) : LOGICAL;
|
||||
#The value unique function returns a logical value depending on whether or not the elements
|
||||
#of an aggregation are value unique.
|
||||
#Parameters : V is an aggregation of any type.
|
||||
#Result :
|
||||
#a) If V is indeterminate (?), unknown is returned.
|
||||
#b) If any any two elements of V are value equal, false is returned.
|
||||
#c) If any element of V is indeterminate (?), unknown is returned.
|
||||
#d) Otherwise true is returned.
|
||||
#EXAMPLE 153 { The following test ensures tht each point is a set is at a dierent position, (by
|
||||
#denition they are distinct, i.e., instance unique).
|
||||
#IF VALUE_UNIQUE(points) THEN ...
|
||||
def VALUE_UNIQUE(V):
|
||||
if not isinstance(V,Aggregate):
|
||||
raise TypeError("VALUE_UNIQUE method takes an aggregate as first parameter")
|
||||
return V.get_value_unique()
|
||||
|
||||
|
||||
@@ -30,25 +30,27 @@
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import sys
|
||||
import BaseType
|
||||
|
||||
def type_is_defined(type_str):
|
||||
""" Look for the type definition in the global scope from the type string.
|
||||
@TODO: find a better implementation than testing all modules!
|
||||
class EnumerationId(object):
|
||||
"""
|
||||
modules = sys.modules
|
||||
for module in modules.values():
|
||||
if (module is not None) and (not '__' in module.__name__):
|
||||
module_variables = vars(module)
|
||||
if module_variables.has_key(type_str):
|
||||
typ = module_variables[type_str]
|
||||
return True, vars(module)[type_str]
|
||||
return False,None
|
||||
|
||||
EXPRESS definition:
|
||||
===================
|
||||
An enumeration data type has as its domain an ordered set of names. The names represent
|
||||
values of the enumeration data type. These names are designated by enumeration_ids and are
|
||||
referred to as enumeration items.
|
||||
"""
|
||||
pass
|
||||
|
||||
class ENUMERATION(object):
|
||||
""" EXPRESS definition : An ENUMERATION data type has as its domain an ordered set of names. The names represent
|
||||
"""
|
||||
EXPRESS definition:
|
||||
===================
|
||||
An ENUMERATION data type has as its domain an ordered set of names. The names represent
|
||||
values of the enumeration data type.
|
||||
|
||||
Python implementation:
|
||||
======================
|
||||
An enumeration is initialized from strings defining the types.
|
||||
For instance, some EXPRESS definition:
|
||||
TYPE ahead_or_behind = ENUMERATION OF
|
||||
@@ -57,63 +59,72 @@ class ENUMERATION(object):
|
||||
END_TYPE; -- ahead_or_behind
|
||||
|
||||
is implemented in python with the line:
|
||||
ahead_of_behind = ENUMERATION('ahead','behind')
|
||||
>>> ahead_of_behind = ENUMERATION('ahead','behind', the_current_scope)
|
||||
>>> ahead_or_behind.ahead
|
||||
>>> ahead_of_behind.behind
|
||||
|
||||
The ENUMERATION definition takes python strings because of the resolution ordre
|
||||
that could be an issue.
|
||||
|
||||
When getting the authorized types but the ENUMERATION, python looks for the object
|
||||
definition from the globals() dictionary.
|
||||
And, if and only if ahead and/or behind are not in scope (e.g. they are not entity names,
|
||||
and/or many enums define the same enumeration identifier):
|
||||
>>> ahead
|
||||
>>> behind
|
||||
"""
|
||||
|
||||
def __init__(self,*kargs):
|
||||
self._base_types = list(kargs)
|
||||
|
||||
def get_allowed_types(self):
|
||||
_auth_types = []
|
||||
for typ in self._base_types:
|
||||
if type(typ)==str:
|
||||
res,value = type_is_defined(typ)
|
||||
if not res:
|
||||
raise TypeError("'%s' does not name a type"%typ)
|
||||
else:
|
||||
_auth_types.append(value)
|
||||
else:
|
||||
_auth_types.append(ty)
|
||||
return _auth_types
|
||||
|
||||
def get_allowed_basic_types(self):
|
||||
''' if a select contains some subselect, goes down through the different
|
||||
sublayers untill there is no more '''
|
||||
b = []
|
||||
_auth_types = self.get_allowed_types()
|
||||
for _auth_type in _auth_types:
|
||||
if isinstance(_auth_type,SELECT) or isinstance(_auth_type,ENUMERATION):
|
||||
h = _auth_type.get_allowed_types()
|
||||
b.extend(h)
|
||||
return b
|
||||
def __init__(self,*kargs,**args):
|
||||
# first defining the scope
|
||||
if args.has_key('scope'):
|
||||
self._scope = args['scope']
|
||||
else:
|
||||
self._scope = None
|
||||
# store passed enum identifiers
|
||||
self._enum_id_names = list(kargs)
|
||||
self._enum_ids = []
|
||||
# we create enums id from names, and create attributes
|
||||
# for instance, from the identifier name 'ahead',
|
||||
# we create an attribute ahead with which is a new
|
||||
# instance of EnumerationId
|
||||
for enum_id_name in self._enum_id_names:
|
||||
setattr(self,enum_id_name,EnumerationId())
|
||||
# we store this new attributes to the enum_ids list, which
|
||||
# will be accessed by the type checker with the get_enum_ids method
|
||||
self._enum_ids.append(self.__getattribute__(enum_id_name))
|
||||
#
|
||||
# Then we check if the enums names can be added to the current scope:
|
||||
# if the name is already in the scope, then another enums id or select
|
||||
# has the same name -> we do nothing, enums will be called
|
||||
# with ahead_of_behind.ahead or ahead_or_behind.behind.
|
||||
# otherwise, they can be called as only ahead or behind
|
||||
# Note: since ENUMERATIONS are defined *before* entities, if an entity
|
||||
# has the same name as an enum id, it will replace it in the current scope.
|
||||
#
|
||||
for enum_id_name in self._enum_id_names:
|
||||
if not vars(self._scope).has_key(enum_id_name):
|
||||
vars(self._scope)[enum_id_name] = self.__getattribute__(enum_id_name)
|
||||
|
||||
def get_enum_ids(self):
|
||||
return self._enum_ids
|
||||
|
||||
class SELECT(object):
|
||||
""" A select data type has as its domain the union of the domains of the named data types in
|
||||
its select list. The select data type is a generalization of each of the named data types in its
|
||||
select list.
|
||||
"""
|
||||
def __init__(self,*kargs):
|
||||
self._base_types = list(kargs)
|
||||
|
||||
def __init__(self,*kargs,**args):
|
||||
# first defining the scope
|
||||
if args.has_key('scope'):
|
||||
self._scope = args['scope']
|
||||
else:
|
||||
self._scope = None
|
||||
# create the types from the list of arguments
|
||||
self._base_types = []
|
||||
for types in list(kargs):
|
||||
new_type = BaseType.Type(types,self._scope)
|
||||
self._base_types.append(new_type)
|
||||
|
||||
def get_allowed_types(self):
|
||||
_auth_types = []
|
||||
for typ in self._base_types:
|
||||
if type(typ)==str:
|
||||
res,value = type_is_defined(typ)
|
||||
if not res:
|
||||
raise TypeError("'%s' does not name a type"%typ)
|
||||
else:
|
||||
_auth_types.append(value)
|
||||
else:
|
||||
_auth_types.append(ty)
|
||||
for types in self._base_types:
|
||||
_auth_types.append(types.get_type())
|
||||
return _auth_types
|
||||
|
||||
|
||||
def get_allowed_basic_types(self):
|
||||
''' if a select contains some subselect, goes down through the different
|
||||
sublayers untill there is no more '''
|
||||
@@ -123,13 +134,6 @@ class SELECT(object):
|
||||
if isinstance(_auth_type,SELECT) or isinstance(_auth_type,ENUMERATION):
|
||||
h = _auth_type.get_allowed_types()
|
||||
b.extend(h)
|
||||
else:
|
||||
b = _auth_types
|
||||
return b
|
||||
|
||||
if __name__=='__main__':
|
||||
class line:
|
||||
pass
|
||||
class point:
|
||||
pass
|
||||
a = ENUMERATION('line','point')
|
||||
print a.get_allowed_types()
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
# Copyright (c) 2011-2012, Thomas Paviot (tpaviot@gmail.com)
|
||||
# All rights reserved.
|
||||
|
||||
# This file is part of the StepClassLibrary (SCL).
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# Neither the name of the <ORGANIZATION> nor the names of its contributors may
|
||||
# be used to endorse or promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
__doc__ = "This module defines EXPRESS rules"
|
||||
|
||||
class Rule(object):
|
||||
'''
|
||||
This class describes a RULE
|
||||
@TODO: to be implemented
|
||||
'''
|
||||
pass
|
||||
@@ -35,18 +35,27 @@ Docstrings are courtesy of ISO 10303-11:1994(E)
|
||||
|
||||
class NUMBER:
|
||||
"""
|
||||
EXPRESS definition:
|
||||
===================
|
||||
The number data type has as its domain all numeric values in the language. The number data
|
||||
type shall be used when a more specific numeric representation is not important.
|
||||
type shall be used when a more specic numeric representation is not important.
|
||||
Syntax:
|
||||
248 number_type = NUMBER .
|
||||
EXAMPLE 15 - Since we may not know the context of size we do not know how to correctly
|
||||
represent it, e.g. the size of the crowd at a football game would be an integer, whereas the area
|
||||
of the pitch would be a real.
|
||||
size : NUMBER ;
|
||||
|
||||
Python mapping: cannot be mapped to a builtin python type. The constructor only checks that
|
||||
the parameter passed at initialization is a number.
|
||||
Python definition:
|
||||
==================
|
||||
class NUMBER is an abstract class, aimed at being specialized.
|
||||
"""
|
||||
def __init__(self,value):
|
||||
# should test the type of value (float, or integer)
|
||||
pass
|
||||
pass
|
||||
|
||||
class REAL(float):
|
||||
class REAL(float,NUMBER):
|
||||
"""
|
||||
EXPRESS definition:
|
||||
===================
|
||||
The real data type has as its domain all rational, irrational and scientfic real numbers. It is
|
||||
a specialization of the number data type.
|
||||
Syntax:
|
||||
@@ -65,16 +74,37 @@ class REAL(float):
|
||||
b) When no resolution specification is given the precision of the real number is uncon-
|
||||
strained.
|
||||
|
||||
Python mapping: REAL is mapped to 'float' type
|
||||
Note 9.2.6:
|
||||
integer and real are both specializations of number;
|
||||
|
||||
Python definition:
|
||||
==================
|
||||
REAL both inherits from float and NUMBER
|
||||
"""
|
||||
pass
|
||||
|
||||
class INTEGER(int):
|
||||
class INTEGER(int,NUMBER):
|
||||
"""
|
||||
EXPRESS definition:
|
||||
===================
|
||||
The integer data type has as its domain all integer numbers. It is a specialization of the real
|
||||
data type.
|
||||
Syntax:
|
||||
227 integer_type = INTEGER .
|
||||
EXAMPLE 16 - This example uses an integer data type to represent an attribute named nodes.
|
||||
The domain of this attribute is all integers, with no further constraint.
|
||||
ENTITY foo;
|
||||
nodes : INTEGER;
|
||||
END_ENTITY;
|
||||
|
||||
Python mapping: INTEGER is mapped to 'int' type"""
|
||||
Note 9.2.6: integer and real are both specializations of number;
|
||||
|
||||
Python definition:
|
||||
==================
|
||||
INTEGER both inherits from int and NUMBER
|
||||
|
||||
@TODO: note 9.2.6 tells that integer is a specialization of real
|
||||
"""
|
||||
pass
|
||||
|
||||
class STRING(str):
|
||||
|
||||
@@ -30,8 +30,10 @@
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from ConstructedDataTypes import ENUMERATION, SELECT
|
||||
import BaseType
|
||||
|
||||
RAISE_EXCEPTION_IF_TYPE_DOES_NOT_MATCH = True
|
||||
DEBUG = False
|
||||
|
||||
def cast_python_object_to_aggregate(obj, aggregate):
|
||||
""" This function casts a python object to an aggregate type. For instance:
|
||||
@@ -48,11 +50,20 @@ def check_type(instance, expected_type):
|
||||
returns False or True
|
||||
"""
|
||||
type_match = False #by default, will be set to True if any match
|
||||
if DEBUG:
|
||||
print "==="
|
||||
print "Instance passed: ",instance
|
||||
print "Expected type: ", expected_type
|
||||
# in the case of an enumeration, we have to check if the instance is in the list
|
||||
if (isinstance(expected_type,SELECT) or isinstance(expected_type,ENUMERATION)):
|
||||
if (isinstance(expected_type,ENUMERATION)):
|
||||
allowed_ids = expected_type.get_enum_ids()
|
||||
if instance in allowed_ids:
|
||||
type_match = True
|
||||
else:
|
||||
raise TypeError('Enumeration ids must be %s ( passed %s)'%(allowed_ids,type(instance)))
|
||||
elif (isinstance(expected_type,SELECT)):
|
||||
# we check if the instance is of the type of any of the types that are in the SELECT
|
||||
allowed_types = expected_type.get_allowed_basic_types()
|
||||
#if instance in allowed_types:
|
||||
for allowed_type in allowed_types:
|
||||
if isinstance(instance,allowed_type):
|
||||
type_match = True
|
||||
@@ -62,7 +73,24 @@ def check_type(instance, expected_type):
|
||||
else:
|
||||
print "WARNING: expected '%s' but passed a '%s', casting from python value to EXPRESS type"%(allowed_types, type(instance))
|
||||
return False
|
||||
else:
|
||||
elif (isinstance(expected_type, BaseType.Aggregate)):
|
||||
# first check that they are instance of the same class
|
||||
if not (type(instance) == type(expected_type)):
|
||||
raise TypeError('Expected %s but passed %s'%(type(expected_type),type(instance)))
|
||||
# then check that the base type is the same
|
||||
elif not (instance.get_type() == expected_type.get_type()):
|
||||
#print instance.get_type()
|
||||
#print expected_type.get_type()
|
||||
raise TypeError('Expected %s:%s base type but passed %s:%s base type'%(type(expected_type),expected_type.get_type(),type(instance), instance.get_type()))
|
||||
# check optional and unique attributes
|
||||
#elif not (instance._unique == expected_type._unique):
|
||||
# raise TypeError('Aggregate expects UNIQUE:%s property but passed UNIQUE:%s'%(expected_type._unique, instance._unique))
|
||||
#elif not (instance._optional == expected_type._optional):
|
||||
# raise TypeError('Aggregate expects OPTIONAL:%s property but passed OPTIONAL:%s'%(expected_type._optional, instance._optional))
|
||||
# @TODO: check aggregate bounds
|
||||
else:
|
||||
type_match = True
|
||||
else: # simple data types
|
||||
type_match = isinstance(instance,expected_type)
|
||||
if not type_match:
|
||||
if RAISE_EXCEPTION_IF_TYPE_DOES_NOT_MATCH:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "complexSupport.h"
|
||||
|
||||
extern int corba_binding;
|
||||
|
||||
void use_ref( Schema, Express, FILES * );
|
||||
@@ -142,6 +143,8 @@ void
|
||||
SCOPEPrint( Scope scope, FILES * files, Schema schema, Express model,
|
||||
ComplexCollect * col, int cnt ) {
|
||||
Linked_List list = SCOPEget_entities_superclass_order( scope );
|
||||
Linked_List function_list = SCOPEget_functions(scope);
|
||||
Linked_List rule_list = SCOPEget_rules(scope);
|
||||
DictionaryEntry de;
|
||||
Type i;
|
||||
int redefs = 0;// index = 0;
|
||||
@@ -207,9 +210,21 @@ SCOPEPrint( Scope scope, FILES * files, Schema schema, Express model,
|
||||
ENTITYPrint( e, files, schema );
|
||||
e->search_id = PROCESSED;
|
||||
}
|
||||
LISTod;
|
||||
|
||||
LISTod;
|
||||
LISTfree( list );
|
||||
|
||||
// process each function. This must be done *before* typedefs are defined
|
||||
LISTdo( function_list, f, Function );
|
||||
FUNCPrint( f, files, schema );
|
||||
LISTod;
|
||||
LISTfree( function_list );
|
||||
|
||||
// process each rule. This must be done *before* typedefs are defined
|
||||
LISTdo( rule_list, r, Rule );
|
||||
RULEPrint( r, files, schema );
|
||||
LISTod;
|
||||
LISTfree( rule_list );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -338,12 +353,22 @@ SCHEMAprint( Schema schema, FILES * files, Express model, void * complexCol,
|
||||
return;
|
||||
}
|
||||
//fprintf( libfile, "/* %cId$ */ \n", '$' );
|
||||
fprintf(libfile,"import sys\n");
|
||||
fprintf(libfile,"\n");
|
||||
fprintf(libfile,"from SCL.SCLBase import *\n");
|
||||
fprintf(libfile,"from SCL.SimpleDataTypes import *\n");
|
||||
fprintf(libfile,"from SCL.ConstructedDataTypes import *\n");
|
||||
fprintf(libfile,"from SCL.AggregationDataTypes import *\n");
|
||||
fprintf(libfile,"from SCL.TypeChecker import check_type\n");
|
||||
fprintf(libfile,"from SCL.Expr import *\n");
|
||||
fprintf(libfile,"from SCL.Builtin import *\n");
|
||||
fprintf(libfile,"from SCL.Rules import *\n");
|
||||
|
||||
/********* export schema name *******/
|
||||
fprintf(libfile,"\nschema_name = '%s'\n\n",SCHEMAget_name(schema));
|
||||
|
||||
/******** export schema scope *******/
|
||||
fprintf(libfile,"schema_scope = sys.modules[__name__]\n\n");
|
||||
|
||||
|
||||
/********** do the schemas ***********/
|
||||
|
||||
|
||||
@@ -693,19 +693,7 @@ TYPEselect_lib_print( const Type type, FILE * f, Schema schema ) {
|
||||
int nbr_select = 0;
|
||||
int num = 0;
|
||||
|
||||
fprintf( f, "# SELECT TYPE %s_\n", TYPEget_name(type) );
|
||||
// writes the variable with strings
|
||||
LISTdo( SEL_TYPEget_items( type ), t, Type )
|
||||
if (is_python_keyword(TYPEget_name(t))) {
|
||||
fprintf(f,"if (not '%s_' in globals().keys()):\n",TYPEget_name(t));
|
||||
fprintf( f, "%s_ = '%s_'\n",TYPEget_name(t),TYPEget_name(t));
|
||||
}
|
||||
else {
|
||||
fprintf(f,"if (not '%s' in globals().keys()):\n",TYPEget_name(t));
|
||||
fprintf( f, "\t%s = '%s'\n",TYPEget_name(t),TYPEget_name(t));
|
||||
}
|
||||
LISTod;
|
||||
|
||||
fprintf( f, "# SELECT TYPE %s\n", TYPEget_name(type) );
|
||||
// create the SELECT
|
||||
if (is_python_keyword(TYPEget_name(type))) {
|
||||
fprintf( f, "%s_ = SELECT(",TYPEget_name(type));
|
||||
@@ -731,7 +719,7 @@ TYPEselect_lib_print( const Type type, FILE * f, Schema schema ) {
|
||||
if (num < nbr_select -1 ) fprintf(f,",");
|
||||
num++;
|
||||
LISTod;
|
||||
fprintf(f,")\n");
|
||||
fprintf(f,",\n\tscope = schema_scope)\n");
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
# Copyright (c) 2011, Thomas Paviot (tpaviot@gmail.com)
|
||||
# All rights reserved.
|
||||
|
||||
# This file is part StepClassLibrary (SCL).
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# Neither the name of the <ORGANIZATION> nor the names of its contributors may
|
||||
# be used to endorse or promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import unittest
|
||||
|
||||
import test_base
|
||||
import test_unitary_schemas
|
||||
import test_builtin
|
||||
|
||||
suite = unittest.TestSuite()
|
||||
|
||||
# Get all test suites from modules
|
||||
base_suite = test_base.suite()
|
||||
unitary_schemas_suite = test_unitary_schemas.suite()
|
||||
builtin_suite = test_builtin.suite()
|
||||
|
||||
tests = []
|
||||
tests.append(base_suite)
|
||||
tests.append(unitary_schemas_suite)
|
||||
tests.append(builtin_suite)
|
||||
suite.addTests(tests)
|
||||
|
||||
# Run test suite
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
@@ -29,6 +29,7 @@
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from SCL.SimpleDataTypes import *
|
||||
@@ -59,6 +60,11 @@ class TestINTEGER(unittest.TestCase):
|
||||
a = INTEGER(5)
|
||||
self.assertTrue(type(a) == INTEGER)
|
||||
|
||||
def test_inherit_from_NUMBER(self):
|
||||
a = INTEGER(6)
|
||||
self.assertTrue(isinstance(a,INTEGER))
|
||||
self.assertTrue(isinstance(a,NUMBER))
|
||||
|
||||
def test_INTEGER_ops(self):
|
||||
a = INTEGER(2)
|
||||
b = INTEGER(3)
|
||||
@@ -99,6 +105,11 @@ class TestREAL(unittest.TestCase):
|
||||
a = REAL(5)
|
||||
self.assertTrue(type(a) == REAL)
|
||||
|
||||
def test_inherit_from_NUMBER(self):
|
||||
a = REAL(4.5)
|
||||
self.assertTrue(isinstance(a,REAL))
|
||||
self.assertTrue(isinstance(a,NUMBER))
|
||||
|
||||
def test_REAL_ops(self):
|
||||
a = REAL(1.5)
|
||||
b = REAL(2)
|
||||
@@ -136,7 +147,7 @@ class TestBOOLEAN(unittest.TestCase):
|
||||
self.assertFalse(b)
|
||||
|
||||
#
|
||||
# AggregationDataTypeSimple
|
||||
# AggregationDataType
|
||||
#
|
||||
class TestARRAY(unittest.TestCase):
|
||||
'''
|
||||
@@ -160,6 +171,12 @@ class TestARRAY(unittest.TestCase):
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
|
||||
def test_create_array_from_type_string(self):
|
||||
# the scope is the current module
|
||||
scp = sys.modules[__name__]
|
||||
a = ARRAY(1,7,'REAL',scope = scp)
|
||||
a[2] = REAL(2.3)
|
||||
|
||||
def test_array_bounds(self):
|
||||
a = ARRAY(3,8,REAL)
|
||||
try:
|
||||
@@ -191,7 +208,7 @@ class TestARRAY(unittest.TestCase):
|
||||
a = ARRAY(1,4,REAL,UNIQUE=True)
|
||||
a[3] = REAL(4)
|
||||
try:
|
||||
a[3] = REAL(4)
|
||||
a[4] = REAL(4)
|
||||
except AssertionError:
|
||||
pass
|
||||
except e:
|
||||
@@ -216,10 +233,22 @@ class TestARRAY(unittest.TestCase):
|
||||
b = ARRAY(1,3,REAL,OPTIONAL=True)
|
||||
b[2] = REAL(5)
|
||||
b[3] = REAL(5)
|
||||
|
||||
#
|
||||
# AggregationDataTypeSimple
|
||||
#
|
||||
|
||||
def test_array_of_array_of_real(self):
|
||||
'''
|
||||
create a 3*3 identify matrix
|
||||
'''
|
||||
my_matrix = ARRAY(1,3,ARRAY(1,3,REAL))
|
||||
my_matrix[1] = ARRAY(1,3,REAL)
|
||||
my_matrix[2] = ARRAY(1,3,REAL)
|
||||
my_matrix[3] = ARRAY(1,3,REAL)
|
||||
my_matrix[1][1] = REAL(1.0)
|
||||
my_matrix[2][2] = REAL(1.0)
|
||||
my_matrix[3][3] = REAL(1.0)
|
||||
my_matrix[1][2] = my_matrix[1][2] = REAL(0.0)
|
||||
my_matrix[1][3] = my_matrix[3][1] = REAL(0.0)
|
||||
my_matrix[2][3] = my_matrix[3][2] = REAL(0.0)
|
||||
|
||||
class TestLIST(unittest.TestCase):
|
||||
'''
|
||||
LIST test
|
||||
@@ -296,24 +325,90 @@ class TestLIST(unittest.TestCase):
|
||||
self.fail('Unexpected exception thrown:', e)
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
|
||||
#
|
||||
# TypeChecker
|
||||
#
|
||||
class TestTypeChecker(unittest.TestCase):
|
||||
def test_match_type(self):
|
||||
class P:
|
||||
pass
|
||||
p = P()
|
||||
match_type = check_type(p,P) #should return True
|
||||
self.assertTrue(match_type)
|
||||
|
||||
def test_type_dontmatch(self):
|
||||
class P:
|
||||
pass
|
||||
p = P()
|
||||
class TestBAG(unittest.TestCase):
|
||||
'''
|
||||
BAG test
|
||||
'''
|
||||
def test_create_bounded_bag(self):
|
||||
BAG(1,7,REAL)
|
||||
BAG(1,5,INTEGER)
|
||||
BAG(0,0,REAL)
|
||||
|
||||
def test_create_unbounded_bag(self):
|
||||
a = BAG(0,None,REAL)
|
||||
|
||||
def test_fill_bounded_bag(self):
|
||||
b = BAG(1,3,REAL)
|
||||
b.add(REAL(1.0))
|
||||
b.add(REAL(2.0))
|
||||
b.add(REAL(3.0))
|
||||
# the bag is full, trying to add other item
|
||||
# will raise an exception
|
||||
try:
|
||||
check_type(3,P)
|
||||
b.add(REAL(4.0))
|
||||
except AssertionError:
|
||||
pass
|
||||
except e:
|
||||
self.fail('Unexpected exception thrown:', e)
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
|
||||
def test_fill_unbounded_bag(self):
|
||||
'''
|
||||
Fill an unbounded bag with one thousand reals
|
||||
This should not raise any exception
|
||||
'''
|
||||
b = BAG(0,None,REAL)
|
||||
for i in range(1000):
|
||||
b.add(REAL(1.0))
|
||||
|
||||
class TestSET(unittest.TestCase):
|
||||
'''
|
||||
SET test
|
||||
'''
|
||||
def test_create_bounded_set(self):
|
||||
SET(1,7,REAL)
|
||||
SET(1,5,INTEGER)
|
||||
SET(0,0,REAL)
|
||||
|
||||
def test_create_unbounded_set(self):
|
||||
a = SET(0,None,REAL)
|
||||
|
||||
def test_fill_bounded_set(self):
|
||||
b = SET(1,3,REAL)
|
||||
b.add(REAL(1.0))
|
||||
b.add(REAL(2.0))
|
||||
b.add(REAL(3.0))
|
||||
# the bag is full, trying to add other item
|
||||
# will raise an exception
|
||||
try:
|
||||
b.add(REAL(4.0))
|
||||
except AssertionError:
|
||||
pass
|
||||
except e:
|
||||
self.fail('Unexpected exception thrown:', e)
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
|
||||
def test_fill_bounded_set(self):
|
||||
# create a set with one value allowed
|
||||
c = SET(0,0,REAL)
|
||||
# fill in with the same value n times
|
||||
# the total size of the set should not increase
|
||||
for i in range(1000):
|
||||
c.add(REAL(1.0))
|
||||
#
|
||||
# Constructed Data Types
|
||||
#
|
||||
class TestENUMERATION(unittest.TestCase):
|
||||
def test_simple_enum(self):
|
||||
scp = sys.modules[__name__]
|
||||
ahead_or_behind = ENUMERATION('ahead','behind',scope=scp)
|
||||
check_type(ahead,ahead_or_behind)
|
||||
check_type(behind,ahead_or_behind)
|
||||
try:
|
||||
check_type("some string",ahead_or_behind)
|
||||
except TypeError:
|
||||
pass
|
||||
except e:
|
||||
@@ -321,8 +416,42 @@ class TestTypeChecker(unittest.TestCase):
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
|
||||
def test_check_enum_type(self):
|
||||
enum = ENUMERATION(["my","string"])
|
||||
class ob1(object):
|
||||
pass
|
||||
class ob2(object):
|
||||
pass
|
||||
class TestSELECT(unittest.TestCase):
|
||||
def test_select(self):
|
||||
scp = sys.modules[__name__]
|
||||
select_typedef = SELECT('ob1','ob2',scope = scp)
|
||||
ob1_instance = ob1()
|
||||
ob2_instance = ob2()
|
||||
# test that line_instance is in enum type
|
||||
check_type(ob1_instance, select_typedef)
|
||||
check_type(ob2_instance,select_typedef)
|
||||
# this one should raise an exception:
|
||||
try:
|
||||
check_type(REAL(3.4),select_typedef)
|
||||
except TypeError:
|
||||
pass
|
||||
except e:
|
||||
self.fail('Unexpected exception thrown:', e)
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
|
||||
def suite():
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(unittest.makeSuite(TestINTEGER))
|
||||
suite.addTest(unittest.makeSuite(TestREAL))
|
||||
suite.addTest(unittest.makeSuite(TestARRAY))
|
||||
suite.addTest(unittest.makeSuite(TestLIST))
|
||||
suite.addTest(unittest.makeSuite(TestBAG))
|
||||
suite.addTest(unittest.makeSuite(TestSET))
|
||||
suite.addTest(unittest.makeSuite(TestENUMERATION))
|
||||
suite.addTest(unittest.makeSuite(TestSELECT))
|
||||
return suite
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
unittest.main()
|
||||
|
||||
@@ -0,0 +1,555 @@
|
||||
# Copyright (c) 2011-2012, Thomas Paviot (tpaviot@gmail.com)
|
||||
# All rights reserved.
|
||||
|
||||
# This file is part StepClassLibrary (SCL).
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# Neither the name of the <ORGANIZATION> nor the names of its contributors may
|
||||
# be used to endorse or promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from SCL.SimpleDataTypes import *
|
||||
from SCL.TypeChecker import *
|
||||
from SCL.ConstructedDataTypes import *
|
||||
from SCL.AggregationDataTypes import *
|
||||
from SCL.Builtin import *
|
||||
|
||||
float_epsilon = 1e-8
|
||||
#
|
||||
# Test builtin functions
|
||||
#
|
||||
class TestABS(unittest.TestCase):
|
||||
def test_abs_REAL(self):
|
||||
a = REAL(-4.5)
|
||||
b = ABS(a)
|
||||
self.assertEqual(b,4.5)
|
||||
self.assertTrue(isinstance(b,REAL))
|
||||
|
||||
def test_abs_INTEGER(self):
|
||||
a = INTEGER(-4)
|
||||
b = ABS(a)
|
||||
self.assertEqual(b,4)
|
||||
self.assertTrue(isinstance(b,INTEGER))
|
||||
|
||||
def test_abs_other_types(self):
|
||||
''' raises an exception is none of REAL orINTEGER types are passed to ABS'''
|
||||
a = STRING("some_str")
|
||||
try:
|
||||
b = ABS(a)
|
||||
except TypeError:
|
||||
pass
|
||||
except e:
|
||||
self.fail('Unexpected exception thrown:', e)
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
|
||||
class TestACOS(unittest.TestCase):
|
||||
def test_acos_REAL(self):
|
||||
a = REAL(0.3)
|
||||
b = ACOS(a)
|
||||
self.assertTrue(isinstance(b,REAL))
|
||||
|
||||
def test_acos_INTEGER(self):
|
||||
a = INTEGER(1)
|
||||
b = ACOS(a)
|
||||
self.assertTrue(isinstance(b,REAL))
|
||||
c = INTEGER(-1)
|
||||
d = ACOS(c)
|
||||
self.assertTrue(isinstance(b,REAL))
|
||||
|
||||
def test_acos_other_types(self):
|
||||
''' raises an exception is none of REAL orINTEGER types are passed to ABS'''
|
||||
a = STRING("some_str")
|
||||
try:
|
||||
b = ACOS(a)
|
||||
except TypeError:
|
||||
pass
|
||||
except e:
|
||||
self.fail('Unexpected exception thrown:', e)
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
|
||||
class TestASIN(unittest.TestCase):
|
||||
def test_asin_REAL(self):
|
||||
a = REAL(0.3)
|
||||
b = ASIN(a)
|
||||
self.assertTrue(isinstance(b,REAL))
|
||||
|
||||
def test_asin_INTEGER(self):
|
||||
a = INTEGER(1)
|
||||
b = ASIN(a)
|
||||
self.assertTrue(isinstance(b,REAL))
|
||||
c = INTEGER(-1)
|
||||
d = ASIN(c)
|
||||
self.assertTrue(isinstance(b,REAL))
|
||||
|
||||
def test_asin_other_types(self):
|
||||
''' raises an exception is none of REAL orINTEGER types are passed to ABS'''
|
||||
a = STRING("some_str")
|
||||
try:
|
||||
b = ASIN(a)
|
||||
except TypeError:
|
||||
pass
|
||||
except e:
|
||||
self.fail('Unexpected exception thrown:', e)
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
|
||||
class TestATAN(unittest.TestCase):
|
||||
def test_atan_REAL_INTEGER(self):
|
||||
a = REAL(0.3)
|
||||
b = INTEGER(0.5)
|
||||
c = ATAN(a,b)
|
||||
self.assertTrue(isinstance(c,REAL))
|
||||
|
||||
def test_atan_INTEGER_REAL(self):
|
||||
a = INTEGER(1)
|
||||
b = REAL(0.6)
|
||||
c = ATAN(a,b)
|
||||
self.assertTrue(isinstance(c,REAL))
|
||||
|
||||
def test_atan_REAL_REAL(self):
|
||||
a = REAL(-5.5)
|
||||
b = REAL(3)
|
||||
c = ATAN(a,b)
|
||||
self.assertTrue(isinstance(c,REAL))
|
||||
|
||||
def test_atan_INTEGER_INTEGER(self):
|
||||
a = INTEGER(450)
|
||||
b = INTEGER(34)
|
||||
c = ATAN(a,b)
|
||||
self.assertTrue(isinstance(c,REAL))
|
||||
|
||||
def test_atan_V2_is_zero(self):
|
||||
a = REAL(5.0)
|
||||
b = REAL(0)
|
||||
c = ATAN(a,b)
|
||||
self.assertTrue(isinstance(c,REAL))
|
||||
self.assertEqual(c,PI/2)
|
||||
d = REAL(-5.0)
|
||||
e = ATAN(d,b)
|
||||
self.assertTrue(isinstance(e,REAL))
|
||||
self.assertEqual(e,-PI/2)
|
||||
|
||||
def test_atan_V1_and_V2_are_zero(self):
|
||||
a = REAL(0.0)
|
||||
b = REAL(0.0)
|
||||
try:
|
||||
c = ATAN(a,b)
|
||||
except ValueError:
|
||||
pass
|
||||
except e:
|
||||
self.fail('Unexpected exception thrown:', e)
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
|
||||
def test_asin_other_types(self):
|
||||
''' raises an exception is none of REAL orINTEGER types are passed to ABS'''
|
||||
a = STRING("some_str")
|
||||
try:
|
||||
b = ASIN(a)
|
||||
except TypeError:
|
||||
pass
|
||||
except e:
|
||||
self.fail('Unexpected exception thrown:', e)
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
|
||||
class TestBLENGTH(unittest.TestCase):
|
||||
def test_blength_BINARY(self):
|
||||
a = BINARY('0101')
|
||||
b = BLENGTH(a)
|
||||
self.assertTrue(isinstance(b,INTEGER))
|
||||
self.assertEqual(b,4)
|
||||
|
||||
def test_blength_other_types(self):
|
||||
''' raises an exception is none of REAL orINTEGER types are passed to ABS'''
|
||||
a = STRING("some_str")
|
||||
try:
|
||||
b = BLENGTH(a)
|
||||
except TypeError:
|
||||
pass
|
||||
except e:
|
||||
self.fail('Unexpected exception thrown:', e)
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
|
||||
class TestCOS(unittest.TestCase):
|
||||
def test_cos_REAL(self):
|
||||
a = REAL(0.56)
|
||||
b = COS(a)
|
||||
self.assertTrue(isinstance(b,REAL))
|
||||
|
||||
def test_cos_REAL(self):
|
||||
a = INTEGER(10)
|
||||
b = COS(a)
|
||||
self.assertTrue(isinstance(b,REAL))
|
||||
|
||||
class TestEXISTS(unittest.TestCase):
|
||||
def test_EXISTS(self):
|
||||
a = ARRAY(1,3,REAL,OPTIONAL=True)
|
||||
a[2] = REAL(4.0)
|
||||
# a[2] is defined, so EXISTS should result True
|
||||
self.assertTrue(EXISTS(a[2]))
|
||||
# other values does not exists
|
||||
self.assertFalse(EXISTS(a[1]))
|
||||
self.assertFalse(EXISTS(a[3]))
|
||||
|
||||
class TestEXP(unittest.TestCase):
|
||||
def test_exp_REAL(self):
|
||||
a = REAL(0.3)
|
||||
b = EXP(a)
|
||||
self.assertTrue(isinstance(b,REAL))
|
||||
|
||||
def test_exp_INTEGER(self):
|
||||
a = INTEGER(-1)
|
||||
b = EXP(a)
|
||||
self.assertTrue(isinstance(b,REAL))
|
||||
|
||||
def test_exp_other_types(self):
|
||||
''' raises an exception is none of REAL orINTEGER types are passed to ABS'''
|
||||
a = STRING("some_str")
|
||||
try:
|
||||
b = EXP(a)
|
||||
except TypeError:
|
||||
pass
|
||||
except e:
|
||||
self.fail('Unexpected exception thrown:', e)
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
|
||||
class TestFORMAT(unittest.TestCase):
|
||||
def test_FORMAT(self):
|
||||
n = INTEGER(10)
|
||||
f = STRING("+7I")
|
||||
result = FORMAT(n,f)
|
||||
self.assertTrue(isinstance(result,STRING))
|
||||
# 123.456789 8.2F ' 123.46'
|
||||
n = REAL(123.456789)
|
||||
f = STRING("8.2F")
|
||||
res2 = FORMAT(n,f)
|
||||
self.assertTrue(isinstance(result,STRING))
|
||||
self.assertEqual(res2,' 123.46')
|
||||
# 123.456789 8.2E '1.23E+02'
|
||||
f = STRING("8.2E")
|
||||
res3 = FORMAT(n,f)
|
||||
self.assertTrue(isinstance(result,STRING))
|
||||
self.assertEqual(res3,'1.23E+02')
|
||||
# @TODO: complete tests
|
||||
|
||||
class TestHIBOUND(unittest.TestCase):
|
||||
def test_HIBOUND_bounded(self):
|
||||
a = ARRAY(-3,19,REAL)
|
||||
a[2] = REAL(3.4)
|
||||
h1 = HIBOUND(a)
|
||||
self.assertEqual(h1,19)
|
||||
|
||||
def test_HIBOUND_unbounded(self):
|
||||
l = LIST(0,None,INTEGER)
|
||||
l[4] = INTEGER(5)
|
||||
h1 = HIBOUND(l)
|
||||
self.assertEqual(h1,None)
|
||||
|
||||
class TestHIINDEX(unittest.TestCase):
|
||||
def test_HIINDEX_ARRAY(self):
|
||||
a = ARRAY(-3,19,REAL)
|
||||
a[2] = REAL(6)
|
||||
h1 = HIINDEX(a)
|
||||
self.assertEqual(h1,19)
|
||||
|
||||
def test_HIINDEX_LIST(self):
|
||||
l = LIST(0,None,REAL)
|
||||
l[3] = REAL(6)
|
||||
l[45] = REAL(7)
|
||||
h2 = HIINDEX(l)
|
||||
self.assertEqual(h2,2)
|
||||
|
||||
def test_HIINDEX_SET(self):
|
||||
s = SET(0,None,INTEGER)
|
||||
s.add(INTEGER(3))
|
||||
s.add(INTEGER(4))
|
||||
s.add(INTEGER(4))
|
||||
h3 = HIINDEX(s)
|
||||
self.assertEqual(h3,2)
|
||||
|
||||
def test_HIINDEX_BAG(self):
|
||||
s = BAG(0,None,STRING)
|
||||
s.add(STRING('1st'))
|
||||
s.add(STRING('2nd'))
|
||||
s.add(STRING('2nd'))
|
||||
h4 = HIINDEX(s)
|
||||
self.assertEqual(h4,3)
|
||||
|
||||
class TestLENGTH(unittest.TestCase):
|
||||
def test_LENGTH(self):
|
||||
x1 = STRING('abc')
|
||||
l1 = LENGTH(x1)
|
||||
self.assertTrue(isinstance(l1,INTEGER))
|
||||
self.assertEqual(l1,3)
|
||||
|
||||
def test_LENGTH_other_types(self):
|
||||
a = REAL(12.3)
|
||||
try:
|
||||
b = LENGTH(a)
|
||||
except TypeError:
|
||||
pass
|
||||
except e:
|
||||
self.fail('Unexpected exception thrown:', e)
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
|
||||
class TestLOBOUND(unittest.TestCase):
|
||||
def test_HIBOUND_bounded(self):
|
||||
a = ARRAY(-3,19,REAL)
|
||||
a[2] = REAL(3.4)
|
||||
h1 = LOBOUND(a)
|
||||
self.assertEqual(h1,-3)
|
||||
|
||||
def test_LOBOUND_unbounded(self):
|
||||
l = LIST(0,None,INTEGER)
|
||||
l[4] = INTEGER(5)
|
||||
h1 = LOBOUND(l)
|
||||
self.assertEqual(h1,0)
|
||||
|
||||
class TestLOG(unittest.TestCase):
|
||||
def test_LOG(self):
|
||||
a = REAL(10)
|
||||
log_a = LOG(a)
|
||||
self.assertTrue(isinstance(log_a,REAL))
|
||||
|
||||
def test_LOG2(self):
|
||||
a = REAL(8)
|
||||
log2_a = LOG2(a)
|
||||
self.assertTrue(isinstance(log2_a,REAL))
|
||||
self.assertEqual(log2_a,3.)
|
||||
|
||||
def test_LOG10(self):
|
||||
a = REAL(10.0)
|
||||
log10_a = LOG10(a)
|
||||
self.assertTrue(isinstance(log10_a,REAL))
|
||||
self.assertEqual(log10_a,1.)
|
||||
|
||||
class TestLOINDEX(unittest.TestCase):
|
||||
def test_LOINDEX_ARRAY(self):
|
||||
a = ARRAY(-3,19,REAL)
|
||||
a[2] = REAL(6)
|
||||
h1 = LOINDEX(a)
|
||||
self.assertEqual(h1,-3)
|
||||
|
||||
def test_LOINDEX_LIST(self):
|
||||
l = LIST(0,None,REAL)
|
||||
l[3] = REAL(6)
|
||||
l[45] = REAL(7)
|
||||
h2 = LOINDEX(l)
|
||||
self.assertEqual(h2,1)
|
||||
|
||||
def test_LOINDEX_SET(self):
|
||||
s = SET(0,None,INTEGER)
|
||||
s.add(INTEGER(3))
|
||||
s.add(INTEGER(4))
|
||||
s.add(INTEGER(4))
|
||||
h3 = LOINDEX(s)
|
||||
self.assertEqual(h3,1)
|
||||
|
||||
def test_LOINDEX_BAG(self):
|
||||
s = BAG(0,None,STRING)
|
||||
s.add(STRING('1st'))
|
||||
s.add(STRING('2nd'))
|
||||
s.add(STRING('2nd'))
|
||||
h4 = LOINDEX(s)
|
||||
self.assertEqual(h4,1)
|
||||
|
||||
class TestNVL(unittest.TestCase):
|
||||
def test_NVL_1(self):
|
||||
a = ARRAY(1,4,REAL, OPTIONAL = True)
|
||||
# a[1] should be None
|
||||
a[2] = REAL(5)
|
||||
o1 = NVL(a[1],REAL(0.0))
|
||||
self.assertEqual(o1,0.0)
|
||||
o2 = NVL(a[2],REAL(0.0))
|
||||
self.assertEqual(o2,5.)
|
||||
|
||||
class TestODD(unittest.TestCase):
|
||||
def test_is_ODD(self):
|
||||
a = INTEGER(121)
|
||||
self.assertTrue(ODD(a))
|
||||
|
||||
def test_not_ODD(self):
|
||||
b = INTEGER(8)
|
||||
self.assertFalse(ODD(b))
|
||||
|
||||
def test_zero_is_not_odd(self):
|
||||
c = INTEGER(0)
|
||||
self.assertFalse(ODD(c))
|
||||
|
||||
class TestROLESOF(unittest.TestCase):
|
||||
# @TODO: not implemented yet
|
||||
pass
|
||||
|
||||
class TestSIN(unittest.TestCase):
|
||||
def test_sin_REAL(self):
|
||||
a = REAL(0.56)
|
||||
b = SIN(a)
|
||||
self.assertTrue(isinstance(b,REAL))
|
||||
|
||||
def test_sin_REAL(self):
|
||||
a = INTEGER(10)
|
||||
b = SIN(a)
|
||||
self.assertTrue(isinstance(b,REAL))
|
||||
|
||||
class TestSIZEOF(unittest.TestCase):
|
||||
def test_SIZEOF_ARRAY(self):
|
||||
a = ARRAY(-3,19,REAL)
|
||||
a[2] = REAL(6)
|
||||
s1 = SIZEOF(a)
|
||||
self.assertEqual(s1,23)
|
||||
|
||||
def test_SIZEOF_LIST(self):
|
||||
l = LIST(0,None,REAL)
|
||||
l[3] = REAL(6)
|
||||
l[45] = REAL(7)
|
||||
s2 = SIZEOF(l)
|
||||
self.assertEqual(s2,2)
|
||||
|
||||
def test_SIZEOF_SET(self):
|
||||
s = SET(0,None,INTEGER)
|
||||
s.add(INTEGER(3))
|
||||
s.add(INTEGER(4))
|
||||
s.add(INTEGER(4))
|
||||
s3 = SIZEOF(s)
|
||||
self.assertEqual(s3,2)
|
||||
|
||||
def test_SIZEOF_BAG(self):
|
||||
s = BAG(0,None,STRING)
|
||||
s.add(STRING('1st'))
|
||||
s.add(STRING('2nd'))
|
||||
s.add(STRING('2nd'))
|
||||
s4 = SIZEOF(s)
|
||||
self.assertEqual(s4,3)
|
||||
|
||||
class TestSQRT(unittest.TestCase):
|
||||
def test_SQRT_INTEGER(self):
|
||||
self.assertEqual(SQRT(INTEGER(9)),REAL(3.0))
|
||||
|
||||
def test_SQRT_REAL(self):
|
||||
self.assertEqual(SQRT(REAL(25.0)),REAL(5.0))
|
||||
|
||||
class TestTAN(unittest.TestCase):
|
||||
def test_tan_REAL(self):
|
||||
a = REAL(0.0)
|
||||
b = TAN(a)
|
||||
self.assertTrue(isinstance(b,REAL))
|
||||
self.assertEqual(b,0.)
|
||||
|
||||
def test_tan_n_pi_with_n_odd(self):
|
||||
for i in range(10):
|
||||
angle = REAL(((i*2+1)*PI/2)) #angle is npi/2 with n odd
|
||||
self.assertEqual(TAN(angle),None) #result should be indeterminate
|
||||
|
||||
def test_tan_n_pi_with_n_not_odd(self):
|
||||
for i in range(10):
|
||||
angle = REAL(i*2*PI/2) #angle is npi/2 with n odd
|
||||
self.assertAlmostEqual(TAN(angle),0.) #result should be indeterminate
|
||||
|
||||
class TestTYPEOF(unittest.TestCase):
|
||||
def test_TYPEOF_REAL(self):
|
||||
a = REAL(5.6)
|
||||
self.assertEqual(TYPEOF(a),set(['REAL','NUMBER']))
|
||||
|
||||
class TestUSEDIN(unittest.TestCase):
|
||||
# @TODO: not implemented yet
|
||||
pass
|
||||
|
||||
class TestVALUE(unittest.TestCase):
|
||||
def test_VALUE_to_INTEGER(self):
|
||||
i = STRING('10')
|
||||
self.assertEqual(VALUE(i),INTEGER(10))
|
||||
|
||||
def test_VALUE_to_REAL(self):
|
||||
f = STRING('1.234')
|
||||
self.assertEqual(VALUE(f),REAL(1.234))
|
||||
|
||||
def test_value_to_None(self):
|
||||
s = STRING('something')
|
||||
self.assertEqual(VALUE(s),None)
|
||||
|
||||
class TestVALUE_IN(unittest.TestCase):
|
||||
# @TODO: not implemented yet
|
||||
pass
|
||||
|
||||
class TestVALUE_UNIQUE(unittest.TestCase):
|
||||
# @TODO: not implemented yet
|
||||
def test_VALUE_UNIQUE_array_1(self):
|
||||
a = ARRAY(1,3,REAL)
|
||||
a[1] = REAL(4)
|
||||
a[2] = REAL(5)
|
||||
a[3] = REAL(6)
|
||||
self.assertTrue(VALUE_UNIQUE(a))
|
||||
|
||||
def test_VALUE_UNIQUE_array_2(self):
|
||||
a = ARRAY(1,3,REAL)
|
||||
a[1] = REAL(4)
|
||||
a[2] = REAL(4)
|
||||
a[3] = REAL(6)
|
||||
self.assertFalse(VALUE_UNIQUE(a))
|
||||
|
||||
def test_VALUE_UNIQUE_array_3(self):
|
||||
a = ARRAY(1,3,REAL)
|
||||
self.assertEqual(VALUE_UNIQUE(a),Unknown)
|
||||
|
||||
def suite():
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(unittest.makeSuite(TestABS))
|
||||
suite.addTest(unittest.makeSuite(TestACOS))
|
||||
suite.addTest(unittest.makeSuite(TestASIN))
|
||||
suite.addTest(unittest.makeSuite(TestATAN))
|
||||
suite.addTest(unittest.makeSuite(TestBLENGTH))
|
||||
suite.addTest(unittest.makeSuite(TestEXISTS))
|
||||
suite.addTest(unittest.makeSuite(TestEXP))
|
||||
suite.addTest(unittest.makeSuite(TestFORMAT))
|
||||
suite.addTest(unittest.makeSuite(TestHIBOUND))
|
||||
suite.addTest(unittest.makeSuite(TestHIINDEX))
|
||||
suite.addTest(unittest.makeSuite(TestLENGTH))
|
||||
suite.addTest(unittest.makeSuite(TestLOBOUND))
|
||||
suite.addTest(unittest.makeSuite(TestLOG))
|
||||
suite.addTest(unittest.makeSuite(TestNVL))
|
||||
suite.addTest(unittest.makeSuite(TestROLESOF))
|
||||
suite.addTest(unittest.makeSuite(TestSIN))
|
||||
suite.addTest(unittest.makeSuite(TestSIZEOF))
|
||||
suite.addTest(unittest.makeSuite(TestSQRT))
|
||||
suite.addTest(unittest.makeSuite(TestTAN))
|
||||
suite.addTest(unittest.makeSuite(TestTYPEOF))
|
||||
suite.addTest(unittest.makeSuite(TestUSEDIN))
|
||||
suite.addTest(unittest.makeSuite(TestVALUE))
|
||||
suite.addTest(unittest.makeSuite(TestVALUE_IN))
|
||||
suite.addTest(unittest.makeSuite(TestVALUE_UNIQUE))
|
||||
return suite
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
|
||||
@@ -0,0 +1,466 @@
|
||||
# Copyright (c) 2011, Thomas Paviot (tpaviot@gmail.com)
|
||||
# All rights reserved.
|
||||
|
||||
# This file is part StepClassLibrary (SCL).
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# Neither the name of the <ORGANIZATION> nor the names of its contributors may
|
||||
# be used to endorse or promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import unittest
|
||||
import sys
|
||||
sys.path.append('../examples/unitary_schemas')
|
||||
|
||||
from SCL.SCLBase import *
|
||||
from SCL.SimpleDataTypes import *
|
||||
from SCL.ConstructedDataTypes import *
|
||||
from SCL.AggregationDataTypes import *
|
||||
from SCL.TypeChecker import check_type
|
||||
from SCL.Expr import *
|
||||
|
||||
class TestSelectDataType(unittest.TestCase):
|
||||
'''
|
||||
unitary_schemas/test_select_data_type.py
|
||||
'''
|
||||
def test_import_schema_module(self):
|
||||
import test_select_data_type
|
||||
|
||||
def test_schema(self):
|
||||
import test_select_data_type
|
||||
my_glue = test_select_data_type.glue(STRING("comp"),STRING("solvent"))
|
||||
wm = test_select_data_type.wall_mounting(STRING("mounting"),STRING("on"),my_glue)
|
||||
|
||||
class TestSingleInheritance(unittest.TestCase):
|
||||
'''
|
||||
unitary_schemas/test_single_inheritance.py, generated from:
|
||||
SCHEMA test_single_inheritance;
|
||||
|
||||
TYPE label = STRING;
|
||||
END_TYPE;
|
||||
|
||||
TYPE length_measure = REAL;
|
||||
END_TYPE;
|
||||
|
||||
TYPE point = REAL;
|
||||
END_TYPE;
|
||||
|
||||
ENTITY shape
|
||||
SUPERTYPE OF (rectangle);
|
||||
item_name : label;
|
||||
number_of_sides : INTEGER;
|
||||
END_ENTITY;
|
||||
|
||||
ENTITY rectangle
|
||||
SUBTYPE OF (shape);
|
||||
height : length_measure;
|
||||
width : length_measure;
|
||||
END_ENTITY;
|
||||
|
||||
END_SCHEMA;
|
||||
'''
|
||||
def test_import_schema_module(self):
|
||||
import test_single_inheritance
|
||||
|
||||
def test_schema(self):
|
||||
import test_single_inheritance
|
||||
my_base_shape = test_single_inheritance.shape(test_single_inheritance.label("spherical shape"),INTEGER(1))
|
||||
my_shape = test_single_inheritance.rectangle(test_single_inheritance.label("rect"),INTEGER(6),test_single_inheritance.length_measure(30.0),test_single_inheritance.length_measure(45.))
|
||||
|
||||
|
||||
class TestSingleInheritanceMultiLevel(unittest.TestCase):
|
||||
'''
|
||||
unitary_schemas/test_single_inheritance_multi_level.py, generated from schema:
|
||||
SCHEMA test_single_inheritance_multi_level;
|
||||
|
||||
TYPE label = STRING;
|
||||
END_TYPE;
|
||||
|
||||
TYPE length_measure = REAL;
|
||||
END_TYPE;
|
||||
|
||||
TYPE point = REAL;
|
||||
END_TYPE;
|
||||
|
||||
ENTITY shape
|
||||
SUPERTYPE OF (subshape);
|
||||
item_name : label;
|
||||
number_of_sides : INTEGER;
|
||||
END_ENTITY;
|
||||
|
||||
ENTITY subshape
|
||||
SUPERTYPE OF (rectangle)
|
||||
SUBTYPE OF (shape);
|
||||
END_ENTITY;
|
||||
|
||||
ENTITY rectangle
|
||||
SUBTYPE OF (subshape);
|
||||
height : length_measure;
|
||||
width : length_measure;
|
||||
END_ENTITY;
|
||||
|
||||
END_SCHEMA;
|
||||
'''
|
||||
def test_import_schema_module(self):
|
||||
import test_single_inheritance_multi_level
|
||||
|
||||
def test_schema(self):
|
||||
import test_single_inheritance_multi_level
|
||||
my_base_shape = test_single_inheritance_multi_level.shape(test_single_inheritance_multi_level.label("spherical shape"),INTEGER(1))
|
||||
my_shape = test_single_inheritance_multi_level.rectangle(test_single_inheritance_multi_level.label("rect"),\
|
||||
INTEGER(6),\
|
||||
test_single_inheritance_multi_level.length_measure(30.0),\
|
||||
test_single_inheritance_multi_level.length_measure(45.))
|
||||
|
||||
|
||||
class TestEnumEntityName(unittest.TestCase):
|
||||
'''
|
||||
unitary_schemas/test_enum_entity_name.py, generated from schema:
|
||||
SCHEMA test_enum_entity_name;
|
||||
|
||||
TYPE simple_datum_reference_modifier = ENUMERATION OF (
|
||||
line,
|
||||
translation);
|
||||
END_TYPE;
|
||||
|
||||
ENTITY line;
|
||||
END_ENTITY;
|
||||
|
||||
END_SCHEMA;
|
||||
'''
|
||||
def test_import_schema_module(self):
|
||||
import test_enum_entity_name
|
||||
|
||||
def test_schema(self):
|
||||
import test_enum_entity_name
|
||||
check_type(test_enum_entity_name.simple_datum_reference_modifier.line,test_enum_entity_name.simple_datum_reference_modifier)
|
||||
check_type(test_enum_entity_name.translation,test_enum_entity_name.simple_datum_reference_modifier)
|
||||
# if line is passed, should raise an error since it is an entity name
|
||||
try:
|
||||
check_type(test_enum_entity_name.line,test_enum_entity_name.simple_datum_reference_modifier)
|
||||
except TypeError:
|
||||
pass
|
||||
except e:
|
||||
self.fail('Unexpected exception thrown:', e)
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
|
||||
|
||||
class TestArray(unittest.TestCase):
|
||||
'''
|
||||
unitary_schemas/test_array.py, generated from schema:
|
||||
SCHEMA test_array;
|
||||
|
||||
ENTITY point;
|
||||
coords : ARRAY[1:3] OF REAL;
|
||||
END_ENTITY;
|
||||
|
||||
END_SCHEMA;
|
||||
'''
|
||||
def test_import_schema_module(self):
|
||||
import test_array
|
||||
|
||||
def test_schema(self):
|
||||
import test_array
|
||||
scp = sys.modules[__name__]
|
||||
my_coords = ARRAY(1,3,REAL)
|
||||
my_point = test_array.point(my_coords)
|
||||
# following cases should raise error
|
||||
# 1. passed LIST whereas ARRAY expected
|
||||
my_coords = LIST(1,3,REAL)
|
||||
try:
|
||||
my_point = test_array.point(my_coords)
|
||||
except TypeError:
|
||||
pass
|
||||
except e:
|
||||
self.fail('Unexpected exception thrown:', e)
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
# 2. passed ARRAY OF INTEGER whereas ARRAY OF REAL expected
|
||||
my_coords = ARRAY(1,3,INTEGER)
|
||||
try:
|
||||
my_point = test_array.point(my_coords)
|
||||
except TypeError:
|
||||
pass
|
||||
except e:
|
||||
self.fail('Unexpected exception thrown:', e)
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
# 3. passed UNIQUE= True whereas False expected
|
||||
my_coords = ARRAY(1,3,REAL, UNIQUE=True)
|
||||
try:
|
||||
my_point = test_array.point(my_coords)
|
||||
except TypeError:
|
||||
pass
|
||||
except e:
|
||||
self.fail('Unexpected exception thrown:', e)
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
# 4. passed OPTIONAL= True whereas False expected
|
||||
my_coords = ARRAY(1,3,REAL, OPTIONAL=True)
|
||||
try:
|
||||
my_point = test_array.point(my_coords)
|
||||
except TypeError:
|
||||
pass
|
||||
except e:
|
||||
self.fail('Unexpected exception thrown:', e)
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
|
||||
class TestArrayOfArrayOfReal(unittest.TestCase):
|
||||
'''
|
||||
unitary_schemas/test_array_of_array_of_real.py, generated from schema:
|
||||
SCHEMA test_array_of_array_of_simple_types;
|
||||
|
||||
ENTITY transformation;
|
||||
rotation : ARRAY[1:3] OF ARRAY[1:3] OF REAL;
|
||||
END_ENTITY;
|
||||
|
||||
END_SCHEMA;
|
||||
|
||||
'''
|
||||
def test_import_schema_module(self):
|
||||
import test_array_of_array_of_simple_types
|
||||
|
||||
def test_schema(self):
|
||||
import test_array_of_array_of_simple_types
|
||||
scp = sys.modules[__name__]
|
||||
# first build the double array my_matrix
|
||||
my_matrix = ARRAY(1,3,ARRAY(1,3,REAL))
|
||||
my_matrix[1] = ARRAY(1,3,REAL)
|
||||
my_matrix[2] = ARRAY(1,3,REAL)
|
||||
my_matrix[3] = ARRAY(1,3,REAL)
|
||||
my_matrix[1][1] = REAL(1.0)
|
||||
my_matrix[2][2] = REAL(1.0)
|
||||
my_matrix[3][3] = REAL(1.0)
|
||||
# create a new 'transformation' instance
|
||||
trsf = test_array_of_array_of_simple_types.transformation(my_matrix)
|
||||
|
||||
class TestDefinedTypesWhereRule(unittest.TestCase):
|
||||
'''
|
||||
unitary_schemas/test_where_rule.py, generated from schema:
|
||||
SCHEMA test_where_rule;
|
||||
|
||||
TYPE positive = INTEGER;
|
||||
WHERE
|
||||
notnegative : SELF > 0;
|
||||
END_TYPE;
|
||||
|
||||
TYPE month = INTEGER;
|
||||
WHERE
|
||||
SELF<=12;
|
||||
SELF>=1;
|
||||
END_TYPE;
|
||||
|
||||
END_SCHEMA;
|
||||
'''
|
||||
def test_import_schema_module(self):
|
||||
import test_where_rule
|
||||
|
||||
def test_rule_notnegative(self):
|
||||
import test_where_rule
|
||||
my_p = test_where_rule.positive(30)
|
||||
try:
|
||||
my_p = test_where_rule.positive(0)
|
||||
except AssertionError:
|
||||
pass
|
||||
except e:
|
||||
self.fail('Unexpected exception thrown:', e)
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
|
||||
def test_month(self):
|
||||
import test_where_rule
|
||||
m = test_where_rule.month(11)
|
||||
try:
|
||||
m = test_where_rule.month(0)
|
||||
except AssertionError:
|
||||
pass
|
||||
except e:
|
||||
self.fail('Unexpected exception thrown:', e)
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
try:
|
||||
m = test_where_rule.month(13)
|
||||
except AssertionError:
|
||||
pass
|
||||
except e:
|
||||
self.fail('Unexpected exception thrown:', e)
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
|
||||
class TestFunctions(unittest.TestCase):
|
||||
'''
|
||||
unitary_schemas/test_function.py, generated from schema:
|
||||
'''
|
||||
def test_import_schema_module(self):
|
||||
import test_function
|
||||
|
||||
def test_add_function(self):
|
||||
'''
|
||||
FUNCTION add(r1:REAL;r2:REAL):REAL;
|
||||
LOCAL
|
||||
result : REAL;
|
||||
END_LOCAL;
|
||||
result := r1+r2;
|
||||
RETURN(result);
|
||||
END_FUNCTION;
|
||||
'''
|
||||
from test_function import add
|
||||
a = REAL(1.0)
|
||||
b = REAL(2.0)
|
||||
c = add(a,b)
|
||||
self.assertEqual(c,REAL(3.0))
|
||||
|
||||
def test_pow_n_function(self):
|
||||
'''
|
||||
FUNCTION pow_n(r1:REAL;n:INTEGER):REAL;
|
||||
LOCAL
|
||||
result : REAL;
|
||||
END_LOCAL;
|
||||
IF n = 0 THEN
|
||||
RETURN(1);
|
||||
ELSE
|
||||
result := r1;
|
||||
REPEAT i := 1 TO n;
|
||||
result := result * r1;
|
||||
END_REPEAT;
|
||||
RETURN(result);
|
||||
END_IF;
|
||||
END_FUNCTION;
|
||||
'''
|
||||
from test_function import pow_n
|
||||
a = REAL(10)
|
||||
b = INTEGER(3)
|
||||
c = pow_n(a,b)
|
||||
self.assertEqual(c,REAL(1000))
|
||||
self.assertEqual(pow_n(REAL(10),INTEGER(0)),REAL(1.))
|
||||
|
||||
def test_case_1_function(self):
|
||||
'''
|
||||
FUNCTION case_1(a:INTEGER):REAL;
|
||||
LOCAL
|
||||
x : REAL;
|
||||
END_LOCAL;
|
||||
CASE a OF
|
||||
1 : x := SIN(a) ;
|
||||
2 : x := EXP(a) ;
|
||||
3 : x := SQRT(a) ;
|
||||
4, 5 : x := LOG(a) ;
|
||||
OTHERWISE : x := 0.0 ;
|
||||
END_CASE ;
|
||||
RETURN(x);
|
||||
END_FUNCTION;
|
||||
'''
|
||||
from test_function import case_1
|
||||
from math import sin,exp,sqrt,log
|
||||
self.assertEqual(case_1(INTEGER(1)),sin(1.))
|
||||
self.assertEqual(case_1(INTEGER(2)),exp(2.))
|
||||
self.assertEqual(case_1(INTEGER(3)),sqrt(3.))
|
||||
self.assertEqual(case_1(INTEGER(4)),log(4.))
|
||||
self.assertEqual(case_1(INTEGER(5)),log(5.))
|
||||
self.assertEqual(case_1(INTEGER(6)),0.)
|
||||
|
||||
class TestEntityWhereRules(unittest.TestCase):
|
||||
'''
|
||||
unitary/test_entity_where_rule
|
||||
'''
|
||||
def test_import_schema(self):
|
||||
import test_entity_where_rule
|
||||
|
||||
def test_entity_unit_vector(self):
|
||||
'''
|
||||
ENTITY unit_vector;
|
||||
a, b, c : REAL;
|
||||
WHERE
|
||||
length_1 : a**2 + b**2 + c**2 = 1.0;
|
||||
END_ENTITY;
|
||||
'''
|
||||
from test_entity_where_rule import unit_vector
|
||||
u = unit_vector(REAL(1),REAL(0),REAL(0))
|
||||
self.assertTrue(u.length_1())
|
||||
v = unit_vector(REAL(0),REAL(0),REAL(0.5))
|
||||
|
||||
def test_entity_address(self):
|
||||
'''
|
||||
TYPE label = STRING;
|
||||
END_TYPE; -- label
|
||||
|
||||
ENTITY address;
|
||||
internal_location : OPTIONAL label;
|
||||
street_number : OPTIONAL label;
|
||||
street : OPTIONAL label;
|
||||
postal_box : OPTIONAL label;
|
||||
town : OPTIONAL label;
|
||||
region : OPTIONAL label;
|
||||
postal_code : OPTIONAL label;
|
||||
country : OPTIONAL label;
|
||||
facsimile_number : OPTIONAL label;
|
||||
telephone_number : OPTIONAL label;
|
||||
electronic_mail_address : OPTIONAL label;
|
||||
telex_number : OPTIONAL label;
|
||||
WHERE
|
||||
WR1: EXISTS(internal_location) OR
|
||||
EXISTS(street_number) OR
|
||||
EXISTS(street) OR
|
||||
EXISTS(postal_box) OR
|
||||
EXISTS(town) OR
|
||||
EXISTS(region) OR
|
||||
EXISTS(postal_code) OR
|
||||
EXISTS(country) OR
|
||||
EXISTS(facsimile_number) OR
|
||||
EXISTS(telephone_number) OR
|
||||
EXISTS(electronic_mail_address) OR
|
||||
EXISTS(telex_number);
|
||||
END_ENTITY; -- address
|
||||
'''
|
||||
from test_entity_where_rule import address, label
|
||||
a = address(None,None,None,None,None,None,None,None,None,None,None,None)
|
||||
# wr1 should raise an issue since a.wr1()
|
||||
try:
|
||||
a.wr1()
|
||||
except AssertionError:
|
||||
pass
|
||||
except e:
|
||||
self.fail('Unexpected exception thrown:', e)
|
||||
else:
|
||||
self.fail('ExpectedException not thrown')
|
||||
a.town = label('Paris')
|
||||
a.wr1()
|
||||
|
||||
def suite():
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(unittest.makeSuite(TestSelectDataType))
|
||||
suite.addTest(unittest.makeSuite(TestSingleInheritance))
|
||||
suite.addTest(unittest.makeSuite(TestSingleInheritanceMultiLevel))
|
||||
suite.addTest(unittest.makeSuite(TestEnumEntityName))
|
||||
suite.addTest(unittest.makeSuite(TestDefinedTypesWhereRule))
|
||||
suite.addTest(unittest.makeSuite(TestFunctions))
|
||||
suite.addTest(unittest.makeSuite(TestEntityWhereRules))
|
||||
return suite
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
SCHEMA test_where_rule;
|
||||
|
||||
TYPE positive = INTEGER;
|
||||
WHERE
|
||||
notnegative : SELF > 0;
|
||||
END_TYPE;
|
||||
|
||||
TYPE month = INTEGER;
|
||||
WHERE
|
||||
SELF<=12;
|
||||
SELF>=1;
|
||||
END_TYPE;
|
||||
|
||||
END_SCHEMA;
|
||||
@@ -0,0 +1,41 @@
|
||||
SCHEMA test_entity_where_rule;
|
||||
|
||||
TYPE label = STRING;
|
||||
END_TYPE; -- label
|
||||
|
||||
ENTITY address;
|
||||
internal_location : OPTIONAL label;
|
||||
street_number : OPTIONAL label;
|
||||
street : OPTIONAL label;
|
||||
postal_box : OPTIONAL label;
|
||||
town : OPTIONAL label;
|
||||
region : OPTIONAL label;
|
||||
postal_code : OPTIONAL label;
|
||||
country : OPTIONAL label;
|
||||
facsimile_number : OPTIONAL label;
|
||||
telephone_number : OPTIONAL label;
|
||||
electronic_mail_address : OPTIONAL label;
|
||||
telex_number : OPTIONAL label;
|
||||
WHERE
|
||||
WR1: EXISTS(internal_location) OR
|
||||
EXISTS(street_number) OR
|
||||
EXISTS(street) OR
|
||||
EXISTS(postal_box) OR
|
||||
EXISTS(town) OR
|
||||
EXISTS(region) OR
|
||||
EXISTS(postal_code) OR
|
||||
EXISTS(country) OR
|
||||
EXISTS(facsimile_number) OR
|
||||
EXISTS(telephone_number) OR
|
||||
EXISTS(electronic_mail_address) OR
|
||||
EXISTS(telex_number);
|
||||
END_ENTITY; -- address
|
||||
|
||||
ENTITY unit_vector;
|
||||
a, b, c : REAL;
|
||||
WHERE
|
||||
length_1 : a**2 + b**2 + c**2 = 1.0;
|
||||
END_ENTITY;
|
||||
|
||||
END_SCHEMA;
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
SCHEMA test_function;
|
||||
|
||||
ENTITY dummy;
|
||||
END_ENTITY;
|
||||
|
||||
FUNCTION add(r1:REAL;r2:REAL):REAL;
|
||||
LOCAL
|
||||
result : REAL;
|
||||
END_LOCAL;
|
||||
result := r1+r2;
|
||||
RETURN(result);
|
||||
END_FUNCTION;
|
||||
|
||||
|
||||
FUNCTION pow_n(r1:REAL;n:INTEGER):REAL;
|
||||
LOCAL
|
||||
result : REAL;
|
||||
END_LOCAL;
|
||||
IF n = 0 THEN
|
||||
RETURN(1);
|
||||
ELSE
|
||||
result := r1;
|
||||
REPEAT i := 1 TO n;
|
||||
result := result * r1;
|
||||
END_REPEAT;
|
||||
RETURN(result);
|
||||
END_IF;
|
||||
END_FUNCTION;
|
||||
|
||||
|
||||
FUNCTION case_1(a:INTEGER):REAL;
|
||||
LOCAL
|
||||
x : REAL;
|
||||
END_LOCAL;
|
||||
CASE a OF
|
||||
1 : x := SIN(a) ;
|
||||
2 : x := EXP(a) ;
|
||||
3 : x := SQRT(a) ;
|
||||
4, 5 : x := LOG(a) ;
|
||||
OTHERWISE : x := 0.0 ;
|
||||
END_CASE ;
|
||||
RETURN(x);
|
||||
END_FUNCTION;
|
||||
|
||||
END_SCHEMA;
|
||||
@@ -0,0 +1,7 @@
|
||||
SCHEMA test_array_of_array_of_simple_types;
|
||||
|
||||
ENTITY transformation;
|
||||
rotation : ARRAY[1:3] OF ARRAY[1:3] OF REAL;
|
||||
END_ENTITY;
|
||||
|
||||
END_SCHEMA;
|
||||
@@ -6,8 +6,13 @@ END_TYPE;
|
||||
TYPE type2 = INTEGER;
|
||||
END_TYPE;
|
||||
|
||||
TYPE type3 = type2;
|
||||
END_TYPE;
|
||||
|
||||
ENTITY line;
|
||||
line_length : measure;
|
||||
other_param : type3;
|
||||
and_another : REAL;
|
||||
END_ENTITY;
|
||||
|
||||
END_SCHEMA;
|
||||
|
||||
Reference in New Issue
Block a user