Update Files

This commit is contained in:
2025-01-22 16:18:30 +01:00
parent ed4603cf95
commit a36294b518
16718 changed files with 2960346 additions and 0 deletions

2737
Kha/Tools/macos/CHANGES.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,25 @@
Contributor License Agreement :
You accept and agree to the following terms and conditions for Your present and future Contributions submitted to the project Haxe :
1) Definitions
"Contribution" : any source code, documentation, including any modifications or additions to an existing work that is intentionally submitted by You to the Haxe Foundation for inclusion in, or documentation of, any of the products managed and maintained by the Haxe Foundation.
"Submitted" means any form or electronic, verbal or written communication, including but not limited to communication on electronic mailing lists, source code control systems and issue tracking system that are managed by, or on behalf of, the Haxe Foundation for the purpose of improving Haxe.
2) Grant of Copyright License. Subject to the terms and conditions of this Grant, You hereby grant to the Haxe Foundation and to recipients of software distributed by the Haxe Foundation a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Your Contributions and such derivative works.
3) You represent that you are legally entitled to grant the above license. If your employer(s) has rights to intellectual property that you create that includes your Contributions, you represent that you have received permission to make Contributions on behalf of that employer, that your employer has waived such rights for your Contributions to the Haxe Foundation, or that your employer has executed a separate Corporate Contributor License Grant with the Haxe Foundation.
4) You represent that each of Your Contributions is Your original creation (see section 7 for submissions on behalf of others). You represent that Your Contribution submissions include complete details of any third-party license or other restriction (including, but not limited to, related patents and trademarks) of which you are personally aware and which are associated with any part of Your Contributions.
5) You are not expected to provide support for Your Contributions, except to the extent You desire to provide support. You may provide support for free, for a fee, or not at all. Unless required by applicable law or agreed to in writing, You provide Your Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON- INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
Full Name :
Email :
Mailing Address :
Country :
Signature:

311
Kha/Tools/macos/LICENSE.txt Normal file
View File

@ -0,0 +1,311 @@
Haxe Licenses
-------------
For details about Haxe Licenses, please read http://haxe.org/foundation/open-source.html
The Haxe Standard Library MIT License :
--------------------------
Copyright (C)2005-2016 Haxe Foundation
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
The Haxe compiler GPL License :
-------------------------------
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "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 THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS

BIN
Kha/Tools/macos/haxe Executable file

Binary file not shown.

View File

@ -0,0 +1,189 @@
Sun Microsystems, Inc. Binary Code License Agreement
SUN MICROSYSTEMS, INC. ("SUN") IS WILLING TO LICENSE THE SOFTWARE TO YOU
ONLY UPON THE CONDITION THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS
BINARY CODE LICENSE AGREEMENT ("AGREEMENT"). PLEASE READ THE AGREEMENT
CAREFULLY. BY DOWNLOADING OR INSTALLING THIS SOFTWARE, YOU ACCEPT THE FULL
TERMS OF THIS AGREEMENT.
1. Definitions.
"Software" means all third party software provided to You in binary code form
by Sun under this License as specifically indicated on the openjdk.java.net
source download web page. Software includes any updates or error corrections
or documentation relating to Software provided to You by Sun under this
License as indicated on the openjdk.java.net source download web page.
2. Permitted Uses.
Subject to the terms and conditions of this Agreement, Sun grants you a
non-exclusive, non-transferable, limited license without fees to
(a) reproduce and use internally the Software for the purposes of developing
or running a distribution based upon OpenJDK code made available from Sun
("OpenJDK Code").
(b) reproduce and distribute the Software, provided that you (i) distribute
the Software bundled as part of, and for the sole purpose of running an
unmodified version of the OpenJDK Code or a runtime environment based upon
theOpenJDK Code; (ii) only distribute and use the Software with the
component of the OpenJDK Code into which such Software was originally
incorporated by Sun; (iii) do not remove or alter any proprietary legends or
notices contained in or on the Software; (iv) only distribute the Software
subject to a license agreement that protects Sun's interests consistent with
the terms contained in this Agreement; and (v) you agree to defend and
indemnify Sun and its licensors from and against any damages, costs,
liabilities, settlement amounts and/or expenses (including attorneys' fees)
incurred in connection with any claim, lawsuit or action by any third party
that arises or results from (A) the use or distribution of your software,
product or materials (or any part thereof) in any manner, or (B) your use or
distribution of the Software in violation of the terms of this Agreement or
applicable law.
3. Restrictions.
(a) The copies of Software provided to you under this Agreement is licensed,
not sold, to you by Sun. Sun reserves all rights not expressly granted.
(b) You may not modify Software.
(c) You may not rent, lease, lend or encumber Software.
(d) You do not remove or alter any proprietary legends or notices contained
in the Software,
(e) Unless enforcement is prohibited by applicable law, you may not
decompile, or reverse engineer Software.
(f) The terms and conditions of this Agreement will apply to any Software
updates, provided to you at Sun's discretion, that replace and/or supplement
the original Software, unless such update contains a separate license.
(g) Software is copyrighted.
(h) Software is not designed, licensed or intended for use in the design,
construction, operation or maintenance of any nuclear facility and Sun and
its licensors disclaim any express or implied warranty of fitness for such
uses.
(i) No right, title or interest in or to any trademark, service mark, logo
or trade name of Sun or its licensors is granted under this Agreement.
(j) If your Permitted Use in this Agreement permits the distribution
Software or portions of the Software, you may only distribute the Software
subject to a license agreement that protects Sun's interests consistent with
the terms contained in this Agreement.
4. Open Source.
Sun supports and benefits from the global community of open source
developers, and thanks the community for its important contributions and
open standards-based technology, which Sun has adopted into many of its
products.
Please note that portions of Software may be provided with notices and open
source licenses from such communities and third parties that govern the use
of those portions, and any licenses granted hereunder do not alter any
rights and obligations you may have under such open source licenses,
however, the disclaimer of warranty and limitation of liability provisions
in this Agreement will apply to all Software in this distribution.
5. Term and Termination.
The Agreement is effective on the Date you receive the Software and remains
effective until terminated. Your rights under this Agreement will terminate
immediately without notice from Sun if you materially breach it or take any
action in derogation of Sun's and/or its licensors' rights to Software. Sun
may terminate this Agreement should any Software become, or in Sun's
reasonable opinion likely to become, the subject of a claim of intellectual
property infringement or trade secret misappropriation. Upon termination,
you will cease use of, and destroy, Software and confirm compliance in
writing to Sun. Sections 1, 3, 4, 5, and 7-13 will survive termination of
the Agreement.
6. Limited Warranty.
Sun warrants to you that for a period of 90 days from the date of receipt,
the media on which Software is furnished (if any) will be free of defects in
materials and workmanship under normal use. Except for the foregoing,
Software is provided "AS IS". Your exclusive remedy and Sun's entire
liability under this limited warranty will be at Sun's option to replace
Software media or refund the fee paid for Software. Some states do not
allow limitations on certain implied warranties, so the above may not apply
to you. This limited warranty gives you specific legal rights. You may
have others, which vary from state to state.
7. Disclaimer of Warranty.
UNLESS SPECIFIED IN THIS AGREEMENT, ALL EXPRESS OR IMPLIED CONDITIONS,
REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT ARE
DISCLAIMED, EXCEPT TO THE EXTENT THAT THESE DISCLAIMERS ARE HELD TO BE
LEGALLY INVALID.
8. Limitation of Liability.
TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL SUN OR ITS LICENSORS
BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR SPECIAL, INDIRECT,
CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED REGARDLESS OF
THE THEORY OF LIABILITY, ARISING OUT OF OR RELATED TO THE USE OF OR
INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY
OF SUCH DAMAGES. In no event will Sun's liability to you, whether in
contract, tort (including negligence), or otherwise, exceed the amount paid
by you Software under this Agreement. The foregoing limitations will apply
even if the above stated warranty fails of its essential purpose. Some
states do not allow the exclusion of incidental or consequential damages, so
some of the terms above may not be applicable to you.
9. Export Regulations.
All Software, documents, technical data, and any other materials delivered
under this Agreement are subject to U.S. export control laws and may be
subject to export or import regulations in other countries. You agree to
comply strictly with these laws and regulations and acknowledge that you
have the responsibility to obtain any licenses to export, re-export, or
import as may be required after delivery to you.
10. U.S. Government Restricted Rights.
If Software is being acquired by or on behalf of the U.S. Government or by a
U.S. Government prime contractor or subcontractor (at any tier), then the
Government's rights in Software and accompanying documentation will be only
as set forth in this Agreement; this is in accordance with 48 CFR 227.7201
through 227.7202-4 (for Department of Defense (DOD) acquisitions) and with
48 CFR 2.101 and 12.212 (for non-DOD acquisitions).
11. Governing Law.
Any action related to this Agreement will be governed by California law and
controlling U.S. federal law. No choice of law rules of any jurisdiction
will apply.
12. Severability.
If any provision of this Agreement is held to be unenforceable, this
Agreement will remain in effect with the provision omitted, unless omission
would frustrate the intent of the parties, in which case this Agreement will
immediately terminate.
13. Integration.
This Agreement is the entire agreement between you and Sun relating to its
subject matter. It supersedes all prior or contemporaneous oral or written
communications, proposals, representations and warranties and prevails over
any conflicting or additional terms of any quote, order, acknowledgment, or
other communication between the parties relating to its subject matter
during the term of this Agreement. No modification of this Agreement will
be binding, unless in writing and signed by an authorized representative of
each party.
SUPPLEMENTAL TERMS.
A. As a condition to the rights and licenses granted to you in this
Agreement, you cannot and shall not distribute a modified version of the AWT
that does not contain all of the class libraries (or equivalent libraries)
of the AWT if such modified version is distributed in association with
dedicated circuitry in silicon. For purposes of this section, "AWT" means
the abstract windowing toolkit class libraries implemented in the OpenJDK
Code or any modified version of such abstract windowing toolkit that is
created and distributed by Sun or its licensees.

View File

@ -0,0 +1 @@
The following bundled file contains the OpenJDK's standard library, and as such, is subject to OpenJDK's license. However, your own code, as generated by Haxe, won't have to include this binary file, and thus is not necessarily subject to its license.

Binary file not shown.

BIN
Kha/Tools/macos/lame Executable file

Binary file not shown.

View File

@ -0,0 +1,144 @@
Mono is made up of many pieces of code, all of them open source, but
different pieces of Mono use different licensing terms.
For comments, corrections and updates, please contact mono@xamarin.com
* Dual Licensing
Parts of Mono are dual licensed, they are available to the
public in GPL or LGPL forms, but we also offer those pieces
under commercial terms from Xamarin for the cases wher the GPL
and the LGPL are not suitable.
We have tried to pick the licenses that will maximize adoption
of Mono, so we tend to use the MIT X11 or LGPL liceses.
Contributions to dual-licensed module require that the author
contributes the code under the terms of the MIT X11 code, or
to sign an agreement that allows Novell to redistribute the
code under other licenses.
Contributions for other modules should be under the same license
terms as the rest of the module, or under MIT X11 terms.
For the actual license links in the Mono distribution see the
bottom of this file.
If you need further information, please contact mono@xamarin.com
* The Modules
** mono/mono: the Mono VM
This code is dual licensed under the LGPL or commercial licenses.
The LGPL ensures that Mono can be used in most scenarios, but
gives Xamarin the flexibility to relicense the code for
embedded systems, static linking or commercial settings where
the LGPL can not be used.
We consider non-LGPL use instances where you use this on an
embedded system where the end user is not able to upgrade the
Mono VM or Moonlight installation or distribution that is part
of your product (Section 6 and 7), you would have to obtain a
commercial license from Xamarin (consider software burned into
a ROM, systems where end users would not be able to upgrade,
an embedded console, a game console that imposes limitations
on the distribution and access to the code, a phone platform
that prevents end users from upgrading Moonlight).
Contact mono@xamarin.com for details on obtaining the Mono
runtime under other terms.
** mono/support: MonoPosixHelper and support code
This code is dual licensed under the LGPL or commercial licenses, with
the same guidelines as mono/mono code.
The ZLib files are included under a "new BSD"-style license.
** mono/eglib: Mono's X11 glib implementation
This is a minimal subset of glib that is to be licensed under
the terms of the MIT X11, this means that this code can be
used for any purposes by anyone.
** mono/metadata/sgen*: Mono's Copying Collector
This new garbage collector is licensed under the terms of
the MIT X11 license, in hopes that the GC could be reused
by third party projects, follows the same spirit than the
Boehm GC.
** mono/arch/*/XXX-codegen.h
This are C macros that are useful when generating native
code on various platforms. This code is MIT X11 licensed.
** mcs/mcs, mcs/gmcs
The C# Compilers (1.0 and 2.0)
These compilers are dual licensed under the GPL and MIT X11
license terms.
** tests
Unless explicitly stated, the tests are under the MIT X11 license.
** mcs/class
The class libraries developed by the Mono team are licensed
under the MIT X11 terms.
In addition to the class libraries developed by the Mono team,
there are a number of class libraries that we bundle as part
of the distribution that were integrated from third-parties or
that contain code that was originally licensed under different
terms, these are:
ByteFX.Data: LGPL
Npgsql: LGPL
FirebirdSql.Data.Firebird: Firebird public license.
See: mcs/class/FirebirdSql.Data.Firebird/license.txt
ICSharpCode.SharpZipLib, GPL with exceptions.
See: mcs/class/ICSharpCode.SharpZipLib/README
** mcs/class/System.Core/System/TimeZoneInfo.Android.cs
This is a port of Apache 2.0-licensed Android code, and thus is
licensed under the Apache 2.0 license:
http://www.apache.org/licenses/LICENSE-2.0
** mcs/tools
These are licensed under the MIT X11 license, except where the
GPL is explicitly used.
** mcs/jay
This is a port of Berkeley yacc, so it is available under the BSD
license. See the license in the individual C files for details.
** mono/man
Manual pages and Mono documentation are covered by the MIT X11 license.
* samples
The code in the "samples" directory is released under the MIT X11 license.
* The Licenses
These are the licenses used in Mono, the files are located:
GNU GPL: details avaliable in the file mcs/LICENSE.GPL
GNU LGPL: details available in the file mcs/LICENSE.LGPL
MIT X11: text available in the file mcs/MIT.X11
MPL: text available in the file mcs/LICENSE.MPL

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Kha/Tools/macos/oggenc Executable file

Binary file not shown.

View File

@ -0,0 +1,44 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/**
`Any` is a type that is compatible with any other in both ways.
This means that a value of any type can be assigned to `Any`, and
vice-versa, a value of `Any` type can be assigned to any other type.
It's a more type-safe alternative to `Dynamic`, because it doesn't
support field access or operators and it's bound to monomorphs. So,
to work with the actual value, it needs to be explicitly promoted
to another type.
**/
@:forward.variance
abstract Any(Dynamic) {
@:noCompletion @:to extern inline function __promote<T>():T
return this;
@:noCompletion @:from extern inline static function __cast<T>(value:T):Any
return cast value;
@:noCompletion extern inline function toString():String
return Std.string(this);
}

View File

@ -0,0 +1,333 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/**
An Array is a storage for values. You can access it using indexes or
with its API.
@see https://haxe.org/manual/std-Array.html
@see https://haxe.org/manual/lf-array-comprehension.html
**/
import haxe.iterators.ArrayKeyValueIterator;
extern class Array<T> {
/**
The length of `this` Array.
**/
var length(default, null):Int;
/**
Creates a new Array.
**/
function new():Void;
/**
Returns a new Array by appending the elements of `a` to the elements of
`this` Array.
This operation does not modify `this` Array.
If `a` is the empty Array `[]`, a copy of `this` Array is returned.
The length of the returned Array is equal to the sum of `this.length`
and `a.length`.
If `a` is `null`, the result is unspecified.
**/
function concat(a:Array<T>):Array<T>;
/**
Returns a string representation of `this` Array, with `sep` separating
each element.
The result of this operation is equal to `Std.string(this[0]) + sep +
Std.string(this[1]) + sep + ... + sep + Std.string(this[this.length-1])`
If `this` is the empty Array `[]`, the result is the empty String `""`.
If `this` has exactly one element, the result is equal to a call to
`Std.string(this[0])`.
If `sep` is null, the result is unspecified.
**/
function join(sep:String):String;
/**
Removes the last element of `this` Array and returns it.
This operation modifies `this` Array in place.
If `this` has at least one element, `this.length` will decrease by 1.
If `this` is the empty Array `[]`, null is returned and the length
remains 0.
**/
function pop():Null<T>;
/**
Adds the element `x` at the end of `this` Array and returns the new
length of `this` Array.
This operation modifies `this` Array in place.
`this.length` increases by 1.
**/
function push(x:T):Int;
/**
Reverse the order of elements of `this` Array.
This operation modifies `this` Array in place.
If `this.length < 2`, `this` remains unchanged.
**/
function reverse():Void;
/**
Removes the first element of `this` Array and returns it.
This operation modifies `this` Array in place.
If `this` has at least one element, `this`.length and the index of each
remaining element is decreased by 1.
If `this` is the empty Array `[]`, `null` is returned and the length
remains 0.
**/
function shift():Null<T>;
/**
Creates a shallow copy of the range of `this` Array, starting at and
including `pos`, up to but not including `end`.
This operation does not modify `this` Array.
The elements are not copied and retain their identity.
If `end` is omitted or exceeds `this.length`, it defaults to the end of
`this` Array.
If `pos` or `end` are negative, their offsets are calculated from the
end of `this` Array by `this.length + pos` and `this.length + end`
respectively. If this yields a negative value, 0 is used instead.
If `pos` exceeds `this.length` or if `end` is less than or equals
`pos`, the result is `[]`.
**/
function slice(pos:Int, ?end:Int):Array<T>;
/**
Sorts `this` Array according to the comparison function `f`, where
`f(x,y)` returns 0 if x == y, a positive Int if x > y and a
negative Int if x < y.
This operation modifies `this` Array in place.
The sort operation is not guaranteed to be stable, which means that the
order of equal elements may not be retained. For a stable Array sorting
algorithm, `haxe.ds.ArraySort.sort()` can be used instead.
If `f` is null, the result is unspecified.
**/
function sort(f:T->T->Int):Void;
/**
Removes `len` elements from `this` Array, starting at and including
`pos`, an returns them.
This operation modifies `this` Array in place.
If `len` is < 0 or `pos` exceeds `this`.length, an empty Array [] is
returned and `this` Array is unchanged.
If `pos` is negative, its value is calculated from the end of `this`
Array by `this.length + pos`. If this yields a negative value, 0 is
used instead.
If the sum of the resulting values for `len` and `pos` exceed
`this.length`, this operation will affect the elements from `pos` to the
end of `this` Array.
The length of the returned Array is equal to the new length of `this`
Array subtracted from the original length of `this` Array. In other
words, each element of the original `this` Array either remains in
`this` Array or becomes an element of the returned Array.
**/
function splice(pos:Int, len:Int):Array<T>;
/**
Returns a string representation of `this` Array.
The result will include the individual elements' String representations
separated by comma. The enclosing [ ] may be missing on some platforms,
use `Std.string()` to get a String representation that is consistent
across platforms.
**/
function toString():String;
/**
Adds the element `x` at the start of `this` Array.
This operation modifies `this` Array in place.
`this.length` and the index of each Array element increases by 1.
**/
function unshift(x:T):Void;
/**
Inserts the element `x` at the position `pos`.
This operation modifies `this` Array in place.
The offset is calculated like so:
- If `pos` exceeds `this.length`, the offset is `this.length`.
- If `pos` is negative, the offset is calculated from the end of `this`
Array, i.e. `this.length + pos`. If this yields a negative value, the
offset is 0.
- Otherwise, the offset is `pos`.
If the resulting offset does not exceed `this.length`, all elements from
and including that offset to the end of `this` Array are moved one index
ahead.
**/
function insert(pos:Int, x:T):Void;
/**
Removes the first occurrence of `x` in `this` Array.
This operation modifies `this` Array in place.
If `x` is found by checking standard equality, it is removed from `this`
Array and all following elements are reindexed accordingly. The function
then returns true.
If `x` is not found, `this` Array is not changed and the function
returns false.
**/
function remove(x:T):Bool;
/**
Returns whether `this` Array contains `x`.
If `x` is found by checking standard equality, the function returns `true`, otherwise
the function returns `false`.
**/
@:pure function contains( x : T ) : Bool;
/**
Returns position of the first occurrence of `x` in `this` Array, searching front to back.
If `x` is found by checking standard equality, the function returns its index.
If `x` is not found, the function returns -1.
If `fromIndex` is specified, it will be used as the starting index to search from,
otherwise search starts with zero index. If it is negative, it will be taken as the
offset from the end of `this` Array to compute the starting index. If given or computed
starting index is less than 0, the whole array will be searched, if it is greater than
or equal to the length of `this` Array, the function returns -1.
**/
function indexOf(x:T, ?fromIndex:Int):Int;
/**
Returns position of the last occurrence of `x` in `this` Array, searching back to front.
If `x` is found by checking standard equality, the function returns its index.
If `x` is not found, the function returns -1.
If `fromIndex` is specified, it will be used as the starting index to search from,
otherwise search starts with the last element index. If it is negative, it will be
taken as the offset from the end of `this` Array to compute the starting index. If
given or computed starting index is greater than or equal to the length of `this` Array,
the whole array will be searched, if it is less than 0, the function returns -1.
**/
function lastIndexOf(x:T, ?fromIndex:Int):Int;
/**
Returns a shallow copy of `this` Array.
The elements are not copied and retain their identity, so
`a[i] == a.copy()[i]` is true for any valid `i`. However,
`a == a.copy()` is always false.
**/
function copy():Array<T>;
/**
Returns an iterator of the Array values.
**/
@:runtime inline function iterator():haxe.iterators.ArrayIterator<T> {
return new haxe.iterators.ArrayIterator(this);
}
/**
Returns an iterator of the Array indices and values.
**/
@:pure @:runtime public inline function keyValueIterator() : ArrayKeyValueIterator<T> {
return new ArrayKeyValueIterator(this);
}
/**
Creates a new Array by applying function `f` to all elements of `this`.
The order of elements is preserved.
If `f` is null, the result is unspecified.
**/
@:runtime inline function map<S>(f:T->S):Array<S> {
#if (cpp && !cppia)
var result = cpp.NativeArray.create(length);
for (i in 0...length) cpp.NativeArray.unsafeSet(result, i, f(cpp.NativeArray.unsafeGet(this, i)));
return result;
#else
return [for (v in this) f(v)];
#end
}
/**
Returns an Array containing those elements of `this` for which `f`
returned true.
The individual elements are not duplicated and retain their identity.
If `f` is null, the result is unspecified.
**/
@:runtime inline function filter(f:T->Bool):Array<T> {
return [for (v in this) if (f(v)) v];
}
/**
Set the length of the Array.
If `len` is shorter than the array's current size, the last
`length - len` elements will be removed. If `len` is longer, the Array
will be extended, with new elements set to a target-specific default
value:
- always null on dynamic targets
- 0, 0.0 or false for Int, Float and Bool respectively on static targets
- null for other types on static targets
**/
function resize(len:Int):Void;
}

View File

@ -0,0 +1,30 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/**
An abstract type that represents a Class.
See `Type` for the Haxe Reflection API.
@see https://haxe.org/manual/types-class-instance.html
**/
@:coreType @:runtimeValue abstract Class<T> {}

183
Kha/Tools/macos/std/Date.hx Normal file
View File

@ -0,0 +1,183 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/**
The Date class provides a basic structure for date and time related
information. Date instances can be created by
- `new Date()` for a specific date,
- `Date.now()` to obtain information about the current time,
- `Date.fromTime()` with a given timestamp or
- `Date.fromString()` by parsing from a String.
There are some extra functions available in the `DateTools` class.
In the context of Haxe dates, a timestamp is defined as the number of
milliseconds elapsed since 1st January 1970 UTC.
## Supported range
Due to platform limitations, only dates in the range 1970 through 2038 are
supported consistently. Some targets may support dates outside this range,
depending on the OS at runtime. The `Date.fromTime` method will not work with
timestamps outside the range on any target.
**/
extern class Date {
/**
Creates a new date object from the given arguments.
The behaviour of a Date instance is only consistent across platforms if
the the arguments describe a valid date.
- month: 0 to 11 (note that this is zero-based)
- day: 1 to 31
- hour: 0 to 23
- min: 0 to 59
- sec: 0 to 59
**/
function new(year:Int, month:Int, day:Int, hour:Int, min:Int, sec:Int):Void;
/**
Returns the timestamp (in milliseconds) of `this` date.
On cpp and neko, this function only has a second resolution, so the
result will always be a multiple of `1000.0`, e.g. `1454698271000.0`.
To obtain the current timestamp with better precision on cpp and neko,
see the `Sys.time` API.
For measuring time differences with millisecond accuracy on
all platforms, see `haxe.Timer.stamp`.
**/
function getTime():Float;
/**
Returns the hours of `this` Date (0-23 range) in the local timezone.
**/
function getHours():Int;
/**
Returns the minutes of `this` Date (0-59 range) in the local timezone.
**/
function getMinutes():Int;
/**
Returns the seconds of `this` Date (0-59 range) in the local timezone.
**/
function getSeconds():Int;
/**
Returns the full year of `this` Date (4 digits) in the local timezone.
**/
function getFullYear():Int;
/**
Returns the month of `this` Date (0-11 range) in the local timezone.
Note that the month number is zero-based.
**/
function getMonth():Int;
/**
Returns the day of `this` Date (1-31 range) in the local timezone.
**/
function getDate():Int;
/**
Returns the day of the week of `this` Date (0-6 range, where `0` is Sunday)
in the local timezone.
**/
function getDay():Int;
/**
Returns the hours of `this` Date (0-23 range) in UTC.
**/
function getUTCHours():Int;
/**
Returns the minutes of `this` Date (0-59 range) in UTC.
**/
function getUTCMinutes():Int;
/**
Returns the seconds of `this` Date (0-59 range) in UTC.
**/
function getUTCSeconds():Int;
/**
Returns the full year of `this` Date (4 digits) in UTC.
**/
function getUTCFullYear():Int;
/**
Returns the month of `this` Date (0-11 range) in UTC.
Note that the month number is zero-based.
**/
function getUTCMonth():Int;
/**
Returns the day of `this` Date (1-31 range) in UTC.
**/
function getUTCDate():Int;
/**
Returns the day of the week of `this` Date (0-6 range, where `0` is Sunday)
in UTC.
**/
function getUTCDay():Int;
/**
Returns the time zone difference of `this` Date in the current locale
to UTC, in minutes.
Assuming the function is executed on a machine in a UTC+2 timezone,
`Date.now().getTimezoneOffset()` will return `-120`.
**/
function getTimezoneOffset():Int;
/**
Returns a string representation of `this` Date in the local timezone
using the standard format `YYYY-MM-DD HH:MM:SS`. See `DateTools.format` for
other formatting rules.
**/
function toString():String;
/**
Returns a Date representing the current local time.
**/
static function now():Date;
/**
Creates a Date from the timestamp (in milliseconds) `t`.
**/
static function fromTime(t:Float):Date;
/**
Creates a Date from the formatted string `s`. The following formats are
accepted by the function:
- `"YYYY-MM-DD hh:mm:ss"`
- `"YYYY-MM-DD"`
- `"hh:mm:ss"`
The first two formats expressed a date in local time. The third is a time
relative to the UTC epoch.
**/
static function fromString(s:String):Date;
}

View File

@ -0,0 +1,256 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/**
The DateTools class contains some extra functionalities for handling `Date`
instances and timestamps.
In the context of Haxe dates, a timestamp is defined as the number of
milliseconds elapsed since 1st January 1970.
**/
class DateTools {
#if php
#elseif (neko && !(macro || interp))
static var date_format = neko.Lib.load("std", "date_format", 2);
#else
static var DAY_SHORT_NAMES = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
static var DAY_NAMES = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
static var MONTH_SHORT_NAMES = [
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
];
static var MONTH_NAMES = [
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
];
private static function __format_get(d:Date, e:String):String {
return switch (e) {
case "%":
"%";
case "a":
DAY_SHORT_NAMES[d.getDay()];
case "A":
DAY_NAMES[d.getDay()];
case "b", "h":
MONTH_SHORT_NAMES[d.getMonth()];
case "B":
MONTH_NAMES[d.getMonth()];
case "C":
StringTools.lpad(Std.string(Std.int(d.getFullYear() / 100)), "0", 2);
case "d":
StringTools.lpad(Std.string(d.getDate()), "0", 2);
case "D":
__format(d, "%m/%d/%y");
case "e":
Std.string(d.getDate());
case "F":
__format(d, "%Y-%m-%d");
case "H", "k":
StringTools.lpad(Std.string(d.getHours()), if (e == "H") "0" else " ", 2);
case "I", "l":
var hour = d.getHours() % 12;
StringTools.lpad(Std.string(hour == 0 ? 12 : hour), if (e == "I") "0" else " ", 2);
case "m":
StringTools.lpad(Std.string(d.getMonth() + 1), "0", 2);
case "M":
StringTools.lpad(Std.string(d.getMinutes()), "0", 2);
case "n":
"\n";
case "p":
if (d.getHours() > 11) "PM"; else "AM";
case "r":
__format(d, "%I:%M:%S %p");
case "R":
__format(d, "%H:%M");
case "s":
Std.string(Std.int(d.getTime() / 1000));
case "S":
StringTools.lpad(Std.string(d.getSeconds()), "0", 2);
case "t":
"\t";
case "T":
__format(d, "%H:%M:%S");
case "u":
var t = d.getDay();
if (t == 0) "7" else Std.string(t);
case "w":
Std.string(d.getDay());
case "y":
StringTools.lpad(Std.string(d.getFullYear() % 100), "0", 2);
case "Y":
Std.string(d.getFullYear());
default:
throw new haxe.exceptions.NotImplementedException("Date.format %" + e + "- not implemented yet.");
}
}
private static function __format(d:Date, f:String):String {
var r = new StringBuf();
var p = 0;
while (true) {
var np = f.indexOf("%", p);
if (np < 0)
break;
r.addSub(f, p, np - p);
r.add(__format_get(d, f.substr(np + 1, 1)));
p = np + 2;
}
r.addSub(f, p, f.length - p);
return r.toString();
}
#end
/**
Format the date `d` according to the format `f`. The format is
compatible with the `strftime` standard format, except that there is no
support in Flash and JS for day and months names (due to lack of proper
internationalization API). On Haxe/Neko/Windows, some formats are not
supported.
```haxe
var t = DateTools.format(Date.now(), "%Y-%m-%d_%H:%M:%S");
// 2016-07-08_14:44:05
var t = DateTools.format(Date.now(), "%r");
// 02:44:05 PM
var t = DateTools.format(Date.now(), "%T");
// 14:44:05
var t = DateTools.format(Date.now(), "%F");
// 2016-07-08
```
**/
public static function format(d:Date, f:String):String {
#if (neko && !(macro || interp))
return new String(untyped date_format(d.__t, f.__s));
#elseif php
return php.Global.strftime(f, php.Syntax.int(@:privateAccess d.__t));
#else
return __format(d, f);
#end
}
/**
Returns the result of adding timestamp `t` to Date `d`.
This is a convenience function for calling
`Date.fromTime(d.getTime() + t)`.
**/
public static inline function delta(d:Date, t:Float):Date {
return Date.fromTime(d.getTime() + t);
}
static var DAYS_OF_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
/**
Returns the number of days in the month of Date `d`.
This method handles leap years.
**/
public static function getMonthDays(d:Date):Int {
var month = d.getMonth();
var year = d.getFullYear();
if (month != 1)
return DAYS_OF_MONTH[month];
var isB = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
return if (isB) 29 else 28;
}
/**
Converts a number of seconds to a timestamp.
**/
public static inline function seconds(n:Float):Float {
return n * 1000.0;
}
/**
Converts a number of minutes to a timestamp.
**/
public static inline function minutes(n:Float):Float {
return n * 60.0 * 1000.0;
}
/**
Converts a number of hours to a timestamp.
**/
public static inline function hours(n:Float):Float {
return n * 60.0 * 60.0 * 1000.0;
}
/**
Converts a number of days to a timestamp.
**/
public static inline function days(n:Float):Float {
return n * 24.0 * 60.0 * 60.0 * 1000.0;
}
/**
Separate a date-time into several components
**/
public static function parse(t:Float) {
var s = t / 1000;
var m = s / 60;
var h = m / 60;
return {
ms: t % 1000,
seconds: Std.int(s % 60),
minutes: Std.int(m % 60),
hours: Std.int(h % 24),
days: Std.int(h / 24),
};
}
/**
Build a date-time from several components
**/
public static function make(o:{
ms:Float,
seconds:Int,
minutes:Int,
hours:Int,
days:Int
}) {
return o.ms + 1000.0 * (o.seconds + 60.0 * (o.minutes + 60.0 * (o.hours + 24.0 * o.days)));
}
#if (js || flash || php || cpp || python)
/**
Retrieve Unix timestamp value from Date components. Takes same argument sequence as the Date constructor.
**/
public static #if (js || flash || php) inline #end function makeUtc(year:Int, month:Int, day:Int, hour:Int, min:Int, sec:Int):Float {
#if (js || flash || python)
return untyped Date.UTC(year, month, day, hour, min, sec);
#elseif php
return php.Global.gmmktime(hour, min, sec, month + 1, day, year) * 1000;
#elseif cpp
return untyped __global__.__hxcpp_utc_date(year, month, day, hour, min, sec) * 1000.0;
#else
// TODO
return 0.;
#end
}
#end
}

203
Kha/Tools/macos/std/EReg.hx Normal file
View File

@ -0,0 +1,203 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/**
The EReg class represents regular expressions.
While basic usage and patterns consistently work across platforms, some more
complex operations may yield different results. This is a necessary trade-
off to retain a certain level of performance.
EReg instances can be created by calling the constructor, or with the
special syntax `~/pattern/modifier`
EReg instances maintain an internal state, which is affected by several of
its methods.
A detailed explanation of the supported operations is available at
<https://haxe.org/manual/std-regex.html>
**/
class EReg {
/**
Creates a new regular expression with pattern `r` and modifiers `opt`.
This is equivalent to the shorthand syntax `~/r/opt`
If `r` or `opt` are null, the result is unspecified.
**/
public function new(r:String, opt:String) {
throw new haxe.exceptions.NotImplementedException("Regular expressions are not implemented for this platform");
}
/**
Tells if `this` regular expression matches String `s`.
This method modifies the internal state.
If `s` is `null`, the result is unspecified.
**/
public function match(s:String):Bool {
return false;
}
/**
Returns the matched sub-group `n` of `this` EReg.
This method should only be called after `this.match` or
`this.matchSub`, and then operates on the String of that operation.
The index `n` corresponds to the n-th set of parentheses in the pattern
of `this` EReg. If no such sub-group exists, the result is unspecified.
If `n` equals 0, the whole matched substring is returned.
**/
public function matched(n:Int):String {
return null;
}
/**
Returns the part to the left of the last matched substring.
If the most recent call to `this.match` or `this.matchSub` did not
match anything, the result is unspecified.
If the global g modifier was in place for the matching, only the
substring to the left of the leftmost match is returned.
The result does not include the matched part.
**/
public function matchedLeft():String {
return null;
}
/**
Returns the part to the right of the last matched substring.
If the most recent call to `this.match` or `this.matchSub` did not
match anything, the result is unspecified.
If the global g modifier was in place for the matching, only the
substring to the right of the leftmost match is returned.
The result does not include the matched part.
**/
public function matchedRight():String {
return null;
}
/**
Returns the position and length of the last matched substring, within
the String which was last used as argument to `this.match` or
`this.matchSub`.
If the most recent call to `this.match` or `this.matchSub` did not
match anything, the result is unspecified.
If the global g modifier was in place for the matching, the position and
length of the leftmost substring is returned.
**/
public function matchedPos():{pos:Int, len:Int} {
return null;
}
/**
Tells if `this` regular expression matches a substring of String `s`.
This function expects `pos` and `len` to describe a valid substring of
`s`, or else the result is unspecified. To get more robust behavior,
`this.match(s.substr(pos,len))` can be used instead.
This method modifies the internal state.
If `s` is null, the result is unspecified.
**/
public function matchSub(s:String, pos:Int, len:Int = -1):Bool {
return false;
}
/**
Splits String `s` at all substrings `this` EReg matches.
If a match is found at the start of `s`, the result contains a leading
empty String "" entry.
If a match is found at the end of `s`, the result contains a trailing
empty String "" entry.
If two matching substrings appear next to each other, the result
contains the empty String `""` between them.
By default, this method splits `s` into two parts at the first matched
substring. If the global g modifier is in place, `s` is split at each
matched substring.
If `s` is null, the result is unspecified.
**/
public function split(s:String):Array<String> {
return null;
}
/**
Replaces the first substring of `s` which `this` EReg matches with `by`.
If `this` EReg does not match any substring, the result is `s`.
By default, this method replaces only the first matched substring. If
the global g modifier is in place, all matched substrings are replaced.
If `by` contains `$1` to `$9`, the digit corresponds to number of a
matched sub-group and its value is used instead. If no such sub-group
exists, the replacement is unspecified. The string `$$` becomes `$`.
If `s` or `by` are null, the result is unspecified.
**/
public function replace(s:String, by:String):String {
return null;
}
/**
Calls the function `f` for the substring of `s` which `this` EReg matches
and replaces that substring with the result of `f` call.
The `f` function takes `this` EReg object as its first argument and should
return a replacement string for the substring matched.
If `this` EReg does not match any substring, the result is `s`.
By default, this method replaces only the first matched substring. If
the global g modifier is in place, all matched substrings are replaced.
If `s` or `f` are null, the result is unspecified.
**/
public function map(s:String, f:EReg->String):String {
return null;
}
/**
Escape the string `s` for use as a part of regular expression.
If `s` is null, the result is unspecified.
**/
public static function escape(s:String):String {
return null;
}
}

View File

@ -0,0 +1,32 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/**
An abstract type that represents an Enum type.
The corresponding enum instance type is `EnumValue`.
See `Type` for the Haxe Reflection API.
@see https://haxe.org/manual/types-enum-instance.html
**/
@:coreType @:runtimeValue abstract Enum<T> {}

View File

@ -0,0 +1,61 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/**
An abstract type that represents any enum value.
See `Type` for the Haxe Reflection API.
@see https://haxe.org/manual/types-enum-instance.html
**/
@:coreType abstract EnumValue {
/**
Matches enum instance `e` against pattern `pattern`, returning `true` if
matching succeeded and `false` otherwise.
Example usage:
```haxe
if (e.match(pattern)) {
// codeIfTrue
} else {
// codeIfFalse
}
```
This is equivalent to the following code:
```haxe
switch (e) {
case pattern:
// codeIfTrue
case _:
// codeIfFalse
}
```
This method is implemented in the compiler. This definition exists only
for documentation.
**/
public function match(pattern:Dynamic):Bool {
return false;
}
}

View File

@ -0,0 +1,65 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/**
IntIterator is used for implementing interval iterations.
It is usually not used explicitly, but through its special syntax:
`min...max`
While it is possible to assign an instance of IntIterator to a variable or
field, it is worth noting that IntIterator does not reset after being used
in a for-loop. Subsequent uses of the same instance will then have no
effect.
@see https://haxe.org/manual/lf-iterators.html
**/
class IntIterator {
var min:Int;
var max:Int;
/**
Iterates from `min` (inclusive) to `max` (exclusive).
If `max <= min`, the iterator will not act as a countdown.
**/
public inline function new(min:Int, max:Int) {
this.min = min;
this.max = max;
}
/**
Returns true if the iterator has other items, false otherwise.
**/
public inline function hasNext() {
return min < max;
}
/**
Moves to the next item of the iterator.
If this is called while hasNext() is false, the result is unspecified.
**/
public inline function next() {
return min++;
}
}

View File

@ -0,0 +1,297 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
import haxe.ds.List;
/**
The `Lambda` class is a collection of methods to support functional
programming. It is ideally used with `using Lambda` and then acts as an
extension to Iterable types.
On static platforms, working with the Iterable structure might be slower
than performing the operations directly on known types, such as Array and
List.
If the first argument to any of the methods is null, the result is
unspecified.
@see https://haxe.org/manual/std-Lambda.html
**/
class Lambda {
/**
Creates an Array from Iterable `it`.
If `it` is an Array, this function returns a copy of it.
**/
public static function array<A>(it:Iterable<A>):Array<A> {
var a = new Array<A>();
for (i in it)
a.push(i);
return a;
}
/**
Creates a List form Iterable `it`.
If `it` is a List, this function returns a copy of it.
**/
public static function list<A>(it:Iterable<A>):List<A> {
var l = new List<A>();
for (i in it)
l.add(i);
return l;
}
/**
Creates a new Array by applying function `f` to all elements of `it`.
The order of elements is preserved.
If `f` is null, the result is unspecified.
**/
public static inline function map<A, B>(it:Iterable<A>, f:(item:A) -> B):Array<B> {
return [for (x in it) f(x)];
}
/**
Similar to map, but also passes the index of each element to `f`.
The order of elements is preserved.
If `f` is null, the result is unspecified.
**/
public static inline function mapi<A, B>(it:Iterable<A>, f:(index:Int, item:A) -> B):Array<B> {
var i = 0;
return [for (x in it) f(i++, x)];
}
/**
Concatenate a list of iterables.
The order of elements is preserved.
**/
public static inline function flatten<A>(it:Iterable<Iterable<A>>):Array<A> {
return [for (e in it) for (x in e) x];
}
/**
A composition of map and flatten.
The order of elements is preserved.
If `f` is null, the result is unspecified.
**/
public static inline function flatMap<A, B>(it:Iterable<A>, f:(item:A) -> Iterable<B>):Array<B> {
return Lambda.flatten(Lambda.map(it, f));
}
/**
Tells if `it` contains `elt`.
This function returns true as soon as an element is found which is equal
to `elt` according to the `==` operator.
If no such element is found, the result is false.
**/
public static function has<A>(it:Iterable<A>, elt:A):Bool {
for (x in it)
if (x == elt)
return true;
return false;
}
/**
Tells if `it` contains an element for which `f` is true.
This function returns true as soon as an element is found for which a
call to `f` returns true.
If no such element is found, the result is false.
If `f` is null, the result is unspecified.
**/
public static function exists<A>(it:Iterable<A>, f:(item:A) -> Bool) {
for (x in it)
if (f(x))
return true;
return false;
}
/**
Tells if `f` is true for all elements of `it`.
This function returns false as soon as an element is found for which a
call to `f` returns false.
If no such element is found, the result is true.
In particular, this function always returns true if `it` is empty.
If `f` is null, the result is unspecified.
**/
public static function foreach<A>(it:Iterable<A>, f:(item:A) -> Bool) {
for (x in it)
if (!f(x))
return false;
return true;
}
/**
Calls `f` on all elements of `it`, in order.
If `f` is null, the result is unspecified.
**/
public static function iter<A>(it:Iterable<A>, f:(item:A) -> Void) {
for (x in it)
f(x);
}
/**
Returns a Array containing those elements of `it` for which `f` returned
true.
If `it` is empty, the result is the empty Array even if `f` is null.
Otherwise if `f` is null, the result is unspecified.
**/
public static function filter<A>(it:Iterable<A>, f:(item:A) -> Bool) {
return [for (x in it) if (f(x)) x];
}
/**
Functional fold on Iterable `it`, using function `f` with start argument
`first`.
If `it` has no elements, the result is `first`.
Otherwise the first element of `it` is passed to `f` alongside `first`.
The result of that call is then passed to `f` with the next element of
`it`, and so on until `it` has no more elements.
If `it` or `f` are null, the result is unspecified.
**/
public static function fold<A, B>(it:Iterable<A>, f:(item:A, result:B) -> B, first:B):B {
for (x in it)
first = f(x, first);
return first;
}
/**
Similar to fold, but also passes the index of each element to `f`.
If `it` or `f` are null, the result is unspecified.
**/
public static function foldi<A, B>(it:Iterable<A>, f:(item:A, result:B, index:Int) -> B, first:B):B {
var i = 0;
for (x in it) {
first = f(x, first, i);
++i;
}
return first;
}
/**
Returns the number of elements in `it` for which `pred` is true, or the
total number of elements in `it` if `pred` is null.
This function traverses all elements.
**/
public static function count<A>(it:Iterable<A>, ?pred:(item:A) -> Bool) {
var n = 0;
if (pred == null)
for (_ in it)
n++;
else
for (x in it)
if (pred(x))
n++;
return n;
}
/**
Tells if Iterable `it` does not contain any element.
**/
public static function empty<T>(it:Iterable<T>):Bool {
return !it.iterator().hasNext();
}
/**
Returns the index of the first element `v` within Iterable `it`.
This function uses operator `==` to check for equality.
If `v` does not exist in `it`, the result is -1.
**/
public static function indexOf<T>(it:Iterable<T>, v:T):Int {
var i = 0;
for (v2 in it) {
if (v == v2)
return i;
i++;
}
return -1;
}
/**
Returns the first element of `it` for which `f` is true.
This function returns as soon as an element is found for which a call to
`f` returns true.
If no such element is found, the result is null.
If `f` is null, the result is unspecified.
**/
public static function find<T>(it:Iterable<T>, f:(item:T) -> Bool):Null<T> {
for (v in it) {
if (f(v))
return v;
}
return null;
}
/**
Returns the index of the first element of `it` for which `f` is true.
This function returns as soon as an element is found for which a call to
`f` returns true.
If no such element is found, the result is -1.
If `f` is null, the result is unspecified.
**/
public static function findIndex<T>(it:Iterable<T>, f:(item:T) -> Bool):Int {
var i = 0;
for (v in it) {
if (f(v))
return i;
i++;
}
return -1;
}
/**
Returns a new Array containing all elements of Iterable `a` followed by
all elements of Iterable `b`.
If `a` or `b` are null, the result is unspecified.
**/
public static function concat<T>(a:Iterable<T>, b:Iterable<T>):Array<T> {
var l = new Array();
for (x in a)
l.push(x);
for (x in b)
l.push(x);
return l;
}
}

View File

@ -0,0 +1,22 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
typedef List<T> = haxe.ds.List<T>;

View File

@ -0,0 +1,26 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
typedef Map<K, V> = haxe.ds.Map<K, V>;
@:dox(hide)
@:deprecated
typedef IMap<K, V> = haxe.Constraints.IMap<K, V>;

309
Kha/Tools/macos/std/Math.hx Normal file
View File

@ -0,0 +1,309 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/**
This class defines mathematical functions and constants.
@see https://haxe.org/manual/std-math.html
**/
#if cpp
@:include("hxMath.h")
#end
@:pure
extern class Math {
/**
Represents the ratio of the circumference of a circle to its diameter,
specified by the constant, π. `PI` is approximately `3.141592653589793`.
**/
static var PI(default, null):Float;
/**
A special `Float` constant which denotes negative infinity.
For example, this is the result of `-1.0 / 0.0`.
Operations with `NEGATIVE_INFINITY` as an operand may result in
`NEGATIVE_INFINITY`, `POSITIVE_INFINITY` or `NaN`.
If this constant is converted to an `Int`, e.g. through `Std.int()`, the
result is unspecified.
**/
static var NEGATIVE_INFINITY(default, null):Float;
/**
A special `Float` constant which denotes positive infinity.
For example, this is the result of `1.0 / 0.0`.
Operations with `POSITIVE_INFINITY` as an operand may result in
`NEGATIVE_INFINITY`, `POSITIVE_INFINITY` or `NaN`.
If this constant is converted to an `Int`, e.g. through `Std.int()`, the
result is unspecified.
**/
static var POSITIVE_INFINITY(default, null):Float;
/**
A special `Float` constant which denotes an invalid number.
`NaN` stands for "Not a Number". It occurs when a mathematically incorrect
operation is executed, such as taking the square root of a negative
number: `Math.sqrt(-1)`.
All further operations with `NaN` as an operand will result in `NaN`.
If this constant is converted to an `Int`, e.g. through `Std.int()`, the
result is unspecified.
In order to test if a value is `NaN`, you should use `Math.isNaN()` function.
**/
static var NaN(default, null):Float;
/**
Returns the absolute value of `v`.
- If `v` is positive or `0`, the result is unchanged. Otherwise the result is `-v`.
- If `v` is `NEGATIVE_INFINITY` or `POSITIVE_INFINITY`, the result is `POSITIVE_INFINITY`.
- If `v` is `NaN`, the result is `NaN`.
**/
static function abs(v:Float):Float;
/**
Returns the smaller of values `a` and `b`.
- If `a` or `b` are `NaN`, the result is `NaN`.
- If `a` or `b` are `NEGATIVE_INFINITY`, the result is `NEGATIVE_INFINITY`.
- If `a` and `b` are `POSITIVE_INFINITY`, the result is `POSITIVE_INFINITY`.
**/
static function min(a:Float, b:Float):Float;
/**
Returns the greater of values `a` and `b`.
- If `a` or `b` are `NaN`, the result is `NaN`.
- If `a` or `b` are `POSITIVE_INFINITY`, the result is `POSITIVE_INFINITY`.
- If `a` and `b` are `NEGATIVE_INFINITY`, the result is `NEGATIVE_INFINITY`.
**/
static function max(a:Float, b:Float):Float;
/**
Returns the trigonometric sine of the specified angle `v`, in radians.
If `v` is `NaN` or infinite, the result is `NaN`.
**/
static function sin(v:Float):Float;
/**
Returns the trigonometric cosine of the specified angle `v`, in radians.
If `v` is `NaN` or infinite, the result is `NaN`.
**/
static function cos(v:Float):Float;
/**
Returns the trigonometric tangent of the specified angle `v`, in radians.
If `v` is `NaN` or infinite, the result is `NaN`.
**/
static function tan(v:Float):Float;
/**
Returns the trigonometric arc of the specified angle `v`, in radians.
If `v` is `NaN` or infinite, the result is `NaN`.
**/
static function asin(v:Float):Float;
/**
Returns the trigonometric arc cosine of the specified angle `v`,
in radians.
If `v` is `NaN` or infinite, the result is `NaN`.
**/
static function acos(v:Float):Float;
/**
Returns the trigonometric arc tangent of the specified angle `v`,
in radians.
If `v` is `NaN` or infinite, the result is `NaN`.
**/
static function atan(v:Float):Float;
/**
Returns the trigonometric arc tangent whose tangent is the quotient of
two specified numbers, in radians.
If parameter `x` or `y` is `NaN`, `NEGATIVE_INFINITY` or `POSITIVE_INFINITY`,
the result is `NaN`.
**/
static function atan2(y:Float, x:Float):Float;
/**
Returns Euler's number, raised to the power of `v`.
`exp(1.0)` is approximately `2.718281828459`.
- If `v` is `POSITIVE_INFINITY`, the result is `POSITIVE_INFINITY`.
- If `v` is `NEGATIVE_INFINITY`, the result is `0.0`.
- If `v` is `NaN`, the result is `NaN`.
**/
static function exp(v:Float):Float;
/**
Returns the natural logarithm of `v`.
This is the mathematical inverse operation of exp,
i.e. `log(exp(v)) == v` always holds.
- If `v` is negative (including `NEGATIVE_INFINITY`) or `NaN`, the result is `NaN`.
- If `v` is `POSITIVE_INFINITY`, the result is `POSITIVE_INFINITY`.
- If `v` is `0.0`, the result is `NEGATIVE_INFINITY`.
**/
static function log(v:Float):Float;
/**
Returns a specified base `v` raised to the specified power `exp`.
**/
static function pow(v:Float, exp:Float):Float;
/**
Returns the square root of `v`.
- If `v` is negative (including `NEGATIVE_INFINITY`) or `NaN`, the result is `NaN`.
- If `v` is `POSITIVE_INFINITY`, the result is `POSITIVE_INFINITY`.
- If `v` is `0.0`, the result is `0.0`.
**/
static function sqrt(v:Float):Float;
/**
Rounds `v` to the nearest integer value.
Ties are rounded up, so that `0.5` becomes `1` and `-0.5` becomes `0`.
If `v` is outside of the signed `Int32` range, or is `NaN`, `NEGATIVE_INFINITY`
or `POSITIVE_INFINITY`, the result is unspecified.
**/
static function round(v:Float):Int;
/**
Returns the largest integer value that is not greater than `v`.
If `v` is outside of the signed `Int32` range, or is `NaN`, `NEGATIVE_INFINITY`
or `POSITIVE_INFINITY`, the result is unspecified.
**/
static function floor(v:Float):Int;
/**
Returns the smallest integer value that is not less than `v`.
If `v` is outside of the signed `Int32` range, or is `NaN`, `NEGATIVE_INFINITY`
or `POSITIVE_INFINITY`, the result is unspecified.
**/
static function ceil(v:Float):Int;
/**
Returns a pseudo-random number which is greater than or equal to `0.0`,
and less than `1.0`.
**/
static function random():Float;
#if (flash || cpp || eval)
/**
Returns the largest integer value that is not greater than `v`, as a `Float`.
If `v` is is `NaN`, `NEGATIVE_INFINITY` or `POSITIVE_INFINITY`,
the result is unspecified.
**/
static function ffloor(v:Float):Float;
/**
Returns the smallest integer value that is not less than `v`, as a `Float`.
If `v` is is `NaN`, `NEGATIVE_INFINITY` or `POSITIVE_INFINITY`,
the result is unspecified.
**/
static function fceil(v:Float):Float;
/**
Rounds `v` to the nearest integer value, as a Float.
Ties are rounded up, so that `0.5` becomes `1` and `-0.5` becomes `0`.
If `v` is is `NaN`, `NEGATIVE_INFINITY` or `POSITIVE_INFINITY`,
the result is unspecified.
**/
static function fround(v:Float):Float;
#else
static inline function ffloor(v:Float):Float {
return floor(v);
}
static inline function fceil(v:Float):Float {
return ceil(v);
}
static inline function fround(v:Float):Float {
return round(v);
}
#end
/**
Tells if `f` is a finite number.
If `f` is `POSITIVE_INFINITY`, `NEGATIVE_INFINITY` or `NaN`, the result
is `false`, otherwise the result is `true`.
**/
static function isFinite(f:Float):Bool;
/**
Tells if `f` is not a valid number.
If `f` is `NaN`, the result is `true`, otherwise the result is `false`.
In particular, both `POSITIVE_INFINITY` and `NEGATIVE_INFINITY` are
not considered `NaN`.
**/
static function isNaN(f:Float):Bool;
#if !eval
private static function __init__():Void
untyped {
#if flash
NaN = __global__["Number"].NaN;
NEGATIVE_INFINITY = __global__["Number"].NEGATIVE_INFINITY;
POSITIVE_INFINITY = __global__["Number"].POSITIVE_INFINITY;
#else
// TODO: Abandoned code block? Js has its own _std/Math.hx
Math.__name__ = ["Math"];
Math.NaN = Number["NaN"];
Math.NEGATIVE_INFINITY = Number["NEGATIVE_INFINITY"];
Math.POSITIVE_INFINITY = Number["POSITIVE_INFINITY"];
#end
Math.isFinite = function(i) {
return #if flash __global__["isFinite"](i); #else false; #end
};
Math.isNaN = function(i) {
return #if flash __global__["isNaN"](i); #else false; #end
};
}
#end
}

View File

@ -0,0 +1,202 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/**
The Reflect API is a way to manipulate values dynamically through an
abstract interface in an untyped manner. Use with care.
@see https://haxe.org/manual/std-reflection.html
**/
extern class Reflect {
/**
Tells if structure `o` has a field named `field`.
This is only guaranteed to work for anonymous structures. Refer to
`Type.getInstanceFields` for a function supporting class instances.
If `o` or `field` are null, the result is unspecified.
**/
static function hasField(o:Dynamic, field:String):Bool;
/**
Returns the value of the field named `field` on object `o`.
If `o` is not an object or has no field named `field`, the result is
null.
If the field is defined as a property, its accessors are ignored. Refer
to `Reflect.getProperty` for a function supporting property accessors.
If `field` is null, the result is unspecified.
**/
static function field(o:Dynamic, field:String):Dynamic;
/**
Sets the field named `field` of object `o` to value `value`.
If `o` has no field named `field`, this function is only guaranteed to
work for anonymous structures.
If `o` or `field` are null, the result is unspecified.
**/
static function setField(o:Dynamic, field:String, value:Dynamic):Void;
/**
Returns the value of the field named `field` on object `o`, taking
property getter functions into account.
If the field is not a property, this function behaves like
`Reflect.field`, but might be slower.
If `o` or `field` are null, the result is unspecified.
**/
static function getProperty(o:Dynamic, field:String):Dynamic;
/**
Sets the field named `field` of object `o` to value `value`, taking
property setter functions into account.
If the field is not a property, this function behaves like
`Reflect.setField`, but might be slower.
If `field` is null, the result is unspecified.
**/
static function setProperty(o:Dynamic, field:String, value:Dynamic):Void;
/**
Call a method `func` with the given arguments `args`.
The object `o` is ignored in most cases. It serves as the `this`-context in the following
situations:
* (neko) Allows switching the context to `o` in all cases.
* (macro) Same as neko for Haxe 3. No context switching in Haxe 4.
* (js, lua) Require the `o` argument if `func` does not, but should have a context.
This can occur by accessing a function field natively, e.g. through `Reflect.field`
or by using `(object : Dynamic).field`. However, if `func` has a context, `o` is
ignored like on other targets.
**/
static function callMethod(o:Dynamic, func:haxe.Constraints.Function, args:Array<Dynamic>):Dynamic;
/**
Returns the fields of structure `o`.
This method is only guaranteed to work on anonymous structures. Refer to
`Type.getInstanceFields` for a function supporting class instances.
If `o` is null, the result is unspecified.
**/
static function fields(o:Dynamic):Array<String>;
/**
Returns true if `f` is a function, false otherwise.
If `f` is null, the result is false.
**/
static function isFunction(f:Dynamic):Bool;
/**
Compares `a` and `b`.
If `a` is less than `b`, the result is negative. If `b` is less than
`a`, the result is positive. If `a` and `b` are equal, the result is 0.
This function is only defined if `a` and `b` are of the same type.
If that type is a function, the result is unspecified and
`Reflect.compareMethods` should be used instead.
For all other types, the result is 0 if `a` and `b` are equal. If they
are not equal, the result depends on the type and is negative if:
- Numeric types: a is less than b
- String: a is lexicographically less than b
- Other: unspecified
If `a` and `b` are null, the result is 0. If only one of them is null,
the result is unspecified.
**/
static function compare<T>(a:T, b:T):Int;
/**
Compares the functions `f1` and `f2`.
If `f1` or `f2` are null, the result is false.
If `f1` or `f2` are not functions, the result is unspecified.
Otherwise the result is true if `f1` and the `f2` are physically equal,
false otherwise.
If `f1` or `f2` are member method closures, the result is true if they
are closures of the same method on the same object value, false otherwise.
**/
static function compareMethods(f1:Dynamic, f2:Dynamic):Bool;
/**
Tells if `v` is an object.
The result is true if `v` is one of the following:
- class instance
- structure
- `Class<T>`
- `Enum<T>`
Otherwise, including if `v` is null, the result is false.
**/
static function isObject(v:Dynamic):Bool;
/**
Tells if `v` is an enum value.
The result is true if `v` is of type EnumValue, i.e. an enum
constructor.
Otherwise, including if `v` is null, the result is false.
**/
static function isEnumValue(v:Dynamic):Bool;
/**
Removes the field named `field` from structure `o`.
This method is only guaranteed to work on anonymous structures.
If `o` or `field` are null, the result is unspecified.
**/
static function deleteField(o:Dynamic, field:String):Bool;
/**
Copies the fields of structure `o`.
This is only guaranteed to work on anonymous structures.
If `o` is null, the result is `null`.
**/
static function copy<T>(o:Null<T>):Null<T>;
/**
Transform a function taking an array of arguments into a function that can
be called with any number of arguments.
**/
@:overload(function(f:Array<Dynamic>->Void):Dynamic {})
static function makeVarArgs(f:Array<Dynamic>->Dynamic):Dynamic;
}

134
Kha/Tools/macos/std/Std.hx Normal file
View File

@ -0,0 +1,134 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#if !(core_api || cross || eval)
#error "Please don't add haxe/std to your classpath, instead set HAXE_STD_PATH env var"
#end
/**
The Std class provides standard methods for manipulating basic types.
**/
extern class Std {
/**
DEPRECATED. Use `Std.isOfType(v, t)` instead.
Tells if a value `v` is of the type `t`. Returns `false` if `v` or `t` are null.
If `t` is a class or interface with `@:generic` meta, the result is `false`.
**/
@:deprecated('Std.is is deprecated. Use Std.isOfType instead.')
static function is(v:Dynamic, t:Dynamic):Bool;
/**
Tells if a value `v` is of the type `t`. Returns `false` if `v` or `t` are null.
If `t` is a class or interface with `@:generic` meta, the result is `false`.
**/
static function isOfType(v:Dynamic, t:Dynamic):Bool;
/**
Checks if object `value` is an instance of class or interface `c`.
Compiles only if the type specified by `c` can be assigned to the type
of `value`.
This method checks if a downcast is possible. That is, if the runtime
type of `value` is assignable to the type specified by `c`, `value` is
returned. Otherwise null is returned.
This method is not guaranteed to work with core types such as `String`,
`Array` and `Date`.
If `value` is null, the result is null. If `c` is null, the result is
unspecified.
**/
static function downcast<T:{}, S:T>(value:T, c:Class<S>):S;
@:deprecated('Std.instance() is deprecated. Use Std.downcast() instead.')
static function instance<T:{}, S:T>(value:T, c:Class<S>):S;
/**
Converts any value to a String.
If `s` is of `String`, `Int`, `Float` or `Bool`, its value is returned.
If `s` is an instance of a class and that class or one of its parent classes has
a `toString` method, that method is called. If no such method is present, the result
is unspecified.
If `s` is an enum constructor without argument, the constructor's name is returned. If
arguments exists, the constructor's name followed by the String representations of
the arguments is returned.
If `s` is a structure, the field names along with their values are returned. The field order
and the operator separating field names and values are unspecified.
If s is null, "null" is returned.
**/
static function string(s:Dynamic):String;
/**
Converts a `Float` to an `Int`, rounded towards 0.
If `x` is outside of the signed Int32 range, or is `NaN`, `NEGATIVE_INFINITY` or `POSITIVE_INFINITY`, the result is unspecified.
**/
static function int(x:Float):Int;
/**
Converts a `String` to an `Int`.
Leading whitespaces are ignored.
If `x` starts with 0x or 0X, hexadecimal notation is recognized where the following digits may
contain 0-9 and A-F.
Otherwise `x` is read as decimal number with 0-9 being allowed characters. `x` may also start with
a - to denote a negative value.
In decimal mode, parsing continues until an invalid character is detected, in which case the
result up to that point is returned. For hexadecimal notation, the effect of invalid characters
is unspecified.
Leading 0s that are not part of the 0x/0X hexadecimal notation are ignored, which means octal
notation is not supported.
If `x` is null, the result is unspecified.
If `x` cannot be parsed as integer, the result is `null`.
**/
static function parseInt(x:String):Null<Int>;
/**
Converts a `String` to a `Float`.
The parsing rules for `parseInt` apply here as well, with the exception of invalid input
resulting in a `NaN` value instead of null.
Additionally, decimal notation may contain a single `.` to denote the start of the fractions.
**/
static function parseFloat(x:String):Float;
/**
Return a random integer between 0 included and `x` excluded.
If `x <= 1`, the result is always 0.
**/
static function random(x:Int):Int;
}

View File

@ -0,0 +1,172 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
// standard Haxe types
/**
The standard `Void` type. Only `null` values can be of the type `Void`.
@see https://haxe.org/manual/types-void.html
**/
#if jvm
@:runtimeValue
#end
@:coreType abstract Void {}
/**
The standard `Float` type, this is a double-precision IEEE 64bit float.
On static targets, `null` cannot be assigned to Float. If this is necessary,
`Null<Float>` can be used instead.
`Std.int` converts a `Float` to an `Int`, rounded towards 0.
`Std.parseFloat` converts a `String` to a `Float`.
@see https://haxe.org/manual/types-basic-types.html
@see https://haxe.org/manual/types-nullability.html
**/
@:coreType @:notNull @:runtimeValue abstract Float {}
/**
The standard `Int` type. Its precision depends on the platform.
On static targets, `null` cannot be assigned to `Int`. If this is necessary,
`Null<Int>` can be used instead.
`Std.int` converts a `Float` to an `Int`, rounded towards 0.
`Std.parseInt` converts a `String` to an `Int`.
@see https://haxe.org/manual/types-basic-types.html
@see https://haxe.org/manual/std-math-integer-math.html
@see https://haxe.org/manual/types-nullability.html
**/
@:coreType @:notNull @:runtimeValue abstract Int to Float {}
#if (java || cs || hl || cpp)
/**
Single-precision IEEE 32bit float (4-byte).
**/
@:coreType @:notNull @:runtimeValue abstract Single to Float from Float {}
#end
/**
`Null<T>` is a wrapper that can be used to make the basic types `Int`,
`Float` and `Bool` nullable on static targets.
If null safety is enabled, only types wrapped in `Null<T>` are nullable.
Otherwise, it has no effect on non-basic-types, but it can be useful as a way to document
that `null` is an acceptable value for a method argument, return value or variable.
@see https://haxe.org/manual/types-nullability.html
**/
@:forward
@:coreType
abstract Null<T> from T to T {}
/**
The standard Boolean type, which can either be `true` or `false`.
On static targets, `null` cannot be assigned to `Bool`. If this is necessary,
`Null<Bool>` can be used instead.
@see https://haxe.org/manual/types-bool.html
@see https://haxe.org/manual/types-nullability.html
**/
@:coreType @:notNull @:runtimeValue abstract Bool {}
/**
`Dynamic` is a special type which is compatible with all other types.
Use of `Dynamic` should be minimized as it prevents several compiler
checks and optimizations. See `Any` type for a safer alternative for
representing values of any type.
@see https://haxe.org/manual/types-dynamic.html
**/
@:coreType @:runtimeValue abstract Dynamic<T> {}
/**
An `Iterator` is a structure that permits iteration over elements of type `T`.
Any class with matching `hasNext()` and `next()` fields is considered an `Iterator`
and can then be used e.g. in `for`-loops. This makes it easy to implement
custom iterators.
@see https://haxe.org/manual/lf-iterators.html
**/
typedef Iterator<T> = {
/**
Returns `false` if the iteration is complete, `true` otherwise.
Usually iteration is considered to be complete if all elements of the
underlying data structure were handled through calls to `next()`. However,
in custom iterators any logic may be used to determine the completion
state.
**/
function hasNext():Bool;
/**
Returns the current item of the `Iterator` and advances to the next one.
This method is not required to check `hasNext()` first. A call to this
method while `hasNext()` is `false` yields unspecified behavior.
On the other hand, iterators should not require a call to `hasNext()`
before the first call to `next()` if an element is available.
**/
function next():T;
}
/**
An `Iterable` is a data structure which has an `iterator()` method.
See `Lambda` for generic functions on iterable structures.
@see https://haxe.org/manual/lf-iterators.html
**/
typedef Iterable<T> = {
function iterator():Iterator<T>;
}
/**
A `KeyValueIterator` is an `Iterator` that has a key and a value.
**/
typedef KeyValueIterator<K, V> = Iterator<{key:K, value:V}>;
/**
A `KeyValueIterable` is a data structure which has a `keyValueIterator()`
method to iterate over key-value-pairs.
**/
typedef KeyValueIterable<K, V> = {
function keyValueIterator():KeyValueIterator<K, V>;
}
/**
`ArrayAccess` is used to indicate a class that can be accessed using brackets.
The type parameter represents the type of the elements stored.
This interface should be used for externs only. Haxe does not support custom
array access on classes. However, array access can be implemented for
abstract types.
@see https://haxe.org/manual/types-abstract-array-access.html
**/
extern interface ArrayAccess<T> {}

View File

@ -0,0 +1,175 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/**
The basic String class.
A Haxe String is immutable, it is not possible to modify individual
characters. No method of this class changes the state of `this` String.
Strings can be constructed using the String literal syntax `"string value"`.
String can be concatenated by using the `+` operator. If an operand is not a
String, it is passed through `Std.string()` first.
@see https://haxe.org/manual/std-String.html
**/
extern class String {
/**
The number of characters in `this` String.
**/
var length(default, null):Int;
/**
Creates a copy from a given String.
**/
function new(string:String):Void;
/**
Returns a String where all characters of `this` String are upper case.
**/
function toUpperCase():String;
/**
Returns a String where all characters of `this` String are lower case.
**/
function toLowerCase():String;
/**
Returns the character at position `index` of `this` String.
If `index` is negative or exceeds `this.length`, the empty String `""`
is returned.
**/
function charAt(index:Int):String;
/**
Returns the character code at position `index` of `this` String.
If `index` is negative or exceeds `this.length`, `null` is returned.
To obtain the character code of a single character, `"x".code` can be
used instead to inline the character code at compile time. Note that
this only works on String literals of length 1.
**/
function charCodeAt(index:Int):Null<Int>;
/**
Returns the position of the leftmost occurrence of `str` within `this`
String.
If `startIndex` is given, the search is performed within the substring
of `this` String starting from `startIndex`.
If `startIndex` exceeds `this.length`, -1 is returned.
If `startIndex` is negative, the result is unspecifed.
Otherwise the search is performed within `this` String. In either case,
the returned position is relative to the beginning of `this` String.
If `str` cannot be found, -1 is returned.
**/
function indexOf(str:String, ?startIndex:Int):Int;
/**
Returns the position of the rightmost occurrence of `str` within `this`
String.
If `startIndex` is given, the search is performed within the substring
of `this` String from 0 to `startIndex + str.length`. Otherwise the search
is performed within `this` String. In either case, the returned position
is relative to the beginning of `this` String.
If `startIndex` is negative, the result is unspecifed.
If `str` cannot be found, -1 is returned.
**/
function lastIndexOf(str:String, ?startIndex:Int):Int;
/**
Splits `this` String at each occurrence of `delimiter`.
If `this` String is the empty String `""`, the result is not consistent
across targets and may either be `[]` (on Js, Cpp) or `[""]`.
If `delimiter` is the empty String `""`, `this` String is split into an
Array of `this.length` elements, where the elements correspond to the
characters of `this` String.
If `delimiter` is not found within `this` String, the result is an Array
with one element, which equals `this` String.
If `delimiter` is null, the result is unspecified.
Otherwise, `this` String is split into parts at each occurrence of
`delimiter`. If `this` String starts (or ends) with `delimiter`, the
result `Array` contains a leading (or trailing) empty String `""` element.
Two subsequent delimiters also result in an empty String `""` element.
**/
function split(delimiter:String):Array<String>;
/**
Returns `len` characters of `this` String, starting at position `pos`.
If `len` is omitted, all characters from position `pos` to the end of
`this` String are included.
If `pos` is negative, its value is calculated from the end of `this`
String by `this.length + pos`. If this yields a negative value, 0 is
used instead.
If the calculated position + `len` exceeds `this.length`, the characters
from that position to the end of `this` String are returned.
If `len` is negative, the result is unspecified.
**/
function substr(pos:Int, ?len:Int):String;
/**
Returns the part of `this` String from `startIndex` to but not including `endIndex`.
If `startIndex` or `endIndex` are negative, 0 is used instead.
If `startIndex` exceeds `endIndex`, they are swapped.
If the (possibly swapped) `endIndex` is omitted or exceeds
`this.length`, `this.length` is used instead.
If the (possibly swapped) `startIndex` exceeds `this.length`, the empty
String `""` is returned.
**/
function substring(startIndex:Int, ?endIndex:Int):String;
/**
Returns the String itself.
**/
function toString():String;
/**
Returns the String corresponding to the character code `code`.
If `code` is negative or has another invalid value, the result is
unspecified.
**/
@:pure static function fromCharCode(code:Int):String;
}

View File

@ -0,0 +1,99 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/**
A String buffer is an efficient way to build a big string by appending small
elements together.
Unlike String, an instance of StringBuf is not immutable in the sense that
it can be passed as argument to functions which modify it by appending more
values.
**/
class StringBuf {
var b:String;
/**
The length of `this` StringBuf in characters.
**/
public var length(get, never):Int;
/**
Creates a new StringBuf instance.
This may involve initialization of the internal buffer.
**/
public inline function new() {
b = "";
}
inline function get_length():Int {
return b.length;
}
/**
Appends the representation of `x` to `this` StringBuf.
The exact representation of `x` may vary per platform. To get more
consistent behavior, this function should be called with
Std.string(x).
If `x` is null, the String "null" is appended.
**/
public inline function add<T>(x:T):Void {
b += x;
}
/**
Appends the character identified by `c` to `this` StringBuf.
If `c` is negative or has another invalid value, the result is
unspecified.
**/
public inline function addChar(c:Int):Void {
b += String.fromCharCode(c);
}
/**
Appends a substring of `s` to `this` StringBuf.
This function expects `pos` and `len` to describe a valid substring of
`s`, or else the result is unspecified. To get more robust behavior,
`this.add(s.substr(pos,len))` can be used instead.
If `s` or `pos` are null, the result is unspecified.
If `len` is omitted or null, the substring ranges from `pos` to the end
of `s`.
**/
public inline function addSub(s:String, pos:Int, ?len:Int):Void {
b += (len == null ? s.substr(pos) : s.substr(pos, len));
}
/**
Returns the content of `this` StringBuf as String.
The buffer is not emptied by this operation.
**/
public inline function toString():String {
return b;
}
}

View File

@ -0,0 +1,640 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
import haxe.iterators.StringIterator;
import haxe.iterators.StringKeyValueIterator;
#if cpp
using cpp.NativeString;
#end
/**
This class provides advanced methods on Strings. It is ideally used with
`using StringTools` and then acts as an [extension](https://haxe.org/manual/lf-static-extension.html)
to the `String` class.
If the first argument to any of the methods is null, the result is
unspecified.
**/
class StringTools {
/**
Encode an URL by using the standard format.
**/
#if (!java && !cpp && !lua && !eval) inline #end public static function urlEncode(s:String):String {
#if flash
return untyped __global__["encodeURIComponent"](s);
#elseif neko
return untyped new String(_urlEncode(s.__s));
#elseif js
return untyped encodeURIComponent(s);
#elseif cpp
return untyped s.__URLEncode();
#elseif java
return postProcessUrlEncode(java.net.URLEncoder.encode(s, "UTF-8"));
#elseif cs
return untyped cs.system.Uri.EscapeDataString(s);
#elseif python
return python.lib.urllib.Parse.quote(s, "");
#elseif hl
var len = 0;
var b = @:privateAccess s.bytes.urlEncode(len);
return @:privateAccess String.__alloc__(b, len);
#elseif lua
s = lua.NativeStringTools.gsub(s, "\n", "\r\n");
s = lua.NativeStringTools.gsub(s, "([^%w %-%_%.%~])", function(c) {
return lua.NativeStringTools.format("%%%02X", lua.NativeStringTools.byte(c) + '');
});
s = lua.NativeStringTools.gsub(s, " ", "+");
return s;
#else
return null;
#end
}
#if java
private static function postProcessUrlEncode(s:String):String {
var ret = new StringBuf();
var i = 0, len = s.length;
while (i < len) {
switch (_charAt(s, i++)) {
case '+'.code:
ret.add('%20');
case '%'.code if (i <= len - 2):
var c1 = _charAt(s, i++), c2 = _charAt(s, i++);
switch [c1, c2] {
case ['2'.code, '1'.code]:
ret.addChar('!'.code);
case ['2'.code, '7'.code]:
ret.addChar('\''.code);
case ['2'.code, '8'.code]:
ret.addChar('('.code);
case ['2'.code, '9'.code]:
ret.addChar(')'.code);
case ['7'.code, 'E'.code] | ['7'.code, 'e'.code]:
ret.addChar('~'.code);
case _:
ret.addChar('%'.code);
ret.addChar(cast c1);
ret.addChar(cast c2);
}
case var chr:
ret.addChar(cast chr);
}
}
return ret.toString();
}
#end
/**
Decode an URL using the standard format.
**/
#if (!java && !cpp && !lua && !eval) inline #end public static function urlDecode(s:String):String {
#if flash
return untyped __global__["decodeURIComponent"](s.split("+").join(" "));
#elseif neko
return untyped new String(_urlDecode(s.__s));
#elseif js
return untyped decodeURIComponent(s.split("+").join(" "));
#elseif cpp
return untyped s.__URLDecode();
#elseif java
try
return java.net.URLDecoder.decode(s, "UTF-8")
catch (e:Dynamic)
throw e;
#elseif cs
return untyped cs.system.Uri.UnescapeDataString(s);
#elseif python
return python.lib.urllib.Parse.unquote(s);
#elseif hl
var len = 0;
var b = @:privateAccess s.bytes.urlDecode(len);
return @:privateAccess String.__alloc__(b, len);
#elseif lua
s = lua.NativeStringTools.gsub(s, "+", " ");
s = lua.NativeStringTools.gsub(s, "%%(%x%x)", function(h) {
return lua.NativeStringTools.char(lua.Lua.tonumber(h, 16));
});
s = lua.NativeStringTools.gsub(s, "\r\n", "\n");
return s;
#else
return null;
#end
}
/**
Escapes HTML special characters of the string `s`.
The following replacements are made:
- `&` becomes `&amp`;
- `<` becomes `&lt`;
- `>` becomes `&gt`;
If `quotes` is true, the following characters are also replaced:
- `"` becomes `&quot`;
- `'` becomes `&#039`;
**/
public static function htmlEscape(s:String, ?quotes:Bool):String {
var buf = new StringBuf();
for (code in #if neko iterator(s) #else new haxe.iterators.StringIteratorUnicode(s) #end) {
switch (code) {
case '&'.code:
buf.add("&amp;");
case '<'.code:
buf.add("&lt;");
case '>'.code:
buf.add("&gt;");
case '"'.code if (quotes):
buf.add("&quot;");
case '\''.code if (quotes):
buf.add("&#039;");
case _:
buf.addChar(code);
}
}
return buf.toString();
}
/**
Unescapes HTML special characters of the string `s`.
This is the inverse operation to htmlEscape, i.e. the following always
holds: `htmlUnescape(htmlEscape(s)) == s`
The replacements follow:
- `&amp;` becomes `&`
- `&lt;` becomes `<`
- `&gt;` becomes `>`
- `&quot;` becomes `"`
- `&#039;` becomes `'`
**/
public static function htmlUnescape(s:String):String {
return s.split("&gt;")
.join(">")
.split("&lt;")
.join("<")
.split("&quot;")
.join('"')
.split("&#039;")
.join("'")
.split("&amp;")
.join("&");
}
/**
Returns `true` if `s` contains `value` and `false` otherwise.
When `value` is `null`, the result is unspecified.
**/
public static inline function contains(s:String, value:String):Bool {
#if (js && js_es >= 6)
return (cast s).includes(value);
#else
return s.indexOf(value) != -1;
#end
}
/**
Tells if the string `s` starts with the string `start`.
If `start` is `null`, the result is unspecified.
If `start` is the empty String `""`, the result is true.
**/
public static #if (cs || java || python || (js && js_es >= 6)) inline #end function startsWith(s:String, start:String):Bool {
#if java
return (cast s : java.NativeString).startsWith(start);
#elseif cs
return untyped s.StartsWith(start);
#elseif hl
return @:privateAccess (s.length >= start.length && s.bytes.compare(0, start.bytes, 0, start.length << 1) == 0);
#elseif python
return python.NativeStringTools.startswith(s, start);
#elseif (js && js_es >= 6)
return (cast s).startsWith(start);
#else
return (s.length >= start.length && s.lastIndexOf(start, 0) == 0);
#end
}
/**
Tells if the string `s` ends with the string `end`.
If `end` is `null`, the result is unspecified.
If `end` is the empty String `""`, the result is true.
**/
public static #if (cs || java || python || (js && js_es >= 6)) inline #end function endsWith(s:String, end:String):Bool {
#if java
return (cast s : java.NativeString).endsWith(end);
#elseif cs
return untyped s.EndsWith(end);
#elseif hl
var elen = end.length;
var slen = s.length;
return @:privateAccess (slen >= elen && s.bytes.compare((slen - elen) << 1, end.bytes, 0, elen << 1) == 0);
#elseif python
return python.NativeStringTools.endswith(s, end);
#elseif (js && js_es >= 6)
return (cast s).endsWith(end);
#else
var elen = end.length;
var slen = s.length;
return (slen >= elen && s.indexOf(end, (slen - elen)) == (slen - elen));
#end
}
/**
Tells if the character in the string `s` at position `pos` is a space.
A character is considered to be a space character if its character code
is 9,10,11,12,13 or 32.
If `s` is the empty String `""`, or if pos is not a valid position within
`s`, the result is false.
**/
public static function isSpace(s:String, pos:Int):Bool {
#if (python || lua)
if (s.length == 0 || pos < 0 || pos >= s.length)
return false;
#end
var c = s.charCodeAt(pos);
return (c > 8 && c < 14) || c == 32;
}
/**
Removes leading space characters of `s`.
This function internally calls `isSpace()` to decide which characters to
remove.
If `s` is the empty String `""` or consists only of space characters, the
result is the empty String `""`.
**/
public #if cs inline #end static function ltrim(s:String):String {
#if cs
return untyped s.TrimStart();
#else
var l = s.length;
var r = 0;
while (r < l && isSpace(s, r)) {
r++;
}
if (r > 0)
return s.substr(r, l - r);
else
return s;
#end
}
/**
Removes trailing space characters of `s`.
This function internally calls `isSpace()` to decide which characters to
remove.
If `s` is the empty String `""` or consists only of space characters, the
result is the empty String `""`.
**/
public #if cs inline #end static function rtrim(s:String):String {
#if cs
return untyped s.TrimEnd();
#else
var l = s.length;
var r = 0;
while (r < l && isSpace(s, l - r - 1)) {
r++;
}
if (r > 0) {
return s.substr(0, l - r);
} else {
return s;
}
#end
}
/**
Removes leading and trailing space characters of `s`.
This is a convenience function for `ltrim(rtrim(s))`.
**/
public #if (cs || java) inline #end static function trim(s:String):String {
#if cs
return untyped s.Trim();
#elseif java
return (cast s : java.NativeString).trim();
#else
return ltrim(rtrim(s));
#end
}
/**
Concatenates `c` to `s` until `s.length` is at least `l`.
If `c` is the empty String `""` or if `l` does not exceed `s.length`,
`s` is returned unchanged.
If `c.length` is 1, the resulting String length is exactly `l`.
Otherwise the length may exceed `l`.
If `c` is null, the result is unspecified.
**/
public static function lpad(s:String, c:String, l:Int):String {
if (c.length <= 0)
return s;
var buf = new StringBuf();
l -= s.length;
while (buf.length < l) {
buf.add(c);
}
buf.add(s);
return buf.toString();
}
/**
Appends `c` to `s` until `s.length` is at least `l`.
If `c` is the empty String `""` or if `l` does not exceed `s.length`,
`s` is returned unchanged.
If `c.length` is 1, the resulting String length is exactly `l`.
Otherwise the length may exceed `l`.
If `c` is null, the result is unspecified.
**/
public static function rpad(s:String, c:String, l:Int):String {
if (c.length <= 0)
return s;
var buf = new StringBuf();
buf.add(s);
while (buf.length < l) {
buf.add(c);
}
return buf.toString();
}
/**
Replace all occurrences of the String `sub` in the String `s` by the
String `by`.
If `sub` is the empty String `""`, `by` is inserted after each character
of `s` except the last one. If `by` is also the empty String `""`, `s`
remains unchanged.
If `sub` or `by` are null, the result is unspecified.
**/
public static function replace(s:String, sub:String, by:String):String {
#if java
if (sub.length == 0)
return s.split(sub).join(by);
else
return (cast s : java.NativeString).replace(sub, by);
#elseif cs
if (sub.length == 0)
return s.split(sub).join(by);
else
return untyped s.Replace(sub, by);
#else
return s.split(sub).join(by);
#end
}
/**
Encodes `n` into a hexadecimal representation.
If `digits` is specified, the resulting String is padded with "0" until
its `length` equals `digits`.
**/
public static function hex(n:Int, ?digits:Int) {
#if flash
var n:UInt = n;
var s:String = untyped n.toString(16);
s = s.toUpperCase();
#else
var s = "";
var hexChars = "0123456789ABCDEF";
do {
s = hexChars.charAt(n & 15) + s;
n >>>= 4;
} while (n > 0);
#end
#if python
if (digits != null && s.length < digits) {
var diff = digits - s.length;
for (_ in 0...diff) {
s = "0" + s;
}
}
#else
if (digits != null)
while (s.length < digits)
s = "0" + s;
#end
return s;
}
/**
Returns the character code at position `index` of String `s`, or an
end-of-file indicator at if `position` equals `s.length`.
This method is faster than `String.charCodeAt()` on some platforms, but
the result is unspecified if `index` is negative or greater than
`s.length`.
End of file status can be checked by calling `StringTools.isEof()` with
the returned value as argument.
This operation is not guaranteed to work if `s` contains the `\0`
character.
**/
public static #if !eval inline #end function fastCodeAt(s:String, index:Int):Int {
#if neko
return untyped __dollar__sget(s.__s, index);
#elseif cpp
return untyped s.cca(index);
#elseif flash
return untyped s.cca(index);
#elseif java
return (index < s.length) ? cast(_charAt(s, index), Int) : -1;
#elseif cs
return (cast(index, UInt) < s.length) ? cast(s[index], Int) : -1;
#elseif js
return (cast s).charCodeAt(index);
#elseif python
return if (index >= s.length) -1 else python.internal.UBuiltins.ord(python.Syntax.arrayAccess(s, index));
#elseif hl
return @:privateAccess s.bytes.getUI16(index << 1);
#elseif lua
#if lua_vanilla
return lua.NativeStringTools.byte(s, index + 1);
#else
return lua.lib.luautf8.Utf8.byte(s, index + 1);
#end
#else
return untyped s.cca(index);
#end
}
/**
Returns the character code at position `index` of String `s`, or an
end-of-file indicator at if `position` equals `s.length`.
This method is faster than `String.charCodeAt()` on some platforms, but
the result is unspecified if `index` is negative or greater than
`s.length`.
This operation is not guaranteed to work if `s` contains the `\0`
character.
**/
public static #if !eval inline #end function unsafeCodeAt(s:String, index:Int):Int {
#if neko
return untyped __dollar__sget(s.__s, index);
#elseif cpp
return untyped s.cca(index);
#elseif flash
return untyped s.cca(index);
#elseif java
return cast(_charAt(s, index), Int);
#elseif cs
return cast(s[index], Int);
#elseif js
return (cast s).charCodeAt(index);
#elseif python
return python.internal.UBuiltins.ord(python.Syntax.arrayAccess(s, index));
#elseif hl
return @:privateAccess s.bytes.getUI16(index << 1);
#elseif lua
#if lua_vanilla
return lua.NativeStringTools.byte(s, index + 1);
#else
return lua.lib.luautf8.Utf8.byte(s, index + 1);
#end
#else
return untyped s.cca(index);
#end
}
/**
Returns an iterator of the char codes.
Note that char codes may differ across platforms because of different
internal encoding of strings in different runtimes.
For the consistent cross-platform UTF8 char codes see `haxe.iterators.StringIteratorUnicode`.
**/
public static inline function iterator(s:String):StringIterator {
return new StringIterator(s);
}
/**
Returns an iterator of the char indexes and codes.
Note that char codes may differ across platforms because of different
internal encoding of strings in different of runtimes.
For the consistent cross-platform UTF8 char codes see `haxe.iterators.StringKeyValueIteratorUnicode`.
**/
public static inline function keyValueIterator(s:String):StringKeyValueIterator {
return new StringKeyValueIterator(s);
}
/**
Tells if `c` represents the end-of-file (EOF) character.
**/
@:noUsing public static inline function isEof(c:Int):Bool {
#if (flash || cpp || hl)
return c == 0;
#elseif js
return c != c; // fast NaN
#elseif (neko || lua || eval)
return c == null;
#elseif (cs || java || python)
return c == -1;
#else
return false;
#end
}
/**
Returns a String that can be used as a single command line argument
on Unix.
The input will be quoted, or escaped if necessary.
**/
@:noCompletion
@:deprecated('StringTools.quoteUnixArg() is deprecated. Use haxe.SysTools.quoteUnixArg() instead.')
public static function quoteUnixArg(argument:String):String {
return inline haxe.SysTools.quoteUnixArg(argument);
}
/**
Character codes of the characters that will be escaped by `quoteWinArg(_, true)`.
**/
@:noCompletion
@:deprecated('StringTools.winMetaCharacters is deprecated. Use haxe.SysTools.winMetaCharacters instead.')
public static var winMetaCharacters:Array<Int> = cast haxe.SysTools.winMetaCharacters;
/**
Returns a String that can be used as a single command line argument
on Windows.
The input will be quoted, or escaped if necessary, such that the output
will be parsed as a single argument using the rule specified in
http://msdn.microsoft.com/en-us/library/ms880421
Examples:
```haxe
quoteWinArg("abc") == "abc";
quoteWinArg("ab c") == '"ab c"';
```
**/
@:noCompletion
@:deprecated('StringTools.quoteWinArg() is deprecated. Use haxe.SysTools.quoteWinArg() instead.')
public static function quoteWinArg(argument:String, escapeMetaCharacters:Bool):String {
return inline haxe.SysTools.quoteWinArg(argument, escapeMetaCharacters);
}
#if java
private static inline function _charAt(str:String, idx:Int):java.StdTypes.Char16
return (cast str : java.NativeString).charAt(idx);
#end
#if neko
private static var _urlEncode = neko.Lib.load("std", "url_encode", 1);
private static var _urlDecode = neko.Lib.load("std", "url_decode", 1);
#end
#if utf16
static inline var MIN_SURROGATE_CODE_POINT = 65536;
static inline function utf16CodePointAt(s:String, index:Int):Int {
var c = StringTools.fastCodeAt(s, index);
if (c >= 0xD800 && c <= 0xDBFF) {
c = ((c - 0xD7C0) << 10) | (StringTools.fastCodeAt(s, index + 1) & 0x3FF);
}
return c;
}
#end
}

171
Kha/Tools/macos/std/Sys.hx Normal file
View File

@ -0,0 +1,171 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/**
This class provides access to various base functions of system platforms.
Look in the `sys` package for more system APIs.
**/
@:require(sys)
extern class Sys {
/**
Prints any value to the standard output.
**/
static function print(v:Dynamic):Void;
/**
Prints any value to the standard output, followed by a newline.
On Windows, this function outputs a CRLF newline.
LF newlines are printed on all other platforms.
**/
static function println(v:Dynamic):Void;
/**
Returns all the arguments that were passed in the command line.
This does not include the interpreter or the name of the program file.
(java)(eval) On Windows, non-ASCII Unicode arguments will not work correctly.
(cs) Non-ASCII Unicode arguments will not work correctly.
**/
static function args():Array<String>;
/**
Returns the value of the given environment variable, or `null` if it
doesn't exist.
**/
static function getEnv(s:String):String;
/**
Sets the value of the given environment variable.
(java) This functionality is not available on Java; calling this function will throw.
**/
static function putEnv(s:String, v:String):Void;
/**
Returns all environment variables.
**/
static function environment():Map<String, String>;
/**
Suspends execution for the given length of time (in seconds).
**/
static function sleep(seconds:Float):Void;
/**
Changes the current time locale, which will affect `DateTools.format` date formating.
Returns `true` if the locale was successfully changed.
**/
static function setTimeLocale(loc:String):Bool;
/**
Gets the current working directory (usually the one in which the program was started).
**/
static function getCwd():String;
/**
Changes the current working directory.
(java) This functionality is not available on Java; calling this function will throw.
**/
static function setCwd(s:String):Void;
/**
Returns the type of the current system. Possible values are:
- `"Windows"`
- `"Linux"`
- `"BSD"`
- `"Mac"`
**/
static function systemName():String;
/**
Runs the given command. The command output will be printed to the same output as the current process.
The current process will block until the command terminates.
The return value is the exit code of the command (usually `0` indicates no error).
Command arguments can be passed in two ways:
1. Using `args` to pass command arguments. Each argument will be automatically quoted and shell meta-characters will be escaped if needed.
`cmd` should be an executable name that can be located in the `PATH` environment variable, or a full path to an executable.
2. When `args` is not given or is `null`, command arguments can be appended to `cmd`. No automatic quoting/escaping will be performed. `cmd` should be formatted exactly as it would be when typed at the command line.
It can run executables, as well as shell commands that are not executables (e.g. on Windows: `dir`, `cd`, `echo` etc).
Use the `sys.io.Process` API for more complex tasks, such as background processes, or providing input to the command.
**/
static function command(cmd:String, ?args:Array<String>):Int;
/**
Exits the current process with the given exit code.
(macro)(eval) Being invoked in a macro or eval context (e.g. with `-x` or `--run`) immediately terminates
the compilation process, which also prevents the execution of any `--next` sections of compilation arguments.
**/
static function exit(code:Int):Void;
/**
Gives the most precise timestamp value available (in seconds).
**/
static function time():Float;
/**
Gives the most precise timestamp value available (in seconds),
but only accounts for the actual time spent running on the CPU for the current thread/process.
**/
static function cpuTime():Float;
/**
Returns the path to the current executable that we are running.
**/
@:deprecated("Use programPath instead") static function executablePath():String;
/**
Returns the absolute path to the current program file that we are running.
Concretely, for an executable binary, it returns the path to the binary.
For a script (e.g. a PHP file), it returns the path to the script.
**/
static function programPath():String;
/**
Reads a single input character from the standard input and returns it.
Setting `echo` to `true` will also display the character on the output.
**/
static function getChar(echo:Bool):Int;
/**
Returns the standard input of the process, from which user input can be read.
Usually it will block until the user sends a full input line.
See `getChar` for an alternative.
**/
static function stdin():haxe.io.Input;
/**
Returns the standard output of the process, to which program output can be written.
**/
static function stdout():haxe.io.Output;
/**
Returns the standard error of the process, to which program errors can be written.
**/
static function stderr():haxe.io.Output;
}

295
Kha/Tools/macos/std/Type.hx Normal file
View File

@ -0,0 +1,295 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/**
The Haxe Reflection API allows retrieval of type information at runtime.
This class complements the more lightweight Reflect class, with a focus on
class and enum instances.
@see https://haxe.org/manual/types.html
@see https://haxe.org/manual/std-reflection.html
**/
extern class Type {
/**
Returns the class of `o`, if `o` is a class instance.
If `o` is null or of a different type, null is returned.
In general, type parameter information cannot be obtained at runtime.
**/
static function getClass<T>(o:T):Class<T>;
/**
Returns the enum of enum instance `o`.
An enum instance is the result of using an enum constructor. Given an
`enum Color { Red; }`, `getEnum(Red)` returns `Enum<Color>`.
If `o` is null, null is returned.
In general, type parameter information cannot be obtained at runtime.
**/
static function getEnum(o:EnumValue):Enum<Dynamic>;
/**
Returns the super-class of class `c`.
If `c` has no super class, null is returned.
If `c` is null, the result is unspecified.
In general, type parameter information cannot be obtained at runtime.
**/
static function getSuperClass(c:Class<Dynamic>):Class<Dynamic>;
/**
Returns the name of class `c`, including its path.
If `c` is inside a package, the package structure is returned dot-
separated, with another dot separating the class name:
`pack1.pack2.(...).packN.ClassName`
If `c` is a sub-type of a Haxe module, that module is not part of the
package structure.
If `c` has no package, the class name is returned.
If `c` is null, the result is unspecified.
The class name does not include any type parameters.
**/
static function getClassName(c:Class<Dynamic>):String;
/**
Returns the name of enum `e`, including its path.
If `e` is inside a package, the package structure is returned dot-
separated, with another dot separating the enum name:
`pack1.pack2.(...).packN.EnumName`
If `e` is a sub-type of a Haxe module, that module is not part of the
package structure.
If `e` has no package, the enum name is returned.
If `e` is null, the result is unspecified.
The enum name does not include any type parameters.
**/
static function getEnumName(e:Enum<Dynamic>):String;
/**
Resolves a class by name.
If `name` is the path of an existing class, that class is returned.
Otherwise null is returned.
If `name` is null or the path to a different type, the result is
unspecified.
The class name must not include any type parameters.
**/
static function resolveClass(name:String):Class<Dynamic>;
/**
Resolves an enum by name.
If `name` is the path of an existing enum, that enum is returned.
Otherwise null is returned.
If `name` is null the result is unspecified.
If `name` is the path to a different type, null is returned.
The enum name must not include any type parameters.
**/
static function resolveEnum(name:String):Enum<Dynamic>;
/**
Creates an instance of class `cl`, using `args` as arguments to the
class constructor.
This function guarantees that the class constructor is called.
Default values of constructors arguments are not guaranteed to be
taken into account.
If `cl` or `args` are null, or if the number of elements in `args` does
not match the expected number of constructor arguments, or if any
argument has an invalid type, or if `cl` has no own constructor, the
result is unspecified.
In particular, default values of constructor arguments are not
guaranteed to be taken into account.
**/
static function createInstance<T>(cl:Class<T>, args:Array<Dynamic>):T;
/**
Creates an instance of class `cl`.
This function guarantees that the class constructor is not called.
If `cl` is null, the result is unspecified.
**/
static function createEmptyInstance<T>(cl:Class<T>):T;
/**
Creates an instance of enum `e` by calling its constructor `constr` with
arguments `params`.
If `e` or `constr` is null, or if enum `e` has no constructor named
`constr`, or if the number of elements in `params` does not match the
expected number of constructor arguments, or if any argument has an
invalid type, the result is unspecified.
**/
static function createEnum<T>(e:Enum<T>, constr:String, ?params:Array<Dynamic>):T;
/**
Creates an instance of enum `e` by calling its constructor number
`index` with arguments `params`.
The constructor indices are preserved from Haxe syntax, so the first
declared is index 0, the next index 1 etc.
If `e` or `constr` is null, or if enum `e` has no constructor named
`constr`, or if the number of elements in `params` does not match the
expected number of constructor arguments, or if any argument has an
invalid type, the result is unspecified.
**/
static function createEnumIndex<T>(e:Enum<T>, index:Int, ?params:Array<Dynamic>):T;
/**
Returns a list of the instance fields of class `c`, including
inherited fields.
This only includes fields which are known at compile-time. In
particular, using `getInstanceFields(getClass(obj))` will not include
any fields which were added to `obj` at runtime.
The order of the fields in the returned Array is unspecified.
If `c` is null, the result is unspecified.
**/
static function getInstanceFields(c:Class<Dynamic>):Array<String>;
/**
Returns a list of static fields of class `c`.
This does not include static fields of parent classes.
The order of the fields in the returned Array is unspecified.
If `c` is null, the result is unspecified.
**/
static function getClassFields(c:Class<Dynamic>):Array<String>;
/**
Returns a list of the names of all constructors of enum `e`.
The order of the constructor names in the returned Array is preserved
from the original syntax.
If `e` is null, the result is unspecified.
**/
static function getEnumConstructs(e:Enum<Dynamic>):Array<String>;
/**
Returns the runtime type of value `v`.
The result corresponds to the type `v` has at runtime, which may vary
per platform. Assumptions regarding this should be minimized to avoid
surprises.
**/
static function typeof(v:Dynamic):ValueType;
/**
Recursively compares two enum instances `a` and `b` by value.
Unlike `a == b`, this function performs a deep equality check on the
arguments of the constructors, if exists.
If `a` or `b` are null, the result is unspecified.
**/
static function enumEq<T:EnumValue>(a:T, b:T):Bool;
/**
Returns the constructor name of enum instance `e`.
The result String does not contain any constructor arguments.
If `e` is null, the result is unspecified.
**/
static function enumConstructor(e:EnumValue):String;
/**
Returns a list of the constructor arguments of enum instance `e`.
If `e` has no arguments, the result is [].
Otherwise the result are the values that were used as arguments to `e`,
in the order of their declaration.
If `e` is null, the result is unspecified.
**/
static function enumParameters(e:EnumValue):Array<Dynamic>;
/**
Returns the index of enum instance `e`.
This corresponds to the original syntactic position of `e`. The index of
the first declared constructor is 0, the next one is 1 etc.
If `e` is null, the result is unspecified.
**/
static function enumIndex(e:EnumValue):Int;
/**
Returns a list of all constructors of enum `e` that require no
arguments.
This may return the empty Array `[]` if all constructors of `e` require
arguments.
Otherwise an instance of `e` constructed through each of its non-
argument constructors is returned, in the order of the constructor
declaration.
If `e` is null, the result is unspecified.
**/
static function allEnums<T>(e:Enum<T>):Array<T>;
}
/**
The different possible runtime types of a value.
**/
enum ValueType {
TNull;
TInt;
TFloat;
TBool;
TObject;
TFunction;
TClass(c:Class<Dynamic>);
TEnum(e:Enum<Dynamic>);
TUnknown;
}

