Repository navigation
Cva Copy
Home › Procedures › Cva_Copy
Macro to initialize variadic argument list object variable from an already initialized variadic argument list object variable
Cva_Copy( dst_list, src_list )dst_listsrc_list
Copies one Cva_List type variable to another Cva_List type variable. dst_list is initialized using current state of src_list
src_list must already have been initialized with a previous Cva_Start or Cva_Copy statement.
Cva_Copy is like a copy constructor for the a variadic argument list object and must eventually have a matching call to Cva_End, which is like the destructor. After Cva_End for dst_list has been called, dst_list can be reused and reinitialized with another call to Cva_Start or Cva_Copy. The Cva_Copy and Cva_End calls must both be called in the same procedure (for cross platform compatibility).
- Not available in the -lang qb dialect unless referenced with the alias
__cva_copy.
- New to FreeBASIC
'' example of using cva_copy to create
'' a copy of the variable argument list
Sub proc cdecl(count As Integer, ... )
Dim args1 As Cva_List
Dim args2 As Cva_List
'' first list
Cva_Start( args1, count )
'' create a copy
Cva_Copy( args2, args1 )
For i As Integer = 1 To count
Print Cva_Arg( args1, Integer ), Cva_Arg( args2, Integer )
Next
'' clean-up
Cva_End( args2 )
Cva_End( args1 )
End Sub
proc( 4, 4000, 300, 20, 1 )'' example of using cva_copy to create
'' a copy of the variable argument list
'' and pass it to another procedure
Sub vproc cdecl(count As Integer, ByRef args As Cva_List )
'' if we don't know that caller made a copy
'' of args, it is safe to make our own copy
'' and leave the passed in args untouched
Dim a As Cva_List
Cva_Copy( a, args )
Print "vproc"
For i As Integer = 1 To count
Print Cva_Arg( a, Integer )
Next
'' clean-up
Cva_End( a )
End Sub
Sub proc cdecl(count As Integer, ... )
Dim args As Cva_List
Cva_Start( args, count )
'' if don't know that the called procedure
'' will make it's own copy, it is safe to
'' make a copy here and pass that instead
Dim tmp As Cva_List
Cva_Copy( tmp, args )
vproc( count, tmp )
Cva_End( tmp )
'' args is still valid, we can use it
Print "proc"
For i As Integer = 1 To count
Print Cva_Arg( args, Integer )
Next
'' clean-up
Cva_End( args )
End Sub
proc( 4, 4000, 300, 20, 1 )Category: Procedures
Kind: keyword
Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing