Foreshore and seabed property rights and resource use
by
Robin Johnson
Poster/Paper, Frontiers in Resource Management: the 7th Annual AARES Symposium, 6-7 October 2004, Auckland, New Zealand.
Theory
- Setting the rules for the rational and fair access to
economic resources.
- Commerce flows from a set of well-designed property rights.
- Should they be set in some abstract far-off world of reason
or ground out in a maelstrom of debate and controversy?
Background
Debate about property rights to the
foreshore and seabed land margins
erupted in 2003 following a High Court
decision to allow maori to take perceived
access issues to the maori land court.
At the heart of the debate is the issue
whether the early administrative
arrangements for land ownership
following annexation of New Zealand in 1840
sufficiently allowed for customary
rights?
The Treaty of Waitangi established among
other things that maori would retain
'full exclusive and undisturbed posession
of their lands and estates forests
fisheries and such other properties as they
may collectively or individually posess,
so long as it is their wish and desire to
retain the same in their posession'.
Governor Grey brought the Torrens
system of land registration with him from
South Australia in the 1840s. Registered
land title was open to all races and
further legislation protected the rights
of Maori over subsequent years ( e.g. the
Maori land court etc).
The foreshore and seabed ownership was
never clearly defined and successive
legislators came to assume that all Maori
rights were extinguished. it was this issue
which came before the High Court and
Court of Appeal in 2003 in a case concerning
the Marlborough tribes' access to
aquaculture sites in Marlborough Sounds.
The Court of Appeal confirmed a High
Court ruling that Maori common law
rights in the foreshore and seabed have
never been extinguished and that the
Maori Land Court was able to declare such
land to be customary land. land below the
low water mark was deemed to be clearly
owned by the Crown due to the particular
statutes concerned.
In response, the government drafted
legislation which nationalised the
foreshore and seabed in the interests of
all New Zealanders with regard to access
and existing rights. Provision was to be
made for Maori to have access to the
courts to establish continuous customary
use of particular sites.
Aboriginal rights in Australia
In the 1992 Mabo case the High Court of
Australia said that the Meriam people had
the right to posess their land on Mer
Island in the Torres Strait according to
their traditional law and custom.
Australian law, for the first time, said
that Aboriginal and Torres Strait islander
people have rights to their country,
according to their traditional laws and
customs.
These rights may be recognised when
people have maintained a continuing
connection with their land and waters and
their rights have not been removed by
government.
Native title is the name given to the rights
of these people and is a unique form of
land title, different from freehold or
leashold titles. Native title cannot be
bought or sold.
Native title is not a land right that
government gives to indigenous people. It
is a right that already exists in places
where indigenous people follow their
traditional laws and customs and have a
continuing connection to their land and
waters.
Source: native title coexistence, national native title tribunal, c1994.
Implications for resources
- The common law approach identified
that the area between high and low
water marks was originally acquired by
the Crown under the Treaty along with
any pre-existing Maori customary
property rights. These rights have never
been extinguished.
- The vast majority of New Zealand land
was converted to a fee simple basis thus
extinguishing any customary rights. As for
land below the high water mark, there
was a general supposition before the
Marlborough Sounds decision that any
customary rights in that zone had been
extinguished when the customary rights
to the contiguous dry land were
extinguished. That supposition was
bolstered by a belief in many quarters
(including influential judicial and legal
quarters) that the Crown owned the
foreshore and seabed anyway as part of
its prerogative right.
- The judges considered the application in
New Zealand of the common law doctrine
of aboriginal title. Aboriginal title is a
mechanism to preserve the pre-existing
rights of indigenous people under their
own laws. It is judge made law. In Australia, Aboriginal rights are A
based on continuity of customary
property rights upon the Crown's
acquisition of sovereignty.
- So the judges in this case merely decided
that the Maoris had a right to establish
before the courts exactly what
customary rights remained.
- From a resource use point of view this
changed very little. The property right
still had to be re-established. Resource
use (in the form of exploitation of fishing
or acqaculture resources) cannot
proceed without first determining what
the right is.
- From a property rights point of view the
necessary conditions for exploitation
involve exclusivity and transferability.
The steps to establishing these conditions
have not yet been taken.
- Exclusivity would mean giving right
holders sole control over use of that
right. Transferability would mean that
the right could be transferred to others
possibly in some market transaction.
- Any solution must address the issue of
multiplicity and ranking of competing and
non-competing rights. Can ownership be
separated from use? Can access be granted
without prejudicing either ownership or
use?
- Expert witness Paul McHugh talks of a
bundle of rights. McHugh postulated that
Crown title to the foreshore did not mean
that the Crown was recognised as having
rights equivalent to full ownership –
access, rights of fishing, navigation and
innocent passge were recognised in
common law. The result is that the
Crown's rights in the foreshore and
seabed, at common law, amounted to a
'bundle of rights' less than full
ownership. This, it was argued, would lead
in turn to the Crown not being in the
position to grant anyone else full
ownership in this view.
- The result of this line of argument is
that no one has developed a theory of
multiple rights for the foreshore and
seabed where the different claims can be
accommodated in some total construct.
- In effect, government legislation to
nationalise the foreshore and seabed
achieves a new ownership structure with
the question of multiple access rights
within it still unresolved.
Questions
Are customary property rights outside current property law structures?
Will it take revolution and not evolution to changes these structures?
Is this a question of profound constitutional change and to be judged in
that context?
According to Judge Wickliffe of the Maori
Land Court "it is time to renegotiate the
unwritten constitution of Aotea/New
Zealand within the framework of the
Treaty of Waitangi, so that government
institutions can be realigned and
legitimated".
So, what follows?
References
Report on the Crown's Foreshore and Seabed Policy, WAI 1071,
Waitangi Tribunal Report, March 2004.
The Torrens Land Registration System and Customary Rights, by
Robin Johnson, New Zealand Association of Economists, June 2004.


IM ONLINE
L|O: {{account.lastLogin}}N/A
Expenses: ( {{account.studentExpensesCount}} )
Reports: ( {{account.reportsManagerReports.length}} )
Students: ( {{account.reportsManagerStudentsCount}} )
Reports:
Students
Created: {{account.created}}


Welcome to Knowtime.
Current Task
What are you working on?
Work for
Break for
minutes left until
minute break from
Browsing Activity
Clear
Site
Time
Percent
Blocked Websites
Empty
Submit
Reset


We can easily expose Sequelize model to REST interface with access control:
Hint: open this page in 2 different browser tabs - you can see that changes persist between clients!
| # | Name | Priority | Scored |
|---|---|---|---|
| {{ trophy.id }} Saving... | |||
It is done like this by providing a thick model (see source):
{{ codeSampleForCRUD }}


