codesimian
Interface CodeSimian

All Known Implementing Classes:
Above, AbsoluteValue, AccelerateAt, Add, AddP, AddParam, AddressShape, AddressShape.Fractal, AddressShape.Linear, AddressShape.Root, ArcSin, Ask, Attract, AudioBuffers.MicBufSiz, AudioBuffers.MicBufSpeed, AudioBuffers.MicCdqSiz, AudioBuffers.SoundBufSiz, AverageOf3DObjects, BayesNet, BayesNode, BayesNode.VerifyCountP, BayesNodeDependence, BayesNodePredictError, BayesNodeUpdate, BeforeExec, Binary, ButtonCS, Chaos.NextFreeChaosInt, ChaosBit, ChaosBit.Static, CharIsInWhichString, CharIsInWhichString.Final, CharTree, CharTree.CharTreeNode, ClassObject, CodesimianOptions, ColorCS, CommandLine, CompareNumbers, CompareNumbers.EqualB, CompareNumbers.EqualC, CompareNumbers.EqualD, CompareNumbers.EqualF, CompareNumbers.EqualI, CompareNumbers.EqualJ, CompareNumbers.EqualS, CompareNumbers.EqualZ, CompareNumbers.LessB, CompareNumbers.LessC, CompareNumbers.LessD, CompareNumbers.LessEqualB, CompareNumbers.LessEqualC, CompareNumbers.LessEqualD, CompareNumbers.LessEqualF, CompareNumbers.LessEqualI, CompareNumbers.LessEqualJ, CompareNumbers.LessEqualS, CompareNumbers.LessF, CompareNumbers.LessI, CompareNumbers.LessJ, CompareNumbers.LessS, CompareNumbers.MoreB, CompareNumbers.MoreC, CompareNumbers.MoreD, CompareNumbers.MoreEqualB, CompareNumbers.MoreEqualC, CompareNumbers.MoreEqualD, CompareNumbers.MoreEqualF, CompareNumbers.MoreEqualI, CompareNumbers.MoreEqualJ, CompareNumbers.MoreEqualS, CompareNumbers.MoreF, CompareNumbers.MoreI, CompareNumbers.MoreJ, CompareNumbers.MoreS, CompareNumbers.NotEqualB, CompareNumbers.NotEqualC, CompareNumbers.NotEqualD, CompareNumbers.NotEqualF, CompareNumbers.NotEqualI, CompareNumbers.NotEqualJ, CompareNumbers.NotEqualS, CompareNumbers.NotEqualZ, Compile, Compile.CompileDefaultCommand, Compile.CompileLiteral, Compile.CompilerPipeline, Compile.FirstCompilerThatWorks, Compile.LParenSymbol, Compile.MyFuelSymbol, Compile.NameSymbol, Compile.ParseObjects, Compile.ParseObjectsByPriority, Compile.RParenSymbol, Compile.SimpleCompiler, Compile.SmallSymbol, Compile.Symbol, Compile.TokenizeCode, Compile.TokensToObjects, Compile.WhitespaceSymbol, CompileAndExecInnerCsFile, Const, Const.ConstByte, Const.ConstDouble, Const.ConstFalse, Const.ConstFloat, Const.ConstInt, Const.ConstShort, Const.ConstTrue, Const.ConstWithUselessParams, ContinuousBayesNode, CopyParams, CopyParamToParam, Count, CS, DecayAve, DecayAve.AndDev, DecayAveAndDev, DeepCopy, DefaultCS, DefaultLetterLevelChatbot, DefaultWordLevelChatbot, Delay, DeleteParam, DeleteParam.DeleteAll, DieSpam, DieSpam.ButtonClicked, Distance, Divide, Do, Do.DoDDDL, Do.DoL, DoNatLang, EqualP, EqualRecurse2, Err, EvolveCode, EvolveNumbers, EvolveNumbers.BellCurveNumberListMutator, EvolveNumbers.ListAndNumber, Exec, Exec.Chaos, Exec.ChaosBit, Exec.Fixnan, Exec.FixnanChaos, Exec.FixnanPrev, Exec.FixnanPrevChaos, Exec.Fuel, Exec.FuelChaos, Exec.FuelFixnan, Exec.FuelFixnanChaos, Exec.FuelFixnanPrev, Exec.FuelFixnanPrevChaos, Exec.FuelPrev, Exec.FuelPrevChaos, Exec.Myfuel, Exec.MyfuelChaos, Exec.MyfuelFixnan, Exec.MyfuelFixnanChaos, Exec.MyfuelFixnanPrev, Exec.MyfuelFixnanPrevChaos, Exec.MyfuelFuel, Exec.MyfuelFuelChaos, Exec.MyfuelFuelFixnan, Exec.MyfuelFuelFixnanChaos, Exec.MyfuelFuelFixnanPrev, Exec.MyfuelFuelFixnanPrevChaos, Exec.MyfuelFuelPrev, Exec.MyfuelFuelPrevChaos, Exec.MyfuelPrev, Exec.MyfuelPrevChaos, Exec.None, Exec.Prev, Exec.PrevChaos, ExecParam, FileOfShorts, FileOrURL, Files.DefaultDownloader, Files.LoadCSFromFile, Files.SaveBytesP1IntoFileP0, Files.SaveCSToFile, Files.TextFileWriter, FileSaveBytesOptionalHumanChooseLocation, FixTypos, FloatBufferCurvesToAvoidEmpty, Fuel, Function, GetCSReflectingInnerFile, GetCSReflectingInnerFile.DefaultCSReflecting, GetJavaCompiler, GetResource, GetSortedSubsetOfStrListByStrToBoolFuncs, GraphSeq, GraphSeq.FastUnordered, GUI, HardCodedCommonControls, HardCodedSelfReplicatingWindow, HuffmanNode, HumanTypesCommand, IfElse, ImageCS, ImagePixels, ImmutBytes, IndentCode, IndependentCS, InnerFiles, InnerFiles.AllInternalFileNames, InnerFiles.DeleteInternalFile, InnerFiles.GetInnerFile, InnerFiles.GetInternalFile, InnerFiles.InnerFileExists, InnerFiles.SetInnerFile, InnerFiles.SetInternalFile, Interpolate, InterpretText, InterpretText.AllLetterPairs, InterpretText.AllLetterTriples, InterpretText.Concat, InterpretText.Normalize, InterpretText.SelectIndexs, InterpretText.Str, InterpretText.WordIndexs, InterpretText.WordPairDistance, InterpretText.WrapAroundSmallerRangeAndAverageOverlappingValues, InvokeMethod, Jars.JarTest, Jars.SaveUpdatedSelf, JavaCodeForNewSubclassOfCS, JavaCompilerWindowsOpSys, JavaCompilerWindowsOpSys.DownloadAndInstall, JavaField, JavaFunctionSimple, JavaObject, JavaOutInit, JavaOutSimple, JavaOutSimple.Lists, JavaType, JavaTypeConst, JudgeTextByGoodAndBadExamples, Keyboard.IsKeyDown, Keyboard.KeyDown, Keyboard.KeyLocationX, Keyboard.KeyLocationY, Keyboard.KeyUp, Keyboard.TypeThisStringOnKeyboard, KeyListenerOnComponent, Layout, LearnSelfDFromSelfListD, LearnSelfDFromSelfListD.Test, LinearAudios, LinearTimeQueue, Liquid, List16BitSignedIntegersFromListNumbersRangePlusMinus1, ListFindIndexFast, ListNumbersRangePlusMinus1FromList16BitSignedIntegers, ListOfStringsGUI, Log, Log.Base2, Log.BaseXOfY, Logic, Logic.And, Logic.Not, Logic.Or, Logic.Xor, LongListOfStrings, Loop, Loop.DynamicLoop, Loop.DynamicLoop.DynamicForLoop, Loop.DynamicLoop.DynamicRepeatLoop, Loop.DynamicLoop.DynamicWhileLoop, Loop.ForEach, Loop.StaticLoop, Loop.StaticLoop.StaticForLoop, Loop.StaticLoop.StaticRepeatLoop, Max, Median, Microphone, MicrophonePredictsBufferSize, MillisecondsSince1970, Min, Modulo, MostCommonSubstrings, MouseNumberList, MousePanel, MoveMouse, MoveMouse.MouseXPosition, MoveMouse.MouseYPosition, MP3, MP3.DefaultMP3Decoder, Multiply, N, NatLangType, NaturalLanguage.RemoveEverythingExceptLetters, Network, New, Num, Object3d, OneChatbotForEachWord, OpenSystemCommandWindow, OpenSystemCommandWindow.ForWindowsOS, OpenSystemCommandWindow.ForWindowsOS.Run, OverlappingPages, ParamCount, Pixels2d, Pixels2d.BrightnessFraction, PNewInstance, Pow, Predict, Primes, Primes.DoesItKnowPrimesByIndex, PrimitiveArray, PrimitiveArray.ByteArray, PrimitiveArray.IntArray, PrimitiveArray.ShortArray, Ptr, Ptr.FieldPtr, Ptr.IndividualPtrs, Ptr.Null, Ptr.ParamPtr, Ptr.PtrSet, RandGaussian, RandomExampleCode, RandomlyCombineCode, RandomNeuron, RandRange, RecurseP, RecurseP.RecursePD, Reflect6, ReflectedFunctions.addB, ReflectedFunctions.addC, ReflectedFunctions.addD, ReflectedFunctions.addF, ReflectedFunctions.addI, ReflectedFunctions.addJ, ReflectedFunctions.addL, ReflectedFunctions.addP, ReflectedFunctions.addPx, ReflectedFunctions.addPxx, ReflectedFunctions.addPxxx, ReflectedFunctions.addPxxxx, ReflectedFunctions.addS, ReflectedFunctions.addZ, ReflectedFunctions.B, ReflectedFunctions.BForProxy, ReflectedFunctions.C, ReflectedFunctions.CForProxy, ReflectedFunctions.clone, ReflectedFunctions.cost, ReflectedFunctions.countP, ReflectedFunctions.D, ReflectedFunctions.decrementMyFuel, ReflectedFunctions.deleteP, ReflectedFunctions.deletePx, ReflectedFunctions.description, ReflectedFunctions.DForProxy, ReflectedFunctions.equals, ReflectedFunctions.F, ReflectedFunctions.FForProxy, ReflectedFunctions.fuel, ReflectedFunctions.getClass, ReflectedFunctions.getExec, ReflectedFunctions.getObject, ReflectedFunctions.hashCode, ReflectedFunctions.heap, ReflectedFunctions.I, ReflectedFunctions.IForProxy, ReflectedFunctions.indexP, ReflectedFunctions.indexPName, ReflectedFunctions.insertB, ReflectedFunctions.insertC, ReflectedFunctions.insertD, ReflectedFunctions.insertF, ReflectedFunctions.insertI, ReflectedFunctions.insertJ, ReflectedFunctions.insertL, ReflectedFunctions.insertL1, ReflectedFunctions.insertLx, ReflectedFunctions.insertP, ReflectedFunctions.insertS, ReflectedFunctions.insertZ, ReflectedFunctions.isIllusion, ReflectedFunctions.J, ReflectedFunctions.JForProxy, ReflectedFunctions.keyword, ReflectedFunctions.L, ReflectedFunctions.LForProxy, ReflectedFunctions.LForProxyx, ReflectedFunctions.Lx, ReflectedFunctions.Lxx, ReflectedFunctions.Lxxx, ReflectedFunctions.Lxxxx, ReflectedFunctions.maxD, ReflectedFunctions.maxP, ReflectedFunctions.minD, ReflectedFunctions.minP, ReflectedFunctions.myFuel, ReflectedFunctions.name, ReflectedFunctions.newInstance, ReflectedFunctions.notify, ReflectedFunctions.notifyAll, ReflectedFunctions.overwrites, ReflectedFunctions.P, ReflectedFunctions.parent, ReflectedFunctions.parsePriority, ReflectedFunctions.PB, ReflectedFunctions.PC, ReflectedFunctions.PD, ReflectedFunctions.PF, ReflectedFunctions.PI, ReflectedFunctions.PJ, ReflectedFunctions.PL, ReflectedFunctions.prevB, ReflectedFunctions.prevC, ReflectedFunctions.prevD, ReflectedFunctions.prevF, ReflectedFunctions.prevI, ReflectedFunctions.prevJ, ReflectedFunctions.prevL, ReflectedFunctions.prevS, ReflectedFunctions.prevZ, ReflectedFunctions.proxyOf, ReflectedFunctions.PS, ReflectedFunctions.PType, ReflectedFunctions.PZ, ReflectedFunctions.reflect, ReflectedFunctions.reflect6, ReflectedFunctions.reflectx, ReflectedFunctions.S, ReflectedFunctions.setB, ReflectedFunctions.setBx, ReflectedFunctions.setC, ReflectedFunctions.setCost, ReflectedFunctions.setCx, ReflectedFunctions.setD, ReflectedFunctions.setDescription, ReflectedFunctions.setDx, ReflectedFunctions.setExec, ReflectedFunctions.setF, ReflectedFunctions.setFuel, ReflectedFunctions.setFx, ReflectedFunctions.setHeap, ReflectedFunctions.setI, ReflectedFunctions.setIx, ReflectedFunctions.setJ, ReflectedFunctions.setJx, ReflectedFunctions.setL, ReflectedFunctions.setL1, ReflectedFunctions.setLx, ReflectedFunctions.setLxx, ReflectedFunctions.setLxxx, ReflectedFunctions.setLxxxx, ReflectedFunctions.setMyFuel, ReflectedFunctions.setName, ReflectedFunctions.setObject, ReflectedFunctions.setP, ReflectedFunctions.setParent, ReflectedFunctions.setParsePriority, ReflectedFunctions.setPrevExec, ReflectedFunctions.setProxyOf, ReflectedFunctions.setPType, ReflectedFunctions.setS, ReflectedFunctions.setSx, ReflectedFunctions.setTester, ReflectedFunctions.setZ, ReflectedFunctions.setZx, ReflectedFunctions.SForProxy, ReflectedFunctions.tester, ReflectedFunctions.toJavaCode, ReflectedFunctions.toString, ReflectedFunctions.V, ReflectedFunctions.VForProxy, ReflectedFunctions.voidReflect, ReflectedFunctions.wait, ReflectedFunctions.waitx, ReflectedFunctions.waitxx, ReflectedFunctions.Z, ReflectedFunctions.ZForProxy, ReflectJavaClass, RegExpInclExcl, Reverse, RoundToInt, S, ScreenPixels, Scroll, SelfPredictingPrimeHashingNumberList, SetEqual, SetEqual.DivideEqual, SetEqual.EqualP, SetEqual.MinusEqual, SetEqual.MultiplyEqual, SetEqual.PlusEqual, SetEqual.SetB, SetEqual.SetC, SetEqual.SetD, SetEqual.SetF, SetEqual.SetI, SetEqual.SetJ, SetEqual.SetL, SetEqual.SetS, SetEqual.SetZ, SetEqual.XEqual, SetParam, Sets.UnionOfSets, SimpleBayesNet, SimpleBayesNet.BayesNodeIndependentChildsDependentParent, SimpleBayesNet.Test, SimpleFastContinuousBayesNet, SimpleFileExecutorOrEditor, SimpleList, SimpleNeuralNode, SimpleNeuralNode.ChainSimpleNeuralNodesTogether, SimpleNeuralNode.WordStringsToNodes, SimpleTextFileEditor, SimpleTextInTextOutRepeaterGUI, Sine, Slidebar, SlideBarReacts, SlowMP3, SortByD, Sound, SoundQuality, SoundSyncMic, SoundSyncMic.MicrophoneSync, SpamData, SplitPane, Squares, Stacks.Peek, Stacks.Pop, Stacks.Push, Stacks.StackSize, StartCodesimian, StartCodesimian.LateInit, StartCodesimian.LateInit.Hooker, Static.AddDefaultCommand, Static.DefaultCommands, Static.DefaultExec, Static.DefaultList, Static.DefaultStack, Static.SingletonList, StrangeMicrophone, StringMyName, Strings.PrintCS, Strings.PrintNumber, Strings.PrintString, Strings.ReadChar, Strings.Similarity, Strings.StringSplit, Strings.TokenizeAllCharPairs, StringTree, SubstringsOfInnerFilesWithRegExpPathNames, Subtract, TabbedPaneCS, TextAreaCS, TextsAndCsGui, ThisComputersScreen, Throw, TimerCS, TimerCS.FixedRate, ToJavaCode, ToStr, TradeCalcExec, TreeList, TreeOfCode, TreeOfCodeGUI, TreeType, Try, Try.CatchException, Try.CatchOther, Try.CatchThrowable, TypeCheckedList, Types.FALSE, Types.TRUE, UpdatePositionBySpeed, Valid, Verify3DObject, View2d, View3d, Wait, WeightedAverage, WindowCS

public interface CodeSimian

CodeSimian is not yet (but will be) the root of the CodeSimian software. Next is CS, then DefaultCS and IndependentCS, then most of the other classes descending from DefaultCS.

CodeSimian is a small interface, and CS is a large class with no variables (only functions). CS has lots of functions for approximately the same thing, each with a different return type and other options. Example: CodeSimian has insertL(int,Object) but CS also has insertF(int,float) insertP(int,CS) insertZ(int,boolean) etc. insertL(int,Object) can do all of those. For primitives, use Objects like new java.lang.Float(1334f).

I plan to make a class that converts a CodeSimian to a CS, like this:
CodeSimian a = ...;
CS b = new CodeSimianToCS(a);

All functions in CS can be REFLECTED through CodeSimian's fewer more-general functions.
Its much easier to connect CodeSimian software (not CodeSimian.java) to external software if you only have to implement 1 interface (CodeSimian.java) instead of extend a class, because you can take the most important classes in your software and make them all implement the interface. You dont have to build a separate wrapper-class. You build the wrapper in. Or if you have more time, it might work better to build a subclass of CS.java (or easier: DefaultCS.java).



CodeSimian.java was made by copy/pasting code from codesimian2.java and L.java, which will be removed, but first their javadoc needs to be copied to this file and modified to read well together.

---------------------BELOW IS codesimian2.java's javadoc---------------------

This is the root interface of all of CodeSimian. Theoretically, anything that any subclass of CodeSimian can do, this class can do.

THE MAIN HEIRARCHY IS:
CodeSimian --> L --> CS --> (DefaultCS and IndependentCS) --> ...

All functions in this class do the same thing, but in different ways for convenience and sometimes for a little more efficiency. They can theoretically reflect any Java function, combinations of CodeSimian objects, or anything else, or can be a general interface to anything.

Reflect whats real and/or reflect anything you can create a consistent illusion of. The ILLUSIONS are most useful for artificial-intelligence (AI) and artificial-life (ALIFE).


DETAILS OF THE HEIRARCHY:

CodeSimian --> L --> CS --> (DefaultCS and IndependentCS) --> ...

CodeSimian is the simplest possible thing that can use all other programs.

L is the next simplest (than CodeSimian), and adds much efficiency for LISTS and COMPOSITES (things that contain things recursively).

CS is more practical (than L) because it has many more functions for LISTS and COMPOSITES multiplied by all Java primitives objects and arrays. For each important function, there are approximately 10 parallel functions, 1 for each type of thing: Java primitives objects and array. Thats for efficiency of using those different parts of Java. CS has no variables (to use less memory).

DefaultCS is practical enough to extend (create a superclass of) in less than 1 minute. Most subclasses of CodeSimian are subclasses of DefaultCS. DefaultCS is big and often has variables that are never used. Each DefaultCS is approximately 70 bytes in memory (my best guess 7/06, I have not measured).

IndependentCS is parallel to DefaultCS (both extend CS), and has NO VARIABLES and no behaviors. All functions return the IndependentCS they're called from, 0, false, or null. IndependentCS is necessary to solve some technical problems related to creating the first few CS objects.


FUZZY: One of the more frustrating things about CodeSimians, Ls, and any subclass, is that you can find some of the things it contains, but other things are hidden until you know EXACTLY what you're looking for. CodeSimian is intentionally designed this way because forcing an Object to be able to describe itself perfectly causes unnecessary restrictions. I choose freedom over certainty. CodeSimian is FUZZY.

---------------------BELOW IS L.java's javadoc---------------------

L is almost the root interface of CodeSimian (second to CodeSimian itself). Its 1 of the only 2 .java files higher than CS.java.

Think of L as the superclass of CS. L is an interface (not a class and therefore not a superclass) because interface is more flexible than a class. CS is a class (not an interface) because classes are faster than interfaces (30% faster last time I tested it).

If you're making a program that uses CodeSimian and you want it to be simpler (at the cost of being slower) then use CSs as Ls (or simpler: as CodeSimians) instead of CSs. Every CS is also an L (and therefore a CodeSimian), and has many more functions than a pure L.

L is much smaller and simpler than CS, but can theoretically do anything a CS can do.
For example: someCS.setFuel(new N(50)) -or- someL.setL("fuel",new N(50))
Ls have no fuel() or setFuel(). They have to use L(Object) and setL(Object,Object) to do those things that a CS has a natural ability to do, like this:
someL.L("fuel") -and- someL.setL("fuel",someCS)

The reason this works is that every CS has all L functions and those functions are supposed to call all the other functions if given those function's names (or abbreviations).

L has some non-L functions (like deleteP(int,int)) because they are necessary to use an L as a list of Ls. deleteP(int,int) removes 1 or more things from any part of the list. But functions like countP() must be used this way: ((Number) someL.L("countP")).intValue();
someL.L("countP") returns a Number because Number is Java's wrapper for primitives, and CS.countP() returns an int primitive.

FUZZY:

One of the more frustrating things about CodeSimians, Ls, and any subclass, is that you can find some of the things it contains, but other things are hidden until you know EXACTLY what you're looking for. Example: a CS may choose to accept any String with an odd number of 'x' chars.

Since there are an infinite number of Strings like that (abxc abxxxc abxxxxxc...), all things that have a name can not be put into a list because that list would have infinite size.

CodeSimian is intentionally designed this way because forcing an Object to be able to describe itself perfectly causes unnecessary restrictions. I choose freedom over certainty. CodeSimian is FUZZY.