321
Kha/Tools/macos/std/UInt.hx Normal file
View File

@ -0,0 +1,321 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#if ((flash || flash9doc || cs || hl) && !doc_gen)
/**
The unsigned `Int` type is only defined for Flash and C#. It's currently
handled the same as a normal Int.
@see https://haxe.org/manual/types-basic-types.html
**/
@:coreType
@:notNull
@:runtimeValue
@:analyzer(no_const_propagation)
abstract UInt to Int from Int {
@:commutative @:op(A + B) private static function addI(lhs:UInt, rhs:Int):UInt;
@:commutative @:op(A + B) private static function addF(lhs:UInt, rhs:Float):Float;
@:op(A + B) private static function add(lhs:UInt, rhs:UInt):UInt;
@:commutative @:op(A * B) private static function mulI(lhs:UInt, rhs:Int):UInt;
@:commutative @:op(A * B) private static function mulF(lhs:UInt, rhs:Float):Float;
@:op(A * B) private static function mul(lhs:UInt, rhs:UInt):UInt;
@:op(A % B) private static function modI(lhs:UInt, rhs:Int):UInt;
@:op(A % B) private static function modF(lhs:UInt, rhs:Float):Float;
@:op(A % B) private static function mod(lhs:UInt, rhs:UInt):UInt;
@:op(A - B) private static function subI(lhs:UInt, rhs:Int):UInt;
@:op(A - B) private static function subF(lhs:UInt, rhs:Float):Float;
@:op(A - B) private static function sub(lhs:UInt, rhs:UInt):UInt;
@:op(A / B) private static function divI(lhs:UInt, rhs:Int):Float;
@:op(A / B) private static function divF(lhs:UInt, rhs:Float):Float;
@:op(A / B) private static function div(lhs:UInt, rhs:UInt):Float;
@:commutative @:op(A | B) private static function orI(lhs:UInt, rhs:Int):UInt;
@:op(A | B) private static function or(lhs:UInt, rhs:UInt):UInt;
@:commutative @:op(A ^ B) private static function xorI(lhs:UInt, rhs:Int):UInt;
@:op(A ^ B) private static function xor(lhs:UInt, rhs:UInt):UInt;
@:commutative @:op(A & B) private static function andI(lhs:UInt, rhs:Int):UInt;
@:op(A & B) private static function and(lhs:UInt, rhs:UInt):UInt;
@:op(A << B) private static function shl(lhs:UInt, rhs:Int):UInt;
@:op(A >> B) private static inline function shr(lhs:UInt, rhs:Int):UInt
return lhs >>> rhs;
@:op(A >>> B) private static function ushr(lhs:UInt, rhs:Int):UInt;
@:op(A > B) private static function gt(lhs:UInt, rhs:UInt):Bool;
@:op(A >= B) private static function gte(lhs:UInt, rhs:UInt):Bool;
@:op(A < B) private static function lt(lhs:UInt, rhs:UInt):Bool;
@:op(A <= B) private static function lte(lhs:UInt, rhs:UInt):Bool;
@:op(A > B) private static function gtf(lhs:UInt, rhs:Float):Bool;
@:op(A > B) private static function gtf2(lhs:Float, rhs:UInt):Bool;
@:op(A >= B) private static function gtef(lhs:UInt, rhs:Float):Bool;
@:op(A >= B) private static function gtef2(lhs:Float, rhs:UInt):Bool;
@:op(A < B) private static function ltf(lhs:UInt, rhs:Float):Bool;
@:op(A < B) private static function ltf2(lhs:Float, rhs:UInt):Bool;
@:op(A <= B) private static function ltef(lhs:UInt, rhs:Float):Bool;
@:op(A <= B) private static function ltef2(lhs:Float, rhs:UInt):Bool;
@:op(~A) private static function bneg(t:UInt):UInt;
@:commutative @:op(A == B) private static function equalsInt<T:Int>(a:UInt, b:T):Bool;
@:commutative @:op(A != B) private static function notEqualsInt<T:Int>(a:UInt, b:T):Bool;
@:commutative @:op(A == B) private static function equalsFloat<T:Float>(a:UInt, b:T):Bool;
@:commutative @:op(A != B) private static function notEqualsFloat<T:Float>(a:UInt, b:T):Bool;
@:op(++A) private function prefixIncrement():UInt;
@:op(A++) private function postfixIncrement():UInt;
@:op(--A) private function prefixDecrement():UInt;
@:op(A--) private function postfixDecrement():UInt;
}
#else
/**
The unsigned `Int` type is only defined for Flash and C#.
Simulate it for other platforms.
@see https://haxe.org/manual/types-basic-types.html
**/
@:transitive
abstract UInt(Int) from Int to Int {
@:op(A + B) private static inline function add(a:UInt, b:UInt):UInt {
return a.toInt() + b.toInt();
}
@:op(A / B) private static inline function div(a:UInt, b:UInt):Float {
return a.toFloat() / b.toFloat();
}
@:op(A * B) private static inline function mul(a:UInt, b:UInt):UInt {
return a.toInt() * b.toInt();
}
@:op(A - B) private static inline function sub(a:UInt, b:UInt):UInt {
return a.toInt() - b.toInt();
}
@:op(A > B)
private static #if !js inline #end function gt(a:UInt, b:UInt):Bool {
var aNeg = a.toInt() < 0;
var bNeg = b.toInt() < 0;
return if (aNeg != bNeg) aNeg; else a.toInt() > b.toInt();
}
@:op(A >= B)
private static #if !js inline #end function gte(a:UInt, b:UInt):Bool {
var aNeg = a.toInt() < 0;
var bNeg = b.toInt() < 0;
return if (aNeg != bNeg) aNeg; else a.toInt() >= b.toInt();
}
@:op(A < B) private static inline function lt(a:UInt, b:UInt):Bool {
return gt(b, a);
}
@:op(A <= B) private static inline function lte(a:UInt, b:UInt):Bool {
return gte(b, a);
}
@:op(A & B) private static inline function and(a:UInt, b:UInt):UInt {
return a.toInt() & b.toInt();
}
@:op(A | B) private static inline function or(a:UInt, b:UInt):UInt {
return a.toInt() | b.toInt();
}
@:op(A ^ B) private static inline function xor(a:UInt, b:UInt):UInt {
return a.toInt() ^ b.toInt();
}
@:op(A << B) private static inline function shl(a:UInt, b:Int):UInt {
return a.toInt() << b;
}
@:op(A >> B) private static inline function shr(a:UInt, b:Int):UInt {
return a.toInt() >>> b;
}
@:op(A >>> B) private static inline function ushr(a:UInt, b:Int):UInt {
return a.toInt() >>> b;
}
@:op(A % B) private static inline function mod(a:UInt, b:UInt):UInt {
return Std.int(a.toFloat() % b.toFloat());
}
@:commutative @:op(A + B) private static inline function addWithFloat(a:UInt, b:Float):Float {
return a.toFloat() + b;
}
@:commutative @:op(A * B) private static inline function mulWithFloat(a:UInt, b:Float):Float {
return a.toFloat() * b;
}
@:op(A / B) private static inline function divFloat(a:UInt, b:Float):Float {
return a.toFloat() / b;
}
@:op(A / B) private static inline function floatDiv(a:Float, b:UInt):Float {
return a / b.toFloat();
}
@:op(A - B) private static inline function subFloat(a:UInt, b:Float):Float {
return a.toFloat() - b;
}
@:op(A - B) private static inline function floatSub(a:Float, b:UInt):Float {
return a - b.toFloat();
}
@:op(A > B) private static inline function gtFloat(a:UInt, b:Float):Bool {
return a.toFloat() > b;
}
@:commutative @:op(A == B) private static inline function equalsInt<T:Int>(a:UInt, b:T):Bool {
return a.toInt() == b;
}
@:commutative @:op(A != B) private static inline function notEqualsInt<T:Int>(a:UInt, b:T):Bool {
return a.toInt() != b;
}
@:commutative @:op(A == B) private static inline function equalsFloat<T:Float>(a:UInt, b:T):Bool {
return a.toFloat() == b;
}
@:commutative @:op(A != B) private static inline function notEqualsFloat<T:Float>(a:UInt, b:T):Bool {
return a.toFloat() != b;
}
@:op(A >= B) private static inline function gteFloat(a:UInt, b:Float):Bool {
return a.toFloat() >= b;
}
@:op(A > B) private static inline function floatGt(a:Float, b:UInt):Bool {
return a > b.toFloat();
}
@:op(A >= B) private static inline function floatGte(a:Float, b:UInt):Bool {
return a >= b.toFloat();
}
@:op(A < B) private static inline function ltFloat(a:UInt, b:Float):Bool {
return a.toFloat() < b;
}
@:op(A <= B) private static inline function lteFloat(a:UInt, b:Float):Bool {
return a.toFloat() <= b;
}
@:op(A < B) private static inline function floatLt(a:Float, b:UInt):Bool {
return a < b.toFloat();
}
@:op(A <= B) private static inline function floatLte(a:Float, b:UInt):Bool {
return a <= b.toFloat();
}
@:op(A % B) private static inline function modFloat(a:UInt, b:Float):Float {
return a.toFloat() % b;
}
@:op(A % B) private static inline function floatMod(a:Float, b:UInt):Float {
return a % b.toFloat();
}
@:op(~A) private inline function negBits():UInt {
return ~this;
}
@:op(++A) private inline function prefixIncrement():UInt {
return ++this;
}
@:op(A++) private inline function postfixIncrement():UInt {
return this++;
}
@:op(--A) private inline function prefixDecrement():UInt {
return --this;
}
@:op(A--) private inline function postfixDecrement():UInt {
return this--;
}
// TODO: radix is just defined to deal with doc_gen issues
private inline function toString(?radix:Int):String {
return Std.string(toFloat());
}
private inline function toInt():Int {
return this;
}
@:to private #if (!js || analyzer) inline #end function toFloat():Float {
var int = toInt();
if (int < 0) {
return 4294967296.0 + int;
} else {
// + 0.0 here to make sure we promote to Float on some platforms
// In particular, PHP was having issues when comparing to Int in the == op.
return int + 0.0;
}
}
}
#end

View File

@ -0,0 +1,443 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
import haxe.io.Bytes;
import haxe.io.Encoding;
import haxe.iterators.StringIteratorUnicode;
import haxe.iterators.StringKeyValueIteratorUnicode;
/**
This abstract provides consistent cross-target unicode support.
@see https://haxe.org/manual/std-UnicodeString.html
**/
@:forward
@:access(StringTools)
abstract UnicodeString(String) from String to String {
/**
Tells if `b` is a correctly encoded UTF8 byte sequence.
**/
static public function validate(b:Bytes, encoding:Encoding):Bool {
switch (encoding) {
case RawNative:
throw "UnicodeString.validate: RawNative encoding is not supported";
case UTF8:
var data = b.getData();
var pos = 0;
var max = b.length;
while (pos < max) {
var c:Int = Bytes.fastGet(data, pos++);
if (c < 0x80) {} else if (c < 0xC2) {
return false;
} else if (c < 0xE0) {
if (pos + 1 > max) {
return false;
}
var c2:Int = Bytes.fastGet(data, pos++);
if (c2 < 0x80 || c2 > 0xBF) {
return false;
}
} else if (c < 0xF0) {
if (pos + 2 > max) {
return false;
}
var c2:Int = Bytes.fastGet(data, pos++);
if (c == 0xE0) {
if (c2 < 0xA0 || c2 > 0xBF)
return false;
} else {
if (c2 < 0x80 || c2 > 0xBF)
return false;
}
var c3:Int = Bytes.fastGet(data, pos++);
if (c3 < 0x80 || c3 > 0xBF) {
return false;
}
c = (c << 16) | (c2 << 8) | c3;
if (0xEDA080 <= c && c <= 0xEDBFBF) { // surrogate pairs
return false;
}
} else if (c > 0xF4) {
return false;
} else {
if (pos + 3 > max) {
return false;
}
var c2:Int = Bytes.fastGet(data, pos++);
if (c == 0xF0) {
if (c2 < 0x90 || c2 > 0xBF)
return false;
} else if (c == 0xF4) {
if (c2 < 0x80 || c2 > 0x8F)
return false;
} else {
if (c2 < 0x80 || c2 > 0xBF)
return false;
}
var c3:Int = Bytes.fastGet(data, pos++);
if (c3 < 0x80 || c3 > 0xBF) {
return false;
}
var c4:Int = Bytes.fastGet(data, pos++);
if (c4 < 0x80 || c4 > 0xBF) {
return false;
}
}
}
return true;
}
}
#if target.unicode
/**
Creates an instance of UnicodeString.
**/
public inline function new(string:String):Void {
this = string;
}
/**
Returns an iterator of the unicode code points.
**/
public inline function iterator():StringIteratorUnicode {
return new StringIteratorUnicode(this);
}
/**
Returns an iterator of the code point indices and unicode code points.
**/
public inline function keyValueIterator():StringKeyValueIteratorUnicode {
return new StringKeyValueIteratorUnicode(this);
}
#if target.utf16
/**
The number of characters in `this` String.
**/
public var length(get, never):Int;
/**
Returns the character at position `index` of `this` String.
If `index` is negative or exceeds `this.length`, the empty String `""`
is returned.
**/
public function charAt(index:Int):String {
if (index < 0)
return '';
var unicodeOffset = 0;
var nativeOffset = 0;
while (nativeOffset < this.length) {
var c = StringTools.utf16CodePointAt(this, nativeOffset++);
if (unicodeOffset == index) {
return String.fromCharCode(c);
}
if (c >= StringTools.MIN_SURROGATE_CODE_POINT) {
nativeOffset++;
}
unicodeOffset++;
}
return '';
}
/**
Returns the character code at position `index` of `this` String.
If `index` is negative or exceeds `this.length`, `null` is returned.
**/
public function charCodeAt(index:Int):Null<Int> {
if (index < 0)
return null;
var unicodeOffset = 0;
var nativeOffset = 0;
while (nativeOffset < this.length) {
var c = StringTools.utf16CodePointAt(this, nativeOffset++);
if (unicodeOffset == index) {
return c;
}
if (c >= StringTools.MIN_SURROGATE_CODE_POINT) {
nativeOffset++;
}
unicodeOffset++;
}
return null;
}
/**
Returns the position of the leftmost occurrence of `str` within `this`
String.
If `startIndex` is given, the search is performed within the substring
of `this` String starting from `startIndex` (if `startIndex` is posivite
or 0) or `max(this.length + startIndex, 0)` (if `startIndex` is negative).
If `startIndex` exceeds `this.length`, -1 is returned.
Otherwise the search is performed within `this` String. In either case,
the returned position is relative to the beginning of `this` String.
If `str` cannot be found, -1 is returned.
**/
public function indexOf(str:String, ?startIndex:Int):Int {
if (startIndex == null) {
startIndex = 0;
} else {
if (startIndex < 0) {
startIndex = (this : UnicodeString).length + startIndex;
}
}
var unicodeOffset = 0;
var nativeOffset = 0;
var matchingOffset = 0;
var result = -1;
while (nativeOffset <= this.length) {
var c = StringTools.utf16CodePointAt(this, nativeOffset);
if (unicodeOffset >= startIndex) {
var c2 = StringTools.utf16CodePointAt(str, matchingOffset);
if (c == c2) {
if (matchingOffset == 0) {
result = unicodeOffset;
}
matchingOffset++;
if (c2 >= StringTools.MIN_SURROGATE_CODE_POINT) {
matchingOffset++;
}
if (matchingOffset == str.length) {
return result;
}
} else if (matchingOffset != 0) {
result = -1;
matchingOffset = 0;
continue;
}
}
nativeOffset++;
if (c >= StringTools.MIN_SURROGATE_CODE_POINT) {
nativeOffset++;
}
unicodeOffset++;
}
return -1;
}
/**
Returns the position of the rightmost occurrence of `str` within `this`
String.
If `startIndex` is given, the search is performed within the substring
of `this` String from 0 to `startIndex + str.length`. Otherwise the search
is performed within `this` String. In either case, the returned position
is relative to the beginning of `this` String.
If `str` cannot be found, -1 is returned.
**/
public function lastIndexOf(str:String, ?startIndex:Int):Int {
if (startIndex == null) {
startIndex = this.length;
} else if (startIndex < 0) {
startIndex = 0;
}
var unicodeOffset = 0;
var nativeOffset = 0;
var result = -1;
var lastIndex = -1;
var matchingOffset = 0;
var strUnicodeLength = (str : UnicodeString).length;
while (nativeOffset < this.length && unicodeOffset < startIndex + strUnicodeLength) {
var c = StringTools.utf16CodePointAt(this, nativeOffset);
var c2 = StringTools.utf16CodePointAt(str, matchingOffset);
if (c == c2) {
if (matchingOffset == 0) {
lastIndex = unicodeOffset;
}
matchingOffset++;
if (c2 >= StringTools.MIN_SURROGATE_CODE_POINT) {
matchingOffset++;
}
if (matchingOffset == str.length) {
result = lastIndex;
lastIndex = -1;
}
} else if (matchingOffset != 0) {
lastIndex = -1;
matchingOffset = 0;
continue;
}
nativeOffset++;
if (c >= StringTools.MIN_SURROGATE_CODE_POINT) {
nativeOffset++;
}
unicodeOffset++;
}
return result;
}
/**
Returns `len` characters of `this` String, starting at position `pos`.
If `len` is omitted, all characters from position `pos` to the end of
`this` String are included.
If `pos` is negative, its value is calculated from the end of `this`
String by `this.length + pos`. If this yields a negative value, 0 is
used instead.
If the calculated position + `len` exceeds `this.length`, the characters
from that position to the end of `this` String are returned.
If `len` is negative, the result is unspecified.
**/
public function substr(pos:Int, ?len:Int):String {
if (pos < 0) {
pos = (this : UnicodeString).length + pos;
if (pos < 0) {
pos = 0;
}
}
if (len != null) {
if (len < 0) {
len = (this : UnicodeString).length + len;
}
if (len <= 0) {
return "";
}
}
var unicodeOffset = 0;
var nativeOffset = 0;
var fromOffset = -1;
var subLength = 0;
while (nativeOffset < this.length) {
var c = StringTools.utf16CodePointAt(this, nativeOffset);
if (unicodeOffset >= pos) {
if (fromOffset < 0) {
if (len == null) {
return this.substr(nativeOffset);
}
fromOffset = nativeOffset;
}
subLength++;
if (subLength >= len) {
var lastOffset = (c < StringTools.MIN_SURROGATE_CODE_POINT ? nativeOffset : nativeOffset + 1);
return this.substr(fromOffset, lastOffset - fromOffset + 1);
}
}
nativeOffset += (c >= StringTools.MIN_SURROGATE_CODE_POINT ? 2 : 1);
unicodeOffset++;
}
return (fromOffset < 0 ? "" : this.substr(fromOffset));
}
/**
Returns the part of `this` String from `startIndex` to but not including `endIndex`.
If `startIndex` or `endIndex` are negative, 0 is used instead.
If `startIndex` exceeds `endIndex`, they are swapped.
If the (possibly swapped) `endIndex` is omitted or exceeds
`this.length`, `this.length` is used instead.
If the (possibly swapped) `startIndex` exceeds `this.length`, the empty
String `""` is returned.
**/
public function substring(startIndex:Int, ?endIndex:Int):String {
if (startIndex < 0) {
startIndex = 0;
}
if (endIndex != null) {
if (endIndex < 0) {
endIndex = 0;
}
if (startIndex == endIndex) {
return "";
}
if (startIndex > endIndex) {
var tmp = startIndex;
startIndex = endIndex;
endIndex = tmp;
}
}
var unicodeOffset = 0;
var nativeOffset = 0;
var fromOffset = -1;
var subLength = 0;
while (nativeOffset < this.length) {
var c = StringTools.utf16CodePointAt(this, nativeOffset);
if (startIndex <= unicodeOffset) {
if (fromOffset < 0) {
if (endIndex == null) {
return this.substr(nativeOffset);
}
fromOffset = nativeOffset;
}
subLength++;
if (subLength >= endIndex - startIndex) {
var lastOffset = (c < StringTools.MIN_SURROGATE_CODE_POINT ? nativeOffset : nativeOffset + 1);
return this.substr(fromOffset, lastOffset - fromOffset + 1);
}
}
nativeOffset += (c >= StringTools.MIN_SURROGATE_CODE_POINT ? 2 : 1);
unicodeOffset++;
}
return (fromOffset < 0 ? "" : this.substr(fromOffset));
}
function get_length():Int {
var l = 0;
for (c in new StringIteratorUnicode(this)) {
l++;
}
return l;
}
#end
#end
@:op(A < B) static function lt(a:UnicodeString, b:UnicodeString):Bool;
@:op(A <= B) static function lte(a:UnicodeString, b:UnicodeString):Bool;
@:op(A > B) static function gt(a:UnicodeString, b:UnicodeString):Bool;
@:op(A >= B) static function gte(a:UnicodeString, b:UnicodeString):Bool;
@:op(A == B) static function eq(a:UnicodeString, b:UnicodeString):Bool;
@:op(A != B) static function neq(a:UnicodeString, b:UnicodeString):Bool;
@:op(A + B) static function add(a:UnicodeString, b:UnicodeString):UnicodeString;
@:op(A += B) static function assignAdd(a:UnicodeString, b:UnicodeString):UnicodeString;
@:op(A + B) @:commutative static function add(a:UnicodeString, b:String):UnicodeString;
@:op(A += B) @:commutative static function assignAdd(a:UnicodeString, b:String):UnicodeString;
}

408
Kha/Tools/macos/std/Xml.hx Normal file
View File

@ -0,0 +1,408 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/**
Xml node types.
@see https://haxe.org/manual/std-Xml.html
**/
enum abstract XmlType(Int) {
/**
Represents an XML element type.
**/
var Element = 0;
/**
Represents XML parsed character data type.
**/
var PCData = 1;
/**
Represents XML character data type.
**/
var CData = 2;
/**
Represents an XML comment type.
**/
var Comment = 3;
/**
Represents an XML doctype element type.
**/
var DocType = 4;
/**
Represents an XML processing instruction type.
**/
var ProcessingInstruction = 5;
/**
Represents an XML document type.
**/
var Document = 6;
public function toString():String {
return switch (cast this : XmlType) {
case Element: "Element";
case PCData: "PCData";
case CData: "CData";
case Comment: "Comment";
case DocType: "DocType";
case ProcessingInstruction: "ProcessingInstruction";
case Document: "Document";
};
}
}
/**
Cross-platform Xml API.
@see https://haxe.org/manual/std-Xml.html
**/
class Xml {
/**
XML element type.
**/
static public var Element(default, never) = XmlType.Element;
/**
XML parsed character data type.
**/
static public var PCData(default, never) = XmlType.PCData;
/**
XML character data type.
**/
static public var CData(default, never) = XmlType.CData;
/**
XML comment type.
**/
static public var Comment(default, never) = XmlType.Comment;
/**
XML doctype element type.
**/
static public var DocType(default, never) = XmlType.DocType;
/**
XML processing instruction type.
**/
static public var ProcessingInstruction(default, never) = XmlType.ProcessingInstruction;
/**
XML document type.
**/
static public var Document(default, never) = XmlType.Document;
/**
Parses the String into an Xml document.
**/
static public function parse(str:String):Xml {
return haxe.xml.Parser.parse(str);
}
/**
Returns the type of the Xml Node. This should be used before
accessing other functions since some might raise an exception
if the node type is not correct.
**/
public var nodeType(default, null):XmlType;
/**
Returns the node name of an Element.
**/
@:isVar public var nodeName(get, set):String;
/**
Returns the node value. Only works if the Xml node is not an Element or a Document.
**/
@:isVar public var nodeValue(get, set):String;
/**
Returns the parent object in the Xml hierarchy.
The parent can be `null`, an Element or a Document.
**/
public var parent(default, null):Xml;
var children:Array<Xml>;
var attributeMap:Map<String, String>;
#if !cppia inline #end function get_nodeName() {
if (nodeType != Element) {
throw 'Bad node type, expected Element but found $nodeType';
}
return nodeName;
}
#if !cppia inline #end function set_nodeName(v) {
if (nodeType != Element) {
throw 'Bad node type, expected Element but found $nodeType';
}
return this.nodeName = v;
}
#if !cppia inline #end function get_nodeValue() {
if (nodeType == Document || nodeType == Element) {
throw 'Bad node type, unexpected $nodeType';
}
return nodeValue;
}
#if !cppia inline #end function set_nodeValue(v) {
if (nodeType == Document || nodeType == Element) {
throw 'Bad node type, unexpected $nodeType';
}
return this.nodeValue = v;
}
/**
Creates a node of the given type.
**/
static public function createElement(name:String):Xml {
var xml = new Xml(Element);
xml.nodeName = name;
return xml;
}
/**
Creates a node of the given type.
**/
static public function createPCData(data:String):Xml {
var xml = new Xml(PCData);
xml.nodeValue = data;
return xml;
}
/**
Creates a node of the given type.
**/
static public function createCData(data:String):Xml {
var xml = new Xml(CData);
xml.nodeValue = data;
return xml;
}
/**
Creates a node of the given type.
**/
static public function createComment(data:String):Xml {
var xml = new Xml(Comment);
xml.nodeValue = data;
return xml;
}
/**
Creates a node of the given type.
**/
static public function createDocType(data:String):Xml {
var xml = new Xml(DocType);
xml.nodeValue = data;
return xml;
}
/**
Creates a node of the given type.
**/
static public function createProcessingInstruction(data:String):Xml {
var xml = new Xml(ProcessingInstruction);
xml.nodeValue = data;
return xml;
}
/**
Creates a node of the given type.
**/
static public function createDocument():Xml {
return new Xml(Document);
}
/**
Get the given attribute of an Element node. Returns `null` if not found.
Attributes are case-sensitive.
**/
public function get(att:String):String {
if (nodeType != Element) {
throw 'Bad node type, expected Element but found $nodeType';
}
return attributeMap[att];
}
/**
Set the given attribute value for an Element node.
Attributes are case-sensitive.
**/
public function set(att:String, value:String):Void {
if (nodeType != Element) {
throw 'Bad node type, expected Element but found $nodeType';
}
attributeMap.set(att, value);
}
/**
Removes an attribute for an Element node.
Attributes are case-sensitive.
**/
public function remove(att:String):Void {
if (nodeType != Element) {
throw 'Bad node type, expected Element but found $nodeType';
}
attributeMap.remove(att);
}
/**
Tells if the Element node has a given attribute.
Attributes are case-sensitive.
**/
public function exists(att:String):Bool {
if (nodeType != Element) {
throw 'Bad node type, expected Element but found $nodeType';
}
return attributeMap.exists(att);
}
/**
Returns an `Iterator` on all the attribute names.
**/
public function attributes():Iterator<String> {
if (nodeType != Element) {
throw 'Bad node type, expected Element but found $nodeType';
}
return attributeMap.keys();
}
/**
Returns an iterator of all child nodes.
Only works if the current node is an Element or a Document.
**/
public #if !cppia inline #end function iterator():Iterator<Xml> {
ensureElementType();
return children.iterator();
}
/**
Returns an iterator of all child nodes which are Elements.
Only works if the current node is an Element or a Document.
**/
public function elements():Iterator<Xml> {
ensureElementType();
var ret = [for (child in children) if (child.nodeType == Element) child];
return ret.iterator();
}
/**
Returns an iterator of all child nodes which are Elements with the given nodeName.
Only works if the current node is an Element or a Document.
**/
public function elementsNamed(name:String):Iterator<Xml> {
ensureElementType();
var ret = [
for (child in children)
if (child.nodeType == Element && child.nodeName == name) child
];
return ret.iterator();
}
/**
Returns the first child node.
**/
public #if !cppia inline #end function firstChild():Xml {
ensureElementType();
return children[0];
}
/**
Returns the first child node which is an Element.
**/
public function firstElement():Xml {
ensureElementType();
for (child in children) {
if (child.nodeType == Element) {
return child;
}
}
return null;
}
/**
Adds a child node to the Document or Element.
A child node can only be inside one given parent node, which is indicated by the `parent` property.
If the child is already inside this Document or Element, it will be moved to the last position among the Document or Element's children.
If the child node was previously inside a different node, it will be moved to this Document or Element.
**/
public function addChild(x:Xml):Void {
ensureElementType();
if (x.parent != null) {
x.parent.removeChild(x);
}
children.push(x);
x.parent = this;
}
/**
Removes a child from the Document or Element.
Returns true if the child was successfuly removed.
**/
public function removeChild(x:Xml):Bool {
ensureElementType();
if (children.remove(x)) {
x.parent = null;
return true;
}
return false;
}
/**
Inserts a child at the given position among the other childs.
A child node can only be inside one given parent node, which is indicated by the [parent] property.
If the child is already inside this Document or Element, it will be moved to the new position among the Document or Element's children.
If the child node was previously inside a different node, it will be moved to this Document or Element.
**/
public function insertChild(x:Xml, pos:Int):Void {
ensureElementType();
if (x.parent != null) {
x.parent.children.remove(x);
}
children.insert(pos, x);
x.parent = this;
}
/**
Returns a String representation of the Xml node.
**/
public #if !cppia inline #end function toString():String {
return haxe.xml.Printer.print(this);
}
function new(nodeType:XmlType) {
this.nodeType = nodeType;
children = [];
attributeMap = new Map();
}
inline function ensureElementType() {
if (nodeType != Document && nodeType != Element) {
throw 'Bad node type, expected Element or Document but found $nodeType';
}
}
}

View File

@ -0,0 +1,31 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
extern class ArrayBase {
// Length is number of elements
var length(default, null):Int;
function getElementSize():Int;
function getByteCount():Int;
function getBase():RawPointer<Char>;
}

View File

@ -0,0 +1,44 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:scalar @:coreType
extern abstract AtomicInt from(Int) to(Int) {
/**
Returns true if exchange took place.
**/
@:native("_hx_atomic_exchange_if")
public static function exchangeIf(ioValue:Pointer<AtomicInt>, test:Int, newVal:Int):Bool;
/**
Returns value before increment.
**/
@:native("_hx_atomic_inc")
public static function atomicInc(ioValue:Pointer<AtomicInt>):Int;
/**
Returns value before decrement.
**/
@:native("_hx_atomic_dec")
public static function atomicDec(ioValue:Pointer<AtomicInt>):Int;
}

View File

@ -0,0 +1,25 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
extern class AutoCast {}

View File

@ -0,0 +1,72 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:noPackageRestrict @:callable
typedef CallableData<T> = T;
/**
The generator intercepts this type and converts it to a cpp.Function<T> on cpp.
**/
@:noPackageRestrict
@:callable
#if cpp
extern
#end
abstract Callable<T>(CallableData<T>) {
inline public function new(inValue:T)
this = inValue;
public var call(get, never):CallableData<T>;
inline function get_call():CallableData<T>
return this;
#if cpp
@:from
inline static public function fromFunction<F>(func:Function<F, cpp.abi.Abi>):Callable<F>
return new Callable<F>(cast func);
@:to
inline public function toFunction():Function<T, cpp.abi.Abi>
return cast this;
inline public static function getProcAddress<T, ABI:cpp.abi.Abi>(inModule:String, inFunction:String):Function<T, ABI>
return Function.getProcAddress(inModule, inFunction);
inline public static function fromStaticFunction<T>(inStaticFunction:T):Callable<T>
return Function.fromStaticFunction(inStaticFunction);
inline public function lt(inOther:Callable<T>):Bool
return toFunction().lt(inOther.toFunction());
inline public function leq(inOther:Callable<T>):Bool
return toFunction().leq(inOther.toFunction());
inline public function gt(inOther:Callable<T>):Bool
return toFunction().gt(inOther.toFunction());
inline public function geq(inOther:Callable<T>):Bool
return toFunction().geq(inOther.toFunction());
#end
}

View File

@ -0,0 +1,36 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
abstract CastCharStar(RawPointer<Char>) to(RawPointer<Char>) {
inline function new(s:String)
this = cast untyped s.__s;
@:from
static public inline function fromString(s:String)
return new CastCharStar(s);
@:to
public inline function toPointer()
return this;
}

View File

@ -0,0 +1,25 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:coreType @:notNull @:runtimeValue abstract Char from Int to Int {}

View File

@ -0,0 +1,38 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
extern abstract ConstCharStar(RawConstPointer<Char>) to(RawConstPointer<Char>) {
inline function new(s:String)
this = untyped s.__s;
@:from
static public inline function fromString(s:String):ConstCharStar
return new ConstCharStar(s);
@:to extern public inline function toString():String
return new String(untyped this);
@:to extern public inline function toPointer():RawConstPointer<Char>
return this;
}

View File

@ -0,0 +1,71 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:coreType @:include("cpp/Pointer.h") @:native("cpp.Pointer") @:semantics(variable)
extern class ConstPointer<T> {
// ptr actually returns the pointer - not strictly a 'T' - for pointers to smart pointers
// Use value or ref to get dereferenced value
var ptr:Star<T>;
var value(get, never):T;
// Typecast to non-const
var raw(get, never):RawPointer<T>;
// const version
var constRaw(get, never):RawConstPointer<T>;
function get_value():Reference<T>;
function get_constRaw():RawConstPointer<T>;
function get_raw():RawPointer<T>;
function lt(inOther:ConstPointer<T>):Bool;
function leq(inOther:ConstPointer<T>):Bool;
function gt(inOther:ConstPointer<T>):Bool;
function geq(inOther:ConstPointer<T>):Bool;
function setRaw<O>(ptr:RawPointer<O>):Void;
static function fromRaw<T>(ptr:RawConstPointer<T>):ConstPointer<T>;
@:native("::cpp::Pointer_obj::fromRaw")
static function fromStar<T>(star:Star<T>):ConstPointer<T>;
static function fromPointer<T>(inNativePointer:Dynamic):ConstPointer<T>;
function reinterpret<Other>():Pointer<Other>;
function rawCast<Other>():RawPointer<Other>;
function at(inIndex:Int):Reference<T>;
function inc():ConstPointer<T>;
function dec():ConstPointer<T>;
function incBy(inT:Int):ConstPointer<T>;
function decBy(inT:Int):ConstPointer<T>;
function add(inT:Int):ConstPointer<T>;
function sub(inT:Int):ConstPointer<T>;
function postIncVal():Reference<T>;
}

View File

@ -0,0 +1,29 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
/**
Allows haxe to type the result correctly, and hxcpp can recognise this uses
the correct type.
**/
typedef ConstStar<T> = Null<T>;

View File

@ -0,0 +1,60 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:native("hx.EnumBase")
extern class EnumBase {
#if (hxcpp_api_level >= 330)
function _hx_getIndex():Int;
function _hx_getTag():String;
function _hx_getParamCount():Int;
function _hx_getParamI(inIndex:Int):Dynamic;
function _hx_getParameters():Array<Dynamic>;
inline function getIndex():Int
return _hx_getIndex();
inline function getTag():String
return _hx_getTag();
inline function getParamCount():Int
return _hx_getParamCount();
inline function getParamI(inIndex:Int):Dynamic
return _hx_getParamI(inIndex);
inline function getParameters():Array<Dynamic>
return _hx_getParameters();
#else
function __EnumParams():Array<Dynamic>;
function __Tag():String;
function __Index():Int;
inline function _hx_getIndex():Int
return untyped __Index();
inline function _hx_getTag():String
return untyped __Tag();
inline function _hx_getParamCount():Int
return untyped __EnumParams() == null ? 0 : __EnumParams().length;
inline function _hx_getParamI(inIndex:Int):Dynamic
return untyped __EnumParams()[inIndex];
inline function _hx_getParameters():Array<Dynamic>
return __EnumParams() == null ? [] : __EnumParams();
#end
}

View File

@ -0,0 +1,40 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
extern class ErrorConstants {
@:native("HX_INVALID_CAST")
static var invalidCast:Dynamic;
@:native("HX_INDEX_OUT_OF_BOUNDS")
static var indexOutOfBounds:Dynamic;
@:native("HX_INVALID_OBJECT")
static var invalidObject:Dynamic;
@:native("HX_INVALID_ARG_COUNT")
static var invalidArgCount:Dynamic;
@:native("HX_NULL_FUNCTION_POINTER")
static var nullFunctionPointer:Dynamic;
}

View File

@ -0,0 +1,27 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:include("stdio.h")
@:native(" ::cpp::Pointer<FILE>")
extern class FILE {}

View File

@ -0,0 +1,28 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
extern class FastIterator<T> {
function hasNext():Bool;
function next():T;
}

View File

@ -0,0 +1,36 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
/**
This is just a helper class. It is not actually required to inherit from this
to use `NativeGc.addFinalizable(this,inPin)`, only a function called
`finalize` is needed.
**/
class Finalizable {
public function new(inPin = false) {
NativeGc.addFinalizable(this, inPin);
}
public function finalize():Void {}
}

View File

@ -0,0 +1,25 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:coreType @:notNull @:runtimeValue abstract Float32 from Float to Float {}

View File

@ -0,0 +1,25 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:coreType @:notNull @:runtimeValue abstract Float64 from Float to Float {}

View File

@ -0,0 +1,60 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:callable
typedef FunctionData<T, ABI> = T;
@:include("cpp/Pointer.h") @:callable
extern abstract Function<T, ABI:cpp.abi.Abi>(FunctionData<T, ABI>) {
inline public function new(inValue:T)
this = inValue;
// Legacy Api
public var call(get, never):FunctionData<T, ABI>;
inline function get_call():FunctionData<T, ABI>
return this;
@:native("::cpp::Function_obj::getProcAddress")
extern static function nativeGetProcAddress<T, ABI:cpp.abi.Abi>(inModule:String, inFunction:String):AutoCast;
inline public static function getProcAddress<T, ABI:cpp.abi.Abi>(inModule:String, inFunction:String):Function<T, ABI> {
return cast nativeGetProcAddress(inModule, inFunction);
}
@:native("::cpp::Function_obj::fromStaticFunction")
extern static function nativeFromStaticFunction<T>(inStaticFunction:T):AutoCast;
inline public static function fromStaticFunction<T>(inStaticFunction:T):Callable<T> {
return cast nativeFromStaticFunction(inStaticFunction);
}
extern public function lt(inOther:Function<T, ABI>):Bool;
extern public function leq(inOther:Function<T, ABI>):Bool;
extern public function gt(inOther:Function<T, ABI>):Bool;
extern public function geq(inOther:Function<T, ABI>):Bool;
}

View File

@ -0,0 +1,25 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:coreType @:notNull @:runtimeValue abstract Int16 from Int to Int {}

View File

@ -0,0 +1,25 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:coreType @:notNull @:runtimeValue abstract Int32 from Int to Int {}

View File

@ -0,0 +1,35 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:coreType @:notNull @:runtimeValue abstract Int64 from Int to Int {
@:to
#if !cppia inline #end function toInt64():haxe.Int64 {
return cast this;
}
@:from
static #if !cppia inline #end function ofInt64(x:haxe.Int64):Int64 {
return cast x;
}
}

View File

@ -0,0 +1,25 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:coreType @:notNull @:runtimeValue abstract Int8 from Int to Int {}

View File

@ -0,0 +1,149 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
/**
Platform-specific Cpp Library. Provides some platform-specific functions
for the C++ target, such as conversion from Haxe types to native types
and vice-versa.
**/
class Lib {
/**
Load and return a Cpp primitive from a DLL library.
**/
public static function load(lib:String, prim:String, nargs:Int):Dynamic {
#if (iphone || emscripten)
return loadLazy(lib, prim, nargs);
#else
return untyped __global__.__loadprim(lib, prim, nargs);
#end
}
/**
Unloaded all dynamic libraries in reverse order of loading.
Returns the number of libraries unloaded.
**/
public static function unloadAllLibraries():Int {
return untyped __global__.__hxcpp_unload_all_libraries();
}
public static function _loadPrime(lib:String, prim:String, signature:String, quietFail = false):Dynamic {
var factory:Callable<ConstCharStar->Object> = untyped __global__.__hxcpp_cast_get_proc_address(lib, prim + "__prime", quietFail);
if (factory != null) {
var func:Dynamic = factory.call(signature);
if (func == null && !quietFail)
throw '$prim does not have signature $signature';
return func;
}
return null;
}
/**
Tries to load, and always returns a valid function, but the function may throw
if called.
**/
public static function loadLazy(lib:String, prim:String, nargs:Int):Dynamic {
try {
return untyped __global__.__loadprim(lib, prim, nargs);
} catch (e:Dynamic) {
return switch (nargs) {
case 0: () -> throw e;
case 2: (_, _) -> throw e;
case 3: (_, _, _) -> throw e;
case 4: (_, _, _, _) -> throw e;
case 5: (_, _, _, _, _) -> throw e;
default: _ -> throw e;
};
}
return null;
}
@:noDebug @:native("HX_STACK_DO_RETHROW")
extern static function do_rethrow(inExp:Dynamic);
@:noDebug #if (!cppia) inline #end
public static function rethrow(inExp:Dynamic) {
do_rethrow(inExp);
}
public static function stringReference(inBytes:haxe.io.Bytes):String {
var result:String = "";
untyped __global__.__hxcpp_string_of_bytes(inBytes.b, result, 0, inBytes.length, true);
return result;
}
public static function pushDllSearchPath(inPath:String):Void
untyped __global__.__hxcpp_push_dll_path(inPath);
public static function getDllExtension():String
return untyped __global__.__hxcpp_get_dll_extension();
public static function getBinDirectory():String
return untyped __global__.__hxcpp_get_bin_dir();
/**
Returns bytes referencing the content of a string.
Use with extreme caution - changing constant strings will crash.
Changing one string can cause others to change unexpectedly.
Only really safe if you are using it read-only or if it comes from stringReference above
**/
public inline static function bytesReference(s:String):haxe.io.Bytes {
var bytes = new haxe.io.BytesData();
untyped bytes.__unsafeStringReference(s);
return haxe.io.Bytes.ofData(bytes);
}
/**
Print the specified value on the default output.
**/
public static function print(v:Dynamic):Void {
untyped __global__.__hxcpp_print(v);
}
/**
This function is used to make porting from neko to cpp easy.
It does not need to do anything because the c-code can work with any Dynamic
**/
public static function haxeToNeko(v:Dynamic):Dynamic {
return v;
}
/**
This function is used to make porting from neko to cpp easy.
It does not need to do anything because the c-code can work with any Dynamic
**/
public static function nekoToHaxe(v:Dynamic):Dynamic {
return v;
}
/**
Print the specified value on the default output followed by a newline character.
**/
public static function println(v:Dynamic):Void {
untyped __global__.__hxcpp_println(v);
}
public static function setFloatFormat(inFormat:String):Void {
untyped __global__.__hxcpp_set_float_format(inFormat);
}
}

View File

@ -0,0 +1,103 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:include("stdlib.h")
extern class Native {
@:native("malloc")
static function nativeMalloc(bytes:Int):cpp.Star<cpp.Void>;
@:native("calloc")
static function nativeCalloc(bytes:Int):cpp.Star<cpp.Void>;
@:native("realloc")
static function nativeRealloc(inPtr:cpp.Star<cpp.Void>, bytes:Int):cpp.RawPointer<cpp.Void>;
@:native("free")
static function nativeFree(ptr:cpp.Star<cpp.Void>):Void;
@:native("memcpy")
static function nativeMemcpy(dest:cpp.Star<cpp.Void>, src:cpp.Star<cpp.Void>, bytes:Int):Void;
@:native("::hx::ClassSizeOf") @:templatedCall
static function sizeof<T>(t:T):Int;
#if !cppia
@:native("::hx::Dereference")
static function star<T>(ptr:cpp.Star<T>):cpp.Reference<T>;
@:generic
static inline function set<T>(ptr:cpp.Star<T>, value:T):Void {
var ref:cpp.Reference<T> = star(ptr);
ref = value;
}
@:generic
static inline function get<T>(ptr:cpp.Star<T>):T {
var ref:cpp.Reference<T> = star(ptr);
return ref;
}
@:generic
static inline function memcpy<DEST, SRC>(dest:cpp.Star<DEST>, src:cpp.Star<SRC>, bytes:Int):Void
nativeMemcpy(cast dest, cast src, bytes);
@:generic
static inline function malloc<T>(bytes:Int):cpp.Star<T>
return cast nativeMalloc(bytes);
@:generic
static inline function calloc<T>(bytes:Int):cpp.Star<T>
return cast nativeCalloc(bytes);
@:generic
static inline function realloc<T>(ioPtr:cpp.Star<T>, bytes:Int):cpp.Star<T>
return cast nativeRealloc(cast ioPtr, bytes);
@:generic
static inline function free<T>(ptr:cpp.Star<T>):Void {
if (ptr != null)
nativeFree(cast ptr);
}
@:native("::hx::StarOf")
static function addressOf<T>(inVariable:Reference<T>):Star<T>;
#else
static inline function addressOf<T>(inVariable:Reference<T>):Star<T> {
throw "Native.addressOf not available in cppia";
}
static inline function star<T>(ptr:cpp.Star<T>):cpp.Reference<T> {
throw "Native.star not available in cppia";
}
static inline function set<T>(ptr:cpp.Star<T>, value:T):Void {
throw "Native.set not available in cppia";
}
static inline function get<T>(ptr:cpp.Star<T>):T {
throw "Native.get not available in cppia";
var d:Dynamic = null;
return d;
}
static function memcpy<DEST, SRC>(dest:cpp.Star<DEST>, src:cpp.Star<SRC>, bytes:Int):Void;
static function malloc<T>(bytes:Int):cpp.Star<T>;
static function calloc<T>(bytes:Int):cpp.Star<T>;
static function realloc<T>(ioPtr:cpp.Star<T>, bytes:Int):cpp.Star<T>;
static function free<T>(ptr:cpp.Star<T>):Void;
#end
}

View File

@ -0,0 +1,31 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
extern class NativeArc {
@:native("(__bridge_transfer id)")
static function _bridgeTransfer<T>(ptr:cpp.RawPointer<cpp.Void>):cpp.RawPointer<T>;
static inline function bridgeTransfer<T>(ptr:cpp.RawPointer<cpp.Void>):T
return cast _bridgeTransfer(ptr);
}

View File

@ -0,0 +1,100 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
extern class NativeArray {
#if cppia
static inline function create<T>(length:Int):Array<T> {
var result = new Array<T>();
NativeArray.setSize(result, length);
return result;
}
#else
@:native("_hx_create_array_length")
static function create<T>(length:Int):Array<T>;
#end
static inline function blit<T>(ioDestArray:Array<T>, inDestElement:Int, inSourceArray:Array<T>, inSourceElement:Int, inElementCount:Int):Void {
untyped ioDestArray.blit(inDestElement, inSourceArray, inSourceElement, inElementCount);
};
static inline function getBase(inArray:Array<Dynamic>):ArrayBase {
return untyped inArray;
}
@:nativeStaticExtension
static function reserve<T>(inArray:Array<T>, inElements:Int):Void;
@:nativeStaticExtension
static function capacity<T>(inArray:Array<T>):Int;
@:nativeStaticExtension
static function getElementSize<T>(inArray:Array<T>):Int;
static inline function address<T>(inArray:Array<T>, inIndex:Int):Pointer<T> {
return Pointer.arrayElem(inArray, inIndex);
}
@:nativeStaticExtension
static function setData<T>(inArray:Array<T>, inData:Pointer<T>, inElementCount:Int):Void;
@:nativeStaticExtension
static function setUnmanagedData<T>(inArray:Array<T>, inData:ConstPointer<T>, inElementCount:Int):Void;
@:nativeStaticExtension
static function zero<T>(ioDestArray:Array<T>, ?inFirst:Int, ?inElements:Int):Void;
@:nativeStaticExtension
static function removeAt<T>(ioDestArray:Array<T>, inIndex:Int):Void;
@:nativeStaticExtension
static function memcmp<T>(inArrayA:Array<T>, inArrayB:Array<T>):Int;
@:native("_hx_reslove_virtual_array")
static function resolveVirtualArray(inArray:Array<Dynamic>):Dynamic;
#if cppia
static inline function unsafeGet<T>(inDestArray:Array<T>, inIndex:Int):T {
return untyped inDestArray.__unsafe_get(inIndex);
}
static inline function unsafeSet<T>(ioDestArray:Array<T>, inIndex:Int, inValue:T):T {
return untyped ioDestArray.__unsafe_set(inIndex, inValue);
}
static inline function setSize<T>(ioArray:Array<T>, inSize:Int):Array<T> {
return untyped ioArray.__SetSizeExact(inSize);
}
#else
@:native("_hx_array_unsafe_get")
static function unsafeGet<T>(inDestArray:Array<T>, inIndex:Int):T;
@:native("_hx_array_unsafe_set")
static inline function unsafeSet<T>(ioDestArray:Array<T>, inIndex:Int, inValue:T):T {
return untyped ioDestArray.__unsafe_set(inIndex, inValue);
}
@:native("_hx_array_set_size_exact")
static function setSize<T>(ioArray:Array<T>, inSize:Int):Array<T>;
#end
}

View File

@ -0,0 +1,71 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:buildXml('<include name="${HXCPP}/src/hx/libs/std/Build.xml"/>')
extern class NativeFile {
@:native("_hx_std_file_open")
extern static function file_open(fname:String, r:String):Dynamic;
@:native("_hx_std_file_close")
extern static function file_close(handle:Dynamic):Void;
@:native("_hx_std_file_write")
extern static function file_write(handle:Dynamic, s:haxe.io.BytesData, p:Int, n:Int):Int;
@:native("_hx_std_file_write_char")
extern static function file_write_char(handle:Dynamic, c:Int):Void;
@:native("_hx_std_file_read")
extern static function file_read(handle:Dynamic, s:haxe.io.BytesData, p:Int, n:Int):Int;
@:native("_hx_std_file_read_char")
extern static function file_read_char(handle:Dynamic):Int;
@:native("_hx_std_file_seek")
extern static function file_seek(handle:Dynamic, pos:Int, kind:Int):Void;
@:native("_hx_std_file_tell")
extern static function file_tell(handle:Dynamic):Int;
@:native("_hx_std_file_eof")
extern static function file_eof(handle:Dynamic):Bool;
@:native("_hx_std_file_flush")
extern static function file_flush(handle:Dynamic):Void;
@:native("_hx_std_file_contents_string")
extern static function file_contents_string(name:String):String;
@:native("_hx_std_file_contents_bytes")
extern static function file_contents_bytes(name:String):haxe.io.BytesData;
@:native("_hx_std_file_stdin")
extern static function file_stdin():Dynamic;
@:native("_hx_std_file_stdout")
extern static function file_stdout():Dynamic;
@:native("_hx_std_file_stderr")
extern static function file_stderr():Dynamic;
}

View File

