mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Merge branch 'master' into 1232-local
Conflicts: lib/linguist/samples.json
This commit is contained in:
46
samples/Isabelle/HelloWorld.thy
Normal file
46
samples/Isabelle/HelloWorld.thy
Normal file
@@ -0,0 +1,46 @@
|
||||
theory HelloWorld
|
||||
imports Main
|
||||
begin
|
||||
|
||||
section{*Playing around with Isabelle*}
|
||||
|
||||
text{* creating a lemma with the name hello_world*}
|
||||
lemma hello_world: "True" by simp
|
||||
|
||||
(*inspecting it*)
|
||||
thm hello_world
|
||||
|
||||
text{* defining a string constant HelloWorld *}
|
||||
|
||||
definition HelloWorld :: "string" where
|
||||
"HelloWorld \<equiv> ''Hello World!''"
|
||||
|
||||
(*reversing HelloWorld twice yilds HelloWorld again*)
|
||||
theorem "rev (rev HelloWorld) = HelloWorld"
|
||||
by (fact List.rev_rev_ident)
|
||||
|
||||
text{*now we delete the already proven List.rev_rev_ident lema and show it by hand*}
|
||||
declare List.rev_rev_ident[simp del]
|
||||
hide_fact List.rev_rev_ident
|
||||
|
||||
(*It's trivial since we can just 'execute' it*)
|
||||
corollary "rev (rev HelloWorld) = HelloWorld"
|
||||
apply(simp add: HelloWorld_def)
|
||||
done
|
||||
|
||||
text{*does it hold in general?*}
|
||||
theorem rev_rev_ident:"rev (rev l) = l"
|
||||
proof(induction l)
|
||||
case Nil thus ?case by simp
|
||||
next
|
||||
case (Cons l ls)
|
||||
assume IH: "rev (rev ls) = ls"
|
||||
have "rev (l#ls) = (rev ls) @ [l]" by simp
|
||||
hence "rev (rev (l#ls)) = rev ((rev ls) @ [l])" by simp
|
||||
also have "\<dots> = [l] @ rev (rev ls)" by simp
|
||||
finally show "rev (rev (l#ls)) = l#ls" using IH by simp
|
||||
qed
|
||||
|
||||
corollary "\<forall>(l::string). rev (rev l) = l" by(fastforce intro: rev_rev_ident)
|
||||
|
||||
end
|
||||
232
samples/Mathematica/MiscCalculations.nb
Normal file
232
samples/Mathematica/MiscCalculations.nb
Normal file
@@ -0,0 +1,232 @@
|
||||
(* Content-type: application/vnd.wolfram.mathematica *)
|
||||
|
||||
(*** Wolfram Notebook File ***)
|
||||
(* http://www.wolfram.com/nb *)
|
||||
|
||||
(* CreatedBy='Mathematica 9.0' *)
|
||||
|
||||
(*CacheID: 234*)
|
||||
(* Internal cache information:
|
||||
NotebookFileLineBreakTest
|
||||
NotebookFileLineBreakTest
|
||||
NotebookDataPosition[ 157, 7]
|
||||
NotebookDataLength[ 7164, 223]
|
||||
NotebookOptionsPosition[ 6163, 182]
|
||||
NotebookOutlinePosition[ 6508, 197]
|
||||
CellTagsIndexPosition[ 6465, 194]
|
||||
WindowFrame->Normal*)
|
||||
|
||||
(* Beginning of Notebook Content *)
|
||||
Notebook[{
|
||||
|
||||
Cell[CellGroupData[{
|
||||
Cell[BoxData[
|
||||
RowBox[{
|
||||
RowBox[{"Solve", "[",
|
||||
RowBox[{
|
||||
RowBox[{"y", "'"}], "\[Equal]", " ", "xy"}], "]"}],
|
||||
"\[IndentingNewLine]"}]], "Input",
|
||||
CellChangeTimes->{{3.6112716342092056`*^9, 3.6112716549793935`*^9}}],
|
||||
|
||||
Cell[BoxData[
|
||||
RowBox[{"{",
|
||||
RowBox[{"{",
|
||||
RowBox[{"xy", "\[Rule]",
|
||||
SuperscriptBox["y", "\[Prime]",
|
||||
MultilineFunction->None]}], "}"}], "}"}]], "Output",
|
||||
CellChangeTimes->{3.6112716579295626`*^9}]
|
||||
}, Open ]],
|
||||
|
||||
Cell[CellGroupData[{
|
||||
|
||||
Cell[BoxData[
|
||||
RowBox[{"Log", "[",
|
||||
RowBox[{"Sin", "[", "38", "]"}], "]"}]], "Input",
|
||||
CellChangeTimes->{{3.611271663920905*^9, 3.6112716759275913`*^9}}],
|
||||
|
||||
Cell[BoxData[
|
||||
RowBox[{"Log", "[",
|
||||
RowBox[{"Sin", "[", "38", "]"}], "]"}]], "Output",
|
||||
CellChangeTimes->{3.611271678256725*^9}]
|
||||
}, Open ]],
|
||||
|
||||
Cell[CellGroupData[{
|
||||
|
||||
Cell[BoxData[
|
||||
RowBox[{"N", "[",
|
||||
RowBox[{"Log", "[",
|
||||
RowBox[{"Sin", "[", "38", "]"}], "]"}], "]"}]], "Input",
|
||||
NumberMarks->False],
|
||||
|
||||
Cell[BoxData[
|
||||
RowBox[{"-", "1.2161514009320473`"}]], "Output",
|
||||
CellChangeTimes->{3.611271682061942*^9}]
|
||||
}, Open ]],
|
||||
|
||||
Cell[CellGroupData[{
|
||||
|
||||
Cell[BoxData[
|
||||
RowBox[{"Abs", "[",
|
||||
RowBox[{"-", "1.2161514009320473`"}], "]"}]], "Input",
|
||||
NumberMarks->False],
|
||||
|
||||
Cell[BoxData["1.2161514009320473`"], "Output",
|
||||
CellChangeTimes->{3.6112716842780695`*^9}]
|
||||
}, Open ]],
|
||||
|
||||
Cell[CellGroupData[{
|
||||
|
||||
Cell[BoxData[
|
||||
RowBox[{"RealDigits", "[", "1.2161514009320473`", "]"}]], "Input",
|
||||
NumberMarks->False],
|
||||
|
||||
Cell[BoxData[
|
||||
RowBox[{"{",
|
||||
RowBox[{
|
||||
RowBox[{"{",
|
||||
RowBox[{
|
||||
"1", ",", "2", ",", "1", ",", "6", ",", "1", ",", "5", ",", "1", ",", "4",
|
||||
",", "0", ",", "0", ",", "9", ",", "3", ",", "2", ",", "0", ",", "4",
|
||||
",", "7"}], "}"}], ",", "1"}], "}"}]], "Output",
|
||||
CellChangeTimes->{3.611271685319129*^9}]
|
||||
}, Open ]],
|
||||
|
||||
Cell[CellGroupData[{
|
||||
|
||||
Cell[BoxData[
|
||||
RowBox[{
|
||||
RowBox[{"Graph", "[",
|
||||
RowBox[{"Log", "[", "x", "]"}], "]"}], "\[IndentingNewLine]"}]], "Input",
|
||||
CellChangeTimes->{{3.611271689258354*^9, 3.611271702038085*^9}}],
|
||||
|
||||
Cell[BoxData[
|
||||
RowBox[{"Graph", "[",
|
||||
RowBox[{"Log", "[", "x", "]"}], "]"}]], "Output",
|
||||
CellChangeTimes->{3.611271704295214*^9}]
|
||||
}, Open ]],
|
||||
|
||||
Cell[BoxData[""], "Input",
|
||||
CellChangeTimes->{{3.611271712769699*^9, 3.6112717423153887`*^9}}],
|
||||
|
||||
Cell[CellGroupData[{
|
||||
|
||||
Cell[BoxData[
|
||||
RowBox[{
|
||||
RowBox[{"Plot", "[",
|
||||
RowBox[{
|
||||
RowBox[{"Log", "[", "x", "]"}], ",", " ",
|
||||
RowBox[{"{",
|
||||
RowBox[{"x", ",", " ", "0", ",", " ", "10"}], "}"}]}], "]"}],
|
||||
"\[IndentingNewLine]"}]], "Input",
|
||||
CellChangeTimes->{{3.6112717573482485`*^9, 3.6112717747822456`*^9}}],
|
||||
|
||||
Cell[BoxData[
|
||||
GraphicsBox[{{}, {},
|
||||
{Hue[0.67, 0.6, 0.6], LineBox[CompressedData["
|
||||
1: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
|
||||
/wc13qzo
|
||||
"]]}},
|
||||
AspectRatio->NCache[GoldenRatio^(-1), 0.6180339887498948],
|
||||
Axes->True,
|
||||
AxesLabel->{None, None},
|
||||
AxesOrigin->{0, 0},
|
||||
Method->{},
|
||||
PlotRange->{{0, 10}, {-1.623796532045525, 2.3025850725858823`}},
|
||||
PlotRangeClipping->True,
|
||||
PlotRangePadding->{
|
||||
Scaled[0.02],
|
||||
Scaled[0.02]}]], "Output",
|
||||
CellChangeTimes->{3.6112717778594217`*^9}]
|
||||
}, Open ]]
|
||||
},
|
||||
WindowSize->{716, 833},
|
||||
WindowMargins->{{Automatic, 214}, {Automatic, 26}},
|
||||
FrontEndVersion->"9.0 for Microsoft Windows (64-bit) (January 25, 2013)",
|
||||
StyleDefinitions->"Default.nb"
|
||||
]
|
||||
(* End of Notebook Content *)
|
||||
|
||||
(* Internal cache information *)
|
||||
(*CellTagsOutline
|
||||
CellTagsIndex->{}
|
||||
*)
|
||||
(*CellTagsIndex
|
||||
CellTagsIndex->{}
|
||||
*)
|
||||
(*NotebookFileOutline
|
||||
Notebook[{
|
||||
Cell[CellGroupData[{
|
||||
Cell[579, 22, 224, 6, 52, "Input"],
|
||||
Cell[806, 30, 211, 6, 31, "Output"]
|
||||
}, Open ]],
|
||||
Cell[CellGroupData[{
|
||||
Cell[1054, 41, 155, 3, 31, "Input"],
|
||||
Cell[1212, 46, 130, 3, 31, "Output"]
|
||||
}, Open ]],
|
||||
Cell[CellGroupData[{
|
||||
Cell[1379, 54, 137, 4, 31, "Input"],
|
||||
Cell[1519, 60, 105, 2, 31, "Output"]
|
||||
}, Open ]],
|
||||
Cell[CellGroupData[{
|
||||
Cell[1661, 67, 113, 3, 31, "Input"],
|
||||
Cell[1777, 72, 90, 1, 31, "Output"]
|
||||
}, Open ]],
|
||||
Cell[CellGroupData[{
|
||||
Cell[1904, 78, 102, 2, 31, "Input"],
|
||||
Cell[2009, 82, 321, 8, 31, "Output"]
|
||||
}, Open ]],
|
||||
Cell[CellGroupData[{
|
||||
Cell[2367, 95, 191, 4, 52, "Input"],
|
||||
Cell[2561, 101, 131, 3, 31, "Output"]
|
||||
}, Open ]],
|
||||
Cell[2707, 107, 94, 1, 31, "Input"],
|
||||
Cell[CellGroupData[{
|
||||
Cell[2826, 112, 299, 8, 52, "Input"],
|
||||
Cell[3128, 122, 3019, 57, 265, "Output"]
|
||||
}, Open ]]
|
||||
}
|
||||
]
|
||||
*)
|
||||
|
||||
(* End of internal cache information *)
|
||||
3666
samples/Mathematica/MiscCalculations2.nb
Normal file
3666
samples/Mathematica/MiscCalculations2.nb
Normal file
File diff suppressed because it is too large
Load Diff
8
samples/Mathematica/Problem12.m
Normal file
8
samples/Mathematica/Problem12.m
Normal file
@@ -0,0 +1,8 @@
|
||||
(* ::Package:: *)
|
||||
|
||||
(* Problem12.m *)
|
||||
(* Author: William Woodruff *)
|
||||
(* Problem: What is the value of the first triangle number to have over five hundred divisors? *)
|
||||
|
||||
Do[If[Length[Divisors[Binomial[i + 1, 2]]] > 500,
|
||||
Print[Binomial[i + 1, 2]]; Break[]], {i, 1000000}]
|
||||
260
samples/Prolog/format_spec.pl
Normal file
260
samples/Prolog/format_spec.pl
Normal file
@@ -0,0 +1,260 @@
|
||||
:- module(format_spec, [ format_error/2
|
||||
, format_spec/2
|
||||
, format_spec//1
|
||||
, spec_arity/2
|
||||
, spec_types/2
|
||||
]).
|
||||
|
||||
:- use_module(library(dcg/basics), [eos//0, integer//1, string_without//2]).
|
||||
:- use_module(library(error)).
|
||||
:- use_module(library(when), [when/2]).
|
||||
|
||||
% TODO loading this module is optional
|
||||
% TODO it's for my own convenience during development
|
||||
%:- use_module(library(mavis)).
|
||||
|
||||
%% format_error(+Goal, -Error:string) is nondet.
|
||||
%
|
||||
% True if Goal exhibits an Error in its format string. The
|
||||
% Error string describes what is wrong with Goal. Iterates each
|
||||
% error on backtracking.
|
||||
%
|
||||
% Goal may be one of the following predicates:
|
||||
%
|
||||
% * format/2
|
||||
% * format/3
|
||||
% * debug/3
|
||||
format_error(format(Format,Args), Error) :-
|
||||
format_error_(Format, Args,Error).
|
||||
format_error(format(_,Format,Args), Error) :-
|
||||
format_error_(Format,Args,Error).
|
||||
format_error(debug(_,Format,Args), Error) :-
|
||||
format_error_(Format,Args,Error).
|
||||
|
||||
format_error_(Format,Args,Error) :-
|
||||
format_spec(Format, Spec),
|
||||
!,
|
||||
is_list(Args),
|
||||
spec_types(Spec, Types),
|
||||
types_error(Args, Types, Error).
|
||||
format_error_(Format,_,Error) :-
|
||||
% \+ format_spec(Format, _),
|
||||
format(string(Error), "Invalid format string: ~q", [Format]).
|
||||
|
||||
types_error(Args, Types, Error) :-
|
||||
length(Types, TypesLen),
|
||||
length(Args, ArgsLen),
|
||||
TypesLen =\= ArgsLen,
|
||||
!,
|
||||
format( string(Error)
|
||||
, "Wrong argument count. Expected ~d, got ~d"
|
||||
, [TypesLen, ArgsLen]
|
||||
).
|
||||
types_error(Args, Types, Error) :-
|
||||
types_error_(Args, Types, Error).
|
||||
|
||||
types_error_([Arg|_],[Type|_],Error) :-
|
||||
ground(Arg),
|
||||
\+ is_of_type(Type,Arg),
|
||||
message_to_string(error(type_error(Type,Arg),_Location),Error).
|
||||
types_error_([_|Args],[_|Types],Error) :-
|
||||
types_error_(Args, Types, Error).
|
||||
|
||||
|
||||
% check/0 augmentation
|
||||
:- multifile check:checker/2.
|
||||
:- dynamic check:checker/2.
|
||||
check:checker(format_spec:checker, "format/2 strings and arguments").
|
||||
|
||||
:- dynamic format_fail/3.
|
||||
|
||||
checker :-
|
||||
prolog_walk_code([ module_class([user])
|
||||
, infer_meta_predicates(false)
|
||||
, autoload(false) % format/{2,3} are always loaded
|
||||
, undefined(ignore)
|
||||
, trace_reference(_)
|
||||
, on_trace(check_format)
|
||||
]),
|
||||
retract(format_fail(Goal,Location,Error)),
|
||||
print_message(warning, format_error(Goal,Location,Error)),
|
||||
fail. % iterate all errors
|
||||
checker. % succeed even if no errors are found
|
||||
|
||||
check_format(Module:Goal, _Caller, Location) :-
|
||||
predicate_property(Module:Goal, imported_from(Source)),
|
||||
memberchk(Source, [system,prolog_debug]),
|
||||
can_check(Goal),
|
||||
format_error(Goal, Error),
|
||||
assert(format_fail(Goal, Location, Error)),
|
||||
fail.
|
||||
check_format(_,_,_). % succeed to avoid printing goals
|
||||
|
||||
% true if format_error/2 can check this goal
|
||||
can_check(Goal) :-
|
||||
once(clause(format_error(Goal,_),_)).
|
||||
|
||||
prolog:message(format_error(Goal,Location,Error)) -->
|
||||
prolog:message_location(Location),
|
||||
['~n In goal: ~q~n ~s'-[Goal,Error]].
|
||||
|
||||
|
||||
%% format_spec(-Spec)//
|
||||
%
|
||||
% DCG for parsing format strings. It doesn't yet generate format
|
||||
% strings from a spec. See format_spec/2 for details.
|
||||
format_spec([]) -->
|
||||
eos.
|
||||
format_spec([escape(Numeric,Modifier,Action)|Rest]) -->
|
||||
"~",
|
||||
numeric_argument(Numeric),
|
||||
modifier_argument(Modifier),
|
||||
action(Action),
|
||||
format_spec(Rest).
|
||||
format_spec([text(String)|Rest]) -->
|
||||
{ when((ground(String);ground(Codes)),string_codes(String, Codes)) },
|
||||
string_without("~", Codes),
|
||||
{ Codes \= [] },
|
||||
format_spec(Rest).
|
||||
|
||||
|
||||
%% format_spec(+Format, -Spec:list) is semidet.
|
||||
%
|
||||
% Parse a format string. Each element of Spec is one of the following:
|
||||
%
|
||||
% * `text(Text)` - text sent to the output as is
|
||||
% * `escape(Num,Colon,Action)` - a format escape
|
||||
%
|
||||
% `Num` represents the optional numeric portion of an esape. `Colon`
|
||||
% represents the optional colon in an escape. `Action` is an atom
|
||||
% representing the action to be take by this escape.
|
||||
format_spec(Format, Spec) :-
|
||||
when((ground(Format);ground(Codes)),text_codes(Format, Codes)),
|
||||
once(phrase(format_spec(Spec), Codes, [])).
|
||||
|
||||
%% spec_arity(+FormatSpec, -Arity:positive_integer) is det.
|
||||
%
|
||||
% True if FormatSpec requires format/2 to have Arity arguments.
|
||||
spec_arity(Spec, Arity) :-
|
||||
spec_types(Spec, Types),
|
||||
length(Types, Arity).
|
||||
|
||||
|
||||
%% spec_types(+FormatSpec, -Types:list(type)) is det.
|
||||
%
|
||||
% True if FormatSpec requires format/2 to have arguments of Types. Each
|
||||
% value of Types is a type as described by error:has_type/2. This
|
||||
% notion of types is compatible with library(mavis).
|
||||
spec_types(Spec, Types) :-
|
||||
phrase(spec_types(Spec), Types).
|
||||
|
||||
spec_types([]) -->
|
||||
[].
|
||||
spec_types([Item|Items]) -->
|
||||
item_types(Item),
|
||||
spec_types(Items).
|
||||
|
||||
item_types(text(_)) -->
|
||||
[].
|
||||
item_types(escape(Numeric,_,Action)) -->
|
||||
numeric_types(Numeric),
|
||||
action_types(Action).
|
||||
|
||||
numeric_types(number(_)) -->
|
||||
[].
|
||||
numeric_types(character(_)) -->
|
||||
[].
|
||||
numeric_types(star) -->
|
||||
[number].
|
||||
numeric_types(nothing) -->
|
||||
[].
|
||||
|
||||
action_types(Action) -->
|
||||
{ atom_codes(Action, [Code]) },
|
||||
{ action_types(Code, Types) },
|
||||
phrase(Types).
|
||||
|
||||
|
||||
%% text_codes(Text:text, Codes:codes).
|
||||
text_codes(Var, Codes) :-
|
||||
var(Var),
|
||||
!,
|
||||
string_codes(Var, Codes).
|
||||
text_codes(Atom, Codes) :-
|
||||
atom(Atom),
|
||||
!,
|
||||
atom_codes(Atom, Codes).
|
||||
text_codes(String, Codes) :-
|
||||
string(String),
|
||||
!,
|
||||
string_codes(String, Codes).
|
||||
text_codes(Codes, Codes) :-
|
||||
is_of_type(codes, Codes).
|
||||
|
||||
|
||||
numeric_argument(number(N)) -->
|
||||
integer(N).
|
||||
numeric_argument(character(C)) -->
|
||||
"`",
|
||||
[C].
|
||||
numeric_argument(star) -->
|
||||
"*".
|
||||
numeric_argument(nothing) -->
|
||||
"".
|
||||
|
||||
|
||||
modifier_argument(colon) -->
|
||||
":".
|
||||
modifier_argument(no_colon) -->
|
||||
\+ ":".
|
||||
|
||||
|
||||
action(Action) -->
|
||||
[C],
|
||||
{ is_action(C) },
|
||||
{ atom_codes(Action, [C]) }.
|
||||
|
||||
|
||||
%% is_action(+Action:integer) is semidet.
|
||||
%% is_action(-Action:integer) is multi.
|
||||
%
|
||||
% True if Action is a valid format/2 action character. Iterates all
|
||||
% acceptable action characters, if Action is unbound.
|
||||
is_action(Action) :-
|
||||
action_types(Action, _).
|
||||
|
||||
%% action_types(?Action:integer, ?Types:list(type))
|
||||
%
|
||||
% True if Action consumes arguments matching Types. An action (like
|
||||
% `~`), which consumes no arguments, has `Types=[]`. For example,
|
||||
%
|
||||
% ?- action_types(0'~, Types).
|
||||
% Types = [].
|
||||
% ?- action_types(0'a, Types).
|
||||
% Types = [atom].
|
||||
action_types(0'~, []).
|
||||
action_types(0'a, [atom]).
|
||||
action_types(0'c, [integer]). % specifically, a code
|
||||
action_types(0'd, [integer]).
|
||||
action_types(0'D, [integer]).
|
||||
action_types(0'e, [float]).
|
||||
action_types(0'E, [float]).
|
||||
action_types(0'f, [float]).
|
||||
action_types(0'g, [float]).
|
||||
action_types(0'G, [float]).
|
||||
action_types(0'i, [any]).
|
||||
action_types(0'I, [integer]).
|
||||
action_types(0'k, [any]).
|
||||
action_types(0'n, []).
|
||||
action_types(0'N, []).
|
||||
action_types(0'p, [any]).
|
||||
action_types(0'q, [any]).
|
||||
action_types(0'r, [integer]).
|
||||
action_types(0'R, [integer]).
|
||||
action_types(0's, [text]).
|
||||
action_types(0'@, [callable]).
|
||||
action_types(0't, []).
|
||||
action_types(0'|, []).
|
||||
action_types(0'+, []).
|
||||
action_types(0'w, [any]).
|
||||
action_types(0'W, [any, list]).
|
||||
194
samples/Prolog/func.pl
Normal file
194
samples/Prolog/func.pl
Normal file
@@ -0,0 +1,194 @@
|
||||
:- module(func, [ op(675, xfy, ($))
|
||||
, op(650, xfy, (of))
|
||||
, ($)/2
|
||||
, (of)/2
|
||||
]).
|
||||
:- use_module(library(list_util), [xfy_list/3]).
|
||||
:- use_module(library(function_expansion)).
|
||||
:- use_module(library(arithmetic)).
|
||||
:- use_module(library(error)).
|
||||
|
||||
|
||||
% true if the module whose terms are being read has specifically
|
||||
% imported library(func).
|
||||
wants_func :-
|
||||
prolog_load_context(module, Module),
|
||||
Module \== func, % we don't want func sugar ourselves
|
||||
predicate_property(Module:of(_,_),imported_from(func)).
|
||||
|
||||
|
||||
%% compile_function(+Term, -In, -Out, -Goal) is semidet.
|
||||
%
|
||||
% True if Term represents a function from In to Out
|
||||
% implemented by calling Goal. This multifile hook is
|
||||
% called by $/2 and of/2 to convert a term into a goal.
|
||||
% It's used at compile time for macro expansion.
|
||||
% It's used at run time to handle functions which aren't
|
||||
% known at compile time.
|
||||
% When called as a hook, Term is guaranteed to be =nonvar=.
|
||||
%
|
||||
% For example, to treat library(assoc) terms as functions which
|
||||
% map a key to a value, one might define:
|
||||
%
|
||||
% :- multifile compile_function/4.
|
||||
% compile_function(Assoc, Key, Value, Goal) :-
|
||||
% is_assoc(Assoc),
|
||||
% Goal = get_assoc(Key, Assoc, Value).
|
||||
%
|
||||
% Then one could write:
|
||||
%
|
||||
% list_to_assoc([a-1, b-2, c-3], Assoc),
|
||||
% Two = Assoc $ b,
|
||||
:- multifile compile_function/4.
|
||||
compile_function(Var, _, _, _) :-
|
||||
% variables storing functions must be evaluated at run time
|
||||
% and can't be compiled, a priori, into a goal
|
||||
var(Var),
|
||||
!,
|
||||
fail.
|
||||
compile_function(Expr, In, Out, Out is Expr) :-
|
||||
% arithmetic expression of one variable are simply evaluated
|
||||
\+ string(Expr), % evaluable/1 throws exception with strings
|
||||
arithmetic:evaluable(Expr),
|
||||
term_variables(Expr, [In]).
|
||||
compile_function(F, In, Out, func:Goal) :-
|
||||
% composed functions
|
||||
function_composition_term(F),
|
||||
user:function_expansion(F, func:Functor, true),
|
||||
Goal =.. [Functor,In,Out].
|
||||
compile_function(F, In, Out, Goal) :-
|
||||
% string interpolation via format templates
|
||||
format_template(F),
|
||||
( atom(F) ->
|
||||
Goal = format(atom(Out), F, In)
|
||||
; string(F) ->
|
||||
Goal = format(string(Out), F, In)
|
||||
; error:has_type(codes, F) ->
|
||||
Goal = format(codes(Out), F, In)
|
||||
; fail % to be explicit
|
||||
).
|
||||
compile_function(Dict, In, Out, Goal) :-
|
||||
is_dict(Dict),
|
||||
Goal = get_dict(In, Dict, Out).
|
||||
|
||||
%% $(+Function, +Argument) is det.
|
||||
%
|
||||
% Apply Function to an Argument. A Function is any predicate
|
||||
% whose final argument generates output and whose penultimate argument
|
||||
% accepts input.
|
||||
%
|
||||
% This is realized by expanding function application to chained
|
||||
% predicate calls at compile time. Function application itself can
|
||||
% be chained.
|
||||
%
|
||||
% ==
|
||||
% Reversed = reverse $ sort $ [c,d,b].
|
||||
% ==
|
||||
:- meta_predicate $(2,+).
|
||||
$(_,_) :-
|
||||
throw(error(permission_error(call, predicate, ($)/2),
|
||||
context(_, '$/2 must be subject to goal expansion'))).
|
||||
|
||||
user:function_expansion($(F,X), Y, Goal) :-
|
||||
wants_func,
|
||||
( func:compile_function(F, X, Y, Goal) ->
|
||||
true
|
||||
; var(F) -> Goal = % defer until run time
|
||||
( func:compile_function(F, X, Y, P) ->
|
||||
call(P)
|
||||
; call(F, X, Y)
|
||||
)
|
||||
; Goal = call(F, X, Y)
|
||||
).
|
||||
|
||||
|
||||
%% of(+F, +G) is det.
|
||||
%
|
||||
% Creates a new function by composing F and G. The functions are
|
||||
% composed at compile time to create a new, compiled predicate which
|
||||
% behaves like a function. Function composition can be chained.
|
||||
% Composed functions can also be applied with $/2.
|
||||
%
|
||||
% ==
|
||||
% Reversed = reverse of sort $ [c,d,b].
|
||||
% ==
|
||||
:- meta_predicate of(2,2).
|
||||
of(_,_).
|
||||
|
||||
|
||||
%% format_template(Format) is semidet.
|
||||
%
|
||||
% True if Format is a template string suitable for format/3.
|
||||
% The current check is very naive and should be improved.
|
||||
format_template(Format) :-
|
||||
atom(Format), !,
|
||||
atom_codes(Format, Codes),
|
||||
format_template(Codes).
|
||||
format_template(Format) :-
|
||||
string(Format),
|
||||
!,
|
||||
string_codes(Format, Codes),
|
||||
format_template(Codes).
|
||||
format_template(Format) :-
|
||||
error:has_type(codes, Format),
|
||||
memberchk(0'~, Format). % ' fix syntax highlighting
|
||||
|
||||
|
||||
% True if the argument is a function composition term
|
||||
function_composition_term(of(_,_)).
|
||||
|
||||
% Converts a function composition term into a list of functions to compose
|
||||
functions_to_compose(Term, Funcs) :-
|
||||
functor(Term, Op, 2),
|
||||
Op = (of),
|
||||
xfy_list(Op, Term, Funcs).
|
||||
|
||||
% Thread a state variable through a list of functions. This is similar
|
||||
% to a DCG expansion, but much simpler.
|
||||
thread_state([], [], Out, Out).
|
||||
thread_state([F|Funcs], [Goal|Goals], In, Out) :-
|
||||
( compile_function(F, In, Tmp, Goal) ->
|
||||
true
|
||||
; var(F) ->
|
||||
instantiation_error(F)
|
||||
; F =.. [Functor|Args],
|
||||
append(Args, [In, Tmp], NewArgs),
|
||||
Goal =.. [Functor|NewArgs]
|
||||
),
|
||||
thread_state(Funcs, Goals, Tmp, Out).
|
||||
|
||||
user:function_expansion(Term, func:Functor, true) :-
|
||||
wants_func,
|
||||
functions_to_compose(Term, Funcs),
|
||||
debug(func, 'building composed function for: ~w', [Term]),
|
||||
variant_sha1(Funcs, Sha),
|
||||
format(atom(Functor), 'composed_function_~w', [Sha]),
|
||||
debug(func, ' name: ~s', [Functor]),
|
||||
( func:current_predicate(Functor/2) ->
|
||||
debug(func, ' composed predicate already exists', [])
|
||||
; true ->
|
||||
reverse(Funcs, RevFuncs),
|
||||
thread_state(RevFuncs, Threaded, In, Out),
|
||||
xfy_list(',', Body, Threaded),
|
||||
Head =.. [Functor, In, Out],
|
||||
func:assert(Head :- Body),
|
||||
func:compile_predicates([Functor/2])
|
||||
).
|
||||
|
||||
|
||||
% support foo(x,~,y) evaluation
|
||||
user:function_expansion(Term, Output, Goal) :-
|
||||
wants_func,
|
||||
compound(Term),
|
||||
|
||||
% has a single ~ argument
|
||||
setof( X
|
||||
, ( arg(X,Term,Arg), Arg == '~' )
|
||||
, [N]
|
||||
),
|
||||
|
||||
% replace ~ with a variable
|
||||
Term =.. [Name|Args0],
|
||||
nth1(N, Args0, ~, Rest),
|
||||
nth1(N, Args, Output, Rest),
|
||||
Goal =.. [Name|Args].
|
||||
241
samples/Python/Cinema4DPythonPlugin.pyp
Normal file
241
samples/Python/Cinema4DPythonPlugin.pyp
Normal file
@@ -0,0 +1,241 @@
|
||||
#
|
||||
# Cinema 4D Python Plugin Source file
|
||||
# https://github.com/nr-plugins/nr-xpresso-alignment-tools
|
||||
#
|
||||
|
||||
# coding: utf-8
|
||||
#
|
||||
# Copyright (C) 2012, Niklas Rosenstein
|
||||
# Licensed under the GNU General Public License
|
||||
#
|
||||
# XPAT - XPresso Alignment Tools
|
||||
# ==============================
|
||||
#
|
||||
# The XPAT plugin provides tools for aligning nodes in the Cinema 4D
|
||||
# XPresso Editor, improving readability of complex XPresso set-ups
|
||||
# immensively.
|
||||
#
|
||||
# Requirements:
|
||||
# - MAXON Cinema 4D R13+
|
||||
# - Python `c4dtools` library. Get it from
|
||||
# http://github.com/NiklasRosenstein/c4dtools
|
||||
#
|
||||
# Author: Niklas Rosenstein <rosensteinniklas@gmail.com>
|
||||
# Version: 1.1 (01/06/2012)
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import c4d
|
||||
import c4dtools
|
||||
import itertools
|
||||
|
||||
from c4d.modules import graphview as gv
|
||||
from c4dtools.misc import graphnode
|
||||
|
||||
res, importer = c4dtools.prepare(__file__, __res__)
|
||||
settings = c4dtools.helpers.Attributor({
|
||||
'options_filename': res.file('config.json'),
|
||||
})
|
||||
|
||||
def align_nodes(nodes, mode, spacing):
|
||||
r"""
|
||||
Aligns the passed nodes horizontally and apply the minimum spacing
|
||||
between them.
|
||||
"""
|
||||
|
||||
modes = ['horizontal', 'vertical']
|
||||
if not nodes:
|
||||
return
|
||||
if mode not in modes:
|
||||
raise ValueError('invalid mode, choices are: ' + ', '.join(modes))
|
||||
|
||||
get_0 = lambda x: x.x
|
||||
get_1 = lambda x: x.y
|
||||
set_0 = lambda x, v: setattr(x, 'x', v)
|
||||
set_1 = lambda x, v: setattr(x, 'y', v)
|
||||
|
||||
if mode == 'vertical':
|
||||
get_0, get_1 = get_1, get_0
|
||||
set_0, set_1 = set_1, set_0
|
||||
|
||||
nodes = [graphnode.GraphNode(n) for n in nodes]
|
||||
nodes.sort(key=lambda n: get_0(n.position))
|
||||
midpoint = graphnode.find_nodes_mid(nodes)
|
||||
|
||||
# Apply the spacing between the nodes relative to the coordinate-systems
|
||||
# origin. We can offset them later because we now the nodes' midpoint
|
||||
# already.
|
||||
first_position = nodes[0].position
|
||||
new_positions = []
|
||||
prev_offset = 0
|
||||
for node in nodes:
|
||||
# Compute the relative position of the node.
|
||||
position = node.position
|
||||
set_0(position, get_0(position) - get_0(first_position))
|
||||
|
||||
# Obtain it's size and check if the node needs to be re-placed.
|
||||
size = node.size
|
||||
if get_0(position) < prev_offset:
|
||||
set_0(position, prev_offset)
|
||||
prev_offset += spacing + get_0(size)
|
||||
else:
|
||||
prev_offset = get_0(position) + get_0(size) + spacing
|
||||
|
||||
set_1(position, get_1(midpoint))
|
||||
new_positions.append(position)
|
||||
|
||||
# Center the nodes again.
|
||||
bbox_size = prev_offset - spacing
|
||||
bbox_size_2 = bbox_size * 0.5
|
||||
for node, position in itertools.izip(nodes, new_positions):
|
||||
# TODO: Here is some issue with offsetting the nodes. Some value
|
||||
# dependent on the spacing must be added here to not make the nodes
|
||||
# move horizontally/vertically although they have already been
|
||||
# aligned.
|
||||
set_0(position, get_0(midpoint) + get_0(position) - bbox_size_2 + spacing)
|
||||
node.position = position
|
||||
|
||||
def align_nodes_shortcut(mode, spacing):
|
||||
master = gv.GetMaster(0)
|
||||
if not master:
|
||||
return
|
||||
|
||||
root = master.GetRoot()
|
||||
if not root:
|
||||
return
|
||||
|
||||
nodes = graphnode.find_selected_nodes(root)
|
||||
if nodes:
|
||||
master.AddUndo()
|
||||
align_nodes(nodes, mode, spacing)
|
||||
c4d.EventAdd()
|
||||
|
||||
return True
|
||||
|
||||
class XPAT_Options(c4dtools.helpers.Attributor):
|
||||
r"""
|
||||
This class organizes the options for the XPAT plugin, i.e.
|
||||
validating, loading and saving.
|
||||
"""
|
||||
|
||||
defaults = {
|
||||
'hspace': 50,
|
||||
'vspace': 20,
|
||||
}
|
||||
|
||||
def __init__(self, filename=None):
|
||||
super(XPAT_Options, self).__init__()
|
||||
self.load(filename)
|
||||
|
||||
def load(self, filename=None):
|
||||
r"""
|
||||
Load the options from file pointed to by filename. If filename
|
||||
is None, it defaults to the filename defined in options in the
|
||||
global scope.
|
||||
"""
|
||||
|
||||
if filename is None:
|
||||
filename = settings.options_filename
|
||||
|
||||
if os.path.isfile(filename):
|
||||
self.dict_ = self.defaults.copy()
|
||||
with open(filename, 'rb') as fp:
|
||||
self.dict_.update(json.load(fp))
|
||||
else:
|
||||
self.dict_ = self.defaults.copy()
|
||||
self.save()
|
||||
|
||||
def save(self, filename=None):
|
||||
r"""
|
||||
Save the options defined in XPAT_Options instance to HD.
|
||||
"""
|
||||
|
||||
if filename is None:
|
||||
filename = settings.options_filename
|
||||
|
||||
values = dict((k, v) for k, v in self.dict_.iteritems()
|
||||
if k in self.defaults)
|
||||
with open(filename, 'wb') as fp:
|
||||
json.dump(values, fp)
|
||||
|
||||
class XPAT_OptionsDialog(c4d.gui.GeDialog):
|
||||
r"""
|
||||
This class implements the behavior of the XPAT options dialog,
|
||||
taking care of storing the options on the HD and loading them
|
||||
again on startup.
|
||||
"""
|
||||
|
||||
# c4d.gui.GeDialog
|
||||
|
||||
def CreateLayout(self):
|
||||
return self.LoadDialogResource(res.DLG_OPTIONS)
|
||||
|
||||
def InitValues(self):
|
||||
self.SetLong(res.EDT_HSPACE, options.hspace)
|
||||
self.SetLong(res.EDT_VSPACE, options.vspace)
|
||||
return True
|
||||
|
||||
def Command(self, id, msg):
|
||||
if id == res.BTN_SAVE:
|
||||
options.hspace = self.GetLong(res.EDT_HSPACE)
|
||||
options.vspace = self.GetLong(res.EDT_VSPACE)
|
||||
options.save()
|
||||
self.Close()
|
||||
return True
|
||||
|
||||
class XPAT_Command_OpenOptionsDialog(c4dtools.plugins.Command):
|
||||
r"""
|
||||
This Cinema 4D CommandData plugin opens the XPAT options dialog
|
||||
when being executed.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super(XPAT_Command_OpenOptionsDialog, self).__init__()
|
||||
self._dialog = None
|
||||
|
||||
@property
|
||||
def dialog(self):
|
||||
if not self._dialog:
|
||||
self._dialog = XPAT_OptionsDialog()
|
||||
return self._dialog
|
||||
|
||||
# c4dtools.plugins.Command
|
||||
|
||||
PLUGIN_ID = 1029621
|
||||
PLUGIN_NAME = res.string.XPAT_COMMAND_OPENOPTIONSDIALOG()
|
||||
PLUGIN_HELP = res.string.XPAT_COMMAND_OPENOPTIONSDIALOG_HELP()
|
||||
|
||||
# c4d.gui.CommandData
|
||||
|
||||
def Execute(self, doc):
|
||||
return self.dialog.Open(c4d.DLG_TYPE_MODAL)
|
||||
|
||||
class XPAT_Command_AlignHorizontal(c4dtools.plugins.Command):
|
||||
|
||||
PLUGIN_ID = 1029538
|
||||
PLUGIN_NAME = res.string.XPAT_COMMAND_ALIGNHORIZONTAL()
|
||||
PLUGIN_ICON = res.file('xpresso-align-h.png')
|
||||
PLUGIN_HELP = res.string.XPAT_COMMAND_ALIGNHORIZONTAL_HELP()
|
||||
|
||||
def Execute(self, doc):
|
||||
align_nodes_shortcut('horizontal', options.hspace)
|
||||
return True
|
||||
|
||||
class XPAT_Command_AlignVertical(c4dtools.plugins.Command):
|
||||
|
||||
PLUGIN_ID = 1029539
|
||||
PLUGIN_NAME = res.string.XPAT_COMMAND_ALIGNVERTICAL()
|
||||
PLUGIN_ICON = res.file('xpresso-align-v.png')
|
||||
PLUGIN_HELP = res.string.XPAT_COMMAND_ALIGNVERTICAL_HELP()
|
||||
|
||||
def Execute(self, doc):
|
||||
align_nodes_shortcut('vertical', options.vspace)
|
||||
return True
|
||||
|
||||
options = XPAT_Options()
|
||||
|
||||
if __name__ == '__main__':
|
||||
c4dtools.plugins.main()
|
||||
|
||||
|
||||
21
samples/XML/sample.nuspec
Normal file
21
samples/XML/sample.nuspec
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0"?>
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>Sample</id>
|
||||
<title>Sample</title>
|
||||
<version>0.101.0</version>
|
||||
<authors>Hugh Bot</authors>
|
||||
<owners>Hugh Bot</owners>
|
||||
<summary>A package of nuget</summary>
|
||||
<description>
|
||||
It just works
|
||||
</description>
|
||||
<projectUrl>http://hubot.github.com</projectUrl>
|
||||
<copyright/>
|
||||
<licenseUrl>https://github.com/github/hubot/LICENSEmd</licenseUrl>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="tools\**" target="tools"/>
|
||||
</files>
|
||||
</package>
|
||||
22
samples/Xojo/App.xojo_code
Normal file
22
samples/Xojo/App.xojo_code
Normal file
@@ -0,0 +1,22 @@
|
||||
#tag Class
|
||||
Protected Class App
|
||||
Inherits Application
|
||||
#tag Constant, Name = kEditClear, Type = String, Dynamic = False, Default = \"&Delete", Scope = Public
|
||||
#Tag Instance, Platform = Windows, Language = Default, Definition = \"&Delete"
|
||||
#Tag Instance, Platform = Linux, Language = Default, Definition = \"&Delete"
|
||||
#tag EndConstant
|
||||
|
||||
#tag Constant, Name = kFileQuit, Type = String, Dynamic = False, Default = \"&Quit", Scope = Public
|
||||
#Tag Instance, Platform = Windows, Language = Default, Definition = \"E&xit"
|
||||
#tag EndConstant
|
||||
|
||||
#tag Constant, Name = kFileQuitShortcut, Type = String, Dynamic = False, Default = \"", Scope = Public
|
||||
#Tag Instance, Platform = Mac OS, Language = Default, Definition = \"Cmd+Q"
|
||||
#Tag Instance, Platform = Linux, Language = Default, Definition = \"Ctrl+Q"
|
||||
#tag EndConstant
|
||||
|
||||
|
||||
#tag ViewBehavior
|
||||
#tag EndViewBehavior
|
||||
End Class
|
||||
#tag EndClass
|
||||
23
samples/Xojo/BillingReport.xojo_report
Normal file
23
samples/Xojo/BillingReport.xojo_report
Normal file
@@ -0,0 +1,23 @@
|
||||
#tag Report
|
||||
Begin Report BillingReport
|
||||
Compatibility = ""
|
||||
Units = 0
|
||||
Width = 8.5
|
||||
Begin PageHeader
|
||||
Type = 1
|
||||
Height = 1.0
|
||||
End
|
||||
Begin Body
|
||||
Type = 3
|
||||
Height = 2.0
|
||||
End
|
||||
Begin PageFooter
|
||||
Type = 5
|
||||
Height = 1.0
|
||||
End
|
||||
End
|
||||
#tag EndReport
|
||||
|
||||
#tag ReportCode
|
||||
#tag EndReportCode
|
||||
|
||||
112
samples/Xojo/MainMenuBar.xojo_menu
Normal file
112
samples/Xojo/MainMenuBar.xojo_menu
Normal file
@@ -0,0 +1,112 @@
|
||||
#tag Menu
|
||||
Begin Menu MainMenuBar
|
||||
Begin MenuItem FileMenu
|
||||
SpecialMenu = 0
|
||||
Text = "&File"
|
||||
Index = -2147483648
|
||||
AutoEnable = True
|
||||
Visible = True
|
||||
Begin QuitMenuItem FileQuit
|
||||
SpecialMenu = 0
|
||||
Text = "#App.kFileQuit"
|
||||
Index = -2147483648
|
||||
ShortcutKey = "#App.kFileQuitShortcut"
|
||||
Shortcut = "#App.kFileQuitShortcut"
|
||||
AutoEnable = True
|
||||
Visible = True
|
||||
End
|
||||
End
|
||||
Begin MenuItem EditMenu
|
||||
SpecialMenu = 0
|
||||
Text = "&Edit"
|
||||
Index = -2147483648
|
||||
AutoEnable = True
|
||||
Visible = True
|
||||
Begin MenuItem EditUndo
|
||||
SpecialMenu = 0
|
||||
Text = "&Undo"
|
||||
Index = -2147483648
|
||||
ShortcutKey = "Z"
|
||||
Shortcut = "Cmd+Z"
|
||||
MenuModifier = True
|
||||
AutoEnable = True
|
||||
Visible = True
|
||||
End
|
||||
Begin MenuItem EditSeparator1
|
||||
SpecialMenu = 0
|
||||
Text = "-"
|
||||
Index = -2147483648
|
||||
AutoEnable = True
|
||||
Visible = True
|
||||
End
|
||||
Begin MenuItem EditCut
|
||||
SpecialMenu = 0
|
||||
Text = "Cu&t"
|
||||
Index = -2147483648
|
||||
ShortcutKey = "X"
|
||||
Shortcut = "Cmd+X"
|
||||
MenuModifier = True
|
||||
AutoEnable = True
|
||||
Visible = True
|
||||
End
|
||||
Begin MenuItem EditCopy
|
||||
SpecialMenu = 0
|
||||
Text = "&Copy"
|
||||
Index = -2147483648
|
||||
ShortcutKey = "C"
|
||||
Shortcut = "Cmd+C"
|
||||
MenuModifier = True
|
||||
AutoEnable = True
|
||||
Visible = True
|
||||
End
|
||||
Begin MenuItem EditPaste
|
||||
SpecialMenu = 0
|
||||
Text = "&Paste"
|
||||
Index = -2147483648
|
||||
ShortcutKey = "V"
|
||||
Shortcut = "Cmd+V"
|
||||
MenuModifier = True
|
||||
AutoEnable = True
|
||||
Visible = True
|
||||
End
|
||||
Begin MenuItem EditClear
|
||||
SpecialMenu = 0
|
||||
Text = "#App.kEditClear"
|
||||
Index = -2147483648
|
||||
AutoEnable = True
|
||||
Visible = True
|
||||
End
|
||||
Begin MenuItem EditSeparator2
|
||||
SpecialMenu = 0
|
||||
Text = "-"
|
||||
Index = -2147483648
|
||||
AutoEnable = True
|
||||
Visible = True
|
||||
End
|
||||
Begin MenuItem EditSelectAll
|
||||
SpecialMenu = 0
|
||||
Text = "Select &All"
|
||||
Index = -2147483648
|
||||
ShortcutKey = "A"
|
||||
Shortcut = "Cmd+A"
|
||||
MenuModifier = True
|
||||
AutoEnable = True
|
||||
Visible = True
|
||||
End
|
||||
Begin MenuItem UntitledSeparator
|
||||
SpecialMenu = 0
|
||||
Text = "-"
|
||||
Index = -2147483648
|
||||
AutoEnable = True
|
||||
Visible = True
|
||||
End
|
||||
Begin AppleMenuItem AboutItem
|
||||
SpecialMenu = 0
|
||||
Text = "About This App..."
|
||||
Index = -2147483648
|
||||
AutoEnable = True
|
||||
Visible = True
|
||||
End
|
||||
End
|
||||
End
|
||||
#tag EndMenu
|
||||
14
samples/Xojo/MyToolbar.xojo_toolbar
Normal file
14
samples/Xojo/MyToolbar.xojo_toolbar
Normal file
@@ -0,0 +1,14 @@
|
||||
#tag Toolbar
|
||||
Begin Toolbar MyToolbar
|
||||
Begin ToolButton FirstItem
|
||||
Caption = "First Item"
|
||||
HelpTag = ""
|
||||
Style = 0
|
||||
End
|
||||
Begin ToolButton SecondItem
|
||||
Caption = "Second Item"
|
||||
HelpTag = ""
|
||||
Style = 0
|
||||
End
|
||||
End
|
||||
#tag EndToolbar
|
||||
304
samples/Xojo/Window1.xojo_window
Normal file
304
samples/Xojo/Window1.xojo_window
Normal file
@@ -0,0 +1,304 @@
|
||||
#tag Window
|
||||
Begin Window Window1
|
||||
BackColor = &cFFFFFF00
|
||||
Backdrop = 0
|
||||
CloseButton = True
|
||||
Compatibility = ""
|
||||
Composite = False
|
||||
Frame = 0
|
||||
FullScreen = False
|
||||
FullScreenButton= False
|
||||
HasBackColor = False
|
||||
Height = 400
|
||||
ImplicitInstance= True
|
||||
LiveResize = True
|
||||
MacProcID = 0
|
||||
MaxHeight = 32000
|
||||
MaximizeButton = True
|
||||
MaxWidth = 32000
|
||||
MenuBar = 1153981589
|
||||
MenuBarVisible = True
|
||||
MinHeight = 64
|
||||
MinimizeButton = True
|
||||
MinWidth = 64
|
||||
Placement = 0
|
||||
Resizeable = True
|
||||
Title = "Sample App"
|
||||
Visible = True
|
||||
Width = 600
|
||||
Begin PushButton HelloWorldButton
|
||||
AutoDeactivate = True
|
||||
Bold = False
|
||||
ButtonStyle = "0"
|
||||
Cancel = False
|
||||
Caption = "Push Me"
|
||||
Default = True
|
||||
Enabled = True
|
||||
Height = 20
|
||||
HelpTag = ""
|
||||
Index = -2147483648
|
||||
InitialParent = ""
|
||||
Italic = False
|
||||
Left = 260
|
||||
LockBottom = False
|
||||
LockedInPosition= False
|
||||
LockLeft = True
|
||||
LockRight = False
|
||||
LockTop = True
|
||||
Scope = 0
|
||||
TabIndex = 0
|
||||
TabPanelIndex = 0
|
||||
TabStop = True
|
||||
TextFont = "System"
|
||||
TextSize = 0.0
|
||||
TextUnit = 0
|
||||
Top = 32
|
||||
Underline = False
|
||||
Visible = True
|
||||
Width = 80
|
||||
End
|
||||
End
|
||||
#tag EndWindow
|
||||
|
||||
#tag WindowCode
|
||||
#tag EndWindowCode
|
||||
|
||||
#tag Events HelloWorldButton
|
||||
#tag Event
|
||||
Sub Action()
|
||||
Dim total As Integer
|
||||
|
||||
For i As Integer = 0 To 10
|
||||
total = total + i
|
||||
Next
|
||||
|
||||
MsgBox "Hello World! " + Str(total)
|
||||
End Sub
|
||||
#tag EndEvent
|
||||
#tag EndEvents
|
||||
#tag ViewBehavior
|
||||
#tag ViewProperty
|
||||
Name="BackColor"
|
||||
Visible=true
|
||||
Group="Appearance"
|
||||
InitialValue="&hFFFFFF"
|
||||
Type="Color"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="Backdrop"
|
||||
Visible=true
|
||||
Group="Appearance"
|
||||
Type="Picture"
|
||||
EditorType="Picture"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="CloseButton"
|
||||
Visible=true
|
||||
Group="Appearance"
|
||||
InitialValue="True"
|
||||
Type="Boolean"
|
||||
EditorType="Boolean"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="Composite"
|
||||
Visible=true
|
||||
Group="Appearance"
|
||||
InitialValue="False"
|
||||
Type="Boolean"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="Frame"
|
||||
Visible=true
|
||||
Group="Appearance"
|
||||
InitialValue="0"
|
||||
Type="Integer"
|
||||
EditorType="Enum"
|
||||
#tag EnumValues
|
||||
"0 - Document"
|
||||
"1 - Movable Modal"
|
||||
"2 - Modal Dialog"
|
||||
"3 - Floating Window"
|
||||
"4 - Plain Box"
|
||||
"5 - Shadowed Box"
|
||||
"6 - Rounded Window"
|
||||
"7 - Global Floating Window"
|
||||
"8 - Sheet Window"
|
||||
"9 - Metal Window"
|
||||
"10 - Drawer Window"
|
||||
"11 - Modeless Dialog"
|
||||
#tag EndEnumValues
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="FullScreen"
|
||||
Group="Appearance"
|
||||
InitialValue="False"
|
||||
Type="Boolean"
|
||||
EditorType="Boolean"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="FullScreenButton"
|
||||
Visible=true
|
||||
Group="Appearance"
|
||||
InitialValue="False"
|
||||
Type="Boolean"
|
||||
EditorType="Boolean"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="HasBackColor"
|
||||
Visible=true
|
||||
Group="Appearance"
|
||||
InitialValue="False"
|
||||
Type="Boolean"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="Height"
|
||||
Visible=true
|
||||
Group="Position"
|
||||
InitialValue="400"
|
||||
Type="Integer"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="ImplicitInstance"
|
||||
Visible=true
|
||||
Group="Appearance"
|
||||
InitialValue="True"
|
||||
Type="Boolean"
|
||||
EditorType="Boolean"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="Interfaces"
|
||||
Visible=true
|
||||
Group="ID"
|
||||
Type="String"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="LiveResize"
|
||||
Visible=true
|
||||
Group="Appearance"
|
||||
InitialValue="True"
|
||||
Type="Boolean"
|
||||
EditorType="Boolean"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="MacProcID"
|
||||
Visible=true
|
||||
Group="Appearance"
|
||||
InitialValue="0"
|
||||
Type="Integer"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="MaxHeight"
|
||||
Visible=true
|
||||
Group="Position"
|
||||
InitialValue="32000"
|
||||
Type="Integer"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="MaximizeButton"
|
||||
Visible=true
|
||||
Group="Appearance"
|
||||
InitialValue="True"
|
||||
Type="Boolean"
|
||||
EditorType="Boolean"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="MaxWidth"
|
||||
Visible=true
|
||||
Group="Position"
|
||||
InitialValue="32000"
|
||||
Type="Integer"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="MenuBar"
|
||||
Visible=true
|
||||
Group="Appearance"
|
||||
Type="MenuBar"
|
||||
EditorType="MenuBar"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="MenuBarVisible"
|
||||
Group="Appearance"
|
||||
InitialValue="True"
|
||||
Type="Boolean"
|
||||
EditorType="Boolean"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="MinHeight"
|
||||
Visible=true
|
||||
Group="Position"
|
||||
InitialValue="64"
|
||||
Type="Integer"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="MinimizeButton"
|
||||
Visible=true
|
||||
Group="Appearance"
|
||||
InitialValue="True"
|
||||
Type="Boolean"
|
||||
EditorType="Boolean"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="MinWidth"
|
||||
Visible=true
|
||||
Group="Position"
|
||||
InitialValue="64"
|
||||
Type="Integer"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="Name"
|
||||
Visible=true
|
||||
Group="ID"
|
||||
Type="String"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="Placement"
|
||||
Visible=true
|
||||
Group="Position"
|
||||
InitialValue="0"
|
||||
Type="Integer"
|
||||
EditorType="Enum"
|
||||
#tag EnumValues
|
||||
"0 - Default"
|
||||
"1 - Parent Window"
|
||||
"2 - Main Screen"
|
||||
"3 - Parent Window Screen"
|
||||
"4 - Stagger"
|
||||
#tag EndEnumValues
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="Resizeable"
|
||||
Visible=true
|
||||
Group="Appearance"
|
||||
InitialValue="True"
|
||||
Type="Boolean"
|
||||
EditorType="Boolean"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="Super"
|
||||
Visible=true
|
||||
Group="ID"
|
||||
Type="String"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="Title"
|
||||
Visible=true
|
||||
Group="Appearance"
|
||||
InitialValue="Untitled"
|
||||
Type="String"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="Visible"
|
||||
Visible=true
|
||||
Group="Appearance"
|
||||
InitialValue="True"
|
||||
Type="Boolean"
|
||||
EditorType="Boolean"
|
||||
#tag EndViewProperty
|
||||
#tag ViewProperty
|
||||
Name="Width"
|
||||
Visible=true
|
||||
Group="Position"
|
||||
InitialValue="600"
|
||||
Type="Integer"
|
||||
#tag EndViewProperty
|
||||
#tag EndViewBehavior
|
||||
17
samples/Xojo/database.xojo_script
Normal file
17
samples/Xojo/database.xojo_script
Normal file
@@ -0,0 +1,17 @@
|
||||
Dim dbFile As FolderItem
|
||||
Dim db As New SQLiteDatabase
|
||||
dbFile = GetFolderItem("Employees.sqlite")
|
||||
db.DatabaseFile = dbFile
|
||||
If db.Connect Then
|
||||
db.SQLExecute("BEGIN TRANSACTION")
|
||||
db.SQLExecute ("INSERT INTO Employees (Name,Job,YearJoined) VALUES "_
|
||||
+"('Dr.Strangelove','Advisor',1962)")
|
||||
If db.Error then
|
||||
MsgBox("Error: " + db.ErrorMessage)
|
||||
db.Rollback
|
||||
Else
|
||||
db.Commit
|
||||
End If
|
||||
Else
|
||||
MsgBox("The database couldn't be opened. Error: " + db.ErrorMessage)
|
||||
End If
|
||||
28
samples/Zephir/filenames/exception.zep.c
generated
Normal file
28
samples/Zephir/filenames/exception.zep.c
generated
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../../ext_config.h"
|
||||
#endif
|
||||
|
||||
#include <php.h>
|
||||
#include "../../php_ext.h"
|
||||
#include "../../ext.h"
|
||||
|
||||
#include <Zend/zend_operators.h>
|
||||
#include <Zend/zend_exceptions.h>
|
||||
#include <Zend/zend_interfaces.h>
|
||||
|
||||
#include "kernel/main.h"
|
||||
|
||||
|
||||
/**
|
||||
* Test\Router\Exception
|
||||
*
|
||||
* Exceptions generated by the router
|
||||
*/
|
||||
ZEPHIR_INIT_CLASS(Test_Router_Exception) {
|
||||
|
||||
ZEPHIR_REGISTER_CLASS_EX(Test\\Router, Exception, test, router_exception, zend_exception_get_default(TSRMLS_C), NULL, 0);
|
||||
|
||||
return SUCCESS;
|
||||
|
||||
}
|
||||
4
samples/Zephir/filenames/exception.zep.h
generated
Normal file
4
samples/Zephir/filenames/exception.zep.h
generated
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
extern zend_class_entry *test_router_exception_ce;
|
||||
|
||||
ZEPHIR_INIT_CLASS(Test_Router_Exception);
|
||||
8
samples/Zephir/filenames/exception.zep.php
generated
Normal file
8
samples/Zephir/filenames/exception.zep.php
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Test\Router;
|
||||
|
||||
class Exception extends \Exception
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user