NAME CHANGES: insertP should become insertP1, or probably better: anyfunctions1 should become anyfunction, and the previous anyfunction should become anyfunctionM. M means many. 1 should be the default. Currently some functions have 1 and the default while others have many as the default, despite their names not including this info. All defaults need to become 1, and Many will be specified by putting M on the end of a function name.

See Also:
CS

Method Summary
 boolean deleteP(int startIndex, int indexQuantity)
           
 boolean insertL(int startIndex, java.lang.Object value)
           
 boolean insertL1(int singleIndex, java.lang.Object value)
           
 java.lang.Object L(int startIndex, java.lang.Object key, int indexQuantity)
           
 java.lang.Object L(java.lang.Object key)
          common keys have type Class (try to cast to that type), Number (return something from index Number.intValue()), or String (return something with that name, often has an int index too)
 java.lang.Object reflect(java.lang.Object[] nameAndParameters)
          Calls any function by reflection, including reflective functions on higher levels, reflection of reflection of reflection...
 java.lang.Object reflect(java.lang.String name, java.lang.Object[] parameters)
          same as reflect(Object[]) except the array is 1 smaller, and all indexs are 1 lower, and the first element which was taken out is String name,

This function is useful because it can use the same array as java.lang.reflect.Method.invoke(Object[]); Name should equal java.lang.reflect.Method.getName() of some Java function (Method).
 CodeSimian reflect6(java.lang.Class returnType, java.lang.Class instanceType, byte getSetInsertOrDelete, java.lang.Class locationType, byte quantityType, java.lang.Class valueType)
          Returns a CS with countP()==6, that reflects almost any possible action in codesimian language.
 boolean setL(int startIndex, java.lang.Object value)
           
 boolean setL(int startIndex, java.lang.Object value, int indexQuantity)
           
 boolean setL(java.lang.Object key, java.lang.Object value)
           
 boolean setL1(int singleIndex, java.lang.Object value)
           
 void voidReflect(java.lang.Object[] returnAndNameAndParameters)
          Same as reflect(Object[]) except the array is 1 bigger, and returnAndNameAndParameters[0] is replaced by the return-value of the reflected function being called, and all indexs are 1 higher.
 

Method Detail

L

java.lang.Object L(java.lang.Object key)
common keys have type Class (try to cast to that type), Number (return something from index Number.intValue()), or String (return something with that name, often has an int index too)


L

java.lang.Object L(int startIndex,
                   java.lang.Object key,
                   int indexQuantity)

setL

boolean setL(int startIndex,
             java.lang.Object value,
             int indexQuantity)

setL

boolean setL(int startIndex,
             java.lang.Object value)

setL

boolean setL(java.lang.Object key,
             java.lang.Object value)

setL1

boolean setL1(int singleIndex,
              java.lang.Object value)

insertL1

boolean insertL1(int singleIndex,
                 java.lang.Object value)

insertL

boolean insertL(int startIndex,
                java.lang.Object value)

deleteP

boolean deleteP(int startIndex,
                int indexQuantity)

reflect6

CodeSimian reflect6(java.lang.Class returnType,
                    java.lang.Class instanceType,
                    byte getSetInsertOrDelete,
                    java.lang.Class locationType,
                    byte quantityType,
                    java.lang.Class valueType)
Returns a CS with countP()==6, that reflects almost any possible action in codesimian language.

Example: CS.reflect6(boolean.class,CS.class,1,int.class,int.class,Object.class) returns a wrapper for java function: CS.insertL(int,Object,int)

Example: CS.reflect6(int.class,CS.class,0,String.class,void.class,void.class) returns a CS that when P(3) is set to "countP" it returns CS.countP(), and when P(3) is set to "maxP" it returns CS.maxP().

Example: CS.reflect6(int.class,CS.class,0,String.class,void.class,String.class) returns a CS that when P(3) is set to "indexPName" and P(5) is set to "xx" it returns the index of the CS with name xx in the instance CS specified in P(1).

THIS FUNCTION, IF IT WORKS, SHOULD REPLACE THE OTHER 3 "reflect" functions. They reflect Java too directly. This function reflects CodeSimian as CodeSimian.

Parameters:
returnType - - what the created function returns, or null if its void.
instanceType - - type of object the created function may be called on. Usually CS.class.
getSetInsertOrDelete - - get=0 set=1 insert=2 delete=3. All other numbers are wrapped around that range.
locationType - - usually int. After that most common are: double, String, or Class
quantityType - - usually int. possibly double. Or should this be the byte 0 for MANY (0 or more) or 1 for ALWAYS ONE. That would prevent double quantity type, unless there were 4 possible values: INTMANY=0, INTONE=1, DOUBLEMANY=2, DOUBLEONE=3
valueType - - Any object or primitive type.

Returns:
a CS whose countP() is 6 that encapsulates the requested function of 6 things, or null if fail to create it or that combination of options dont make sense. May throw Errors instead of returning null. Either make a heirarchy of reflection errors and declare them or fix this.

reflect

java.lang.Object reflect(java.lang.Object[] nameAndParameters)
Calls any function by reflection, including reflective functions on higher levels, reflection of reflection of reflection...

        THE FOLLOWING CODE NEEDS TO BE CHECKED FOR RECURSIVE ARRAY ERRORS...
        

//These 4 examples do the same thing, but with increasing levels of reflection... Boolean setLReturnedTrue1 = new Boolean( someCS.setL(2,"countP",3) ); Boolean setLReturnedTrue2 = (Boolean) someL.reflect( new Object[]{"setL", new Integer(2), "countP", new Integer(3)} ); Boolean setLReturnedTrue3 = (Boolean) someL.reflect( new Object[]{ "reflect", new Object[]{"setL", new Integer(2), "countP", new Integer(3)} } ); Boolean setLReturnedTrue4 = (Boolean) someL.reflect( new Object[]{ "reflect", new Object[]{ "reflect", new Object[]{"setL", new Integer(2), "countP", new Integer(3)} } } ); Boolean setLReturnedTrue5 = (Boolean) someL.reflect( new Object[]{ "reflect", new Object[]{ "reflect", new Object[]{ "reflect", new Object[]{"setL", new Integer(2), "countP", new Integer(3)} } } } ); //Infinite reflection...


If this L is a CS, it should also reflect the functions in CS.

The easiest and most general way to do this is by using the java.lang.reflect package, but


reflect

java.lang.Object reflect(java.lang.String name,
                         java.lang.Object[] parameters)
same as reflect(Object[]) except the array is 1 smaller, and all indexs are 1 lower, and the first element which was taken out is String name,

This function is useful because it can use the same array as java.lang.reflect.Method.invoke(Object[]); Name should equal java.lang.reflect.Method.getName() of some Java function (Method).


voidReflect

void voidReflect(java.lang.Object[] returnAndNameAndParameters)
Same as reflect(Object[]) except the array is 1 bigger, and returnAndNameAndParameters[0] is replaced by the return-value of the reflected function being called, and all indexs are 1 higher.

This is useful if you want to store everything about a function-call together in 1 array.

EFFICIENCY: Depending on the object, reflect(Object[]) or voidReflect(Object[]) may be a little more efficient than the other, even though they do the same thing, because usually reflect calls voidReflect or voidReflect calls reflect.

        //USE THIS CODE IF YOU'RE LAZY (interfaces cant contain code):
        public void voidReflect(Object returnAndNameAndParameters[]){
                Object nameAndParams[] = new Object[returnAndNameAndParameters.length-1];
                //Insert code here to modify nameAndParams, if you want.
                System.arraycopy(nameAndParams, 0, returnAndNameAndParameters, 1, nameAndParams.length);
                returnAndNameAndParameters[0] = reflect(nameAndParams);
        }