@ -0,0 +1,65 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
extern class NativeGc {
@:native("__hxcpp_gc_mem_info")
static function memInfo(inWhatInfo:Int):Float;
@:native("_hx_allocate_extended") @:templatedCall
static function allocateExtended<T>(cls:Class<T>, size:Int):T;
@:native("_hx_add_finalizable")
static function addFinalizable(instance:{function finalize():Void;}, inPin:Bool):Void;
@:native("::hx::InternalNew")
static function allocGcBytesRaw(inBytes:Int, isContainer:Bool):RawPointer<cpp.Void>;
inline static function allocGcBytes(inBytes:Int):Pointer<cpp.Void> {
return Pointer.fromRaw(allocGcBytesRaw(inBytes, false));
}
@:native("__hxcpp_enable") extern static function enable(inEnable:Bool):Void;
@:native("__hxcpp_collect") extern static function run(major:Bool):Void;
@:native("__hxcpp_gc_compact") extern static function compact():Void;
@:native("__hxcpp_gc_trace") extern static function nativeTrace(sought:Class<Dynamic>, printInstances:Bool):Int;
@:native("__hxcpp_gc_do_not_kill") extern static function doNotKill(inObject:Dynamic):Void;
@:native("__hxcpp_get_next_zombie") extern static function getNextZombie():Dynamic;
@:native("__hxcpp_gc_safe_point") extern static function safePoint():Void;
@:native("__hxcpp_enter_gc_free_zone") extern static function enterGCFreeZone():Void;
@:native("__hxcpp_exit_gc_free_zone") extern static function exitGCFreeZone():Void;
@:native("__hxcpp_set_minimum_free_space") extern static function setMinimumFreeSpace(inBytes:Int):Void;
@:native("__hxcpp_set_target_free_space_percentage") extern static function setTargetFreeSpacePercentage(inPercentage:Int):Void;
@:native("__hxcpp_set_minimum_working_memory") extern static function setMinimumWorkingMemory(inBytes:Int):Void;
}

View File

@ -0,0 +1,49 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:noPackageRestrict
extern class NativeMath {
#if (cpp && !cppia)
@:native("_hx_idiv")
static function idiv(num:Int, denom:Int):Int;
@:native("_hx_imod")
static function imod(num:Int, denom:Int):Int;
@:native("_hx_cast_int")
static function castInt(f:Float):Int;
@:native("_hx_fast_floor")
static function fastInt(f:Float):Int;
#else
static inline function imod(num:Int, denom:Int):Int
return num % denom;
static inline function idiv(num:Int, denom:Int):Int
return Std.int(num / denom);
static inline function castInt(f:Float):Int
return Std.int(f);
static inline function fastInt(f:Float):Int
return Std.int(f);
#end
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:buildXml('<include name="${HXCPP}/src/hx/libs/std/Build.xml"/>')
extern class NativeProcess {
@:native("_hx_std_process_run")
static function process_run(cmd:String, vargs:Array<String>):Dynamic;
@:native("_hx_std_process_run")
static function process_run_with_show(cmd:String, vargs:Array<String>, inShow:Int):Dynamic;
@:native("_hx_std_process_stdout_read")
static function process_stdout_read(handle:Dynamic, buf:haxe.io.BytesData, pos:Int, len:Int):Int;
@:native("_hx_std_process_stderr_read")
static function process_stderr_read(handle:Dynamic, buf:haxe.io.BytesData, pos:Int, len:Int):Int;
@:native("_hx_std_process_stdin_write")
static function process_stdin_write(handle:Dynamic, buf:haxe.io.BytesData, pos:Int, len:Int):Int;
@:native("_hx_std_process_stdin_close")
static function process_stdin_close(handle:Dynamic):Void;
@:native("_hx_std_process_exit")
static function process_exit(handle:Dynamic):Int;
@:native("_hx_std_process_pid")
static function process_pid(handle:Dynamic):Int;
@:native("_hx_std_process_kill")
static function process_kill(handle:Dynamic):Void;
@:native("_hx_std_process_close")
static function process_close(handle:Dynamic):Void;
}

View File

@ -0,0 +1,38 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:buildXml('<include name="${HXCPP}/src/hx/libs/std/Build.xml"/>')
extern class NativeRandom {
@:native("_hx_std_random_new")
static function random_new():Dynamic;
@:native("_hx_std_random_set_seed")
static function random_set_seed(handle:Dynamic, v:Int):Void;
@:native("_hx_std_random_int")
static function random_int(handle:Dynamic, max:Int):Int;
@:native("_hx_std_random_float")
static function random_float(handle:Dynamic):Float;
}

View File

@ -0,0 +1,145 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
import sys.net.Socket;
@:buildXml('<include name="${HXCPP}/src/hx/libs/std/Build.xml"/>')
extern class NativeSocket {
@:native("_hx_std_socket_init")
static function socket_init():Void;
@:native("_hx_std_socket_new")
static function socket_new(udp:Bool):Dynamic;
@:native("_hx_std_socket_new")
static function socket_new_ip(udp:Bool, ipv6:Bool):Dynamic;
@:native("_hx_std_socket_close")
static function socket_close(handle:Dynamic):Void;
@:native("_hx_std_socket_bind")
static function socket_bind(o:Dynamic, host:Int, port:Int):Void;
@:native("_hx_std_socket_bind_ipv6")
static function socket_bind_ipv6(o:Dynamic, host:haxe.io.BytesData, port:Int):Void;
@:native("_hx_std_socket_send_char")
static function socket_send_char(o:Dynamic, c:Int):Void;
@:native("_hx_std_socket_send")
static function socket_send(o:Dynamic, buf:haxe.io.BytesData, p:Int, l:Int):Int;
@:native("_hx_std_socket_recv")
static function socket_recv(o:Dynamic, buf:haxe.io.BytesData, p:Int, l:Int):Int;
@:native("_hx_std_socket_recv_char")
static function socket_recv_char(o:Dynamic):Int;
@:native("_hx_std_socket_write")
static function socket_write(o:Dynamic, buf:haxe.io.BytesData):Void;
@:native("_hx_std_socket_read")
static function socket_read(o:Dynamic):haxe.io.BytesData;
@:native("_hx_std_host_resolve_ipv6")
static function host_resolve_ipv6(host:String):haxe.io.BytesData;
@:native("_hx_std_host_resolve")
static function host_resolve(host:String):Int;
@:native("_hx_std_host_to_string")
static function host_to_string(ip:Int):String;
@:native("_hx_std_host_to_string_ipv6")
static function host_to_string_ipv6(ipv6:haxe.io.BytesData):String;
@:native("_hx_std_host_reverse")
static function host_reverse(host:Int):String;
@:native("_hx_std_host_reverse_ipv6")
static function host_reverse_ipv6(ipv6:haxe.io.BytesData):String;
@:native("_hx_std_host_local")
static function host_local():String;
inline static function host_local_ipv6():String
return "::1";
@:native("_hx_std_socket_connect")
static function socket_connect(o:Dynamic, host:Int, port:Int):Void;
@:native("_hx_std_socket_connect_ipv6")
static function socket_connect_ipv6(o:Dynamic, host:haxe.io.BytesData, port:Int):Void;
@:native("_hx_std_socket_listen")
static function socket_listen(o:Dynamic, n:Int):Void;
@:native("_hx_std_socket_select")
static function socket_select(rs:Array<Dynamic>, ws:Array<Dynamic>, es:Array<Dynamic>, timeout:Dynamic):Array<Dynamic>;
@:native("_hx_std_socket_fast_select")
static function socket_fast_select(rs:Array<Dynamic>, ws:Array<Dynamic>, es:Array<Dynamic>, timeout:Dynamic):Void;
@:native("_hx_std_socket_accept")
static function socket_accept(o:Dynamic):Dynamic;
@:native("_hx_std_socket_peer")
static function socket_peer(o:Dynamic):Array<Int>;
@:native("_hx_std_socket_host")
static function socket_host(o:Dynamic):Array<Int>;
@:native("_hx_std_socket_set_timeout")
static function socket_set_timeout(o:Dynamic, t:Dynamic):Void;
@:native("_hx_std_socket_shutdown")
static function socket_shutdown(o:Dynamic, r:Bool, w:Bool):Void;
@:native("_hx_std_socket_set_blocking")
static function socket_set_blocking(o:Dynamic, b:Bool):Void;
@:native("_hx_std_socket_set_fast_send")
static function socket_set_fast_send(o:Dynamic, b:Bool):Void;
@:native("_hx_std_socket_set_broadcast")
static function socket_set_broadcast(o:Dynamic, b:Bool):Void;
@:native("_hx_std_socket_poll_alloc")
static function socket_poll_alloc(nsocks:Int):Dynamic;
@:native("_hx_std_socket_poll_prepare")
static function socket_poll_prepare(pdata:Dynamic, rsocks:Array<Socket>, wsocks:Array<Socket>):Array<Array<Int>>;
@:native("_hx_std_socket_poll_events")
static function socket_poll_events(pdata:Dynamic, timeout:Float):Void;
@:native("_hx_std_socket_poll")
static function socket_poll(socks:Array<Socket>, pdata:Dynamic, timeout:Float):Array<Socket>;
@:native("_hx_std_socket_send_to")
static function socket_send_to(o:Dynamic, buf:haxe.io.BytesData, p:Int, l:Int, inAddr:Dynamic):Int;
@:native("_hx_std_socket_recv_from")
static function socket_recv_from(o:Dynamic, buf:haxe.io.BytesData, p:Int, l:Int, outAddr:Dynamic):Int;
}

View File

@ -0,0 +1,137 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:buildXml('<include name="${HXCPP}/src/hx/libs/ssl/Build.xml"/>')
extern class NativeSsl {
@:native("_hx_ssl_debug_set")
static function ssl_debug_set(int:Int):Void;
@:native("_hx_ssl_new")
static function ssl_new(conf:Dynamic):Dynamic;
@:native("_hx_ssl_close")
static function ssl_close(ctx:Dynamic):Void;
@:native("_hx_ssl_handshake")
static function ssl_handshake(ctx:Dynamic):Void;
@:native("_hx_ssl_set_socket")
static function ssl_set_socket(ctx:Dynamic, socket:Dynamic):Void;
@:native("_hx_ssl_set_hostname")
static function ssl_set_hostname(ctx:Dynamic, hostname:String):Void;
@:native("_hx_ssl_get_peer_certificate")
static function ssl_get_peer_certificate(ctx:Dynamic):Dynamic;
@:native("_hx_ssl_get_verify_result")
static function ssl_get_verify_result(ctx:Dynamic):Bool;
@:native("_hx_ssl_send_char")
static function ssl_send_char(ctx:Dynamic, char:Int):Void;
@:native("_hx_ssl_send")
static function ssl_send(ctx:Dynamic, buf:haxe.io.BytesData, p:Int, l:Int):Int;
@:native("_hx_ssl_write")
static function ssl_write(ctx:Dynamic, data:haxe.io.BytesData):Void;
@:native("_hx_ssl_recv_char")
static function ssl_recv_char(ctx:Dynamic):Int;
@:native("_hx_ssl_recv")
static function ssl_recv(ctx:Dynamic, buf:haxe.io.BytesData, p:Int, l:Int):Int;
@:native("_hx_ssl_read")
static function ssl_read(ctx:Dynamic):haxe.io.BytesData;
@:native("_hx_ssl_conf_new")
static function conf_new(server:Bool):Dynamic;
@:native("_hx_ssl_conf_close")
static function conf_close(conf:Dynamic):Void;
@:native("_hx_ssl_conf_set_ca")
static function conf_set_ca(conf:Dynamic, cert:Dynamic):Void;
@:native("_hx_ssl_conf_set_verify")
static function conf_set_verify(conf:Dynamic, mode:Int):Void;
@:native("_hx_ssl_conf_set_cert")
static function conf_set_cert(conf:Dynamic, cert:Dynamic, pkey:Dynamic):Void;
@:native("_hx_ssl_conf_set_servername_callback")
static function conf_set_servername_callback(conf:Dynamic, cb:Dynamic):Void;
@:native("_hx_ssl_cert_load_defaults")
static function cert_load_defaults():Dynamic;
@:native("_hx_ssl_cert_load_file")
static function cert_load_file(file:String):Dynamic;
@:native("_hx_ssl_cert_load_path")
static function cert_load_path(path:String):Dynamic;
@:native("_hx_ssl_cert_get_subject")
static function cert_get_subject(cert:Dynamic, field:String):String;
@:native("_hx_ssl_cert_get_issuer")
static function cert_get_issuer(cert:Dynamic, field:String):String;
@:native("_hx_ssl_cert_get_altnames")
static function cert_get_altnames(cert:Dynamic):Array<String>;
@:native("_hx_ssl_cert_get_notbefore")
static function cert_get_notbefore(cert:Dynamic):Array<Int>;
@:native("_hx_ssl_cert_get_notafter")
static function cert_get_notafter(cert:Dynamic):Array<Int>;
@:native("_hx_ssl_cert_get_next")
static function cert_get_next(cert:Dynamic):Dynamic;
@:native("_hx_ssl_cert_add_pem")
static function cert_add_pem(cert:Dynamic, data:String):Dynamic;
@:native("_hx_ssl_cert_add_der")
static function cert_add_der(cert:Dynamic, data:haxe.io.BytesData):Dynamic;
@:native("_hx_ssl_key_from_der")
static function key_from_der(data:haxe.io.BytesData, pub:Bool):Dynamic;
@:native("_hx_ssl_key_from_pem")
static function key_from_pem(data:String, pub:Bool, pass:String):Dynamic;
@:native("_hx_ssl_dgst_make")
static function dgst_make(data:haxe.io.BytesData, alg:String):haxe.io.BytesData;
@:native("_hx_ssl_dgst_sign")
static function dgst_sign(data:haxe.io.BytesData, key:Dynamic, alg:String):haxe.io.BytesData;
@:native("_hx_ssl_dgst_verify")
static function dgst_verify(data:haxe.io.BytesData, sign:haxe.io.BytesData, key:Dynamic, alg:String):Bool;
@:native("_hx_ssl_init")
static function init():Void;
}

View File

@ -0,0 +1,73 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
extern class NativeString {
static inline function raw(inString:String):RawConstPointer<Char> {
return untyped inString.raw_ptr();
}
static inline function c_str(inString:String):ConstPointer<Char> {
return cpp.ConstPointer.fromPointer(untyped inString.c_str());
}
static inline function fromPointer(inPtr:ConstPointer<Char>):String {
return untyped __global__.String(inPtr.ptr);
}
static inline function fromGcPointer(inPtr:ConstPointer<Char>, inLen:Int):String {
return untyped __global__.String(inPtr.ptr, inLen);
}
@:native("__hxcpp_parse_float")
public static function parseFloat(inString:String):Float;
@:native("__hxcpp_parse_substr_float")
public static function parseSubstrFloat(inString:String,start:Int, length:Int):Float;
// Will return 0 for invalid string
@:native("__hxcpp_parse_substr_int")
public static function parseInt(inString:String):Int;
// Will return 0 for invalid string
@:native("__hxcpp_parse_substr_int")
public static function parseSubstrInt(inString:String,start:Int, length:Int):Int;
@:native("_hx_string_compare")
static function compare(inString0:String, inString1:String):Int;
@:native("_hx_utf8_char_code_at")
static function utf8CharCodeAt(inString:String, inIndex:Int):Int;
@:native("_hx_utf8_length")
static function utf8Length(inString:String):Int;
@:native("_hx_utf8_is_valid")
static function utf8IsValid(inString:String):Bool;
@:native("_hx_utf8_sub")
static function utf8Sub(inString:String, charStart:Int, inLen:Int):String;
@:native("_hx_string_create")
static function fromPointerLen(inPtr:ConstPointer<Char>, len:Int):String;
@:native("_hx_utf8_decode_advance")
static function utf8DecodeAdvance(reference:Char):Int;
}

View File

@ -0,0 +1,107 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:buildXml('<include name="${HXCPP}/src/hx/libs/std/Build.xml"/>')
extern class NativeSys {
@:native("__hxcpp_print")
static function print(v:Dynamic):Void;
@:native("__hxcpp_println")
static function println(v:Dynamic):Void;
@:native("_hx_std_get_env")
extern static function get_env(v:String):String;
@:native("_hx_std_put_env")
extern static function put_env(e:String, v:String):Void;
@:native("_hx_std_sys_sleep")
extern static function sys_sleep(f:Float):Void;
@:native("_hx_std_set_time_locale")
extern static function set_time_locale(l:String):Bool;
@:native("_hx_std_get_cwd")
extern static function get_cwd():String;
@:native("_hx_std_set_cwd")
extern static function set_cwd(d:String):Void;
@:native("_hx_std_sys_string")
extern static function sys_string():String;
@:native("_hx_std_sys_is64")
extern static function sys_is64():Bool;
@:native("_hx_std_sys_command")
extern static function sys_command(cmd:String):Int;
@:native("_hx_std_sys_exit")
extern static function sys_exit(code:Int):Void;
@:native("_hx_std_sys_exists")
extern static function sys_exists(path:String):Bool;
@:native("_hx_std_file_delete")
extern static function file_delete(path:String):Void;
@:native("_hx_std_sys_rename")
extern static function sys_rename(path:String, newname:String):Bool;
@:native("_hx_std_sys_stat")
extern static function sys_stat(path:String):Dynamic;
@:native("_hx_std_sys_file_type")
extern static function sys_file_type(path:String):String;
@:native("_hx_std_sys_create_dir")
extern static function sys_create_dir(path:String, mode:Int):Bool;
@:native("_hx_std_sys_remove_dir")
extern static function sys_remove_dir(path:String):Void;
@:native("_hx_std_sys_time")
extern static function sys_time():Float;
@:native("_hx_std_sys_cpu_time")
extern static function sys_cpu_time():Float;
@:native("_hx_std_sys_read_dir")
extern static function sys_read_dir(p:String):Array<String>;
@:native("_hx_std_file_full_path")
extern static function file_full_path(path:String):String;
@:native("_hx_std_sys_exe_path")
extern static function sys_exe_path():String;
@:native("_hx_std_sys_env")
extern static function sys_env():Array<String>;
@:native("_hx_std_sys_getch")
extern static function sys_getch(b:Bool):Int;
@:native("_hx_std_sys_get_pid")
extern static function sys_get_pid():Int;
}

View File

@ -0,0 +1,473 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
enum abstract XmlType(Int) {
/**
Represents an XML element type.
**/
var Element = 0;
/**
Represents XML parsed character data type.
**/
var PCData = 1;
/**
Represents XML character data type.
**/
var CData = 2;
/**
Represents an XML comment type.
**/
var Comment = 3;
/**
Represents an XML doctype element type.
**/
var DocType = 4;
/**
Represents an XML processing instruction type.
**/
var ProcessingInstruction = 5;
/**
Represents an XML document type.
**/
var Document = 6;
}
class NativeXmlState {
var cur:Xml;
public function new(x:Xml) {
x._children = new Array<Xml>();
cur = x;
}
@:keep
public function xml(name:String, att:Dynamic<String>) {
var x = new Xml();
x._parent = cur;
x.nodeType = Xml.Element;
x._nodeName = name;
x._attributes = att;
x._children = new Array<Xml>();
cur.addChild(x);
cur = x;
}
@:keep
public function cdata(text:String) {
var x = new Xml();
x._parent = cur;
x.nodeType = Xml.CData;
x._nodeValue = text;
cur.addChild(x);
}
@:keep
public function pcdata(text:String) {
var x = new Xml();
x._parent = cur;
x.nodeType = Xml.PCData;
x._nodeValue = text;
cur.addChild(x);
}
@:keep
public function comment(text:String) {
var x = new Xml();
x._parent = cur;
if (text.length > 1 && StringTools.fastCodeAt(text, 0) == 63) {
x.nodeType = Xml.ProcessingInstruction;
text = text.substr(1, text.length - 2);
} else {
x.nodeType = Xml.Comment;
}
x._nodeValue = text;
cur.addChild(x);
}
@:keep
public function doctype(text:String) {
var x = new Xml();
x._parent = cur;
x.nodeType = Xml.DocType;
x._nodeValue = text.substr(1);
cur.addChild(x);
}
@:keep
public function done() {
cur = cur._parent;
}
}
private class NativeXmlIterator {
var cur = 0;
var children:Array<Xml>;
public function new(inChildren:Array<Xml>) {
children = inChildren;
cur = 0;
}
public function hasNext():Bool {
var k = cur;
var l = children.length;
while (k < l) {
if (children[k].nodeType == Xml.Element)
break;
k += 1;
}
cur = k;
return k < l;
}
public function next():Xml {
var k = cur;
var l = children.length;
while (k < l) {
var n = children[k];
k += 1;
if (n.nodeType == Xml.Element) {
cur = k;
return n;
}
}
return null;
}
}
private class NativeXmlNamedIterator {
var cur = 0;
var children:Array<Xml>;
var name:String;
public function new(inChildren:Array<Xml>, inName:String) {
children = inChildren;
name = inName;
cur = 0;
}
public function hasNext():Bool {
var k = cur;
var l = children.length;
while (k < l) {
var n = children[k];
if (n.nodeType == Xml.Element && n._nodeName == name)
break;
k++;
}
cur = k;
return k < l;
}
public function next():Xml {
var k = cur;
var l = children.length;
while (k < l) {
var n = children[k];
k++;
if (n.nodeType == Xml.Element && n._nodeName == name) {
cur = k;
return n;
}
}
return null;
}
}
@:cppInclude("./NativeXmlImport.cpp")
@:allow(cpp.NativeXmlState) @:allow(cpp.NativeXmlIterator) @:allow(cpp.NativeXmlNamedIterator)
class Xml {
static inline var Element = XmlType.Element;
static inline var PCData = XmlType.PCData;
static inline var CData = XmlType.CData;
static inline var Comment = XmlType.Comment;
static inline var DocType = XmlType.DocType;
static inline var ProcessingInstruction = XmlType.ProcessingInstruction;
static inline var Document = XmlType.Document;
private var _nodeName:String;
private var _nodeValue:String;
private var _attributes:Dynamic<String>;
private var _children:Array<Xml>;
private var _parent:Xml;
function new():Void {}
@:native("parse_xml")
extern static function parse_xml(str:String, state:NativeXmlState);
public static function parse(str:String):Xml {
var x = new Xml();
var state = new NativeXmlState(x);
parse_xml(str, state);
x.nodeType = Xml.Document;
return x;
}
public static function createElement(name:String):Xml {
var r = new Xml();
r.nodeType = Xml.Element;
r._nodeName = name;
r._attributes = null;
r._children = new Array();
return r;
}
public static function createPCData(data:String):Xml {
var r = new Xml();
r.nodeType = Xml.PCData;
r._nodeValue = data;
return r;
}
public static function createCData(data:String):Xml {
var r = new Xml();
r.nodeType = Xml.CData;
r._nodeValue = data;
return r;
}
public static function createComment(data:String):Xml {
var r = new Xml();
r.nodeType = Xml.Comment;
r._nodeValue = data;
return r;
}
public static function createDocType(data:String):Xml {
var r = new Xml();
r.nodeType = Xml.DocType;
r._nodeValue = data;
return r;
}
public static function createProcessingInstruction(data:String):Xml {
var r = new Xml();
r.nodeType = Xml.ProcessingInstruction;
r._nodeValue = data;
return r;
}
public static function createDocument():Xml {
var r = new Xml();
r.nodeType = Xml.Document;
r._children = new Array();
return r;
}
public var nodeType(default, null):XmlType;
public var nodeName(get, set):String;
public var nodeValue(get, set):String;
private function get_nodeName():String {
if (nodeType != Xml.Element)
throw "bad nodeType";
return _nodeName;
}
private function set_nodeName(n:String):String {
if (nodeType != Xml.Element)
throw "bad nodeType";
return _nodeName = n;
}
private function get_nodeValue():String {
if (nodeType == Xml.Element || nodeType == Xml.Document)
throw "bad nodeType";
return _nodeValue;
}
private function set_nodeValue(v:String):String {
if (nodeType == Xml.Element || nodeType == Xml.Document)
throw "bad nodeType";
return _nodeValue = v;
}
public var parent(get, null):Xml;
private function get_parent():Xml {
return _parent;
}
public function get(att:String):String {
if (nodeType != Xml.Element)
throw "bad nodeType";
return Reflect.field(_attributes, att);
}
public function set(att:String, value:String):Void {
if (nodeType != Xml.Element)
throw "bad nodeType";
if (_attributes == null)
_attributes = {};
Reflect.setField(_attributes, att, value);
return;
}
public function remove(att:String):Void {
if (nodeType != Xml.Element)
throw "bad nodeType";
Reflect.deleteField(_attributes, att);
return;
}
public function exists(att:String):Bool {
if (nodeType != Xml.Element)
throw "bad nodeType";
return Reflect.hasField(_attributes, att);
}
public function attributes():Iterator<String> {
if (nodeType != Xml.Element)
throw "bad nodeType";
return Reflect.fields(_attributes).iterator();
}
public function iterator():Iterator<Xml> {
if (_children == null)
throw "bad nodetype";
return untyped _children.iterator();
}
public function elements():Iterator<Xml> {
if (_children == null)
throw "bad nodetype";
return new NativeXmlIterator(_children);
}
public function elementsNamed(name:String):Iterator<Xml> {
if (_children == null)
throw "bad nodetype";
return new NativeXmlNamedIterator(_children, name);
}
public function firstChild():Xml {
if (_children == null)
throw "bad nodetype";
return _children[0];
}
public function firstElement():Xml {
if (_children == null)
throw "bad nodetype";
for (cur in 0..._children.length) {
var n:Xml = _children[cur];
if (n.nodeType == Xml.Element)
return n;
}
return null;
}
public function addChild(x:Xml):Void {
if (_children == null)
throw "bad nodetype";
if (x._parent != null)
x._parent._children.remove(x);
x._parent = this;
_children.push(x);
return;
}
public function removeChild(x:Xml):Bool {
if (_children == null)
throw "bad nodetype";
var b = _children.remove(x);
if (b)
x._parent = null;
return b;
}
public function insertChild(x:Xml, pos:Int):Void {
if (_children == null)
throw "bad nodetype";
if (x._parent != null)
x._parent._children.remove(x);
x._parent = this;
_children.insert(pos, x);
return;
}
public function toString():String {
var s = new StringBuf();
toStringRec(s);
return s.toString();
}
private function toStringRec(s:StringBuf):Void {
switch (nodeType) {
case Xml.Document:
for (x in _children)
x.toStringRec(s);
case Xml.Element:
s.addChar("<".code);
s.add(_nodeName);
for (k in Reflect.fields(_attributes)) {
s.addChar(" ".code);
s.add(k);
s.addChar("=".code);
s.addChar("\"".code);
s.add(Reflect.field(_attributes, k));
s.addChar("\"".code);
}
if (_children.length == 0) {
s.addChar("/".code);
s.addChar(">".code);
return;
}
s.addChar(">".code);
for (x in _children)
x.toStringRec(s);
s.addChar("<".code);
s.addChar("/".code);
s.add(_nodeName);
s.addChar(">".code);
case Xml.PCData:
s.add(StringTools.htmlEscape(_nodeValue));
case Xml.CData:
s.add("<![CDATA[");
s.add(_nodeValue);
s.add("]]>");
case Xml.Comment:
s.add("<!--");
s.add(_nodeValue);
s.add("-->");
case Xml.DocType:
s.add("<!DOCTYPE ");
s.add(_nodeValue);
s.add(">");
case Xml.ProcessingInstruction:
s.add("<?");
s.add(_nodeValue);
s.add("?>");
}
}
}

View File

@ -0,0 +1,386 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifdef EPPC
#include <memory>
#else
#include <memory.h>
#endif
#ifndef HX_WINDOWS
# include <strings.h>
# undef strcmpi
# define strcmpi(a,b) strcasecmp(a,b)
#else
# include <string.h>
#endif
// -------------- parsing --------------------------
enum STATE {
IGNORE_SPACES,
BEGIN,
BEGIN_NODE,
TAG_NAME,
BODY,
ATTRIB_NAME,
EQUALS,
ATTVAL_BEGIN,
ATTRIB_VAL,
CHILDS,
CLOSE,
WAIT_END,
WAIT_END_RET,
PCDATA,
HEADER,
COMMENT,
DOCTYPE,
CDATA,
};
static void xml_error( const char *xml, const char *inWhere, int *line, String msg ) {
String b = HX_CSTRING("Xml parse error : ") + msg + HX_CSTRING(" at line ") + String(*line) + HX_CSTRING(" : ");
String where(inWhere);
int l = where.length;
int nchars = 30;
if( inWhere != xml )
b += HX_CSTRING("...");
if (where.length==0)
b+= HX_CSTRING("<eof>");
else if (where.length<nchars)
b+= where;
else
b+= where.substr(0,nchars) + HX_CSTRING("...");
hx::Throw(b);
}
#define ERRORSTR(msg) xml_error(xml,p,line,msg);
#define ERROR(msg) xml_error(xml,p,line,HX_CSTRING(msg));
static bool is_valid_char( int c ) {
return ( c >= 'a' && c <= 'z' ) || ( c >= 'A' && c <= 'Z' ) || ( c >= '0' && c <= '9' ) || c == ':' || c == '.' || c == '_' || c == '-';
}
static void do_parse_xml( const char *xml, const char **lp, int *line, cpp::NativeXmlState callb, String parentname )
{
STATE state = BEGIN;
STATE next = BEGIN;
String aname;
hx::Anon attribs;
String nodename;
const char *start = NULL;
const char *p = *lp;
char c = *p;
int nsubs = 0, nbrackets = 0;
while( c ) {
switch( state ) {
case IGNORE_SPACES:
switch( c ) {
case '\n':
case '\r':
case '\t':
case ' ':
break;
default:
state = next;
continue;
}
break;
case BEGIN:
switch( c ) {
case '<':
state = IGNORE_SPACES;
next = BEGIN_NODE;
break;
default:
start = p;
state = PCDATA;
continue;
}
break;
case PCDATA:
if( c == '<' ) {
callb->pcdata(String(start,p-start).dup());
nsubs++;
state = IGNORE_SPACES;
next = BEGIN_NODE;
}
break;
case CDATA:
if( c == ']' && p[1] == ']' && p[2] == '>' ) {
callb->cdata(String(start,p-start).dup());
nsubs++;
p += 2;
state = BEGIN;
}
break;
case BEGIN_NODE:
switch( c ) {
case '!':
if( p[1] == '[' ) {
p += 2;
if( (p[0] != 'C' && p[0] != 'c') ||
(p[1] != 'D' && p[1] != 'd') ||
(p[2] != 'A' && p[2] != 'a') ||
(p[3] != 'T' && p[3] != 't') ||
(p[4] != 'A' && p[4] != 'a') ||
(p[5] != '[') )
ERROR("Expected <![CDATA[");
p += 5;
state = CDATA;
start = p + 1;
break;
}
if( p[1] == 'D' || p[1] == 'd' ) {
if( (p[2] != 'O' && p[2] != 'o') ||
(p[3] != 'C' && p[3] != 'c') ||
(p[4] != 'T' && p[4] != 't') ||
(p[5] != 'Y' && p[5] != 'y') ||
(p[6] != 'P' && p[6] != 'p') ||
(p[7] != 'E' && p[7] != 'e') )
ERROR("Expected <!DOCTYPE");
p += 7;
state = DOCTYPE;
start = p + 1;
break;
}
if( p[1] != '-' || p[2] != '-' )
ERROR("Expected <!--");
p += 2;
state = COMMENT;
start = p + 1;
break;
case '?':
state = HEADER;
start = p;
break;
case '/':
if( parentname.length==0 )
ERROR("Expected node name");
start = p + 1;
state = IGNORE_SPACES;
next = CLOSE;
break;
default:
state = TAG_NAME;
start = p;
continue;
}
break;
case TAG_NAME:
if( !is_valid_char(c) ) {
if( p == start )
ERROR("Expected node name");
nodename = String(start,p-start).dup();
attribs = hx::Anon_obj::Create();
state = IGNORE_SPACES;
next = BODY;
continue;
}
break;
case BODY:
switch( c ) {
case '/':
state = WAIT_END;
nsubs++;
callb->xml(nodename,attribs);
break;
case '>':
state = CHILDS;
nsubs++;
callb->xml(nodename,attribs);
break;
default:
state = ATTRIB_NAME;
start = p;
continue;
}
break;
case ATTRIB_NAME:
if( !is_valid_char(c) ) {
if( start == p )
ERROR("Expected attribute name");
aname = String(start,p-start).dup();
if( attribs->__Field(aname,hx::paccDynamic) != null() )
ERROR("Duplicate attribute");
state = IGNORE_SPACES;
next = EQUALS;
continue;
}
break;
case EQUALS:
switch( c ) {
case '=':
state = IGNORE_SPACES;
next = ATTVAL_BEGIN;
break;
default:
ERROR("Expected =");
}
break;
case ATTVAL_BEGIN:
switch( c ) {
case '"':
case '\'':
state = ATTRIB_VAL;
start = p;
break;
default:
ERROR("Expected \"");
}
break;
case ATTRIB_VAL:
if( c == *start ) {
attribs->Add( aname, String(start+1,p-start-1).dup() );
state = IGNORE_SPACES;
next = BODY;
}
break;
case CHILDS:
*lp = p;
do_parse_xml(xml,lp,line,callb,nodename);
p = *lp;
start = p;
state = BEGIN;
break;
case WAIT_END:
switch( c ) {
case '>':
callb->done();
state = BEGIN;
break;
default :
ERROR("Expected >");
}
break;
case WAIT_END_RET:
switch( c ) {
case '>':
if( nsubs == 0 )
callb->pcdata(HX_CSTRING(""));
*lp = p;
return;
default :
ERROR("Expected >");
}
break;
case CLOSE:
if( !is_valid_char(c) ) {
if( start == p )
ERROR("Expected node name");
{
String v = String(start,p - start).dup();
if( strcmpi(parentname.__s,v.__s) != 0 ) {
ERRORSTR(HX_CSTRING("Expected </") + parentname + HX_CSTRING(">"));
}
}
state = IGNORE_SPACES;
next = WAIT_END_RET;
continue;
}
break;
case COMMENT:
if( c == '-' && p[1] == '-' && p[2] == '>' ) {
callb->comment(String(start,p-start).dup());
p += 2;
state = BEGIN;
}
break;
case DOCTYPE:
if( c == '[' )
nbrackets++;
else if( c == ']' )
nbrackets--;
else if( c == '>' && nbrackets == 0 ) {
callb->doctype(String(start,p-start).dup());
state = BEGIN;
}
break;
case HEADER:
if( c == '?' && p[1] == '>' ) {
p++;
callb->comment(String(start,p-start).dup());
state = BEGIN;
}
break;
}
c = *++p;
if( c == '\n' )
(*line)++;
}
if( state == BEGIN ) {
start = p;
state = PCDATA;
}
if( parentname.__s == 0 && state == PCDATA ) {
if( p != start || nsubs == 0 )
callb->pcdata(String(start,p-start).dup());
return;
}
ERROR("Unexpected end");
}
// ----------------------------------------------
/**
<doc>
<h1>Xml</h1>
<p>
The standard event-driven XML parser.
</p>
</doc>
**/
/**
parse_xml : xml:string -> events:object -> void
<doc>
The [parse_xml] parse a string and for each parsed element call the
corresponding object method in [events] :
<ul>
<li>[void xml( name : string, attribs : object)] when an XML node is found</li>
<li>[void done()] when an XML node is closed</li>
<li>[void pcdata(string)] when PCData chars found</li>
<li>[void cdata(string)] when a CData session is found</li>
<li>[void comment(string)] when some comment or special header is found</li>
</ul>
You can then implement the events so they build the appropriate XML data
structure needed by your language.
</doc>
**/
static void parse_xml( String str, cpp::NativeXmlState state )
{
int line = 0;
const char *p = str.__s;
// skip BOM
if( p[0] == (char)0xEF && p[1] == (char)0xBB && p[2] == (char)0xBF )
p += 3;
do_parse_xml(p,&p,&line,state,String());
}

View File

@ -0,0 +1,26 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:noPackageRestrict
typedef Object = Dynamic;

View File

@ -0,0 +1,39 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
extern class ObjectType {
inline static var vtUnknown = -1;
inline static var vtInt = 0xff;
inline static var vtNull = 0;
inline static var vtFloat = 1;
inline static var vtBool = 2;
inline static var vtString = 3;
inline static var vtObject = 4;
inline static var vtArray = 5;
inline static var vtFunction = 6;
inline static var vtEnum = 7;
inline static var vtClass = 8;
inline static var vtInt64 = 9;
inline static var vtAbstractBase = 0x100;
}

View File

@ -0,0 +1,86 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
import haxe.extern.AsVar;
@:coreType
@:semantics(variable)
extern class Pointer<T> extends ConstPointer<T> implements ArrayAccess<T> {
var ref(get, set):Reference<T>;
function get_ref():Reference<T>;
function set_ref(t:T):Reference<T>;
function setAt(inIndex:Int, value:T):Void;
static function fromRaw<T>(ptr:RawPointer<T>):Pointer<T>;
@:native("::cpp::Pointer_obj::fromRaw")
static function fromStar<T>(star:Star<T>):Pointer<T>;
@:native("::cpp::Pointer_obj::fromHandle")
static function nativeFromHandle<T>(inHandle:Dynamic, ?inKind:String):AutoCast;
inline static function fromHandle<T>(inHandle:Dynamic, ?inKind:String):Pointer<T> {
return cast nativeFromHandle(inHandle, inKind);
}
static function fromPointer<T>(inNativePointer:Dynamic):Pointer<T>;
static function addressOf<T>(inVariable:cpp.Reference<T>):Pointer<T>;
static function endOf<T:{}>(inVariable:T):Pointer<cpp.Void>;
@:native("::cpp::Pointer_obj::arrayElem")
static function nativeArrayElem<T>(array:Array<T>, inElem:Int):AutoCast;
inline static function arrayElem<T>(array:Array<T>, inElem:Int):Pointer<T> {
return cast nativeArrayElem(array, inElem);
}
@:native("::cpp::Pointer_obj::ofArray")
static function nativeOfArray<T>(array:Array<T>):AutoCast;
inline static function ofArray<T>(array:Array<T>):Pointer<T> {
return cast nativeOfArray(array);
}
inline function toUnmanagedArray(elementCount:Int):Array<T> {
var result = new Array<T>();
NativeArray.setUnmanagedData(result, this, elementCount);
return result;
}
inline function toUnmanagedVector(elementCount:Int):haxe.ds.Vector<T>
return cast toUnmanagedArray(elementCount);
override function inc():Pointer<T>;
override function dec():Pointer<T>;
override function incBy(inT:Int):Pointer<T>;
override function decBy(inT:Int):Pointer<T>;
override function add(inT:Int):Pointer<T>;
override function sub(inT:Int):Pointer<T>;
function postIncRef():Reference<T>;
function destroy():Void;
function destroyArray():Void;
}

View File

@ -0,0 +1,117 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
#if macro
import haxe.macro.Context;
import haxe.macro.Type;
import haxe.macro.Expr;
#end
@:noPackageRestrict
class Prime {
#if (!macro && cpp)
public static function _loadPrime(lib:String, prim:String, signature:String, quietFail = false):Dynamic {
var factory:Callable<ConstCharStar->Object> = untyped __global__.__hxcpp_cast_get_proc_address(lib, prim + "__prime", quietFail);
if (factory != null) {
var func:Dynamic = factory.call(signature);
if (func == null && !quietFail)
throw '$prim does not have signature $signature';
return func;
}
return null;
}
#end
#if (macro)
static function codeToType(code:String, forCpp:Bool):String {
if (code == "c" && !forCpp)
throw "const char * type only supported in cpp mode";
switch (code) {
case "b":
return "Bool";
case "i":
return "Int";
case "d":
return "Float";
case "s":
return "String";
case "f":
return forCpp ? "cpp.Float32" : "Float";
case "o":
return forCpp ? "cpp.Object" : "Dynamic";
case "v":
return forCpp ? "cpp.Void" : "Dynamic";
case "c":
return "cpp.ConstCharStar";
default:
throw "Unknown signature type :" + code;
}
}
#end
public static function nekoInit(inModuleName:String):Bool {
#if neko
var init = neko.Lib.load(inModuleName, "neko_init", 5);
if (init != null) {
init(function(s) return new String(s), function(len:Int) {
var r = [];
if (len > 0)
r[len - 1] = null;
return r;
}, null, true, false);
return true;
}
#end
return false;
}
public static macro function load(inModule:String, inName:String, inSig:String, inAllowFail:Bool = false) {
var parts = inSig.split("");
if (parts.length < 1)
throw "Invalid function signature " + inSig;
var argCount = parts.length - 1;
var cppiaMode = Context.defined("cppia");
var cppMode = Context.defined("cpp") && !cppiaMode;
var typeString = parts.length == 1 ? "Void" : codeToType(parts.shift(), cppMode);
for (p in parts)
typeString += "->" + codeToType(p, cppMode);
if (cppMode) {
typeString = "cpp.Callable<" + typeString + ">";
var expr = 'new $typeString(cpp.Prime._loadPrime("$inModule","$inName","$inSig",$inAllowFail))';
return Context.parse(expr, Context.currentPos());
} else {
if (argCount > 5)
argCount = -1;
var lazy = inAllowFail ? "loadLazy" : "load";
var lib = cppiaMode ? "cpp" : "neko";
var expr = 'new cpp.Callable<$typeString>($lib.Lib.$lazy("$inModule","$inName",$argCount))';
return Context.parse(expr, Context.currentPos());
}
}
}

View File

@ -0,0 +1,43 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
class Random {
var r:Dynamic;
public function new() {
r = cpp.NativeRandom.random_new();
}
public function setSeed(s:Int) {
cpp.NativeRandom.random_set_seed(r, s);
}
public function int(max:Int):Int {
return cpp.NativeRandom.random_int(r, max);
}
public function float():Float {
return cpp.NativeRandom.random_float(r);
}
}

View File

@ -0,0 +1,29 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:unreflective
extern class RawConstPointer<T> implements ArrayAccess<T> {
@:native("::hx::AddressOf")
static function addressOf<T>(t:T):RawConstPointer<T>;
}

View File

@ -0,0 +1,29 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:unreflective
extern class RawPointer<T> extends RawConstPointer<T> {
@:native("::hx::AddressOf")
static function addressOf<T>(t:T):RawPointer<T>;
}

View File

@ -0,0 +1,30 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
/**
Allows haxe to type result correctly, and hxcpp can recognise this and
prevent unwanted casting.
**/
@:semantics(reference)
typedef Reference<T> = T;

View File

@ -0,0 +1,25 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
abstract Rest<T>(Array<T>) {}

View File

@ -0,0 +1,27 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:native("size_t")
@:scalar @:coreType @:notNull
extern abstract SizeT from(Int) to(Int) {}

View File

@ -0,0 +1,29 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
/**
Allows haxe to type result correctly, and hxcpp can recognise this use the
correct type.
**/
typedef Star<T> = Null<T>;

View File

@ -0,0 +1,49 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
using cpp.NativeString;
@:native("::hx::StdString")
@:include("hx/StdString.h")
@:stackOnly
@:structAccess
@:unreflective
extern class StdString {
@:native("std::string::npos")
static var npos(default, null):Int;
// function new(inData:StdStringData);
@:native("::hx::StdString")
static function ofString(s:String):StdString;
// function toString():String;
// function find(s:String):Int;
// function substr(pos:Int, len:Int):StdString;
function c_str():ConstPointer<Char>;
function size():Int;
function find(s:String):Int;
function substr(pos:Int, len:Int):StdString;
function toString():String;
function toStdString():StdString;
}

View File

@ -0,0 +1,37 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
using cpp.NativeString;
@:native("::hx::StdString const &")
@:include("hx/StdString.h")
@:structAccess
extern class StdStringRef {
function c_str():ConstPointer<Char>;
function size():Int;
function find(s:String):Int;
function substr(pos:Int, len:Int):StdString;
function toString():String;
function toStdString():StdString;
}

View File

@ -0,0 +1,41 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:include("stdio.h")
extern class Stdio {
@:native("printf")
static function printf(format:ConstCharStar, rest:Rest<VarArg>):Void;
@:native("fopen")
static function fopen(filename:ConstCharStar, mode:ConstCharStar):FILE;
@:native("fwrite")
static function fwrite<T>(data:RawPointer<T>, elemSize:SizeT, elemCount:SizeT, file:FILE):SizeT;
@:native("fclose")
static function fclose(file:FILE):Int;
@:native("fprintf")
static function fprintf(file:FILE, format:ConstCharStar, rest:Rest<VarArg>):Void;
}

View File

@ -0,0 +1,59 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:include("stdlib.h")
extern class Stdlib {
@:native("malloc")
static function nativeMalloc(bytes:Int):cpp.RawPointer<cpp.Void>;
@:native("calloc")
static function nativeCalloc(bytes:Int):cpp.RawPointer<cpp.Void>;
@:native("realloc")
static function nativeRealloc(inPtr:cpp.RawPointer<cpp.Void>, bytes:Int):cpp.RawPointer<cpp.Void>;
@:native("free")
static function nativeFree(ptr:cpp.RawPointer<cpp.Void>):Void;
@:native("memcpy")
static function nativeMemcpy(dest:cpp.RawPointer<cpp.Void>, src:cpp.RawConstPointer<cpp.Void>, bytes:Int):Void;
@:native("::hx::ClassSizeOf") @:templatedCall
static function sizeof<T>(t:T):Int;
inline static function memcpy<DEST, SRC>(dest:cpp.Pointer<DEST>, src:cpp.ConstPointer<SRC>, bytes:Int):Void
nativeMemcpy(cast dest.ptr, cast src.ptr, bytes);
inline static function malloc<T>(bytes:Int):cpp.Pointer<T>
return cast nativeMalloc(bytes);
inline static function calloc<T>(bytes:Int):cpp.Pointer<T>
return cast nativeCalloc(bytes);
inline static function realloc<T>(ioPtr:cpp.Pointer<T>, bytes:Int):Void
ioPtr.setRaw(nativeRealloc(cast ioPtr.ptr, bytes));
inline static function free<T>(ptr:cpp.Pointer<T>):Void {
if (ptr != null) {
nativeFree(cast ptr.ptr);
ptr.ptr = null;
}
}
}

View File

@ -0,0 +1,28 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
/**
Wraps external types with a class that integrates with Dynamic.
**/
typedef Struct<T> = T;

View File

@ -0,0 +1,25 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:coreType @:notNull @:runtimeValue abstract UInt16 from Int to Int {}

View File

@ -0,0 +1,25 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:coreType @:notNull @:runtimeValue abstract UInt32 from Int to Int {}

View File

@ -0,0 +1,25 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:coreType @:notNull @:runtimeValue abstract UInt64 from Int to Int {}

View File

@ -0,0 +1,25 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:coreType @:notNull @:runtimeValue abstract UInt8 from Int to Int {}

View File

@ -0,0 +1,29 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
/**
Allows haxe to type params correctly, and hxcpp can recognise this use the
correct type.
**/
typedef VarArg = Dynamic;

View File

@ -0,0 +1,136 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package cpp;
@:native("cpp::VirtualArray")
@:coreType extern class NativeVirtualArray implements ArrayAccess<Dynamic> {
function new():Void;
var length(get, null):Int;
// concat<T>( a:Array<T> ) : Array<T> ?
function concat(a:VirtualArray):VirtualArray;
function join(sep:String):String;
function pop():Dynamic;
function push(x:Dynamic):Int;
function reverse():Void;
function shift():Dynamic;
function slice(pos:Int, ?end:Int):VirtualArray;
function sort(f:Dynamic->Dynamic->Int):Void;
function splice(pos:Int, len:Int):VirtualArray;
function toString():String;
function unshift(x:Dynamic):Void;
function insert(pos:Int, x:Dynamic):Void;
function remove(x:Dynamic):Bool;
function indexOf(x:Dynamic, ?fromIndex:Int):Int;
function lastIndexOf(x:Dynamic, ?fromIndex:Int):Int;
function copy():VirtualArray;
function iterator():Iterator<Dynamic>;
function keyValueIterator():KeyValueIterator<Int, Dynamic>;
function map<S>(f:Dynamic->S):VirtualArray;
function filter(f:Dynamic->Bool):VirtualArray;
function resize(len:Int):Void;
}
abstract VirtualArray(NativeVirtualArray) {
// Add these two functions...
@:from extern inline static public function fromArray<T>(a:Array<T>):VirtualArray
return untyped a;
@:to extern inline public function toArray<T>():Array<T>
return untyped this;
// The rest is just boiler-plate
inline public function new()
this = new NativeVirtualArray();
@:arrayAccess extern inline function get(idx:Int):Dynamic
return untyped this[idx];
@:arrayAccess extern inline function set<T>(pos:Int, value:T):T
return untyped this[idx] = value;
public var length(get, never):Int;
extern inline public function get_length():Int
return this.length;
// concat<T>( a:Array<T> ) : Array<T> ?
extern inline public function concat(a:VirtualArray):VirtualArray
return this.concat(a);
extern inline public function join(sep:String):String
return this.join(sep);
extern inline public function pop():Dynamic
return this.pop();
extern inline public function push(x:Dynamic):Int
return this.push(x);
extern inline public function reverse():Void
this.reverse();
extern inline public function shift():Dynamic
return this.shift();
extern inline public function slice(pos:Int, ?end:Int):VirtualArray
return this.slice(pos, end);
extern inline public function sort(f:Dynamic->Dynamic->Int):Void
this.sort(f);
extern inline public function splice(pos:Int, len:Int):VirtualArray
return this.slice(pos, len);
extern inline public function unshift(x:Dynamic):Void
this.unshift(x);
extern inline public function insert(pos:Int, x:Dynamic):Void
this.insert(pos, x);
extern inline public function remove(x:Dynamic):Bool
return this.remove(x);
extern inline public function indexOf(x:Dynamic, ?fromIndex:Int):Int
return this.indexOf(x, fromIndex);
extern inline public function lastIndexOf(x:Dynamic, ?fromIndex:Int):Int
return this.lastIndexOf(x, fromIndex);
extern inline public function copy():VirtualArray
return this.copy();
extern inline public function iterator():Iterator<Dynamic>
return this.iterator();
extern inline public function keyValueIterator():KeyValueIterator<Int, Dynamic>
return this.keyValueIterator();
extern inline public function map<S>(f:Dynamic->S):VirtualArray
return this.map(f);
extern inline public function filter(f:Dynamic->Bool):VirtualArray
return this.filter(f);
extern inline public function resize(len:Int):Void
return this.resize(len);
}

Some files were not shown because too many files have changed in this diff Show More