Calling C and Fortran Code¶
Though most code can be written in Julia, there are many high-quality,
mature libraries for numerical computing already written in C and
Fortran. To allow easy use of this existing code, Julia makes it simple
and efficient to call C and Fortran functions. Julia has a “no
boilerplate” philosophy: functions can be called directly from Julia
without any “glue” code, code generation, or compilation — even from the
interactive prompt. This is accomplished just by making an appropriate call
with ccall()
syntax, which looks like an ordinary function call.
The code to be called must be available as a shared library. Most C and
Fortran libraries ship compiled as shared libraries already, but if you
are compiling the code yourself using GCC (or Clang), you will need to
use the -shared
and -fPIC
options. The machine instructions
generated by Julia’s JIT are the same as a native C call would be, so
the resulting overhead is the same as calling a library function from C
code. (Non-library function calls in both C and Julia can be inlined and
thus may have even less overhead than calls to shared library functions.
When both libraries and executables are generated by LLVM, it is
possible to perform whole-program optimizations that can even optimize
across this boundary, but Julia does not yet support that. In the
future, however, it may do so, yielding even greater performance gains.)
Shared libraries and functions are referenced by a tuple of the
form (:function, "library")
or ("function", "library")
where function
is the C-exported function name. library
refers to the shared library
name: shared libraries available in the (platform-specific) load path
will be resolved by name, and if necessary a direct path may be specified.
A function name may be used alone in place of the tuple (just
:function
or "function"
). In this case the name is resolved within
the current process. This form can be used to call C library functions,
functions in the Julia runtime, or functions in an application linked to
Julia.
By default, Fortran compilers generate mangled names
(for example, converting function names to lowercase or uppercase,
often appending an underscore), and so to call a Fortran function via
ccall()
you must pass the mangled identifier corresponding to the rule
followed by your Fortran compiler. Also, when calling a Fortran
function, all inputs must be passed by reference.
Finally, you can use ccall()
to actually generate a call to the
library function. Arguments to ccall()
are as follows:
- (:function, “library”) pair (must be a constant, but see below).
- Return type (see below for mapping the declared C type to Julia)
- This argument will be evaluated at compile-time.
- A tuple of input types. The input types must be written as a literal tuple,
not a tuple-valued variable or expression.
- This argument will be evaluated at compile-time.
- The following arguments, if any, are the actual argument values passed to the function.
As a complete but simple example, the following calls the clock
function from the standard C library:
julia> t = ccall( (:clock, "libc"), Int32, ())
2292761
julia> t
2292761
julia> typeof(ans)
Int32
clock
takes no arguments and returns an Int32
. One common gotcha
is that a 1-tuple must be written with a trailing comma. For
example, to call the getenv
function to get a pointer to the value
of an environment variable, one makes a call like this:
julia> path = ccall((:getenv, "libc"), Cstring, (Cstring,), "SHELL")
Cstring(@0x00007fff5fbffc45)
julia> unsafe_string(path)
"/bin/bash"
Note that the argument type tuple must be written as (Cstring,)
,
rather than (Cstring)
. This is because (Cstring)
is just
the expression Cstring
surrounded by parentheses, rather than
a 1-tuple containing Cstring
:
julia> (Cstring)
Cstring
julia> (Cstring,)
(Cstring,)
In practice, especially when providing reusable functionality, one
generally wraps ccall()
uses in Julia functions that set up arguments
and then check for errors in whatever manner the C or Fortran function
indicates them, propagating to the Julia caller as exceptions. This is
especially important since C and Fortran APIs are notoriously
inconsistent about how they indicate error conditions. For example, the
getenv
C library function is wrapped in the following Julia function,
which is a simplified version of the actual definition from
env.jl:
function getenv(var::AbstractString)
val = ccall((:getenv, "libc"),
Cstring, (Cstring,), var)
if val == C_NULL
error("getenv: undefined variable: ", var)
end
unsafe_string(val)
end
The C getenv
function indicates an error by returning NULL
, but
other standard C functions indicate errors in various different ways,
including by returning -1, 0, 1 and other special values. This wrapper
throws an exception clearly indicating the problem if the caller tries
to get a non-existent environment variable:
julia> getenv("SHELL")
"/bin/bash"
julia> getenv("FOOBAR")
getenv: undefined variable: FOOBAR
Here is a slightly more complex example that discovers the local machine’s hostname:
function gethostname()
hostname = Array{UInt8}(128)
ccall((:gethostname, "libc"), Int32,
(Ptr{UInt8}, Csize_t),
hostname, sizeof(hostname))
hostname[end] = 0; # ensure null-termination
return unsafe_string(pointer(hostname))
end
This example first allocates an array of bytes, then calls the C library
function gethostname
to fill the array in with the hostname, takes a
pointer to the hostname buffer, and converts the pointer to a Julia
string, assuming that it is a NUL-terminated C string. It is common for
C libraries to use this pattern of requiring the caller to allocate
memory to be passed to the callee and filled in. Allocation of memory
from Julia like this is generally accomplished by creating an
uninitialized array and passing a pointer to its data to the C function.
This is why we don’t use the Cstring
type here: as the array is
uninitialized, it could contain NUL bytes. Converting to a Cstring
as
part of the ccall()
checks for contained NUL bytes and could therefore
throw a conversion error.
Creating C-Compatible Julia Function Pointers¶
It is possible to pass Julia functions to native C functions that accept function pointer arguments. For example, to match C prototypes of the form:
typedef returntype (*functiontype)(argumenttype,...)
The function cfunction()
generates the C-compatible function pointer for
a call to a Julia library function.
Arguments to cfunction()
are as follows:
- A Julia Function
- Return type
- A tuple of input types
A classic example is the standard C library qsort
function,
declared as:
void qsort(void *base, size_t nmemb, size_t size,
int(*compare)(const void *a, const void *b));
The base
argument is a pointer to an array of length nmemb
, with elements of
size
bytes each. compare
is a callback function which takes pointers to two
elements a
and b
and returns an integer less/greater than zero if a
should
appear before/after b
(or zero if any order is permitted). Now, suppose that we
have a 1d array A
of values in Julia that we want to sort using the qsort
function (rather than Julia’s built-in sort
function). Before we worry about calling
qsort
and passing arguments, we need to write a comparison function that works for
some arbitrary type T:
function mycompare{T}(a::T, b::T)
return convert(Cint, a < b ? -1 : a > b ? +1 : 0)::Cint
end
Notice that we have to be careful about the return type: qsort
expects a function
returning a C int
, so we must be sure to return Cint
via a call to convert
and a typeassert
.
In order to pass this function to C, we obtain its address using the function cfunction
:
const mycompare_c = cfunction(mycompare, Cint, (Ref{Cdouble}, Ref{Cdouble}))
cfunction()
accepts three arguments: the Julia function (mycompare
),
the return type (Cint
), and a tuple of the argument types, in this case to
sort an array of Cdouble
(Float64
) elements.
The final call to qsort
looks like this:
A = [1.3, -2.7, 4.4, 3.1]
ccall(:qsort, Void, (Ptr{Cdouble}, Csize_t, Csize_t, Ptr{Void}),
A, length(A), sizeof(eltype(A)), mycompare_c)
After this executes, A
is changed to the sorted array [-2.7, 1.3, 3.1, 4.4]
.
Note that Julia knows how to convert an array into a Ptr{Cdouble}
, how to compute
the size of a type in bytes (identical to C’s sizeof
operator), and so on.
For fun, try inserting a println("mycompare($a,$b)")
line into mycompare
, which
will allow you to see the comparisons that qsort
is performing (and to verify that
it is really calling the Julia function that you passed to it).
Mapping C Types to Julia¶
It is critical to exactly match the declared C type with its declaration in Julia. Inconsistencies can cause code that works correctly on one system to fail or produce indeterminate results on a different system.
Note that no C header files are used anywhere in the process of calling C functions: you are responsible for making sure that your Julia types and call signatures accurately reflect those in the C header file. (The Clang package can be used to auto-generate Julia code from a C header file.)
Auto-conversion:¶
Julia automatically inserts calls to the cconvert()
function to convert
each argument to the specified type. For example, the following call:
ccall((:foo, "libfoo"), Void, (Int32, Float64), x, y)
will behave as if the following were written:
ccall((:foo, "libfoo"), Void, (Int32, Float64),
Base.unsafe_convert(Int32, Base.cconvert(Int32, x)),
Base.unsafe_convert(Float64, Base.cconvert(Float64, y)))
cconvert()
normally just calls convert()
, but can be defined to return
an arbitrary new object more appropriate for passing to C. For example,
this is used to convert an Array
of objects (e.g. strings) to an
array of pointers.
unsafe_convert()
handles conversion to Ptr
types. It is considered
unsafe because converting an object to a native pointer can hide the object
from the garbage collector, causing it to be freed prematurely.
Type Correspondences:¶
First, a review of some relevant Julia type terminology:
| Syntax / Keyword | Example | Description |
|---|---|---|
type |
String |
“Leaf Type” :: A group of related data that includes
a type-tag, is managed by the Julia GC, and
is defined by object-identity.
The type parameters of a leaf type must be fully defined
(no TypeVars are allowed)
in order for the instance to be constructed. |
abstract |
Any ,
AbstractArray{T,N} ,
Complex{T} |
“Super Type” :: A super-type (not a leaf-type) that cannot be instantiated, but can be used to describe a group of types. |
{T} |
Vector{Int} |
“Type Parameter” :: A specialization of a type (typically used for dispatch or storage optimization). “TypeVar” :: The |
bitstype |
Int ,
Float64 |
“Bits Type” :: A type with no fields, but a size. It is stored and defined by-value. |
immutable |
|
“Immutable” :: A type with all fields defined to be constant. It is defined by-value. And may be stored with a type-tag. “Is-Bits” :: A |
type ...; end |
nothing |
“Singleton” :: a Leaf Type or Immutable with no fields. |
(...) or tuple(...)` |
(1,2,3) |
“Tuple” :: an immutable data-structure similar to an anonymous immutable type, or a constant array. Represented as either an array or a struct. |
typealias |
Not applicable here | Type aliases, and other similar mechanisms of doing type indirection, are resolved to their base type (this includes assigning a type to another name, or getting the type out of a function call). |
Bits Types:¶
There are several special types to be aware of, as no other type can be defined to behave the same:
Float32
- Exactly corresponds to the
float
type in C (orREAL*4
in Fortran). Float64
- Exactly corresponds to the
double
type in C (orREAL*8
in Fortran). Complex64
- Exactly corresponds to the
complex float
type in C (orCOMPLEX*8
in Fortran). Complex128
- Exactly corresponds to the
complex double
type in C (orCOMPLEX*16
in Fortran). Signed
- Exactly corresponds to the
signed
type annotation in C (or anyINTEGER
type in Fortran). Any Julia type that is not a subtype ofSigned
is assumed to be unsigned. Ref{T}
- Behaves like a
Ptr{T}
that owns its memory. Array{T,N}
When an array is passed to C as a
Ptr{T}
argument, it is not reinterpret-cast: Julia requires that the element type of the array matchesT
, and the address of the first element is passed.Therefore, if an
Array
contains data in the wrong format, it will have to be explicitly converted using a call such astrunc(Int32,a)
.To pass an array
A
as a pointer of a different type without converting the data beforehand (for example, to pass aFloat64
array to a function that operates on uninterpreted bytes), you can declare the argument asPtr{Void}
.If an array of eltype
Ptr{T}
is passed as aPtr{Ptr{T}}
argument,Base.cconvert()
will attempt to first make a null-terminated copy of the array with each element replaced by itscconvert()
version. This allows, for example, passing anargv
pointer array of typeVector{String}
to an argument of typePtr{Ptr{Cchar}}
.
On all systems we currently support, basic C/C++ value types may be
translated to Julia types as follows. Every C type also has a corresponding
Julia type with the same name, prefixed by C. This can help for writing portable code (and remembering that an int
in C is not the same as an Int
in Julia).
System Independent:
| C name | Fortran name | Standard Julia Alias | Julia Base Type |
|---|---|---|---|
|
CHARACTER |
Cuchar |
UInt8 |
short |
|
Cshort |
Int16 |
unsigned short |
Cushort |
UInt16 |
|
|
|
Cint |
Int32 |
unsigned int |
Cuint |
UInt32 |
|
long long |
|
Clonglong |
Int64 |
unsigned long long |
Culonglong |
UInt64 |
|
intmax_t |
Cintmax_t |
Int64 |
|
uintmax_t |
Cuintmax_t |
UInt64 |
|
float |
REAL*4i |
Cfloat |
Float32 |
double |
REAL*8 |
Cdouble |
Float64 |
complex float |
COMPLEX*8 |
Complex64 |
Complex{Float32} |
complex double |
COMPLEX*16 |
Complex128 |
Complex{Float64} |
ptrdiff_t |
Cptrdiff_t |
Int |
|
ssize_t |
Cssize_t |
Int |
|
size_t |
Csize_t |
UInt |
|
void |
Void |
||
void and
[[noreturn]] or _Noreturn |
Union{} |
||
void* |
Ptr{Void} |
||
T* (where T represents an
appropriately defined type) |
Ref{T} |
||
char*
(or char[] , e.g. a string) |
CHARACTER*N |
Cstring if NUL-terminated, or
Ptr{UInt8} if not |
|
char** (or *char[] ) |
Ptr{Ptr{UInt8}} |
||
jl_value_t*
(any Julia Type) |
Any |
||
jl_value_t**
(a reference to a Julia Type) |
Ref{Any} |
||
va_arg |
Not supported | ||
...
(variadic function specification) |
T... (where T
is one of the above types,
variadic functions of different
argument types are not supported) |
The Cstring
type is essentially a synonym for Ptr{UInt8}
, except the conversion to Cstring
throws an
error if the Julia string contains any embedded NUL characters (which would cause the string to be silently
truncated if the C routine treats NUL as the terminator). If you are passing a char*
to a C routine that
does not assume NUL termination (e.g. because you pass an explicit string length), or if you know for certain that
your Julia string does not contain NUL and want to skip the check, you can use Ptr{UInt8}
as the argument type.
Cstring
can also be used as the ccall()
return type, but in that case it obviously does not introduce any extra
checks and is only meant to improve readability of the call.
System-dependent:
| C name | Standard Julia Alias | Julia Base Type |
|---|---|---|
char |
Cchar |
|
long |
Clong |
|
unsigned long |
Culong |
|
wchar_t |
Cwchar_t |
|
Note
When calling a Fortran function, all inputs must be passed by reference, so
all type correspondences above should contain an additional Ptr{..}
or
Ref{..}
wrapper around their type specification.
Warning
For string arguments (char*
) the Julia type should be Cstring
(if NUL-
terminated data is expected) or either Ptr{Cchar}
or Ptr{UInt8}
otherwise (these two pointer types have the same effect), as described above,
not String
. Similarly, for array arguments (T[]
or T*
), the
Julia type should again be Ptr{T}
, not Vector{T}
.
Warning
Julia’s Char
type is 32 bits, which is not the same as the wide character
type (wchar_t
or wint_t
) on all platforms.
Warning
A return type of Union{}
means the function will not return
i.e. C++11 [[noreturn]]
or C11 _Noreturn
(e.g. jl_throw
or
longjmp
). Do not use this for functions that return
no value (void
) but do return.
Note
For wchar_t*
arguments, the Julia type should be Cwstring
(if the C
routine expects a NUL-terminated string) or Ptr{Cwchar_t}
otherwise. Note
also that UTF-8 string data in Julia is internally NUL-terminated, so it can
be passed to C functions expecting NUL-terminated data without making a copy
(but using the Cwstring
type will cause an error to be thrown if the string
itself contains NUL characters).
Note
C functions that take an argument of the type char**
can be called by
using a Ptr{Ptr{UInt8}}
type within Julia. For example, C functions of the
form:
int main(int argc, char **argv);
can be called via the following Julia code:
argv = [ "a.out", "arg1", "arg2" ]
ccall(:main, Int32, (Int32, Ptr{Ptr{UInt8}}), length(argv), argv)
Note
A C function declared to return Void
will return the value nothing
in
Julia.
Struct Type correspondences¶
Composite types, aka struct
in C or TYPE
in Fortran90
(or STRUCTURE
/ RECORD
in some variants of F77),
can be mirrored in Julia by creating a type
or immutable
definition with the same field layout.
When used recursively, isbits
types are stored inline.
All other types are stored as a pointer to the data.
When mirroring a struct used by-value inside another struct in C,
it is imperative that you do not attempt to manually copy the fields over,
as this will not preserve the correct field alignment.
Instead, declare an immutable isbits
type and use that instead.
Unnamed structs are not possible in the translation to Julia.
Packed structs and union declarations are not supported by Julia.
You can get a near approximation of a union
if you know, a priori,
the field that will have the greatest size (potentially including padding).
When translating your fields to Julia, declare the Julia field to be only
of that type.
Arrays of parameters must be expanded manually, currently (either inline, or in an immutable helper type). For example:
in C:
struct B {
int A[3];
};
b_a_2 = B.A[2];
in Julia:
immutable B_A
A_1::Cint
A_2::Cint
A_3::Cint
end
type B
A::B_A
end
b_a_2 = B.A.(2)
Arrays of unknown size are not supported.
In the future, some of these restrictions may be reduced or eliminated.
SIMD Values¶
Note: This feature is currently implemented on 64-bit x86 and AArch64 platforms only.
If a C/C++ routine has an argument or return value that is a native
SIMD type, the corresponding Julia type is a homogeneous tuple
of VecElement
that naturally maps to the SIMD type. Specifically:
- The tuple must be the same size as the SIMD type. For example, a tuple representing an
__m128
on x86 must have a size of 16 bytes.- The element type of the tuple must be an instance of
VecElement{T}
whereT
is a bitstype that is 1, 2, 4 or 8 bytes.
For instance, consider this C routine that uses AVX intrinsics:
#include <immintrin.h>
__m256 dist( __m256 a, __m256 b ) {
return _mm256_sqrt_ps(_mm256_add_ps(_mm256_mul_ps(a, a),
_mm256_mul_ps(b, b)));
}
The following Julia code calls dist
using ccall
:
typealias m256 NTuple{8,VecElement{Float32}}
a = m256(ntuple(i->VecElement(sin(Float32(i))),8))
b = m256(ntuple(i->VecElement(cos(Float32(i))),8))
function call_dist(a::m256, b::m256)
ccall((:dist, "libdist"), m256, (m256, m256), a, b)
end
println(call_dist(a,b))
The host machine must have the requisite SIMD registers. For example, the code above will not work on hosts without AVX support.
Memory Ownership¶
malloc/free
Memory allocation and deallocation of such objects must be
handled by calls to the appropriate cleanup routines in the libraries
being used, just like in any C program. Do not try to free an object
received from a C library with Libc.free
in Julia, as this may result
in the free
function being called via the wrong libc
library and
cause Julia to crash. The reverse (passing an object allocated in Julia
to be freed by an external library) is equally invalid.
When to use T, Ptr{T} and Ref{T}¶
In Julia code wrapping calls to external C routines, ordinary (non-pointer)
data should be declared to be of type T
inside the ccall()
, as they
are passed by value. For C code accepting pointers, Ref{T}
should
generally be used for the types of input arguments, allowing the use of
pointers to memory managed by either Julia or C through the implicit call to
cconvert()
. In contrast, pointers returned by the C function called
should be declared to be of output type Ptr{T}
, reflecting that the memory
pointed to is managed by C only. Pointers contained in C structs should be
represented as fields of type Ptr{T}
within the corresponding Julia
immutable types designed to mimic the internal structure of corresponding C
structs.
In Julia code wrapping calls to external Fortran routines, all input arguments
should be declared as of type Ref{T}
, as Fortran passes all variables by
reference. The return type should either be Void
for Fortran subroutines,
or a T
for Fortran functions returning the type T
.
Mapping C Functions to Julia¶
ccall
/cfunction
argument translation guide¶
For translating a C argument list to Julia:
T
, whereT
is one of the primitive types:char
,int
,long
,short
,float
,double
,complex
,enum
or any of theirtypedef
equivalentsT
, whereT
is an equivalent Julia Bits Type (per the table above)- if
T
is anenum
, the argument type should be equivalent toCint
orCuint
- argument value will be copied (passed by value)
struct T
(including typedef to a struct)T
, whereT
is a Julia leaf type- argument value will be copied (passed by value)
void*
- depends on how this parameter is used, first translate this to the intended pointer type, then determine the Julia equivalent using the remaining rules in this list
- this argument may be declared as
Ptr{Void}
, if it really is just an unknown pointer
jl_value_t*
Any
- argument value must be a valid Julia object
- currently unsupported by
cfunction()
jl_value_t**
Ref{Any}
- argument value must be a valid Julia object (or
C_NULL
) - currently unsupported by
cfunction()
T*
Ref{T}
, whereT
is the Julia type corresponding toT
- argument value will be copied if it is an
isbits
type otherwise, the value must be a valid Julia object
(T*)(...)
(e.g. a pointer to a function)Ptr{Void}
(you may need to usecfunction()
explicitly to create this pointer)
...
(e.g. a vararg)T...
, whereT
is the Julia type
va_arg
- not supported
ccall
/cfunction
return type translation guide¶
For translating a C return type to Julia:
void
Void
(this will return the singleton instancenothing::Void
)
T
, whereT
is one of the primitive types:char
,int
,long
,short
,float
,double
,complex
,enum
or any of theirtypedef
equivalentsT
, whereT
is an equivalent Julia Bits Type (per the table above)- if
T
is anenum
, the argument type should be equivalent toCint
orCuint
- argument value will be copied (returned by-value)
struct T
(including typedef to a struct)T
, whereT
is a Julia Leaf Type- argument value will be copied (returned by-value)
void*
- depends on how this parameter is used, first translate this to the intended pointer type, then determine the Julia equivalent using the remaining rules in this list
- this argument may be declared as
Ptr{Void}
, if it really is just an unknown pointer
jl_value_t*
Any
- argument value must be a valid Julia object
jl_value_t**
Ref{Any}
- argument value must be a valid Julia object (or
C_NULL
)
T*
- If the memory is already owned by Julia, or is an
isbits
type, and is known to be non-null:Ref{T}
, whereT
is the Julia type corresponding toT
- a return type of
Ref{Any}
is invalid, it should either beAny
(corresponding tojl_value_t*
) orPtr{Any}
(corresponding toPtr{Any}
) - C MUST NOT modify the memory returned via
Ref{T}
ifT
is anisbits
type
- If the memory is owned by C:
Ptr{T}
, whereT
is the Julia type corresponding toT
- If the memory is already owned by Julia, or is an
(T*)(...)
(e.g. a pointer to a function)Ptr{Void}
(you may need to usecfunction()
explicitly to create this pointer)
Passing Pointers for Modifying Inputs¶
Because C doesn’t support multiple return values,
often C functions will take pointers to data that the function will modify.
To accomplish this within a ccall()
,
you need to first encapsulate the value inside an Ref{T}
of the appropriate type.
When you pass this Ref
object as an argument,
Julia will automatically pass a C pointer to the encapsulated data:
width = Ref{Cint}(0)
range = Ref{Cfloat}(0)
ccall(:foo, Void, (Ref{Cint}, Ref{Cfloat}), width, range)
Upon return, the contents of width
and range
can be retrieved
(if they were changed by foo
) by width[]
and range[]
; that is,
they act like zero-dimensional arrays.
Special Reference Syntax for ccall (deprecated):¶
The &
syntax is deprecated, use the Ref{T}
argument type instead.
A prefix &
is used on an argument to ccall()
to indicate that a pointer
to a scalar argument should be passed instead of the scalar value itself
(required for all Fortran function arguments, as noted above). The following
example computes a dot product using a BLAS function.
function compute_dot(DX::Vector{Float64}, DY::Vector{Float64})
assert(length(DX) == length(DY))
n = length(DX)
incx = incy = 1
product = ccall((:ddot_, "libLAPACK"),
Float64,
(Ptr{Int32}, Ptr{Float64}, Ptr{Int32}, Ptr{Float64}, Ptr{Int32}),
&n, DX, &incx, DY, &incy)
return product
end
The meaning of prefix &
is not quite the same as in C. In
particular, any changes to the referenced variables will not be
visible in Julia unless the type is mutable (declared via
type
). However, even for immutable types it will not cause any
harm for called functions to attempt such modifications (that is,
writing through the passed pointers). Moreover, &
may be used with
any expression, such as &0
or &f(x)
.
When a scalar value is passed with &
as an argument of type
Ptr{T}
, the value will first be converted to type T
.
Some Examples of C Wrappers¶
Here is a simple example of a C wrapper that returns a Ptr
type:
type gsl_permutation
end
# The corresponding C signature is
# gsl_permutation * gsl_permutation_alloc (size_t n);
function permutation_alloc(n::Integer)
output_ptr = ccall(
(:gsl_permutation_alloc, :libgsl), #name of C function and library
Ptr{gsl_permutation}, #output type
(Csize_t,), #tuple of input types
n #name of Julia variable to pass in
)
if output_ptr==C_NULL # Could not allocate memory
throw(OutOfMemoryError())
end
return output_ptr
end
The GNU Scientific Library (here assumed
to be accessible through :libgsl
) defines an opaque pointer,
gsl_permutation *
, as the return type of the C function
gsl_permutation_alloc()
. As user code never has to look inside the
gsl_permutation
struct, the corresponding Julia wrapper simply needs a new
type declaration, gsl_permutation
, that has no internal fields and whose
sole purpose is to be placed in the type parameter of a Ptr
type. The
return type of the ccall()
is declared as Ptr{gsl_permutation}
, since the
memory allocated and pointed to by output_ptr
is controlled by C (and not
Julia).
The input n
is passed by value, and so the function’s input signature is
simply declared as (Csize_t,)
without any Ref
or Ptr
necessary.
(If the wrapper was calling a Fortran function instead, the corresponding
function input signature should instead be (Ref{Csize_t},)
, since Fortran
variables are passed by reference.) Furthermore, n
can be any type that is
convertable to a Csize_t
integer; the ccall()
implicitly calls
Base.cconvert(Csize_t, n)
.
Here is a second example wrapping the corresponding destructor:
# The corresponding C signature is
# void gsl_permutation_free (gsl_permutation * p);
function permutation_free(p::Ref{gsl_permutation})
ccall(
(:gsl_permutation_free, :libgsl), #name of C function and library
Void, #output type
(Ref{gsl_permutation},), #tuple of input types
p #name of Julia variable to pass in
)
end
Here, the input p
is declared to be of type Ref{gsl_permutation}
,
meaning that the memory that p
points to may be managed by Julia or by C.
A pointer to memory allocated by C should be of type Ptr{gsl_permutation}
,
but it is convertable using cconvert()
and therefore can be used in the
same (covariant) context of the input argument to a ccall()
. A pointer to
memory allocated by Julia must be of type Ref{gsl_permutation}
, to ensure
that the memory address pointed to is valid and that Julia’s garbage collector
manages the chunk of memory pointed to correctly. Therefore, the
Ref{gsl_permutation}
declaration allows pointers managed by C or Julia to
be used.
If the C wrapper never expects the user to pass pointers to memory managed by
Julia, then using p::Ptr{gsl_permutation}
for the method signature of the
wrapper and similarly in the ccall()
is also acceptable.
Here is a third example passing Julia arrays:
# The corresponding C signature is
# int gsl_sf_bessel_Jn_array (int nmin, int nmax, double x,
# double result_array[])
function sf_bessel_Jn_array(nmin::Integer, nmax::Integer, x::Real)
if nmax<nmin throw(DomainError()) end
result_array = Array{Cdouble}(nmax-nmin+1)
errorcode = ccall(
(:gsl_sf_bessel_Jn_array, :libgsl), #name of C function and library
Cint, #output type
(Cint, Cint, Cdouble, Ref{Cdouble}),#tuple of input types
nmin, nmax, x, result_array #names of Julia variables to pass in
)
if errorcode!= 0 error("GSL error code $errorcode") end
return result_array
end
The C function wrapped returns an integer error code; the results of the actual
evaluation of the Bessel J function populate the Julia array result_array
.
This variable can only be used with corresponding input type declaration
Ref{Cdouble}
, since its memory is allocated and managed by
Julia, not C. The implicit call to Base.cconvert(Ref{Cdouble},
result_array)
unpacks the Julia pointer to a Julia array data
structure into a form understandable by C.
Note that for this code to work correctly, result_array
must be declared to
be of type Ref{Cdouble}
and not Ptr{Cdouble}
. The memory is managed by
Julia and the Ref
signature alerts Julia’s garbage collector to keep
managing the memory for result_array
while the ccall()
executes. If
Ptr{Cdouble}
were used instead, the ccall()
may still work, but
Julia’s garbage collector would not be aware that the memory declared for
result_array
is being used by the external C function. As a result, the
code may produce a memory leak if result_array
never gets freed by the
garbage collector, or if the garbage collector prematurely frees
result_array
, the C function may end up throwing an invalid memory access
exception.
Garbage Collection Safety¶
When passing data to a ccall()
, it is best to avoid using the pointer()
function. Instead define a convert method and pass the variables directly to
the ccall()
. ccall()
automatically arranges that all of its arguments will be
preserved from garbage collection until the call returns. If a C API will
store a reference to memory allocated by Julia, after the ccall()
returns, you
must arrange that the object remains visible to the garbage collector. The
suggested way to handle this is to make a global variable of type
Array{Ref,1}
to hold these values, until the C library notifies you that
it is finished with them.
Whenever you have created a pointer to Julia data, you must ensure the original data
exists until you are done with using the pointer. Many methods in Julia such as
unsafe_load()
and String()
make copies of data instead of taking ownership
of the buffer, so that it is safe to free (or alter) the original data without
affecting Julia. A notable exception is unsafe_wrap()
which, for performance
reasons, shares (or can be told to take ownership of) the underlying buffer.
The garbage collector does not guarantee any order of finalization. That is, if a
contained a reference to b
and both a
and b
are due for garbage
collection, there is no guarantee that b
would be finalized after a
. If
proper finalization of a
depends on b
being valid, it must be handled in
other ways.
Non-constant Function Specifications¶
A (name, library)
function specification must be a constant expression.
However, it is possible to use computed values as function names by staging
through eval
as follows:
@eval ccall(($(string("a","b")),"lib"), ...
This expression constructs a name using string
, then substitutes this
name into a new ccall()
expression, which is then evaluated. Keep in mind that
eval
only operates at the top level, so within this expression local
variables will not be available (unless their values are substituted with
$
). For this reason, eval
is typically only used to form top-level
definitions, for example when wrapping libraries that contain many
similar functions.
If your usage is more dynamic, use indirect calls as described in the next section.
Indirect Calls¶
The first argument to ccall()
can also be an expression evaluated at run time.
In this case, the expression must evaluate to a Ptr
,
which will be used as the address of the native function to call.
This behavior occurs when the first ccall()
argument contains references to non-constants,
such as local variables, function arguments, or non-constant globals.
For example, you might lookup the function via dlsym
,
then cache it in a global variable for that session. For example:
macro dlsym(func, lib)
z, zlocal = gensym(string(func)), gensym()
eval(current_module(),:(global $z = C_NULL))
z = esc(z)
quote
let $zlocal::Ptr{Void} = $z::Ptr{Void}
if $zlocal == C_NULL
$zlocal = dlsym($(esc(lib))::Ptr{Void}, $(esc(func)))
global $z = $zlocal
end
$zlocal
end
end
end
mylibvar = dlopen("mylib")
ccall(@dlsym("myfunc", mylibvar), Void, ())
Calling Convention¶
The second argument to ccall()
can optionally be a calling convention
specifier (immediately preceding return type). Without any specifier,
the platform-default C calling convention is used. Other supported
conventions are: stdcall
, cdecl
, fastcall
, and thiscall
.
For example (from base/libc.jl
) we see the same gethostname
ccall()
as above,
but with the correct signature for Windows:
hn = Array{UInt8}(256)
err = ccall(:gethostname, stdcall, Int32, (Ptr{UInt8}, UInt32), hn, length(hn))
For more information, please see the LLVM Language Reference.
Accessing Global Variables¶
Global variables exported by native libraries can be accessed by name using the
cglobal()
function. The arguments to cglobal()
are a symbol specification
identical to that used by ccall()
, and a type describing the value stored in
the variable:
julia> cglobal((:errno,:libc), Int32)
Ptr{Int32} @0x00007f418d0816b8
The result is a pointer giving the address of the value. The value can be
manipulated through this pointer using unsafe_load()
and unsafe_store()
.
Accessing Data through a Pointer¶
The following methods are described as “unsafe” because a bad pointer or type declaration can cause Julia to terminate abruptly.
Given a Ptr{T}
, the contents of type T
can generally be copied from
the referenced memory into a Julia object using unsafe_load(ptr, [index])
.
The index argument is optional (default is 1),
and follows the Julia-convention of 1-based indexing.
This function is intentionally similar to the behavior of getindex()
and setindex!()
(e.g. []
access syntax).
The return value will be a new object initialized to contain a copy of the contents of the referenced memory. The referenced memory can safely be freed or released.
If T
is Any
, then the memory is assumed to contain a reference to
a Julia object (a jl_value_t*
), the result will be a reference to this object,
and the object will not be copied. You must be careful in this case to ensure
that the object was always visible to the garbage collector (pointers do not
count, but the new reference does) to ensure the memory is not prematurely freed.
Note that if the object was not originally allocated by Julia, the new object
will never be finalized by Julia’s garbage collector. If the Ptr
itself
is actually a jl_value_t*
, it can be converted back to a Julia object
reference by unsafe_pointer_to_objref(ptr)
.
(Julia values v
can be converted to jl_value_t*
pointers, as
Ptr{Void}
, by calling pointer_from_objref(v)
.)
The reverse operation (writing data to a Ptr{T}
), can be performed using
unsafe_store!(ptr, value, [index])
. Currently, this is only supported
for bitstypes or other pointer-free (isbits
) immutable types.
Any operation that throws an error is probably currently unimplemented and should be posted as a bug so that it can be resolved.
If the pointer of interest is a plain-data array (bitstype or immutable), the
function unsafe_wrap(Array, ptr,dims,[own])
may be
more useful. The final parameter should be true if Julia should “take
ownership” of the underlying buffer and call free(ptr)
when the returned
Array
object is finalized. If the own
parameter is omitted or false,
the caller must ensure the buffer remains in existence until all access is
complete.
Arithmetic on the Ptr
type in Julia (e.g. using +
) does not behave the
same as C’s pointer arithmetic. Adding an integer to a Ptr
in Julia always
moves the pointer by some number of bytes, not elements. This way, the
address values obtained from pointer arithmetic do not depend on the
element types of pointers.
Thread-safety¶
Some C libraries execute their callbacks from a different thread, and
since Julia isn’t thread-safe you’ll need to take some extra
precautions. In particular, you’ll need to set up a two-layered
system: the C callback should only schedule (via Julia’s event loop)
the execution of your “real” callback.
To do this, create a AsyncCondition
object and wait on it:
cond = Base.AsyncCondition()
wait(cond)
The callback you pass to C should only execute a ccall()
to
:uv_async_send
, passing cb.handle
as the argument,
taking care to avoid any allocations or other interactions with the Julia runtime.
Note that events may be coalesced, so multiple calls to uv_async_send may result in a single wakeup notification to the condition.


Eduardo
_
Zambrano
.
Homepage
Research
C.V.
Book
Links
Dead Man Walking
, 5.9+, 135 ft, El Potrero Chico (December, 2019)
Inquiry-Based Stress Reduction ("The Work")
Unified Mindfulness
Personal Homepage
Outdoor Climbing
Indoor Climbing


WITNESS LIST Land & Resource Management Committee May 5, 1997-2:00P SB 478 For: McCall, Brian Rep. ((House Dist.)) SB 1922 For: Zbranek, Zeb Rep. ((House Dist.))


This portfolio is designed to showcase the breadth and scope of my skill-set. It is built using Angular 6.x and leverages the GitHub API for populating and displaying my work in the Projects menu on the left sidebar. I will add more functionality as time allows.
Since this portfolio is technically still in development consider yourself a bonafide tester. As such, you may feel free to navigate freely throughout the site and email me if you encounter any bugs.


Reads the evolutions from the application.
Reads the evolutions from the application.
the database name
Apply pending evolutions for the given DB.
Applies a script to the database.
Applies a script to the database.
the DBApi
to use
the database name
the script to run
Checks the evolutions state.
Checks the evolutions state.
the DBApi
to use
the database name
error if the database is in an inconsistent state
Reads evolutions from the database.
Reads evolutions from the database.
the DBApi
to use
the database name
Computes the evolution script.
Computes the evolution script.
the DBApi
to use
the database name
Resolves evolution conflicts.
Resolves evolution conflicts.
the DBApi
to use
the database name
the revision to mark as resolved
Translates an evolution script to something human-readable.
Translates an evolution script to something human-readable.
a formatted script
Updates a local (file-based) evolution script.
Defines Evolutions utilities functions.


Random Quote Generator
A collection of Baseball's most inspiring and impactful quotes.
New Quote
Tweet It!


Getting your roof repaired and locating a reputable contractor shouldn’t be a struggle, especially if your existing roof has suffered damage from wind or hail. At Total Residential Roofing, we believe your roofing repair process should be a pleasant experience. We work with all insurance companies to get you the best insurance settlements from roof damage.
At Total Residential Roofing, we service the Dallas, Fort Worth, Austin and surrounding areas. Our roofing repair company offers exceptional customer service, as well as trained technicians that are well educated on the installation process for all roofing types and roof systems, including those made from wood, metal or composition.
We service both residential and commercial roofing systems and handle re-roofing, new construction and repairs. Our Dallas roofing repair company professionally installs complete roof systems, as well as patio covers and durable metal roofs.


Basic User Profile Form
Click here to register
New PlayLists
Create New PlayList
PlayList id
Artist
Song title
Genre
Mood Classification
PlayList ID
Artist
Song Title
Genre
Mood Classification
Edit
Delete


The QuantConnect platform hosts a specific set of data so the history data is limited to a few specific formats. See the table below for a guide to the format of data by security type:
| Security Type | Supported Types |
|---|---|
| Equity | TradeBar Tick, Second, Minute, Hour, Daily |
| Forex, CFD | QuoteBar Tick, Second, Minute, Hour, Daily |
| Crypto | TradeBar (default), QuoteBar (available) Tick, Second, Minute, Hour, Daily |
| Future Contracts | TradeBar (default), QuoteBar (available) Tick, Second, Minute |
| Option Contracts | TradeBar (default), QuoteBar (available) Minute |
History is returned in TradeBars by default, but for Futures, Crypto and Options QuoteBars are also available. To request data as QuoteBars you must specify the type in the query.
// Get BTCUSD symbol and use it to request history var btcusd = AddCrypto("BTCUSD", Resolution.Daily, Market.GDAX).Symbol; var quotes = History<QuoteBar>(btcusd, 14, Resolution.Daily)


A creative developer with a passion for coding, always looking to learn more and continue to evolve in the web development field. A socially adept team player able to communicate and adapt effectively within a breadth of workplace cultures.
I found my passion in programming and coding. A former firefighter/EMT, and Army Veteran. My experiences helped form my ability to think quickly on my feet and to come up with practical solutions to complex problems. I find Web Development just as challenging and even more rewarding than both of my previous careers. I feel even more passionate and motivated by web development with my ability to create useful, functional apps and beautiful designs.
Proficiencies in skills learned and technologies used.
”I don't think about art when I'm working. I try to think about life.”
Jean-Michel Basquiat
“I am seeking. I am striving. I am in it with all my heart.”
Vincent Van Gogh
“The only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven't found it yet, keep looking. Don't settle.”
Steve Jobs


{% extends 'form.html' %} {% block title %}Delete Group{% endblock %} {% block form_fields %}
Are you sure you want to delete {{ localgroup.name }}? This operation cannot be undone.


Add As First
Add As Last
Remove First
Remove Last
Show All
Show All Reversed
Clear
Use both data field and index field to insert data by index
Add By Index
Remove By Index
Search By Index
Index
Data


Blood Bank
Home
About
Contact us
Register
As Donor
As Hospital
Blood Request
Search Donor
Log in
About
Hospital
Blood Details
Name
Age
Mobile Number
Gender
Male
Female
Other
Blood Group
A+
A-
B+
B-
O+
O-
AB+
AB-
Next
Hospital's Name
Area
Street
Is Donor
Is Donor
Yes
No
Pincode
Previous
Next
Whole Blood
Red Blood Cells
Platelets
Plasma
Previous


GroupHub
Toggle navigation
4
You have 4 messages
Support Team
5 mins
Why not buy a new awesome theme?
GroupHub Design Team
2 hours
Why not buy a new awesome theme?
Developers
Today
Why not buy a new awesome theme?
Sales Department
Yesterday
Why not buy a new awesome theme?
Reviewers
2 days
Why not buy a new awesome theme?
See All Messages
10
You have 10 notifications
5 new members joined today
Very long description here that may not fit into the page and may cause design problems
5 new members joined
25 sales made
You changed your username
View all
9
You have 9 tasks
Design some buttons
20%
20% Complete
Create a nice theme
40%
40% Complete
Some task I need to do
60%
60% Complete
Make beautiful transitions
80%
80% Complete
View all tasks
Jane Doe
Jane Doe - Web Developer
Member since Nov. 2012
Followers
Sales
Friends
Profile
Sign out


Saints boss Jim Goodwin eyeing up squad reinforcements in January
The St Mirren gaffer hopes the club can strengthen their side when the transfer window swings open again.
by Ben RamageSaints manager Jim Goodwin says the club are already looking at reinforcements in the January transfer window.
While he is pleased with the squad he has assembled, he believes it’s only right that the club are always looking to improve the side.
“We’re always looking for reinforcements, absolutely,” he told Express Sport.
“We’d like to strengthen again in January if we can. I think we need to.
“I’m not going to say in what areas at this time but we’re similar to every other team out there.
“We’ll try and get people in that can improve the squad, which is the same in every window.
"If there’s players available that we think are good enough, who can make us better then we’ll certainly look to try and do something.”
One player who won’t be signing up at the Simple Digital Arena is Ross Wallace.
While some media outlets reported he was undertaking a trial with St Mirren , Goodwin revealed he was simply using the training facilities to keep fit.
He added: “Ross is a friend and asked if he could come in and do a bit of training.
“We were short of bodies at the time so that was more to facilitate Ross.
"It wasn’t a trial and he’s not back in with us now.”


Copyright (c) 2009-2010:
Luc Vandal, Edovia Inc.
Ortwin Gentz, FutureTap GmbH
All rights reserved.
It is appreciated but not required that you give credit to Luc Vandal and Ortwin Gentz,
as the original authors of this code. You can give credit in a blog post, a tweet or on
a info page of your app. Also, the original authors appreciate letting them know if you
use this code.
The above copyright notice and this permission notice shall be included in all copies
or substantial portions of the Software.
This code is licensed under the BSD license.
Copyright 2013-2014 Timothy Oliver. All rights reserved.
Features logic designed by Satoshi Asano (ninjinkun) for NJKWebViewProgress, also licensed under the MIT License. Re-implemented by Timothy Oliver.
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.
 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.


Welcome to MockSwift!
MockSwift allows you to write mocks and make better tests. Because MockSwift is an open source library 100% written in Swift, it is AVAILABLE ON ALL PLATFORMS.
Initially MockSwift is inspired by Mockito.
Table of Contents
Features
Actually MockSwift supports:
- Mocking
- Call verification
- [x] Generics
- [x] Parameters matching
- [x] Default values for Types
CHANGELOG
You can see all changes and new features here.
Installation
Swift Package Manager
MockSwift has been designed to work with Swift Package Manager.
// swift-tools-version:5.1
import PackageDescription
let package = Package(
name: "MyProject",
dependencies: [
.package(url: "https://github.com/leoture/MockSwift.git", from: "0.6.0")
],
targets: [
.testTarget(name: "MyProjectTests", dependencies: ["MockSwift"])
]
)
Usage
Suppose that you have a UserService
protocol.
struct User: Equatable {
let identifier: String
let name: String
}
protocol UserService {
func fetch(identifier: String) -> User
}
And you want to test this UserCore
class.
class UserCore {
private let service: UserService
init(_ service: UserService) {
self.service = service
}
func fetchCurrentUser() -> User {
service.fetch(identifier: "current")
}
}
Make better tests
Now, with MockSwift, you can use a mocked UserService
in your tests with the @Mock
annotation.
@Mock private var service: UserService
// equivalent to
private var service: UserService = Mock()
And easly configure it to fully test UseCore
.
class UserCoreTests: XCTestCase {
private var core: UserCore!
@Mock private var service: UserService
override func setUp() {
core = UserCore(service)
}
func test_fetchCurrentUser() {
// Given
let expectedUser = User(identifier: "current", name: "John")
given(service).fetch(identifier: .any()).willReturn(expectedUser)
// When
let user = core.fetchCurrentUser()
// Then
then(service).fetch(identifier: .any()).called()
XCTAssertEqual(user, expectedUser)
}
}
Given
given()
enables you to define behaviours.
example:
given(service).fetch(identifier: .any()).willReturn(expectedUser)
// equivalent to
given(service) {
$0.fetch(identifier: .any()).willReturn(expectedUser)
}
given(service) {
$0.fetch(identifier: "current")
.willReturn(expectedUser, expectedUser1, expectedUser2)
$0.fetch(identifier: .match(when: \.isEmpty))
.will { (params) -> User in
// do something else
return expectedUser
}
}
you can also define behaviours when you instantiate the mock.
@Mock({
$0.fetch(identifier: .any()).willReturn(expectedUser)
})
private var service: UserService
Then
then()
enables you to verify calls.
example:
then(service).fetch(identifier: .any()).called()
// equivalent to
then(service) {
$0.fetch(identifier: .any()).called()
}
then(service) {
$0.fetch(identifier: "current").called(times: >=2)
$0.fetch(identifier: =="").called(times: 0)
}
Stubs
In MockSwift, stubs are default values that are returned when no behaviours has been found.
Global Stubs
You can define a global stub for any type. It will concern all mocks you will use in every tests.
extension User: GlobalStub {
static func stub() -> User {
User(identifier: "id", name: "John")
}
}
Local Stubs
You can also define a stub localy for any type. It will concern only the current mock.
@Mock(localStubs: [
User.self => User(identifier: "id", name: "John")
])
private var service: UserService
Strategy
The default strategy is to find behaviour defined with given()
. If no behaviour is found, it will return a local stub. If no local stub is found, it will return a global stub.
@Mock private var service: UserService
// equivalent to
@Mock(strategy: .default)
private var service: UserService
// equivalent to
@Mock(strategy: [.given, .localStubs, .globalStubs])
private var service: UserService
You can change the order of the strategy list or remove items as you want.
Write mocks
Automatically
MockSwift provides a stencil template for sourcery. You can use the AutoMockable
annotation to generate code.
// sourcery: AutoMockable
protocol UserService {
func fetch(identifier: String) -> User
}
To generate code at every build, you can add a build phase before Compile Sources
.
sourcery \
--sources MyLibrary \
--templates MyLibraryTests/path/to/MockSwift.stencil \
--output MyLibraryTests/path/to/GeneratedMocks.swift \
--args module=MyLibrary
Manually
To enable MockSwift for UserService type, you have to extend Mock.
extension Mock: UserService where WrappedType == UserService {
public func fetch(identifier: String) -> User {
mocked(identifier)
}
}
To allow behaviour definition through given()
method, you have to extend Given.
extension Given where WrappedType == UserService {
public func fetch(identifier: Predicate<String>) -> Mockable<User> {
mockable(identifier)
}
public func fetch(identifier: String) -> Mockable<User> {
mockable(identifier)
}
}
To allow call verification through then()
method, you have to extend Then.
extension Then where WrappedType == UserService {
public func fetch(identifier: Predicate<String>) -> Verifiable<User> {
verifiable(identifier)
}
public func fetch(identifier: String) -> Verifiable<User> {
verifiable(identifier)
}
}
Documentation
If you need more details about the API, you can check out our API documentation or our GitBook.
Playgrounds
This project contains playgrounds that can help you experiment MockSwift .
To use playgrounds:
- open MockSwift.xcworkspace
- build the MockSwiftPlayground scheme.
Contribution
Would you like to contribute to MockSwift? Please read our contributing guidelines and code of conduct.
License
MockSwift is released under the MIT license. See LICENSE for details.


#include <cciddriver.h>
Public Attributes | |
| unsigned char | bmFindexDindex |
| B7-4 – FI – Index into the table 7 in ISO/IEC 7816-3:1997 selecting a. More... | |
| unsigned char | bmTCCKST1 |
| For T=1, B7-2 – 000100b. More... | |
| unsigned char | bGuardTimeT1 |
| Extra Guardtime (0 to 254 etu between two characters). More... | |
| unsigned char | bmWaitingIntegersT1 |
| B7-4 = BWI. More... | |
| unsigned char | bClockStop |
| ICC Clock Stop Support. More... | |
| unsigned char | bIFSC |
| Size of negotiated IFSC. More... | |
| unsigned char | bNadValue |
| Nad value used by CCID. More... | |
| unsigned char _S_ccid_protocol_t1::bClockStop |
ICC Clock Stop Support.
00 = Stopping the Clock is not allowed 01 = Stop with Clock signal Low 02 = Stop with Clock signal High 03 = Stop with Clock either High or Low
| unsigned char _S_ccid_protocol_t1::bGuardTimeT1 |
Extra Guardtime (0 to 254 etu between two characters).
If value is FFh, then guardtime is reduced by 1.
| unsigned char _S_ccid_protocol_t1::bIFSC |
Size of negotiated IFSC.
| unsigned char _S_ccid_protocol_t1::bmFindexDindex |
B7-4 – FI – Index into the table 7 in ISO/IEC 7816-3:1997 selecting a.
clock rate conversion factor B3-0 – DI - Index into the table 8 in ISO/IEC 7816-3:1997 selecting a baud rate conversion factor
| unsigned char _S_ccid_protocol_t1::bmTCCKST1 |
For T=1, B7-2 – 000100b.
B0 – Checksum type (b0=0 for LRC, b0=1 for CRC B1 – Convention used (b1=0 for direct, b1=1 for inverse)
| unsigned char _S_ccid_protocol_t1::bmWaitingIntegersT1 |
B7-4 = BWI.
B3-0 = CWI
| unsigned char _S_ccid_protocol_t1::bNadValue |
Nad value used by CCID.


Happy and giant waterfall-adjacent
In 2011, I started teaching adult learners from diverse backrounds how to double-click, browse Wikipedia, and enter functions into Excel.
Six years later, I still love helping learners work towards their goals with technology, but I draw upon a different toolkit: developing web applications, consulting with clients from diverse backgrounds and with varying levels of technical expertise, mentoring young developers, and writing.
As the Social Science and Geospatial Data Librarian at Cornell University, I specialize in helping learners and researchers find & interpret data across the social sciences, including supporting those who are new to digital methods. My techniques of choice include manipulating complex & messy datasets, data visualization, text mining, and generally using Python and other programming languages to pursue research questions.
In particular, I focus on critical applications of data science, open source packages and software, machine learning, and natural language processing.
Exploratory data analysis; natural language processing; web application development; data skills instruction with learners with diverse backgrounds; data visualization and storytelling; technical writing
Python (pandas, pyspark, jupyter, etc.) and R (tidyverse); SQL; web app development (django, flask, HTML/CSS, JavaScript); visualization (d3, seaborn, bokeh, Tableau); machine learning & nlp (scikit-learn, Spark, TensorFlow); and open source collaboration (git/github).
Spark and Hadoop architecture, intermediate/advanced JavaScript, test-driven development best practices, contributing more pull requests to FOSS projects
Outside of work I love writing, pinball, zines, hikes, cats, speculative fiction, and trains.


Namespace RogueSharp.DiceNotation
Classes
Dice
The Dice class is a static class that has convenience methods for parsing and rolling dice
DiceExpression
The DiceExpression class can be used to fluently add DiceTerms to a collection and then Roll them.
DiceParser
The DiceParser class is used to parse a string into a DiceExpression
DiceResult
The DiceResult class represents the result of rolling a DiceExpression
TermResult
The TermResult class represents a single result of one of the terms in a DiceExpression
Interfaces
IDiceParser
The DiceParser interface can be implemented to parse a string into a DiceExpression


Jenkins Mobile Client
React-Native Jenkins Client for iOS and Android
Setup
Step 1:
Clone the repo:
git clone https://github.com/derickwarshaw/jenkins.git
Step 2:
Change directories into the repo:
cd jenkins
Step 3:
Install the npm application:
npm install
Step 4:
If you run into an issue building the project, check out React's issues page. You may need to go into XCode and doubleclick on the RCTWebSocket project in your navigator and remove the flags under build settings > custom compiler flags.
Run the App
Step 1:
Make sure you're in the project folder. If not, change directories into the folder:
cd jenkins
Step 2:
Run Build: See Facebook's official instructions on getting started for your mobile and development OS instructions
Want to make a contribution?
Troubleshooting
- BUILD FAILED
- CFBundleIdentifier
- Typically the result of another process running on the same port. To resolve this find the PID for the process on port 8081
- run lsof -n -i4TCP:8081 which should return any process running on 8081.
- run kill -p PID - where PID is the PID of the process identified by the command above.
- CFBundleIdentifier


Graphics Objects are used to create 3D objects, pictures, text, graphs, arrows, and other graphical components needed to visualise and monitor a simulation. The following objects are included in the Graphics Objects palette.
Graphics Objects Palette
|
Object |
Description |
|
Region |
Local coordinate system. |
|
DisplayEntity |
Graphical object displaying either a 3D shape or a 2D picture. |
|
Shape |
Two-dimensional graphical object whose shape and colour can be selected. |
|
Polyline |
Straight or curved line segments. |
|
Arrow |
Line that terminates in an arrow head. |
|
Text |
Text that appears in the 3D model universe. |
|
Graph |
Chart that shows model outputs as they change in time. |
|
BarGauge |
Gauge that displays the value of an expression. |
|
BooleanIndicator |
Circular entity that changes colour to indicate TRUE and FALSE. |
|
EntityLabel |
Text that labels another object. An EntityLabel can only be created by selecting the "Show Label" option in an object's context menu. Since they cannot be dragged and dropped, EntityLabel does not appear in the Model Builder. |
|
OverlayImage |
Picture that appears in a fixed position in the display window. |
|
OverlayText |
Text that appears in a fixed position in the display window. |
|
OverylayClock |
Time and date display that appears in a fixed position in the display window. |
|
BillboardText |
Text that follows a 3D position but is always upright on the screen. |
|
MimicEntity |
Graphical object that copies the appearance of another DisplayEntity. |
|
View |
Display window showing view of the 3D model universe. A View can only be created using the Views menu in the Menu Bar. |
|
VideoRecorder |
Object that makes a video recording of the model. |


Production of parametric models and experiments seeking to determine hydrodynamic effects of fish scale morphology. Imaging and analysis of surface properties of fish and marine mammals.
Segmentation and analysis of scales in Thunnus obesus (Bigeye Tuna) including previously unknown structures such as fatty deposits and vasculature internal to the scale.


Your state variables are transiting to an unreachable state:
NOISY
.Transit()
method for the variable. Volume=NOISY
will slow the code down considerably. You should lower the volume once problems have been resolved.Using default Utility() equal to 0. Your derived DDP should provide a replacement for Bellman::Utility().
MyModel
list Utility()
as a non-static method (see all examples). Utility()
in the .ox file. If you don't do this a Ox runtime error will occur saying the routine does not exist.Setting iseed to 0 means ranseed is not reset
Number of replications R not set or invalid. Setting to 1.
The creator routine for OneDimensionalChoice states has not been called. Runtime errors likely.
Dynamic approximation to continuous state has not defined. Call SetKeep().
Using AgeBrackets with deterministic aging: consider using Aging().
Simulating ergodic paths without fixed Tmax? Path may be of unbounded length.
Masking data for observability.
print level invalid
Tracking of auxiliary outcomes still experimental. It may not work.
Do not add to tracking list after predictions made ... ignored
Transitions and actual values …
Transitions and actual values are fixed. They are computed in CreateSpaces() and never again.
Setting update time to OnlyOnce. Transitions and actual values do not depend on fixed or random effect values. If they do, results are not reliable.
Setting update time to AfterFixed. Transitions and actual values can depend on fixed effect values but not random effects. If they do, results are not reliable.
Setting update time to AfterRandom. Transitions and actual values can depend on fixed and random effects, which is safe but may be redundant and therefore slower than necessary.
Clock must be set before calling SubsampleStates. Setting clock type to InfiniteHorizon.
State Space Already Defined. DryRun request ignored.
Only a dry run of creating the state space Theta will be performed. Program ends at the end of CreateSpaces().
No actions have been added to the model. A no-choice action inserted.
Clock has not been set. Setting clock type to InfiniteHorizon.
clock is ergodic but terminal states exist? Inconsistency in the set up.
Linear systems solution for stationary distribution returns code 2. May be unreliable.
User code has called the default Solve() function for GSolve(instate)
User code has called the default Solve() function for Method. Does not do anything
User code has not set the discount factor yet. Setting it to default value of 0.90
Must call SubSampleStates() before you use KeaneWolpin::Solve().
Using KW approximazation on a model with infeasible actions at some states. All reachable states at a given time t for which the approximation is used must have the same feasible action set for results to be sensible.
Label for discrete value should be a string.
a. Trigger values must be integer or matrix b. Reset value must be integer between -1 and b.N


Your interview history for the past 6 months only is displayed
If you cannot attend an interview, you must inform the company latest 1 working day before the interview. You may be tagged as “No Show” on your resume or banned from applying in the future if you don’t.


Skeleton implementation of a named axis.
An AbstractController is a skeleton implementation of a controller that
contains a fixed number of axes, controllers, and rumblers.
An axis is a single button, slider, or dial, which has a single range.
Identifiers for different Axes.
KeyIDs for standard PC (LATIN-1) keyboards
A Controller represents a physical device, such as a keyboard, mouse,
or joystick, or a logical grouping of related controls, such as a button
pad or mouse ball.
Common controller port types.
Types of controller objects.
A ControllerEnvironment represents a collection of controllers that are
physically or logically linked.
An event that is fired when the state of a controller changes
A listener for changes in the state of controllers
A FIFO queue for input events.
A Rumbler is a controller's mechanism for delivering feedback
to the user through the device.


Height Prediction
Height is a classic example of a "missing heritability" trait:
it is known to be associated with genetic factors (approximately 75% heritable),
but thus far, association studies have only been able to
explain ~20% of the heritability.
In this exercise, we will attempt to predict your height based on 145 SNPs and compare this to a similar prediction based on the height of your parents.


Provides tools for importing and working with bibliographic references. It greatly enhances the 'bibentry' class by providing a class 'BibEntry' which stores 'BibTeX' and 'BibLaTeX' references, supports 'UTF-8' encoding, and can be easily searched by any field, by date ranges, and by various formats for name lists (author by last names, translator by full names, etc.). Entries can be updated, combined, sorted, printed in a number of styles, and exported. 'BibTeX' and 'BibLaTeX' '.bib' files can be read into 'R' and converted to 'BibEntry' objects. Interfaces to 'NCBI Entrez', 'CrossRef', and 'Zotero' are provided for importing references and references can be created from locally stored 'PDF' files using 'Poppler'. Includes functions for citing and generating a bibliography with hyperlinks for documents prepared with 'RMarkdown' or 'RHTML'.
| Version: | 1.2.0 |
| Depends: | R (≥ 3.0) |
| Imports: | xml2, jsonlite, utils, plyr, tools, httr, bibtex (≥ 0.4.1), lubridate (≥ 1.5.0), stringr, methods |
| Suggests: | knitr, testthat |
| Published: | 2018-04-25 |
| Author: | Mathew W. McLean [aut, cre] |
| Maintainer: | Mathew W. McLean <mathew.w.mclean at gmail.com> |
| BugReports: | https://github.com/ropensci/RefManageR/issues |
| License: | GPL-2 | GPL-3 | BSD_3_clause + file LICENSE |
| URL: | https://github.com/ropensci/RefManageR/ |
| NeedsCompilation: | no |
| Citation: | RefManageR citation info |
| Materials: | README NEWS |
| In views: | ReproducibleResearch, WebTechnologies |
| CRAN checks: | RefManageR results |
| Reference manual: | RefManageR.pdf |
| Vignettes: |
RMarkdown Citations - Alphabetic Style RHTML Citations Example RMarkdown Citations Example RefManageR User Manual |
| Package source: | RefManageR_1.2.0.tar.gz |
| Windows binaries: | r-devel: RefManageR_1.2.0.zip, r-release: RefManageR_1.2.0.zip, r-oldrel: RefManageR_1.2.0.zip |
| OS X binaries: | r-release: RefManageR_1.2.0.tgz, r-oldrel: RefManageR_1.2.0.tgz |
| Old sources: | RefManageR archive |
| Reverse imports: | Cite, citr, knitcitations, psychmeta |
| Reverse suggests: | HWxtest |
Please use the canonical form https://CRAN.R-project.org/package=RefManageR to link to this page.


Your To-dos!
Study for CSC396 midterm
Get started on CSC463 assignment
Apply to jobs
Already Done
Feed Self
Start Working!


Go to the reset password page →
If something does not work, simply copy and paste this link into your browser:
{{shopUrl}}/reset?code={{code}}


Doggy Memory
×
FAQ
Select the level on the left panel. After starting the game it is not possible to change the level. While playing use the restart button on the right panel to change the level.
If your browser supports datasaving, your moves, the played fieldsize and time will be saved.
Let's play and have fun!
×
Rankinglist of the last six
×
Congratulation!

Play again?