text stringlengths 454 608k | url stringlengths 17 896 | dump stringclasses 91 values | source stringclasses 1 value | word_count int64 101 114k | flesch_reading_ease float64 50 104 |
|---|---|---|---|---|---|
Recently, more robust and reusable, but also because some of them are quite tricky when you are not used to generics. I decided to break this post into four chapters that pretty much map my experience with generics during my studies and work experience.
Do you understand generics?
When we take a look around we can observe that generics are quite heavily used in many different framework around Java universe. They span from web application frameworks to collections in Java itself. Since this topic has been explained by many before me, I will just list resources that I found valuable and move on to stuff that sometimes does not get any mention at all or is not explained quite well (usually in the notes or articles posted online). So, if you lack the understanding of core generics concepts, you can check out some of the following materials:
- SCJP Sun Certified Programmer for Java 6 Exam by Katherine Sierra and Bert Bates
- For me, primary aim of this book was to prepare myself for OCP exams provided by Oracle. But I came to realize that notes in this book regarding generics can also be beneficial for anyone studying generics and how to use them. Definitely worth reading, however, the book was written for Java 6 so the explanation is not complete and you will have to look up missing stuff like diamond operator by yourself.
- Lesson: Generics (Updated) by Oracle
- Resource provided by Oracle itself. You can go through many simple examples in this Java tutorial. It will provide you with the general orientation in generics and sets the stage for more complex topics such as those in following book.
- Java Generics and Collections by Maurice Naftalin and Philip Wadler
- Another great Java book from O’Reilly Media’s production. This book is well-organized and the material is well-presented with all details included. This book is unfortunately also rather dated, so same restrictions as with first resource apply.
What is not allowed to do with generics?
Assuming you are aware of generics and want to find out more, lets move to what can not be done. Surprisingly, there is quite a lot of stuff that cannot be used with generics. I selected following six examples of pitfalls to avoid, when working with generics.
Static field of type
<T>
One common mistake many inexperienced programmers do is to try to declare static members. As you can see in following example, any attempt to do so ends up with compiler error like this one:
Cannot make a static reference to the non-static type T.
public class StaticMember<T> { // causes compiler error static T member; }
Instance of type
<T>
Another mistake is to try instantiate any type by calling new on generic type. By doing so, compiler causes error saying:
Cannot instantiate the type T.
public class GenericInstance<T> { public GenericInstance() { // causes compiler error new T(); } }
Incompatibility with primitive types
One of the biggest limitation while working with generics is seemingly their incompatibility with primitive types. It is true that you can’t use primitives directly in your declarations, however, you can substitute them with appropriate wrapper types and you are fine to go. Whole situation is presented in the example below:
public class Primitives<T> { public final List<T> list = new ArrayList<>(); public static void main(String[] args) { final int i = 1; // causes compiler error // final Primitives<int> prim = new Primitives<>(); final Primitives<Integer> prim = new Primitives<>(); prim.list.add(i); } }
First instantiation of
Primitives class would fail during compilation with an error similar to this one:
Syntax error on token "int", Dimensions expected after this token. This limitation is bypassed using wrapper type and little bit of auto-boxing magic.
Array of type
<T>
Another obvious limitation of using generics is the inability to instantiate generically typed arrays. The reason is pretty obvious given the basic characteristics of an array objects – they preserve their type information during runtime. Should their runtime type integrity be violated, the runtime exception ArrayStoreException comes to rescue the day.
public class GenericArray<T> { // this one is fine public T[] notYetInstantiatedArray; // causes compiler error public T[] array = new T[5]; }
However, if you try to directly instantiate a generic array, you will end up with compiler error like this one:
Cannot create a generic array of T.
Generic exception class
Sometimes, programmer might be in need of passing an instance of generic type along with exception being thrown. This is not possible to do in Java. Following example depicts such an effort.
// causes compiler error public class GenericException<T> extends Exception {}
When you try to create such an exception, you will end up with message like this:
The generic class GenericException<T> may not subclass java.lang.Throwable.
Alternate meaning of keywords
super and
extends
Last limitation worth mentioning, especially for the newcomers, is the alternate meaning of keywords
super and
extends, when it comes to generics. This is really useful to know in order to produce well-designed code that makes use of generics.
<? extends T>
- Meaning: Wildcard refers to any type extending type T and the type T itself.
<? super T>
- Meaning: Wildcard refers to any super type of T and the type T itself.
Bits of beauty
One of my favorite things about Java is its strong typing. As we all know, generics were introduced in Java 5 and they were used to make it easier for us to work with collections (they were used in more areas than just collections, but this was one of the core arguments for generics in design phase). Even though generics provide only compile time protection and do not enter the bytecode, they provide rather efficient way to ensure type safety. Following examples show some of the nice features or use cases for generics.
Generics work with classes as well as interfaces
This might not come as a surprise at all, but yes – interfaces and generics are compatible constructs. Even though the use of generics in conjunction with interfaces is quite common occurrence, I find this fact to be actually pretty cool feature. This allows programmers to create even more efficient code with type safety and code reuse in mind. For example, consider following example from interface
Comparable from package
java.lang:
public interface Comparable<T> { public int compareTo(T o); }
Simple introduction of generics made it possible to omit instance of check from
compareTo method making the code more cohesive and increased its readability. In general, generics helped make the code easier to read and understand as well as they helped with introduction of type order.
Generics allow for elegant use of bounds
When it comes to bounding the wildcard, there is a pretty good example of what can be achieved in the library class
Collections. This class declares method
copy, which is defined in the following example and uses bounded wildcards to ensure type safety for copy operations of lists.
public static <T> void copy(List<? super T> dest, List<? extends T> src) { ... }
Lets take a closer look. Method
copy is declared as a static generic method returning void. It accepts two arguments – destination and source (and both are bounded). Destination is bounded to store only types that are super types of
T or
T type itself. Source, on the other hand, is bounded to be made of only extending types of
T type or
T type itself. These two constraints guarantee that both collections as well as the operation of copying stay type safe. Which we don’t have to care for with arrays since they prevent any type safety violations by throwing aforementioned
ArrayStoreException exception.
Generics support multibounds
It is not hard to imagine why would one want to use more that just one simple bounding condition. Actually, it is pretty easy to do so. Consider following example: I need to create a method that accepts argument that is both
Comparable and
List of numbers. Developer would be forced to create unnecessary interface ComparableList in order to fulfill described contract in pre-generic times.
public class BoundsTest { interface ComparableList extends List, Comparable {} class MyList implements ComparableList { ... } public static void doStuff(final ComparableList comparableList) {} public static void main(final String[] args) { BoundsTest.doStuff(new BoundsTest().new MyList()); } }
With following take on this task we get to disregard the limitations. Using generics allows us to create concrete class that fulfills required contract, yet leaves
doStuff method to be as open as possible. The only downside I found was this rather verbose syntax. But since it still remains nicely readable and easily understandable, I can overlook this flaw.
public class BoundsTest { class MyList<T> implements List<T>, Comparable<T> { ... } public static <T, U extends List<T> & Comparable<T>> void doStuff(final U comparableList) {} public static void main(final String[] args) { BoundsTest.doStuff(new BoundsTest().new MyList<String>()); } }
Bits of strangeness
I decided to dedicate the last chapter of this post two the strangest constructs or behaviors I have encountered so far. It is highly possible that you will never encounter code like this, but I find it interesting enough to mention it. So without any further ado, lets meet the weird stuff.
Awkward code
As with any other language construct, you might end up facing some really weird looking code. I was wondering what would the most bizarre code look like and whether it would even pass the compilation. Best I could come up with is following piece of code. Can you guess whether this code compiles or not?
public class AwkwardCode<T> { public static <T> T T(T T) { return T; } }
Even though this is an example of really bad coding, it will compile successfully and the application will run without any problems. First line declares generic class
AwkwardCode and second line declares generic method
T. Method
T is generic method returning instances of
T. It takes parameter of type
T unfortunately called
T. This parameter is also returned in method body.
Generic method invocation
This last example shows how type inference works when combined with generics. I stumbled upon this problem when I saw a piece of code that did not contain generic signature for a method call yet claimed to pass the compilation. When someone has only a little experience with generics, code like this might startle them at first sight. Can you explain the behavior of following code?))); } } class Compare { public static <T> boolean genericCompare(final T object1, final T object2) { System.out.println("Inside generic"); return object1.equals(object2); } }
Ok, let’s break this down. First call to
genericCompare is pretty straight forward. I denote what type methods arguments will be of and supply two objects of that type – no mysteries here. Second call to
genericCompare fails to compile since
Long is not
String. And finally, third call to
genericCompare returns
false. This is rather strange since this method is declared to accept two parameters of the same type, yet it is all good to pass it
String literal and a
Long object. This is caused by type erasure process executed during compilation. Since the method call is not using
<String> syntax of generics, compiler has no way to tell you, that you are passing two different types. Always remember that the closest shared inherited type is used to find matching method declaration. Meaning, when
genericCompare accepts
object1 and
object2, they are casted to
Object, yet compared as
String and
Long instances due to runtime polymorphism – hence the method returns
false. Now let’s modify this code a little bit.))); // compilation error Compare.<? extends Number> randomMethod(); // runs fine Compare.<Number> randomMethod(); } } class Compare { public static <T> boolean genericCompare(final T object1, final T object2) { System.out.println("Inside generic"); return object1.equals(object2); } public static boolean genericCompare(final String object1, final Long object2) { System.out.println("Inside non-generic"); return object1.equals(object2); } public static void randomMethod() {} }
This new code sample modifies
Compare class by adding a non-generic version of
genericCompare method and defining a new
randomMethod that does nothing and gets called twice from
main method in
GenericMethodInvocation class. This code makes the second call to
genericCompare possible since I provided new method that matches given call. But this raises a question about yet another strange behavior – Is the second call generic or not? As it turns out – no, it is not. Yet, it is still possible to use
<String> syntax of generics. To demonstrate this ability more clearly I created new call to
randomMethod with this generic syntax. This is possible thanks to the type erasure process again – erasing this generic syntax.
However, this changes when a bounded wildcard comes on the stage. Compiler sends us clear message in form of compiler error saying:
Wildcard is not allowed at this location, which makes it impossible to compile the code. To make the code compile and run you have to comment out line number 12. When the code is modified this way it produces following output:
Inside generic true Inside non-generic false Inside non-generic false | http://www.javacodegeeks.com/2014/06/beauty-and-strangeness-of-generics.html | CC-MAIN-2016-07 | refinedweb | 2,169 | 53.71 |
Answered by:
Get Mac Address for remote Domain Computers based on IP or hostname - Both online and Off
Question
Hello,
I'm Using Get-ADComputer to query information about our clients. Once I have the Name, OS, LastlogonDate, etc, then I use
Resolve-DNSName to get an array(of 1 ip somtimes) of IP addresses for the given host. Is there a similar cmdlet or other process to query say the DHCP servers and get the MAC address that would be associated with each IP?
I've seen many posts on approaching this from several angles but it appears in all those cases, the host needs to be online. I need to get this info weather the systems are on or off.
ThanksThursday, January 31, 2019 10:54 PM
Answers
All replies
Just search the for the answer and it will pop up:
\_(ツ)_/Thursday, January 31, 2019 11:09 PM
I was trying to work with this on a windows 10 client, but apparently this will only work on a server 2012 and up with a dhcp server installed. I was hoping to not have to do it that way.
Thank YouThursday, January 31, 2019 11:17 PM
- Well , Even on the windows Server 2012 R2 with DHCP Get-Dhcpserver4Lease error no cmdlet named that existThursday, January 31, 2019 11:23 PM
You can remote it. Just use Invoke-Command.
You can also use WMI.
$namespace = 'root/Microsoft/Windows/DHCP'
$class = 'DhcpServerv4OptionValue'
\_(ツ)_/Thursday, January 31, 2019 11:26 PM | https://social.technet.microsoft.com/Forums/en-US/cbb85730-49de-4aea-b6cb-055455b45df9/get-mac-address-for-remote-domain-computers-based-on-ip-or-hostname-both-online-and-off?forum=ITCG | CC-MAIN-2020-50 | refinedweb | 255 | 66.78 |
PackStream implementation in Swift
PackStream is a binary message format very similar to MessagePack. It can be used stand-alone, but it has been built as a message format for use in the Bolt protocol to communicate between the Neo4j server and its clients.
This implementation is written in Swift, primarily as a dependency for the Swift Bolt implementation. That implementation will in turn provide Theo, the Neo4j Swift driver, with Bolt support.
Usage
Through PackStream you can encode Bool, Int, Float (Double in Swift lingo), String, List, Map and Structure. They all implement the
PackProtocol, so if you want to have a collection of packable items, you can specify them as implementing PackProtocol.
Example
First, remember to
import PackStream
Then you can use it, like for instance so:
let map = Map(dictionary: [ "alpha": 42, "beta": 39.3, "gamma": "☺", "delta": List(items: [1,2,3,4]) ]) let result = try map.pack() let restored = try Map.unpack(result)
A list of the numbers 1 to 40
let items = Array(Int8(1)...Int8(40)) let value = List(items: items)
gets encoded to the following bytes
D4:28:01:02:03:04:05:06:07:08:09:0A:0B:0C:0D:0E:0F:10:11:12:13:14:15:16:17:18:19:1A:1B:1C:1D:1E:1F:20:22:23:24:25:26:27:28
Getting started
To use directly with Xcode, type "swift package generate-xcodeproj"
Swift Package Manager
Add the following to your dependencies array in Package.swift:
.Package(url: "", majorVersion: 0),
and you can now do a
swift build
CocoaPods
Add the
pod "PackStream"
to your Podfile, and you can now do
pod install
to have PackStream included in your Xcode project via CocoaPods
Carthage
Put
github "niklassaers/PackStream-swift"
in your Cartfile. If this is your entire Cartfile, do
carthage bootstrap
If you have already done that, do
carthage update
instead.
Then do
cd Carthage/Checkouts/PackStream-swift swift package generate-xcodeproj cd -
And Carthage is now set up. You can now do
carthage build
and you should find a build for macOS, iOS, tvOS and watchOS in Carthage/Build
Protocol documentation
For reference, please see driver.py in Boltkit
Latest podspec
{ "name": "PackStream", "version": "1.0.2", "summary": "PackStream implementation in Swift", "description": "PackStream is a binary message format very similar to [MessagePack](). It can be used stand-alone, but it has been built as a message format for use in the Bolt protocol to communicate between the Neo4j server and its clients.nnThis implementation is written in Swift, primarily as a dependency for the Swift Bolt implementation. That implementation will in turn provide Theo, the Neo4j Swift driver, with Bolt support.", "homepage": "", "authors": { "Niklas Saers": "[email protected]" }, "social_media_url": "", "license": { "type": "BSD", "file": "LICENSE" }, "platforms": { "ios": "8.0", "osx": "10.9", "watchos": "2.0", "tvos": "9.0" }, "source": { "git": "", "tag": "1.0.2" }, "source_files": "Sources" }
Tue, 03 Apr 2018 10:01:03 +0000 | https://tryexcept.com/articles/cocoapod/packstream | CC-MAIN-2018-22 | refinedweb | 487 | 55.54 |
The reason there is no UserType is because Types are the exclusive domain of the C side of Python. Under normal circumstances, extentions/additions of this nature in C end up making "types", while extentions/additions in Python end up making Classes, which are not, under normal circumstances, able to be made in C. This is my understanding, at least. The missing behavior that you wish is a result of the fact that Classes and Types really don't have that much in common yet... Sure, some types have wrappers around them, but there is no ultimate ancestor that is available... The problem is, I think, is that there really is no functionality to wrap in a 'TypeType'. And until classes and types get all combined into the same thing, where you'd then have an ultimate ancestor to inherit from and compare to, I don't think you'll get a way to do what you want exactly like you want. Then again, I may be talking out of my ass. I'm a semi newbie who just lurks forever. :) --Ix (Replace 'NOSPAM' with 'seraph' to respond in email) Carlos Alberto Reis Ribeiro wrote in message ... >At 02:56 28/03/01 -0800, you wrote: >>You get the idea. AnyType above will be eternally happy to be equivelent to >>anything you compare it to. Note that you can't do 'IntType is AnyType', >>that tells you actual object identity. Now, if you wanted it to only show up >>as 'equivelent' to TypeTypes, and not say, strings, (e.g. "string" == >>AnyType) you could do a check to make sure what its being compared to is a >>TypeType..... > >My first instinct it was to do something like this. However, it did not >work, but because of a dumb mistake of mine :-) I tried again now, and this >is the resulting code: > >class CAnyType: > def __cmp__(self, other): > return (type(other) != TypeType) > def __rcmp__(self, other): > return (type(other) != TypeType) > >AnyType = CAnyType() > >That was my fault - I was trying to compare the class to IntType, but I >need an instance for the code to work. > >Anyway, I felt that should be a better way to make it, maybe be inheriting >from some "UserType" object. However no such object exists. I don't know if >"UserType" does not exist because it not make sense, or if it does not >exist simply because no one else required it before. The way it is, it's >inconsistent, because: > > >>> type(AnyType) # should return "TypeType" ><type 'instance'> > > > >Carlos Ribeiro > > > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- | http://mail.python.org/pipermail/python-list/2001-March/095480.html | CC-MAIN-2013-20 | refinedweb | 443 | 71.24 |
0
I have a program that has a custom class that I would like to create many of and access them like an array. Example:
#include <iostream> using namespace std; class Thing { public: Thing(int value) { a = value; } int doStuff(int diffValue) { a = diffValue + a; } private: int a; }; int main() { Thing things(12)[100]; things[4].doStuff(12); return 0; }
Obviously that will not work but is there an easy way to do this? I am not too familiar with pointers but if there is an easy way to use them in this case...
Thanks I'm open to any suggestions! | https://www.daniweb.com/programming/software-development/threads/146374/an-array-of-class-objects-question | CC-MAIN-2017-04 | refinedweb | 101 | 77.98 |
How to upload data from ESP8266 to Google Spreadsheet: a step by step guide
Over the past couple of years, the ESP8266 platform has come a long way in its development and has become one of the most popular hardware tools among electronics and IoT enthusiasts. Equipped with a 32-bit CPU with 80 MHz RISC architecture, fully integrated WiFi module with TCP / IP protocol stack, serial interfaces (I2C, SPI, and UART), ADC channel and general-purpose I / O pins. ESP8266 is The most integrated and affordable WiFi solution on the Internet of Things today.
Hardware modules, such as NodeMCU, with their peripherals, can directly work with sensors and upload data from them to a local or remote web server via the Internet. Already, there are many cloud platforms for the Internet of Things (ThingSpeak, thinger.io, TESPA.io, Xively, etc. - the list continues to grow every day), which provide an application programming interface and tools for downloading sensor readings directly, for their further visualization and access to them from anywhere in the world in real time. Regular Google Drive users will probably notice that accessing Google Spreadsheets and using them to store and process data is much easier than with the cloud platforms of the Internet of Things.
In this guide, we will describe how to directly connect an ESP8266 based device to Google Table to store sensor data without using any third party add-ons. For example, we will use the NodeMCU board, by means of which we consider the analog data of the soil moisture sensor installed in a flower pot, and directly enter them into an electronic Google spreadsheet.
The project is divided into two parts. The first is the assembly of equipment based on the NodeMCU ESP8266 for reading data from a soil moisture sensor. The second is the creation of a Google Table and its configuration for receiving sensor data from the ESP8266 module via the Internet using a Google Apps Script language script, which is attached to this manual.
To implement the project from this article, we need the following components:
- Nodemcu V3 Lua Wi-Fi
- Soil moisture sensor
- Breadboard
- Wires
CONNECTION OF SOIL MOUNT SENSOR TO NODEMCU
Soil moisture sensor
The project uses a very simple and cheap kit with a soil moisture sensor, consisting of two open metal plates and a measuring PCB with a comparator. Open plates are a device that reacts to soil moisture. The more water in the soil, the higher the conductivity between the plates, and vice versa.
The included board with a comparator provides an analog output with a voltage that varies with the soil moisture level. The board is powered by 3.3 V, and its output is connected to the analog input channel (A0) of the NodeMCU module.
Attention! The analog input of the ESP8266 chip can only work with a maximum voltage of 1 V. But the voltage divider circuit used in the NodeMCU module allows you to work with a voltage on the analog input of the module up to 3.3 V.
The pinout diagram for connecting NodeMCU to a soil moisture sensor is shown in the figure below:
SKETCH FOR GETTING DATA WITH NODEMCU
Let's first take a look at what actually happens when we try to send data to Google servers. To send data, we will, of course, use the GET request method and a URL containing…. When you enter such an address in a web browser, the Google server in response requests the browser to redirect its GET request to another address located in the domain script.googleusercontent.com. Redirection is common and common, and the browser will easily handle it. However, for the ESP8266 chip, it is not so simple. She needs to correctly decode the information in the header received with the response message from the server in order to find out the new address and make a second request to another server.
To simplify redirection processing, a GitHub user is known as an electronics guy posted on GitHub an excellent code snippet in the Arduino Library library format called HTTPSRedirect.
There are other ways to send data to Google spreadsheets from Arduino devices through third-party services (such as pushing boxes) and their application programming interfaces, which are used to fulfill all Google server’s https messages and handling redirects. Using the HTTPS Redirect library greatly simplifies this process by eliminating the mediation of third-party code. So the first thing that needs to be done is to download the HTTPSRedirect library from the GitHub website and install it in your Arduino library folder. For convenience, we have posted the library archive at the link below.
Download HTTPSRedirect Library
To install it in the Arduino IDE, simply download this archived file, unzip it and move it to a folder called HTTPSRedirect, which should be located in the location of your Arduino IDE libraries. On a Windows PC, they are usually located at C: \ Users \ your user \ Documents \ Arduino libraries
Make sure that the package with the library contains both the HTTPSRedirect.cpp and HTTPSRedirect.h files, as shown in the figure below.
PROGRAMMING NODEMCU ESP8266 TO SEND DATA TO GOOGLE TABLE
The code below is for the ESP8266 chip and is written using the Arduino IDE development environment to receive data from the soil moisture sensor and send it to the Google Table located on the Google Disk. For the code to work, you need to change the ssid identifier and password (password) of the WiFi network to your own.
You will also need the script identifier * GScriptId, which can be obtained only after the publication of the corresponding script in the Google Apps Script language. How to get * GScriptId is described closer to the end of this guide.
Sensor data is recorded in a Google table every 15 minutes.
#include <ESP8266WiFi.h>
#include <HTTPSRedirect.h>
const char* ssid = “SSID Wi-Fi“;
const char* password = “password“;
const char *GScriptId = “Google-Script-ID”;
// Push data on this interval
const int dataPostDelay = 900000; // 15 minutes = 15 * 60 * 1000
const char* host = “script.google.com”;
const char* googleRedirHost = “script.googleusercontent.com”;
const int httpsPort = 443;
HTTPSRedirect client(httpsPort);
String url = String(“/macros/s/”) + GScriptId + “/exec?”;
const char* fingerprint = “F0 5C 74 77 3F 6B 25 D7 3B 66 4D 43 2F 7E BC 5B E9 28 86 AD”;…”);
}
Serial.println(“Connection Status: “ + String(client.connected()));
Serial.flush();
if (!flag){
Serial.print(“Could not connect to server: “);
Serial.println(host);
Serial.println(“Exiting…”);
Serial.flush();
return;
}
if (client.verify(fingerprint, host)) {
Serial.println(“Certificate match.”);
} else {
Serial.println(“Certificate mis-match”);
}
}
void postData(String tag, float value){
if (!client.connected()){
Serial.println(“Connecting to client again…”);
client.connect(host, httpsPort);
}
String urlFinal = url + “tag=” + tag + “&value=” + String(value);
client.printRedir(urlFinal, host, googleRedirHost);
}
void loop() {
int data = 1023 – analogRead(AnalogIn);
postData(“SoilMoisture”, data);
delay (dataPostDelay);
}
CREATING A GOOGLE TABLE
Create a Google spreadsheet on your Google Drive and name it, for example, DataCollector (“Data Collector”). Rename the current (or active) sheet to Summary (“General”) and add a second sheet, name it DataLogger (“Data Logger”). From the address bar of the table, copy the characters between the characters "d /" and "/ edit" and save them somewhere. This is a unique key for sharing your spreadsheet, which is later needed for the Google Apps Script language script.
Attention! The name of the Google spreadsheet does not play a big role, as in the Google Apps Script we will use the table sharing the key, which is always unique. At the same time, the names of the sheets (Summary and DataLogger) should coincide with those that you use in the Google Apps Script (described below).
In the Summary: sheet, write “Last Modified On” in cell A1, “DataLogger Count” (“Data logger counter”) in cell A2 and in cell A3 - “Next Read Time” (“Next Read Time "). In cell B2, write a formula that will be used to calculate the value of the data counter: "= counta (DataLogger! D: D) -1". In cell B3, write the following formula: “= B1 + TimeValue (“ 00:15 ”)”, which will simply add 15 minutes to the time of the last change. To create a further calibration chart in the Google Tables, information was added to cells A6 through B7, as shown in the figure below.
On the DataLogger sheet, write “ID” (“Identifier”), “DateTime” (“Date Time”), “Tag” (“Tag”) and “Value” (“Value”) in cells A1, B1, C1, and D1, respectively.
SCRIPT ON GOOGLE APPS SCRIPT
To create a Google Apps Script script in the Google Tables application, select the menu item "Tools> Script Editor" ("Tools> Script Editor"). In the code window, paste the code below. The code or script can be saved under any name.
function doGet(e){
Logger.log("--- doGet ---");
var tag = "",
value = "";
try {
if (e == null){e={}; e.parameters = {tag:"test",value:"-1"};}
tag = e.parameters.tag;
value = e.parameters.value;
save_data(tag, value);
return ContentService.createTextOutput("Wrote:n tag: " + tag + "n value: " + value);
} catch(error) {
Logger.log(error);
return ContentService.createTextOutput("oops...." + error.message
+ "n" + new Date()
+ "ntag: " + tag +
+ "nvalue: " + value);
}
}
function save_data(tag, value){
Logger.log("--- save_data ---");
try {
var dateTime = new Date();
var ss = SpreadsheetApp.openByUrl("---Ваш-Google-Sheet-ID--Goes-Here---/edit");
var summarySheet = ss.getSheetByName("Summary");
var dataLoggerSheet = ss.getSheetByName("DataLogger");
var row = dataLoggerSheet.getLastRow() + 1;
dataLoggerSheet.getRange("A" + row).setValue(row -1); // ID
dataLoggerSheet.getRange("B" + row).setValue(dateTime); // dateTime
dataLoggerSheet.getRange("C" + row).setValue(tag); // tag
dataLoggerSheet.getRange("D" + row).setValue(value); // value
summarySheet.getRange("B1").setValue(dateTime); // Last modified date
// summarySheet.getRange("B2").setValue(row - 1); // Count
}
catch(error) {
Logger.log(JSON.stringify(error));
}
Logger.log("--- save_data end---");
}
Attention! The names of the sheets in the above script must match the names of the sheets in the spreadsheet to which we are going to write data.
var summarySheet = ss.getSheetByName("Summary");
var dataLoggerSheet = ss.getSheetByName("DataLogger");
Similarly, you need to change the spreadsheet sharing key in the script (change the line “—Your-Google-Sheet-ID – Goes-Here-”) to yours (which you copied earlier from the spreadsheet address).
var ss = SpreadsheetApp.openByUrl("");
DEPLOYING SCRIPT AS A WEB APPLICATION
Create a table for data collection with NodeMCU
The next step is to publish the script, so that it can be accessed via the URL. To do this, select the menu item “Publish> Deploy as Web App”.
Note. Every time you change the code, you must create a new version of the project and publish it (Project version: New; Project version: New), otherwise the old code will be available to you at the address.
Copy the address from the Current web app URL field (“Current URL of the web application”) and save it somewhere, since we will need it to retrieve the script ID of the GScriptID. It is usually stored in code, as a comment.
The address of the web application is as follows (instead of “–Your Google Script ID–” there will be an identifier of your script):–Your Google Script ID– / exec? tag = test & value = -1
The characters between the characters “s /” and “/ exec?” Are the identifier of your GScriptID script.
During the publication process, Google will ask for permission from you, you need to grant this permission.
CHECK RESULTS
Table for data collection with NodeMCU
If done correctly, the next test will be successful. Copy the address of the web application obtained during the publication process, bring it into the form specified above, and paste the resulting line into the address field of the web browser. Information should appear in the DataLogger sheet as shown below.
Did everything work out? If not, double-check all steps. If entering the address into the browser led to the addition of data to the list, then fill in the identifier of your GScriptID script in the above code for the ESP8266 chip.
VISUALIZATION OF DATA FROM THE TABLE
We added a graph to visualize the change in time of the sensor readings recorded in the DataLogger sheet. The range of the source for the graph is sufficient for any values sent with the NodeMCU ESP8266. You can also add a calibration chart to display the last added value of soil moisture.
Below is a DataLogger sheet. Humidity readings are recorded along with time stamps.
Add a comment | https://inventr.io/blogs/arduino/how-to-upload-data-from-esp8266-to-google-spreadsheet-a-step-by-step-guide | CC-MAIN-2020-16 | refinedweb | 2,039 | 54.52 |
First time here? Check out the FAQ!
The option has been implemented in April 2020 (
Looks like a compiler error. Have you tried re/installing Catkin?
If you've yaml present in more than a folder, you've to figure out which is the version you've to use (related to the version of python), and then add that folder in the PYTHONPATH.
At least is what I did to solve the problem.
Finally I found the answer.
Looking at morse initialization, there was the following message:
[WARN] [WallTime: 1400249615.593493] Could not process inbound connection: topic types do not match: [geometry_msgs/Pose] vs. [geometry_msgs/PoseStamped]{'topic': '/bee/pose', 'tcp_nodelay': '0', 'md5sum': 'e45d45a5a1ce597b249e23fb30fc871f', 'type': 'geometry_msgs/Pose', 'callerid': '/plan_node'}
So I changed the callback method:
void chatterCallback(const geometry_msgs::PoseStamped& msg)
{
geometry_msgs::Point coord = msg.pose.position;
ROS_INFO("Current position: (%g, %g, %g)", coord.x, coord.y, coord.z);
}
and don't forget to include:
#include "geometry_msgs/PoseStamped.h"
Hi,
I am running a simulation with Morse. tryin to get data from the robot with a C++ program using ROS.
The simulation is simple: a Quadrotor publishes its pose on a topic, and receives a navigation waypoint.
The Morse file is:
from morse.builder import *
bee = Quadrotor()
waypoint = RotorcraftWaypoint()
bee.append(waypoint)
waypoint.add_stream('ros')
#The Quadrototor is called bee
beePose = Pose()
bee.append(beePose)
beePose.add_stream('ros', topic='/bee/pose')
#Environment
env = Environment('land-1/trees')
In the C++ program, the chatterCallback(...) is never called, while it should print the position of the Quadrorotor:
#include "ros/ros.h"
#include "geometry_msgs/Pose.h"
#include <sstream>
void chatterCallback(const geometry_msgs::Pose& msg)
{
geometry_msgs::Point coord = msg.position;
ROS_INFO("Current position: (%g, %g, %g)", coord.x, coord.y, coord.z);
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "plan_node");
/**
* NodeHandle is the main access point to communications with the ROS system.
*/
ros::NodeHandle n;
/**
* The advertise() function is how you tell ROS that you want to
* publish on a given topic name.
*/
ros::Publisher motion = n.advertise<geometry_msgs::Pose>("/bee/waypoint", 1000);
// subscribes to stream
ros::Subscriber sub = n.subscribe("/bee/pose", 1000, chatterCallback);
ros::spin();
return 0;
}
While calling roswtf, I get the following error:
================================================================================
Static checks summary:
Found 1 warning(s).
Warnings are things that may be just fine, but are sometimes at fault
WARNING ROS_HOSTNAME may be incorrect: ROS_HOSTNAME [localhost] resolves to [::1], which does not appear to be a local IP address ['127.0.0.1', 'a.b.c'].
================================================================================
Beginning tests of your ROS graph. These may take awhile...
analyzing graph...
... done analyzing graph
running graph rules...
... done running graph rules
Online checks summary:
Found 1 error(s).
ERROR The following nodes should be connected but aren't:
* /morse->/plan_node (/bee/pose)
The weird thing is that all the nodes are running on the same computer. No network connection problems... in theory.
Finally, I get the desired data when running on another terminal:
rostopic echo /bee/pose
Any advice?
Thanks
I found an alternative solution. The problem here is that (Python3) yaml is called from a Python2.7 script, with evident incompatibilities.
I thus installed yaml in its Python2.7 version:
python2.7 setup.py install --prefix=/opt/ros/electric
and then added the path where it has been installed in PYTHONPATH, which in my case was something like:
export PYTHONPATH=$PYTHONPATH:/opt/ros/electric/lib/python2.7/site-packages
in /opt/ros are left the directories:
dependencies fuerte | https://answers.ros.org/users/9811/ruthven/?sort=recent | CC-MAIN-2021-49 | refinedweb | 572 | 51.65 |
nextgen - enable all of the features of next-generation perl 5 with one command
Version 0.01
The nextgen pragma uses several modules to enable additional features of Perl and of the CPAN.
Instead of copying and pasting all of these
use lines,
instead write only one:
use nextgen;
But the joy doens't stop there, here are some examples of the command line.
perl -Mnextgen -E'say Class->new->meta->name' # You can see warnings is on: perl -Mnextgen -E'(undef) + 5' # And, strict perl -Mnextgen -E'my $foo = "bar"; $$foo = 4; say $$foo' # And, it wouldn't be nextgen if this was allowed. perl -Mnextgen -E'use NEXT;' # Or, this perl -Mnextgen -MNEXT -e1
But the joy doesn't stop there, here are some examples in module.
package Foo; ## easier than strict, warnings, indirect, autodie, mro-c3, Moose, and blacklist use nextgen; ## vanilla Moose to follow has "foo" => ( isa => "Str", is => "rw" ) package main; use nextgen; ## this works my $o = Foo->new; ## this wouldn't ## main is understood to be mode => [qw/procedural]) my $o = main->new
For now, this module just does
asserts 5.10.1+ is loaded -- 5.10.0 is unsupported and not forwards compatable because of smart match.
uses the vanilla strict, and warnings pragmas
disables indirect method syntax via indirect
throws fatal exceptions in a sane fashion for CORE functions via autodie
C3 method resolution order via mro
adds Moose if the package isn't main
uses oose.pm if the program is run via
perl -e, or
perl -E
cleans up the class via namespace::autoclean if the module has a constructor (sub new).
In the future, nextgen will include additional CPAN modules which have proven useful and stable.
This module started out as a fork of Modern::Perl, it wasn't modern enough and the author wasn't attentive enough to the needs for a more modern perl5.
If you wish to write nextgen module that doesn't assume non-"main" packages are object-oriented classes, then use the :procedural token:
use nextgen mode => [qw(:procedural)] or even use nextgen mode => qw(:procedural)
Evan Carroll,
<me at evancarroll.com>
Please report any bugs or feature requests to
bug-nextgen at rt.cpan.org, or through the web interface at. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc nextgen
You can also look for information at:
chromatic,
<chromatic at wgz.org>
KSURI
Copyright 2010 and into the far and distant future, Evan Carroll.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See for more information. | http://search.cpan.org/~ecarroll/nextgen/lib/nextgen.pm | CC-MAIN-2015-40 | refinedweb | 473 | 58.92 |
Details
Description
Characters that are represented as a 2 characters internaly by java are incorrectly converted by the function. The following test displays the problem quite nicely:
import org.apache.commons.lang.*;
public class J2 {
public static void main(String[] args) throws Exception {
// this is the utf8 representation of the character:
// COUNTING ROD UNIT DIGIT THREE
// in unicode
// codepoint: U+1D362
byte[] data = new byte[]
;
//output is: ��
// should be: 𝍢
System.out.println("'" + StringEscapeUtils.escapeHtml(new String(data, "UTF8")) + "'");
}
}
Should be very quick to fix, feel free to drop me an email if you want a patch.
Activity
- All
- Work Log
- History
- Activity
- Transitions
And of course you shouldn't develop before you dring your coffe. Here is a working patch for the same problem.
Unfortunately this patch will have to wait until minimum requirement for commons-lang is JDK 5. Currently commons-lang is still compatible to JDK 1.2. However, talk for a JDK 5 version has already started.
That is a bit sad.
How likely do you think that the JDK 5 version to be, will it happen within this quarter?
I guess i could try to write a patch that is compatible with java 1.2, but that would require me to do my own parsing of the format that java stores characters in memory, so i would really like to avoid having that code in a library.
I've not looked at the code, so this may be nonsense -
Perhaps you could make the processing conditional - if it finds it's running under JVM 1.5+, then use the JVM Method, otherwise ignore the problem?
Wouldn't you have to use reflection, then?
Yes, but AFAICT Class.getMethod() is available in Java 1.2.
The method could be fetched in a static block.
Of course it is.
My point was that we would be engaging in reflection nastiness and it might not be worth it. I would suggest that if Alexander needs a release sooner that they do an "internal" release from the trunk with the changes applied and then "upgrade" when we get a newer release out. I don't like the idea of building in the reflection stuff. We get no compiler checking that way and it leads to unreadable code.
Just my 2 cents, I don't need a release that fixes this bug, i stumbled on it by chance and wrote a patch so that the next person that have the same problem that i do won't have to dig through the library in order to understand what's going on.
I'm mainly interested in fixing this because i don't like buggy software, but i totally agree that building in reflection stuff leads to more problems than it solves in the long run.
My opinion on how to fix this is either push for the JDK 1.5 dependency, or write some code that parses the format the strings are stored in memory. The latter might sound complicated but i think it's quite straight forward.
svn ci -m "Applying Alexander Kjall's patch from
LANG-480; along with a unit test made from his example. Fixes unicode conversion above U+00FFFF being done into 2 characters"
Sending src/java/org/apache/commons/lang/Entities.java
Sending src/test/org/apache/commons/lang/StringEscapeUtilsTest.java
Transmitting file data ..
Committed revision 749095.
Here is a fix for the problem i think | https://issues.apache.org/jira/browse/LANG-480?attachmentSortBy=dateTime | CC-MAIN-2016-30 | refinedweb | 572 | 64.71 |
Go forward in time to September 2008.
Predefined desktop items for Nautilus
Back in the Summer of Code 2007, Sayamindu Dasgupta worked on adding support for predefined desktop items to Nautilus. This is so that system administrators can set up desktop links that will appear on users' desktops. A university could set up an icon to take people to the university's intranet, for example.
Basically, I'm reviving Sayamindu's patch and bringing it up to date for the current Nautilus. The idea is that you set up a GConf key, /apps/nautilus/desktop/predefined_items_dir, and point it to a directory which holds .desktop files. This kind of indirection through a GConf key is what makes the scheme work nicely for deployments with Sabayon: sysadmins can have predefined items for various groups of users, and select among those by simply changing a mandatory GConf key for each user. This wouldn't be so easy if there were a hardcoded directory like /var/nautilus/global-desktop-items.
Sysadmins should be able to define mandatory items, which users cannot change or delete, and also "normal" items, which users can tweak or remove. Mandatory ones would be ones like "Company Intranet" or "Link to Helpdesk". Distros could use normal items for their marketing materials; the perenially hacky "Welcome to FooLinux" icons that currently are hard to do properly.
The problem I'm having is how to make non-mandatory items work. You want this behavior:
I'm leaning toward having two extra boolean values in .desktop files: an X-GNOME-Mandatory and X-GNOME-Deleted. If the "mandatory" value is false, then the user may change or delete the item. For changes, the item is copied from the predefined_items_dir to the user's ~/Desktop and that version is modified. For deletions, the item is copied there as well, but then the "deleted" flag gets turned on.
If the user wants an item back, he turns on "show hidden files" and those files get shown again. (Or we could hack the Trash to restore the item by turning off the "deleted" flag...)
If the sysadmin updates an item in the predefined_items_dir, this item will override items of the same name in users' desktops, based on the item's timestamp.
Does this make sense? Am I overlooking something?
People who use git-mirror.gnome.org may have noticed that SVN tags don't get fetched automatically when they get their daily fix of updates with "git fetch" or "git pull" (that is, you run "git tag" and it doesn't list new tags that appeared since you did your original clone). Within your repository, take a look at .git/config:
[remote "origin"] url = git://git-mirror.gnome.org/git/gtk+ fetch = +refs/heads/*:refs/remotes/origin/* fetch = +refs/tags/*:refs/tags/* ### <---- Add this line!
The first "fetch" line is already in your .git/config and it means, "every time I fetch from the origin, get all the branch heads in the origin's refs/heads and stuff them in the refs/remotes/origin namespace" (i.e. update all the branch heads).
The second "fetch" line is what you need to add. It means, "every time I fetch from the origin, also get all the tags and stuff them in my own namespace".
After that, just do "git fetch origin" and all the tags will be downloaded to your repository.
Mike Wolf has been working madly on rpm2git to make it easier to use. He has made some very cool changes:
Rpm2git no longer requires you to have an environment suitable for rpmbuild (e.g. specfiles in /usr/src/packages/SPECS, patches in /usr/src/packages/SOURCES). If you have a single directory with a specfile and patches, you can simply run rpm2git on that.
You don't need to have all the BuildRequires from the specfile, either.
Perhaps most importantly, you don't need to mess with your $PATH anymore nor install helper scripts. Rpm2git now works out of the box after "make install".
All of these changes are now merged in the rpm2git repository.
Sometimes Oralia boils water in the kettle, and adds a stick of cinnamon to make an infusion. The other day I heard the kettle boiling and I thought, "time for some green tea!". I didn't notice that the water was actually cinnamon, and made my tea as usual.
Well, hot damn, green tea made with cinnamon water turned out to be *good stuff*. I think I could grow an addiction to this.
Labels for RANDR monitors
When you configure multiple monitors, it is useful to know which physical monitor corresponds to each element in the configuration GUI. Both KDE and MacOS display cute labels on each monitor.
I implemented pretty much the same thing for GNOME, with the addition of color-coding. Hello, sexy:
This is in the following Git repositories (look at the monitor-labeling branches in all of them, and also tray-icon-rotation for gnome-settings-daemon):
This is just awaiting approval from the the release team to be committed to SVN :)
Why I want to have the children of git rebase --interactive
Sometimes you are hacking madly and committing often. Your commit log looks like this:
* Add some fields for a popup menu
* Create the popup menu
* Refactor the base object to accomodate the menu's commands
* Implement the signal handlers for the menu's commands
Then you type make and of course your code doesn't compile. So you do one-liner commits, one for each build error:
* Add missing include gtkmenu.h
* Fix typo in popup_menu variable name
* Forgot to declare a menu_item variable
* Add missing argument for gtk_menu_popup function
But you don't want you submit all of those patches upstream! You only want to send perfect patches which are either additions or refactorings to the upstream code. You don't want the maintainer to know that you are a fallible human being who forgets include files and variable declarations; instead, you want him to believe that you are a coding god who sends a perfect series of patches every time.
git rebase --interactive allows you to pretend you are better than you really are. This is a good thing.
We have 8 commits in total (4 "good" ones that don't compile, and 4 "embarrassing" ones that are little fixes). So, run git rebase --interactive HEAD~8. This means, "let me fix any fuckups since 8 commits ago".
Git will drop you in an editor where you edit this:
pick ab365cf Add some fields for a popup menu pick 2478bac Create the popup menu pick 9180ffe Refactor the base object to accomodate the menu's commands pick a6c2467 Implement the signal handlers for the menu's commands pick 289cf1a Add missing include gtkmenu.h pick 378ac2b Fix typo in popup_menu variable name pick 821ac6f Forgot to declare a menu_item variable pick 24acf67 Add missing argument for gtk_menu_popup function # Commands: # p, pick = use commit # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit
Now let's reorder the lines there, and replace some pick commands by squash. I've put in some comments about what each moved line does.
pick ab365cf Add some fields for a popup menu squash 289cf1a Add missing include gtkmenu.h # Oops, forgot to "#include <gtk/gtkmenu.h>" to have a field declared "GtkMenu *popup_menu" pick 2478bac Create the popup menu squash 821ac6f Forgot to declare a menu_item variable # Oops, while creating the menu items I forgot to declare my menu_item variable squash 24acf67 Add missing argument for gtk_menu_popup function # Oops, while creating the menu I also missed an argument to this function (how couldn't anyone?) pick 9180ffe Refactor the base object to accomodate the menu's commands pick a6c2467 Implement the signal handlers for the menu's commands squash 378ac2b Fix typo in popup_menu variable name # ... and I also mistyped popup_menu in a signal handler
When you are done, save that temporary file and exit your editor. Git will rewrite your commit history so that you have a clean log, with no commits like "fix this little thing". When you send that patch series to the maintainer, he'll have an easier time reading your code, and he'll be amazed at your meticulousness.
The important thing here is to do one commit per compilation error. Then it's very easy to reorder your commits, where you squash each fix with the corresponding "real" commit.
Two-stone handicap for me on a 9x9 go board, and the birthdayful HPJ still manages to kick my ass by twenty-something points.
They must have put something in the cake, as I had two big slices while HPJ had a single tiny one.
Here is a second screencast on rpm2git (Ogg Theora, 69 MB). This one tells you how to use rpm2git to take the patches from a SRPM and put them in a Git branch.
During GUADEC in Stuttgart and in Dublin, Evangelia Berdou was interviewing people about how they contribute in GNOME. She used this information for her dissertation, Managing the Bazaar: Commercialization and peripheral participation in mature, community-led Free/Open source software projects. Over 100 people from the GNOME Foundation contributed to her study!
There is very valuable information in this work: how many core-platform hackers, core-desktop hackers, secondary-desktop hackers, translators, and peripheral contributors do we have? Which of them are employed to work only on GNOME, on GNOME and other free software, or are not paid for their contributions? How do people move from being peripheral contributors to core ones?
For people thinking about which sub-group of GNOME needs better tools (translators!) and support from GNOME at large, this is exactly what they need to read.
Two things that made my day today.
First, Andrew Jorgensen packaged Meld for openSUSE 11.0, based on Pavol Rusnak's version, which makes git-mergetool awesome.
Two, Ivan Zlatev packaged git-merge-changelog (README), which makes merging ChangeLog entries surprisingly painless. You can even cherry-pick from other branches, where the ChangeLog's diff would not apply cleanly to the destination branch, and git-merge-changelog Just Works(tm) without any manual intervention. This *is* magic.
Here is a little screencast about the problem that rpm2git tries to solve (Ogg Theora, 12.5 MB):
You can also watch the rpm2git screencast in opensuse.blip.tv.
(Screencast recorded with recordMyDesktop. Man, my voice sucks. I swear it sounded better inside my head.)
I'm no security expert, but the Firefox guys keep saying that the new "this SSL certificate is funny" scheme in Firefox 3 is actually a good thing, but that is just bullshit.
Certificates are broken as designed because every web browser (including Firefox 3) has a button that says "let me access the site anyway", and that's what everyone, including yours truly, does all the time. People just do not know, nor care, how to ensure that a certificate is valid. "What's a certificate, anyway? The site says it is secure!"
If anything, the new scheme for funny certificates in Firefox 3 is worse than it was before, because the warnings are more frequent. So, you get really well-conditioned to hitting the button that says, "begone, stupid warning, and let me access the fucking web site already".
Go backward in time to July 2008.Federico Mena-Quintero <federico@gnome.org> Tue 2008/Aug/05 21:35:35 CDT | http://www.gnome.org/~federico/news-2008-08.html | crawl-002 | refinedweb | 1,919 | 62.48 |
This code is creating a query for use in retrieving a user's profile on a web back end. It creates a query that assembles the necessary information into a DTO (which is just a case class) that is subsequently sent back as JSON.
def getProfile(userId: Long)={
val q = for{
((((u,p),a),b), ba) <- filterById(userId) join
People on (_.personId === _.id) joinLeft
Addresses on (_._2.addressId === _.id) joinLeft
Businesses on (_._1._2.businessId === _.id) joinLeft
Addresses on (_._2.flatMap(_.addressId) === _.id)
}yield(p, a, b, ba)
db.run(q.result.headOption).map{ _.map{case(p,a,b,ba) =>
val business = b match {
case Some(b) => Some(dtos.Business(b.name, b.abn, b.adminFee, ba, b.id))
case _ => None
}
dtos.ProfileInfo(p, a, business)
}}
}
db.run(...)
on (_._1._2.flatMap(_.addressId)
on (_._1._2.businessId
filterByUserId(userId)
Users.filter(_.id === userId
select p.*, a1.*, b.*, a2.* from Users u
innerJoin People p on (u.personId == p.id)
leftJoin Addresses a1 on (p.addressId == a1.id)
leftJoin Businesses b on (p.businessId == b.id)
leftJoin Addresses a2 on ( b.addressId == a2.id)
You should experiment with something like this:
val q = Users join People joinLeft Addresses joinLeft Businesses joinLeft Addresses on { case ((((u, p), a), b), ba) => u.personId === p.id && p.addressId === a.flatMap(_.id) && p.businessId === b.flatMap(_.id) && b.flatMap(_.addressId) === ba.id } map { case ((((u, p), a), b), ba) => (p, a, b, ba) }
The other solution would be to make joins without using for comprehension, so you wouldn't have to use underscores to extract values from tuples:
val q = Users join People on { case (u, p) => u.personId === p.id } joinLeft Addresses on { case ((u, p), a) => p.addressId === a.id } joinLeft Businesses on { case (((u, p), a), b) => p.businessId === b.id } joinLeft Addresses on { case ((((u, p), a), b), ba) => b.flatMap(_.addressId) === ba.id } map { case ((((u, p), a), b), ba) => (p, a, b, ba) }
You haven't provided full definitions of your data so I wasn't able to fully test those solutions, but this should give you some insight into a different way of defining joins in Slick. Let me know if this was helpful at all. | https://codedump.io/share/i3CLZaNk9Vnd/1/how-to-write-readable-nested-join-queries-with-slick-30 | CC-MAIN-2017-43 | refinedweb | 387 | 67.86 |
- In the last tutorial we have discussed the Dart programming fundamentals.From this post onwards we are going to explore Flutter and we will learn more about Dart when we are continue it by doing.
- In the day0 we have completed to setup of our beautiful editor (VS Code) If you are having pretty heavy machine you can go with Android Studio.
Let's create our first app in Flutter by launching the code editor in our case VS Code and follow the steps.
ctrl+shift+pwill invoke Command Palette.
Type “flutter”, and select the Flutter: New Project.
Enter a project name, such as myapp, and press Enter.
Create or select the parent directory for the new project folder , wait for project creation to complete and the main.dart file to appear.
Whenever we are launching our application in an emulator or in real device
main.dartfile runs first.
Using real device:
How to enable developer options:
- open Settings > About phone > tap on Build number 7 times.
USB debugging:
- Connect your mobile to your computer using USB cable.
- Further you should turn on USB debugging in developer options.
- Open settings > Additional Settings > Developer options > USB debugging >turn on
- If you are using Redmi/Xiaomi mobiles then you should turn off MIUI Optimisation option which is present in developer options (At the end of developer options scroll down).
Using Emulator:
-). 5. Then click Next.
- Click Finish. Wait for Android Studio to install the SDK and create the project.
- Press the Run button.
Creating AVD (Android Virtual Device):
Open Android Studio / IntelliJ head back to AVD Manage on the top-right corner / select Tools> Android > AVD Manager and create one there.
If you want to run the app then press
F5.
Here we go we ready now!
Writing Your First Flutter App::
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Welcome to Flutter', home: Scaffold( appBar: AppBar( title: Text('Flutter'), ), body: Center( child: Text('Welcome to Flutter Development Tutorial'), ), ), ); } }
F5or
fn+F5.It will run the code and launch the app in your Emulator/Real Device.
In Flutter everything is a Widget.
Ex. Text is a Widget, Center is a Widget,Scaffold is also a Widget like in Android everything is a View.
Here are some the basic Widgets that everyone must know.
First of all
importthe material package as it contains all the Widgets and Methods to use.
MaterialApp
- Material App is the basic Widget which holds all the views.We have to wrap the main app with Material App because it gives us the default view of the app.
Scaffold:
- Scaffold gives us default structure of the app by providing an AppBar and a Body.
- Implements the basic Material Design visual layout structure. This class provides APIs for showing drawers, snack bars, and bottom sheets.
Appbar:
- A Material Design app bar. An app bar consists of a toolbar and potentially other widgets, such as a Tab Bar and a Flexible Space Bar.
Container:
- A convenience widget that combines common positioning of the widgets.
Row:
- Layout a list of child widgets in the horizontal direction.
Column:
- Layout a list of child widgets in the vertical direction.
Text:
- A run of text with a single style.
Image:
- A widget that displays an image.
Icon:
- A Material Design icon.
Raised Button:
A Material Design raised button. A raised button consists of a rectangular piece of material that hovers over the interface.
Here I am using VS code because it is lightweight and I am testing my app in real device because emulator is very slow in my laptop because I'm using some old stuff.Hope you can understand that.Past I used emulator but now I'm using my real device.
If you wish to use your real device then don't forget to turn on USB degugging
in developer options
Discussion | https://practicaldev-herokuapp-com.global.ssl.fastly.net/bugudiramu/flutter-development-day-2-41e6 | CC-MAIN-2021-04 | refinedweb | 653 | 57.87 |
29 October 2008 02:30 [Source: ICIS news]
SINGAPORE (ICIS news)--South Korea’s polyolefins (PP) producer Honam Petrochemical may shut all its polypropylene (PP) plants due to persistent weak demand, a company source said on Wednesday.
?xml:namespace>
“We will decide shortly whether to shut down all our PP plants,” the source said, adding that the units would be taken offline next week if it decided to stop production.
The producer had been operating at reduced rates since September due to the weak demand.
Honam’s 250,000 tonne/year PP plant at Daesan, operated by its sister company Lotte Daesan, was running at 80% and its 300,000 tonne/year PP line at the same site was operating at 65%, he said.
Its PP facilities at Yeosu – with a combined capacity of 380,000 tonnes/year – were still running at 100%, he said.. | http://www.icis.com/Articles/2008/10/29/9167049/honam-may-shut-all-pp-lines-on-poor-demand.html | CC-MAIN-2013-20 | refinedweb | 145 | 52.73 |
How to display odd and even numbers from a queue link list?
hello everyone i really need some help right now on this program. what this program is supposed to do is copy 11 22 44 77 33 99 66 into a linked list that behaves like a queue. the program should display the queue, display the odd numbers, display the even numbers.
display queue should look like this 11 22 44 77 33 99 66
display odd numbers should look like this 11 77 33 99
display even numbers should look like this 22 44 66
so far i can only display the queue with the program i have so far and odd and even numbers do not show up at all. here is my program would really appreciate the help. thanks to whomever can help me. also the way i got the queue link list to display is there a better way to do it or is it ok how i did it.
#include <iostream> using namespace std; struct NODE { int info; NODE *next; }; NODE *Queue; NODE *t; NODE *rear; int main() { //ask user to enter numbers in Stack link list. Queue=rear=NULL; for(int i=0; i<=6; ++i) { t=new(NODE); cout<<"Enter a number:"; cin>>t->info; t->next=Queue; if(rear==NULL) { Queue=rear=t; } else { rear->next=t; rear=t; } } //displays the nodes in the Queue link list. t=Queue; for(int i=0; i<=6; ++i) { int x; x=Queue->info; Queue=Queue->next; cout<<x<<'\t'; } cout<<endl; //finds and displays the odd numbers. t=Queue; while(t!=NULL) { if(t->info%2!=0) t=t->next; } cout<<t<<'\t'; //finds and displays the even numbers. t=Queue; int EvenCounter=0; while(t!=NULL) { if(t->info%2==0) t=t->next; } cout<<t<<endl; return 0; } | https://www.daniweb.com/programming/software-development/threads/436648/display-odd-and-even-numbers-from-a-queue-link-list | CC-MAIN-2020-50 | refinedweb | 307 | 78.48 |
Building the JCache Java EE 8 Bridge...One Brick at a Time
Building the JCache Java EE 8 Bridge...One Brick at a Time
All in all it's just another brick in the JCache Java EE 8 bridge.
Join the DZone community and get the full member experience.Join For Free
The CMS developers love. Open Source, API-first and Enterprise-grade. Try BloomReach CMS for free.
Let’s quickly look at the Java EE 8-JCache bridge project. This is another concrete step as far as Java EE 8 integration efforts are concerned...
Background
Details on the general idea behind this can be picked up from one of my recent posts on this topic.
A Bridge?? What For?
- Serve as the integration point for JCache & Java EE 8
- Provide decoupling: the Java EE 8 platform and the JCache API can be allowed to evolve separately and the bridge would provide a much-needed cushion. Think of it as a regular Bridge Pattern (from the GoF) – just implemented in the form of a JSR ;-)
Goals
- Derive from existing (and popular) specifications like JPA which can make it easier to adopt and use
- Standardise a JCache descriptor (configuration)
- Implement Cache injection
- Look at support for custom cache properties (which vary across different providers)
- etc…
Crossing the Bridge
Here is a rather simple example. It's a Java EE 7 Maven project on GitHub. You should be able to pull in into any IDE (Netbeans recommended) and get going
All it Does is
- Defines a named cache in cache.xml placed in WEB-INF/classes/META-INF (this is a pre-requisite for WAR based artifacts)
- Inject the cache in a JAX-RS resource
- Save the JSR info in the cache for future use (if it already does not exist there)
- It provides you JSR information e.g. and also scolds you if you ask for it again and again since it has to access the cache of course ;-)
@Path("{jsrNum}") public class JavaEE8Resource { @Inject @CacheContext("jsrinfocache") Cache<String, String> cache; ..... @GET public Response getinfo(@PathParam("jsrNum") String jsrNum) { String resp = null; if(!cache.containsKey(jsrNum)){ //do something ! }else{ //use the cache.... ! } return Response.ok(resp).build(); } .....
Other Notable Points
- The cache bridge API source has been included directly into the sample project to make dependency management easier (since it's not in Maven yet). You might want to have the latest fork for your experiments
- The JCache RI is being used by internally by the bridge. Experiment with another JCache provider (Hazelcast, Infinispan etc.), include its dependency and include it in the cache.xml configuration
<caches> <caching-provider>com.hazelcast.cache.HazelcastCachingProvider</caching-provider> <cache name="jsrinfocache"> <configuration> <property name="store.by.value" value="true"/> <property name="management.enabled" value="false"/> <property name="statistics.enabled" value="true"/> </configuration> </cache> <cache name="anotherone"> <configuration> <property name="store.by.value" value="false"/> <property name="management.enabled" value="true"/> <property name="statistics.enabled" value="false"/> </configuration> </cache> </caches>
How can You Contribute?
- Explore the project
- Provide ideas, files issues
- Write tests, break stuff, file some more issues!
- Get in touch with Adam Bien, translate your ideas into code and submit a PR… }} | https://dzone.com/articles/building-the-jcache-java-ee-8-bridge-one-brick-at | CC-MAIN-2018-51 | refinedweb | 529 | 57.06 |
User:PilotInPyjamas
From HaskellWiki
Latest revision as of 13:57, 14 November 2017
My aim here is to create a reference document for common functions, types, and typeclasses in the style of MDN.
Disclaimer: The following text is opinion.
[edit] 1 Rationale
In my opinion, Haskell is a fantastic language which produces code that has many advantages over other programming languages including:
- Highly expressive syntax
- Strong typing
- Easy parameterised functions, and interfaces
- Fast compared to other high level languages.
- Wide range of well-written libraries
- Based on sound mathematical theory and computer science
... and many others. Unfortunately Haskell has one major disadvantage which overcomes most of it's advantages: Haskell is difficult to learn.
[edit] 1.1 Haskell is not a beginners language
Nobody learns Haskell as a first language. Some people learn other functional programming languages like Lisp, but Haskell is a language by the wayside. Haskell is not accessible. Most pathways of learning Haskell come in the form of tutorials, and most (all?) of these require background knowledge
[edit] 1.2 Learning Haskell is difficult as a second, third, fourth, nth language
On the back cover of the book "Real World Haskell" is says: "when you have worked through the pages of this book, you'll write better code in your current favorite language". Haskell is mainly used in academia rather than in mainstream practice, but to make Haskell a more popular language, it needs to be accessible. Haskell turns your ideas of programming upside-down and perhaps the best people to teach would be those who have an open mind and have no preconceptions of what programming entails.
[edit] 1.3 Tutorials are not (necessarily) the best way to learn
Tutorials are abundant in the Haskell ecosystem, but they are not the be all and end all. Tutorials are not going to fit every style of learning, and one of the problems with tutorials is that they assume knowledge from earlier in the tutorial. If you're just looking for a single piece of information, it may be difficult to find, or hidden in a part where you wouldn't expect.
Haskell lacks a good "reference" style documentation of common functions which are commonly used but hard for a beginner to get their head around. It's often easier (at least for me) currently to look at the source code itself to figure out what is actually going on. Most other programming languages have a well documented interface which spares the programmer learning unnecessary implementation details.
[edit] 1.4 Perhaps we need to start from "Hello World!"
This is likely an unpopular opinion. To fully understand a hello world program in Haskell you need to have knowledge of Monads, IO, do notation and others. Frankly, "Hello World" in C++ is similarly horrific, with operator overloading, namespaces, classes and OOP, CPP directives, arrays and pointers (argv). Yet, still, C++ is often taught as a first language.
Programmers do not need to understand the implementation details of the language to write code, they just need to have some idea of how the code behaves. OOP made implementation details unimportant, but behavior a first class citizen, and similar constructs can be applied to Haskell.
[edit] 1.5 You need bad programmers before you get good ones
In order to get good programmers, first you're going to need bad ones. There's no point trying to have a high barrier of entry to weed out potential users of a language if that means you have none at all. Frankly, the more programmers the better, regardless of quality.
Languages like JavaScript and Python are highly successful, and I don't believe it's because there is anything that is inherently better about these languages than others, it's because these languages are accessible, the communities are welcoming, and they have good support.
[edit] 2 So where now?
My aim is to produce documentation in a similar way, and in similar detail to other languages for common functions, typeclasses and types (essentially those in base, especially Prelude) and present it in a form in which a programmer can quickly google and find the answer they're looking for. The aim of this is to make Haskell a more accessible language for all.
[edit] 2.1 Additional work
There are many projects which can make Haskell more accessible. In my opinion these projects would be: webasm as a compilation target for GHC, better GUI bindings, a language reference or tutorial which is aimed at beginners, and a language reference which is more readable and easier to digest than the Haskell report.
[edit] 2.2 Contact info
If you have any questions, please contact me on reddit: my username is pilotInPyjamas | https://wiki.haskell.org/index.php?title=User:PilotInPyjamas&diff=62204&oldid=0 | CC-MAIN-2018-09 | refinedweb | 787 | 58.92 |
The ruler of the great pome has issued his latest misinformed rant on the Flash player, entitled “Thoughts on Flash”. Just like most edicts against the Flash player by Apple, this too has bits of truth mixed in generous doses of FUD.
For those who haven’t read it, this post by Steve Jobs enumerates Apple’s issues with the Flash player which keep the player off the iPhone OS. He has jotted down his thoughts into a long post divided into 6 points. We shall pass each of these points through the bullshit detector, and see what passes through. We cover some of the major issues under each of the points Steve Jobs discusses.
Point 1: “open”:
- Flash is 100% proprietary
Simply not true. Parts of Flash, perhaps a major part are open specifications or open source. For example, Adobe donated the ActionScript 3 runtime called “Tamarin” to Mozilla for use in their browser. So essentially, the part of Flash Player which runs ActionScript 3 is open source.
Quite a few of the technologies used by the Flash player, such as RTMP, AMF etc are open. Adobe provides a free and open source SDK for creating Flash content called Flex. Flex is completely open source including the compiler.
There is at least one open source project aiming to create a spec compliant open source Flash Player, Gnash.
- Flash is a closed system owned and run entirely by Adobe, which controls its pricing, development and future direction
Essentially true, however quite a few features are those which have been requested by users. The direction of the Flex SDK for example has been known to been affected based on the demands of developers. For example, Flex 4 during its development period was using prefixes for new components, however due to the community reacting against this, Adobe switched to the better namespace based system used in Flex 4. This decision affected Flash Builder 4, and Flash Catalyst CS5 among other products.
- Apple’s products are proprietary too, but they believe the web should be open
Why the distinction between web and native apps? Why should native apps not be open? Many people believe that the iPhone OS should be open as well. Don’t force your beliefs down other people’s throats.
- Apple devices have low power high performance implementations of HTML5
For an HTML5 website performing the same multimedia rich tasks as Flash, it will definitely use as much, or more power, and will perform slower than Flash. Why? Because they are performing the same task. Here is an example of a benchmark the HTML5 canvas against Flash content when they do the same thing. When the same benchmark was run on a Google Nexus One phone, Flash Player 10.1 emerged a victor in performance.
Of course, this will change over time. In my system for example, Opera 10.52 boasted higher speeds than Flash 10. So there certainly is scope for improvement.
- HTML5 is a standard
Just simply NOT true. As a member of the committee this claim by Apple is quite fallacious. HTML5 is far from a “standard”, and by the estimate of the editor of the HTML5 specification it will only reach the W3C recommendation stage by 2022. Of course browsers have already begun adopting it, and will continue to do so over time.
- Apple began with a small open source project and created WebKit
Apple used the open source KHTML KJS web render and JavaScript engine from KDE’s Konqueror and made it into what WebKit is today. KHTML even at that time was one of the smallest lightest and most compliant implementations.
- By making its WebKit technology open, Apple has set the standard for mobile web browsers.
Apple didn’t make WebKit open, it is something they had to do if they wanted to use it. Since KHTML, which used the LGPL licence was open source, the only way to bundle and improve KHTML as WebKit would be to keep it open. Safari itself is not open source.
Point 2: “full web”
- Adobe has repeatedly said that Apple mobile devices cannot access “the full web” because 75% of video on the web is in Flash.
True, but they have also made the same claim for games and web applications made with Flash, some popular ones include Aviary, and Picnik web image editors.
While it might be true that Mobile phones will not be able to use such websites as is, since they are resource intensive, however this should’t hold true for the iPad. Fact is, the iPad is just an oversized iPhone, and not capable of running such apps. Which is a failing on Apple’s part.
It is true though that a lot of current applications cannot perform well on an iPhone and other mobile devices, and Adobe is in fact creating a new Flex SDK for Mobile devices because the current Flex SDK might not perform adequately. Even with the Flash Player 10.1 on the iPhone it would probably not have access to the “full web” but at least in this case it would be a limitation of the hardware and not software.
- What they don’t say is that almost all this video is also available in a more modern format, H.264, and viewable on iPhones, iPods and iPads.
Most such content is available in H.264 because it is supported by the Flash Player and is superior format to the old VP6. If Flash player did not add support for H.264, few websites would have converted to the format just for the benefit of a few iPhone customers who themselves would likely not be enough incentive.
- Adobe claims Apple devices cannot play Flash games. However there are 50,000 games in the app store.
This sidesteps the whole issue. Sure there are 50,000 games for the iPhone, but this is due to the effort of developers, not of Apple. If Flash were allowed, even via the packager, this number would increase greatly.
Point 3: reliability, security, performance
- Symantec recently highlighted Flash for having one of the worst security records in 2009.
Links Steve links! For an advocate of HTML5, you don’t seem to have basic things like the anchor tag down. In any case, the study being referenced to here, seems to be “Internet Security Threat Report: Volume XV: April 2010” which ironically shows more vulnerabilities in Apple Quicktime (27) than in Adobe Flash (23). Additionally, regarding vulnerabilities Safari (94) was second only to Firefox (169). Safari also had the poorest record when it comes to fixing vulnerabilities with a window of exposure -- the time between an exploit being made public, and a patch being issued by the developer. But this is neither here not there.
- Apple doesn’t want to reduce the vulnerability and security of their devices by adding Flash.
It is clear that Flash isn’t the only problem. Most software have vulnerabilities, and they need to be detected and fixed fast. This is something Apple shouldn’t be preaching to others.
- Flash has not performed well on mobile devices for years now, and Jobs has yet to see it do so.
From the benchmark example above, it seems to compare well enough with HTML5 technologies. Smartphones are getting faster, and Adobe’s move isn’t simply for today. In the coming years who knows how powerful they will become. While smartphones will never be powerful enough to run all the Flash content on the web, it will enable a large portion of it to be accessible.
Point 4: battery life
- Mobile devices need to use hardware decoding of video to conserve battery power.
Sure, and this is something the Flash Player does as well.
- Flash has recently added support for H.264
Flash added support for H.264 over 2 and a half years ago with an update to Flash Player 9, hardly recent.
- Video on most Flash websites uses the older generation codec which is decoded by software
This runs contrary to what Steve says a little while back: “almost all this video is also available in a more modern format, H.264, and viewable on iPhones, iPods and iPads.” If the video is available in H.264 and Flash Player can play H.264, why would the website only be using the older format? YouTube for example, only uses the older format for lower quality video, and uses the modern H.264 format for all HD content.
- H.264 decoded in software drains the iPhone battery in just 5hrs while with hardware decoding it can run for 10 hrs
Sure. This is due to the complex nature of the H.264 encoded content, which is quite hardware intensive. You can’t compare H.264 running on a hardware to H.264 running on software as that is not the discussion here. If Flash uses hardware for H.264 this issue will be sidestepped anyway. The comparison should be between H.264 on hardware and VP6 on software, as that is a possible scenario with Flash. Here VP6 running on software will surely run for much more than 5 hours due to its relative simplicity compared to H.264.
Apple has just recently released the API’s for using hardware acceleration for video content on Mac OSX and Adobe already has a preview version of the Mac OS Flash player ready with support for this new feature, not bad for such a lazy company.
- "When websites re-encode their videos using H.264, they can offer them without using Flash at all. They play perfectly in browsers like Apple’s Safari and Google’s Chrome without any plugins whatsoever, and look great on iPhones, iPods and iPads."
What about other browsers? H.264 is not a format specified by HTML5 for the video tag. It is NOT an open specification and is patent encumbered. By using H.264 you are no more open than when using Flash. In fact Apple is one of the licensors of H.264 and any opinion they have on this matter is sure to be biased.
Furthermore H.264 is not supported on the major browsers Firefox and Opera and will likely never be a part of Firefox. Let us see if Apple’s “open” attitude holds when there finally is a video codec recommended by HTML5.
Speaking of Google’s Chrome, it is also the first browser to fully integrate the Flash Player into the browser itself.
Also, the Flash player currently offers many features for web video which are still not possible with HTML5 video, such as streaming and DRM protection.
Point 5: touch
- Flash was designed for PCs using mice, not for touch screens using fingers.
HTML was designed to PCs using mice. Well, guess what, things change. One can create products which offer a new form of interactions, for example a device which is entirely voice controlled. It is then the responsibility of the device manufacturer to ensure that their device works with all current content. They can’t expect everyone else to adopt to the new shiny way of interacting that they have created.
- Many Flash sites rely on rollovers which aren’t possible using touchscreens. Flash website will need to be rewritten to support touch-based devices.
Many HTML rely on rollovers. This point is again simple falsehood, as Flash content with rollovers will work fine with touch screens.
- If you need to rewrite anyway, why not use “modern technologies” such as HTML5...
Firstly, you don’t need to rewrite except for performance concerns. Secondly, even if you need to, HTML5 is not as capable as Flash yet, and porting to it is not a trivial task. The amount of effort on this won’t be worth the few extra iPhone visitors.
Point 6: “the most important reason”
- "We know from painful experience that letting a third party layer of software come between the platform and the developer ultimately results in sub-standard apps and hinders the enhancement and progress of the platform."
Such as iTunes for Windows, right? Why don’t you rewrite that mess to use only Windows APIs and conform to Windows’ UI paradigms?
You don’t need a third-party layer to make a sub-standard application, as is evident by some of the content available on Apple’s App Store. Moreover, if even a single App using a third-party layer has landed on the App Store till now -- and many have done so, and become quite popular -- it means that such applications can indeed be successful.
- “We cannot be at the mercy of a third party deciding if and when they will make our enhancements available to our developers.”
If a third party doesn’t support the latest and best features of the iPhone OS, then developers will have less incentive to use such tools to create their apps, as end users will have less incentive to use such apps.
If people still prefer applications made using these tools, then they are not getting enough value out of your platform’s features. In the end isn’t it about what the end users will like the best? Seems.”
Before pointing fingers at Adobe, port your own iTunes to Cocoa, seriously. Someone said it’s been almost 10 years now since Mac OSX has been shipping.
- “We want to continually enhance the platform so developers can create even more amazing, powerful, fun and useful applications.”
Go ahead. But why not give developers the chance to create applications their own way, and just let the consumers decide which applications are more “amazing, powerful, fun and useful.”
- “Everyone wins – we sell more devices because we have the best apps, developers reach a wider and wider audience and customer base, and users are continually delighted by the best and broadest selection of apps on any platform.”
Too many fallacies. There needs to be some kind of award for this. Everybody wins? You sell more devices ‘cause they’re awesome. No doubts there.
Developers reach a wider audience? How? Whether creating a native iPhone application a developer reaches only the iDevices audience. With HTML5 a developer will only reach the small percentage of the web audience which has HTML5 capable browsers. With a Flash application a developer will reach nearly everyone.
As for the “best and broadest” selection of apps on any platform: How do you get a broader selection of applications from limiting ways of creating and publishing applications?
Steve Jobs raises some valid points here, but they seem to be mostly covered up by the verbosity of the FUD added to it. As for Adobe, some of these points are going though everyone’s minds, and Adobe will have to assuage these doubts which people have, even the ones which aren’t true. | http://www.digit.in/laptops/thoughts-on-thoughts-on-flash-cutting-through-steve-jobs-reality-distorting-field-4531.html | CC-MAIN-2017-09 | refinedweb | 2,477 | 72.46 |
#include <Stepper.h>Stepper myStepper(StepsPerRevolution, 8,9,10,11);Stepper myStepper(StepsPerRevolution, 9,10);setSpeed(rpms);step(steps);
then in the case of the stepper.h library is it convenient to use these functions when we use a specialized stepper driver that adjust the pulses and the microsteps manuallyor using direct pulses without any library is better in this case.
will this work with an arduino and the addafruit motor shield?
Is there any chance you could write the code to make this work with the addafruit motor shield?,im sure a lot more people would find that usefull!,cheers Paul.
if its not a suitable device,why is it sold as such?, | https://forum.arduino.cc/index.php?topic=277692.15 | CC-MAIN-2020-50 | refinedweb | 114 | 63.49 |
- Multiplication of variables...
- How to Change image size at runtime in flash
- bitmap to mc
- Flash video stops javascript dropdowns from working in Mozilla
- Design FLV Player
- First letter MUST be uppercase
- Google Earth type catalog-navigating
- Help with "sweeping bar effect"... ActionScript 2.0
- Sweeping bar effect (Flash CS3, ActionScript 2.0)
- As1 to AS2 problem
- Help with "sweeping bar effect"... ActionScript 2.0
- Enviroment Variables
- Mouse Event Nightmare....
- Passing variable php to flash, can't acces the file.php on localhost
- zoom in/out problem
- need help loading flv movie onto stage from button click
- Button RollOVER and RollOUT aniamtion
- Cutting code down using parameters in functions
- 360 rendered images rotation + on drag
- Localization, Natural Language Text Translation
- text follower/ real bubbles
- analog clock
- mutiple masking
- flash preloader/text scroller
- Using a scene's variable in a movieclip
- help with swf movie in frame
- Selected text, highlighting color
- Problem getting data from xml...
- flash 5 actionscript
- target/rewind another MC from another button on stage???
- Converting to symbol
- Special Characters show as squares
- Flash Behavior
- Flash into my Website
- a href in Flash
- Left and right scroll to and stop with buttons?
- how to use actionscript?
- increase loading of flash sites
- increase loading Flash
- Flash Movie Takes alot of time to Laod
- Flash with Dot Net
- flash help
- SWF _ Have play only once
- button to database
- Publish swf in 16:9 wide screen
- flash button connect to database and retrieve data to flash
- movieclip.gotoAndPlay
- strange question, actionscript and lingo
- Help with flash email form using php script
- AS 3.0 - making a movie clip into a clickable button
- attachment through a email form created in flex
- resetting the size of SWF's in a Container
- Flash Onclick
- Flash 8 Database
- Can't figure out how to open links in SAME window
- form GET method on submit parameter name problems!
- flash object in the background! possible? howto?
- Parsing a text...
- setting the mute button to automatic mute
- opening a ppt file from within a flash file
- Flash, XML, and a db Equals a quiz
- graphic designer new to code needs help
- Load image from library into movieclip
- Buttonss...again..
- Memory
- drag and zoom into graph (actionscript)
- Internet explorer is not supporting for thumbnail generation
- Embade Flash with Quick Time ??
- Statements not working...
- how can I make a scrollbar for a box of static text?
- how do I create text that links to another frame?
- FLASH Back Button and Javascript
- Trying to define a concept
- form fillup source code
- Simple continuous scrolling images
- Flash Menu with AJAX driven page content
- "Print" the whole content... ?
- I need help please!!!
- Simple question: Read own filename?
- Flash Widget - remember xml location
- Flash web site
- a cross-domain issue.
- Action Script Job with New Company
- Embedded quicktime on to Flash and put mouse over it for various functions
- Grey boxes around flash elements
- StopDrag, add item ++
- Integration between flash swf with html on ie browser
- Flash not showing on website
- Get screenshot from flv
- how to give html link in flash
- Need help getting flash effect from a fla file
- Mouse Wheel and Defining Movie Clip SIze
- How to do section out in Falsh Action script
- remove FLASH object in IE
- Roll over button caption
- setTimeout
- Need help with a countdown script
- How can I edit a swf file?
- Why would a flash shared object SharedObject.getLocal call crash?
- converting a floating point to a reminder
- LoadVars - getting several variables with for-loop
- online radio player using FLASH
- using Date.getHour()
- how can i call an animation from a button i've made in library?
- How can I call Flash function using JavaScript?
- How to make flash slideshow with thumbnails for client control
- Send flash variables to a php file on a different domain.
- Progress Status Bar?
- GetURL() & iframes links
- general basic bonehead quesitons
- Actionscript 3 with PHP
- A link in a dynamic txt field
- ActionScripts for newbies!!
- anchor inside the text file
- Dynamic arrays animation
- Flash And PHP Sessions
- Deleting files through a web based application
- Actionscript and SNMP
- HELP_Flash/Windows/"click to activate..control"
- How do i record audio from microphone to my local file system
- Checkbox value Transer from Flash to PHP
- Flash Output Settings
- Exporting Movieclips As SWF's from Flash using JSFL
- Adding Components Dynamically
- Nested Buttons
- Action script that acts like a screensaver
- WTF function executes trace but nothing else...
- Quiz How to build one
- parsing variables from a xml file
- problem with externalInterface
- image placement after uploading
- reset bitmap colorTransform to its original.
- General Actionscript Question
- bitmap ColorTransform
- Turn Wheel (like one on a submarine door)
- Smooth Zoom AS
- how to change screen resolution in flash
- How to change flash icon
- rotate circle by dragging
- Multi-coloured text
- How to Create PDF image
- Page Curl script
- Action Script 3.0 Help with CLick Tag
- Mini Map Selection Box
- file upload >> returning uploaded file for display purposes?
- Fitting in a browser window
- Double Click MC???
- How to control a flash animation with Play and Pause buttons ?
- Mouse Wheel ZOOM???
- Mini Map
- Scene to scene
- preloader not working with my animation
- Flash Mp3 Player
- Help Actionscript
- Returning value from a javascript to actionscript call problem
- rollOver rollOut and movement animation
- Breaking glass effect...
- Required Flash Programmers @ Hyderabad
- How to update my flash banner to reflect no. of items in my shopping cart
- Flash 8 Screens: back button goes forward
- How to open a local file and split it in chunks?
- Interpreting String as function name actionscript 3.0
- Programmically calling a button action
- Looping video with a netstream
- can actionscript retrieve navigator.userAgent
- Only one Answer
- movieclip function
- related to grid in actionscript
- Flex Builder 2 - How do I manually close an alert window without user input?
- Video Avatar
- Flash Game Programmer
- interactive flash not loading data database
- related to graph in actionscript
- related to graph in actionscript
- Array maddness programmer on the verge of a breakdown
- Ajax transfer file
- find data in array using another array
- Object expected error after uploading web page
- HorizontalList of images from dynamic source
- duplicate Mc
- problem in loading flash file
- need some help - flash quiz
- removing dynamic text field before second .flv streams
- Editing a Website
- Help: How to load images from xml and scroll the images
- AS3 SQL Tutorials
- getting info from a html page
- Actionscript 3.0 Change font size
- flash website
- Connecting to database in flash
- Actionscript Challenge
- Global MouseEvents...
- Can I get very good and easy tutor to create a website like this?
- getting to data out of a XML file using flash
- Can get flash to see the XML childNode
- i have a problem in my flash site i need help
- Flash Game
- .NET driven Flash email form...
- how to replace the transparent pixels instead of white.
- how to replace transparent pixel instead of white
- How to load my ActionScript Slideshow when i open choosen page?
- Help: Editing The SWF Movie
- movieclip onpress
- flv and contents preloader
- No window
- Flash is integer
- Linking to "home.htm?id=1" ?
- datagrid addItemAt will not work as I would like
- How do I...scroll paragraph
- Send/Receive XML through HTTP
- Load image in a movieclip inside two movieclips
- LoadVars Datagrid can not populate second Datagrid
- Selecting an item in a datagrid
- Website and User accounts and passwords
- intigrating gallery help
- seconds convertor to minutes in flash
- "Authorization" Header not supported in AS3 ?
- Variables not being sent using send() or sendAndLoad()
- Button Rollover/rollout problems
- Dynamically Size the Canvas
- createTextField with createEmptyMovieClip
- Attachmovie for a symbol, it loops continuously
- how to use fs command
- Newbie questions
- Installing a program without admin privilages
- Issues with a dropdown menu
- Video Recording
- hyperlink problem in a flash file
- embedded .swf file rendered too small
- How Do I rotate an Image Horizontally
- flash button in asp.net
- Flash Actionscript
- Flash Button click to ASP.Net
- Button Functions...Lots of them!
- flash
- Adding a line break to actionscript
- Importing Video- Skin and FLVPlayback disappear
- how can I create a line break in a flash string?
- adding effects to dynamic text
- Hide image in a Flash script?
- Adobe Flex 2.0 confusions
- Handling parameters in ActionScript
- Carousel Image Galery
- Flash menu not working immediately, the area needs to be clicked first ?
- Simple progress bar question
- Action Script Tween for Navigation
- Button/area activates when I touch it (without clicking)
- gotoAndPlay causes problems with mouse
- transparent flash
- Link to External Flash File Frame
- How to use Radio buttons
- file upload using webservice
- Internet search engines do not read flash content
- I need help with reflection in rectangular coordinate system URGENTLY!!!!!
- Printing to PDF
- dynamic textbox image
- Text to object
- XML parsing delirium
- problem with flash player
- Read output from script called using loadVariables
- flash width and height
- help with a dynamic text box
- Magic persistent Flash Button
- Help needed for an issue with XPathQuery using AS3
- Problem with consuming a .NET web service from Flex-ActionScript
- help me please
- Health bar percentage rise help needed
- Flex2- SWFLoader - resize problems
- How to loop an external MP3 in flash?
- I unload a flash file...but key presses from previous file are still active
- listHandler - actionscript
- Do you want to develope clone of youtube
- resizing and loading in a new window actionscript help!
- Flash textarea alignment and symbols
- Flash game a.i. help
- Flash mp3 player help!
- Help with scrolling thumbnail?
- listener run my function 2 times
- How to apply a stroke to text in Flash CS3?
- Flash objects in IE cache..!
- Flash registration form
- Attaching a animation to a movie clip and calling it later
- link in actioscript
- how to create hotspots in flash???
- FileReference.browse()...displays error...
- Download via Flash
- Close button for External SWF's (Without loss of Container)
- printing in flash
- Generate Graphs for Statistical Data
- The Flash Challenge
- Causing a button to play backwards onRollOut
- SharedObject Confuse
- auto stream MP3 into flash from external file (not via XML)
- Named functions with return values
- 154 Top Flash Sites
- Assigning specific key presses
- call _root from movie clip
- Unloading createEmptyMovieClip
- How do i get a button to change color when rolled over?
- movie not loaded help
- diff. between runtime and compile time
- Flash Scene command
- Struggling Send variable from scroll Pane
- Passing data to a PHP script
- Dynamic Text problem
- Scrolling Text with Background
- Flash's Security Settings not allowing script
- accessing duplicated movies
- handshake in flash?
- AS3 - Why the change? And layman's synopsis? Thanks!
- gotoAndPlay Problem
- Save input text in flash
- How do I ActionScript a pop-up?
- What is Flash Remoting? - Advanced help needed
- Flash button hide/show a DIV-Layer on a html page?
- Flash Poll Form & Newsletter
- how to get dimension of the .swf file
- Store Values in database using Javascript
- Flash and javascript problem
- Boxes and creating MC instances
- Flash w/ Xml
- SIFR (Scalable Inman Flash Replacement)
- How to split a large swf into smaller swfs
- Pop-Up problems with Flash MX\ActionScript 1.0
- how can i put external javascript in flash
- [Flash8] Dynamic Text Fields / XML / spacing
- Clearing text fields in selteco flash designer 4
- movieclip dynamic color change problem!!! PLEASE
- Passing variables to a component
- actionscript: populate variables based on parameter
- How do I access flash function using javascript?
- How do I create a Popup in flash?
- Flash Button Target
- Setting font using actionscript
- export flash variables to dotnetnuke
- SEO in Flash
- flash problem
- Saving variable's value in the loaded .swf?
- Problem - Simulation Speed slows down quickly (timeinterval)
- Help with simple game
- How do you create Charts
- Dialog Box Problem
- Trouble with custom namespace flex 2 (Could not resolve component implementation)
- Hit Test
- flash scrollpane background color
- problems with stop(), cant play _mc's more than once
- Need help adding an action to a for loop
- problem with embedded content when scrolling in Safari
- Actionscript Math Round
- load button states images from a folder!
- Dynamic Mirror Effect
- Refreshing flash
- Need help!!??Confused
- target right back to the _root from inside movie clips??
- getURL and browser settings
- Resizing swfs without distorting content
- problem with animated movieclip
- To run movie with Actionscript
- problem with animated movieclip
- Problem after importing gif animation
- Preloader flickering...
- Flash getURL help
- Import extrenal images with movement
- Split movie (size problem)
- Slide Out menu link help.(code included)
- Checking to see if a variable contains a string
- how to insert another stage and make 3 stage in a flash?
- Animated and Rollover help (not a newb question)
- slow running flash content
- Php email through flash contact page is jibberish. HELP PLEASE!!!
- backgound transparancy of a flash animation is not applicable in firefox
- Help needed with checkboxes on Flash/PHP form
- Uploading pictures from a folder dynamically in flash
- Listener and CuePoint for FLVPlayback
- URL Flash Script
- Checkbox controlled dynamic text
- Scroll Flash page with mouse wheel
- Button has to be clicked two or three times to work
- need some reference help on col. new to flash/as
- Advice on 'constructing a completely Flash based website ?
- Connect Flash with Database ('Access' or 'Sql Server' or 'XML')
- Actionscript for exit?
- Amazon menu made in flash
- how to send screen content to email address out of flash
- re-publishing a decompiled Flash app
- ie 6 and firefox iframe navigation
- actionscript - mc.rollOver event listener to sendAndLoad
- Help changing Scroll Menu Values
- How to do a substring function in actioncript?
- how to design a graph using flash
- Any pro good in Google map API here?
- please HELP with my drawing application
- Content Slider
- on event - instance name in dyn textfield
- What platform to use?
- flash terminal window
- Movie with waiting message
- Chatbox
- Shockwave Flash Object Com Component
- simple aniamtion if flash 8
- Problem publishing a Transparent Gif / Png image with Flash 8.
- Simple flash animation
- Inserting image on Button through action Script
- particle effects / moving backgrounds
- Make Buttons disappear
- Need help a.s.a.p Urgent
- Access javascript value from flash
- How to create an empty Movie Clip behind other layers?
- [Flash8] Image MouseOver in XML Gallery
- swap actionscript
- Get a value from HTML to Flash
- Problem with Actions (related to Adobe Captivate)
- ActionScript for Flash Lite 2.0 problem!
- Actionscript problem with dynamic image portfolio
- Questions:: Flash image gallery scrolling with mask and actionscript
- HELP. My Head is going to pop.
- flash questions
- getURL question
- Flash to PHP to XML to Flash
- How to create a Subserviant!
- Need help
- How to retrieve value from php file using actionscript?
- Formating Dynamic Text
- Displaying quotation marks from xml
- Back Button in IE not working because of Flash
- video FLV and cue point syncing question
- Bookmark a flash page in flash
- pass php to actionscript code
- need to turn a string into a array
- OGG Audio Streaming in Flash?
- Flash computational power?
- Sending mouse and keyboard inputs from a flash application to another program
- Yes i need a Flash Book
- array.splice() help me
- gotoAndPlay Question
- Collision testing
- Publishing problem?
- Text Effects
- "Browse" button in Flash
- Correct coding? myspace flash
- how to create CMS in the flash website
- Flash AS 2.0 Frames
- getURL actionscript
- Post data from flash form to PHP form
- Flash and 'C'
- Squeeze buttons aside
- optimize flash
- link flash
- Will Flash Basic 8 do ?
- color picker
- Sprite Movement using arrow keys
- MovieClipLoader
- NEED SOME HELP HERE... embedded fonts, css, xml, textfields, dynamic content
- Problem with Flash in firefox!!
- html to flash
- Dynamic flv player with auto resize based on content
- Flash and accesibility
- Uploading A Flash File
- Multidimension arrays in Actionscript
- Using loadMovie method
- does flash have any sql like objects
- parse mp3 or any compressed audio file
- 1. detect word clicked 2.hilite words
- Actionscript PHP and MySql Problem
- asp
- floating menu over flash
- Placing the movie at the center of explorer
- XML node values into actionscript array
- Hello everyone
- Mutiple Choice Question Interactive Video
- Problem importing .swf file into a .fla document
- Flash Query!
- Flash Buttons Query!
- Simulate the "Swap instance button" in ActionScript
- mp3 player with 3 listboxes and category/subcategory
- how to send data of a form to email
- How to load swf file with image
- My menu seems to be heavy and I dont know why. Help?
- dragging
- Completely Stumped
- Flash loading problems Firefox
- Loadvariables problem with IIS
- I really need help for Fading Grid tutorial! please read!!
- Need help with creating buttons
- cannot export an avi of motion along a path when the path is specified with action sc
- Scene Order Problem
- Flash Button Help PLEASE
- On key press with variables
- ActionScript 3.00
- fscommand Help!
- how to use decimals
- Basic XML & Flash issue with FLV player. Help?!
- Web Designers Ireland Asks How to Design a Good E-Commerce Site
- Movie linking to a new window?
- Linking buttons to URL. Something is wrong. Please help!
- is it possible to generate a line graph in flash by calling xml data
- Display boxes in random order
- Interface to interact with a CD
- Help with a Dynamic Text Box
- close swf movie using action script
- save dialogue box in flash (saving external jpg + .doc files)
- 256 levels of recursion were exceeded in one action list Error?
- Noob, Scrollable 800x1100 pixel background with Inputs on it?
- Flash send value to database with PHP
- Embedding flash object into a webpage
- How to pass value from flash
- How to change picture
- REEBOK Image Collection Class
- Developing graphs in flash by calling XMLs
- background sound in flash
- want to get a url name from the flash movie.
- Page Loading / background effect.
- video with preloader
- Question about the collision detection and score indicator......
- flash buttons linked to .asp pages in ajax QUESTION
- Blurry image with mask of clear image that is supposed to show when Mouse rolls over
- Problem publishing a Transparent Gif / Png image with Flash 8.
- I need to know the right answer. Please!
- Flash button not working in IE
- Advanced Application
- fla resize help please!
- Combo Box Actionscript in Flash
- Flash on USB pen
- Getting File in Server Program but not uploding it...Need help
- Flash/PHP form with text fields and checkboxes
- Newbie needs help!
- create text in a parent MC
- .swf files from camtasia does not work in NVU
- Thanks Motoma and Kestrel
- Help Quickly!
- IE7 Skips Preloader (but does load movie)
- Creating Specific Folders Through Flash Exe
- Saving External File Through Flash Exe
- Know the dimension of a picture
- Music Player Security - How do I hide the browser URL?
- external swf files --- close and open??
- Simple quiz help
- Help me in Actionscripting from Biggening Class
- Flash Button - linking to web pages
- Scripting Language
- Play And Exit | https://bytes.com/sitemap/f-274-p-2.html | CC-MAIN-2018-22 | refinedweb | 3,084 | 60.14 |
Understanding the problem
We have to write a program that accepts three sides of a triangle from the user and prints its area. To calculate the area of a triangle from the three given sides, we use Heron’s Formula:
Area = √ s*(s-a)*(s-b)*(s-c),
where s = (a+b+c)/2
Algorithm
- Take input of the three sides of the triangle from the user and store them in the variables a, b and c.
- Now declare a variable of float type and calculate and store the half perimeter in it. (don’t forget to use explicit typecasting since ‘s’ is of float type and a, b, c are int)
- Declare a variable area of float type and calculate and store area of the triangle in it using s and the given formula.
- Print area.
Code:
#include <iostream> #include<cmath> //to use sqrt function using namespace std; int main() { int a,b,c; //taking input of the three sides from the user cout << "Enter the three sides of the triangle\n"; cin>>a>>b>>c; float s=(float)(a+b+c)/2; //calculating s float area=sqrt(s*(s-a)*(s-b)*(s-c)); //calculating area cout<<"Area="<<area; //printing the area return 0; }
Output:
Enter the three sides of the triangle: 5 10 12 Area = 24.5446
Report Error/ Suggestion | https://www.studymite.com/cpp/examples/program-to-find-area-of-a-triangle-cpp/?utm_source=related_posts&utm_medium=related_posts | CC-MAIN-2020-16 | refinedweb | 223 | 56.42 |
Tech Off Thread3 posts
Forum Read Only
This forum has been made read only by the site admins. No new threads or comments can be added.
Get list of resources from a ResourceManager
Conversation locked
This conversation has been locked by the site admins. No new comments can be made.
I'm trying to get a list of strings out of a ResourceManager with the names of all the resources.
It contains icons only.
I'm using .NET 2.0 Beta 2 and writing it in C# .
Anybody who have an idea?
In the .NET Framework v2.0 you can use a class called ResourceSet in the System.Resources namespace. You new up a ResourceSet providing the Resource File Name in the constructor then you have access to the resources by enumerating through the ResourceSet.
Some sample code off the top of my head...
public void GetResources()
{
ResourceSet resources =
new ResourceSet("theresourcefile.resources");
//enumerate through the ResourceSet
IDictionaryEnumerator enumerator =
resources.GetEnumerator();
while(enumerator.MoveNext())
{
Console.WriteLine(enumerator.Key);
}
}
This is one approach to reading ALL the Resource Keys available!
Thanks, now how do I get them add into a String[] ? (Somehow I cannot get ArrayList to accept Generics, so I cannot just put the key into there and run toArray on it). | https://channel9.msdn.com/Forums/TechOff/116314-Get-list-of-resources-from-a-ResourceManager | CC-MAIN-2018-09 | refinedweb | 212 | 68.06 |
From: Reid Sweatman (borderland_at_[hidden])
Date: 2000-07-31 11:24:05
> So, I'll go to the wall fighting BOOST_POSTULATE(), tolerate something
> clumsy like BOOST_COMPILE_TIME_ASSERT() or (better)
> BOOST_STATIC_ASSERT(),
> but prefer something pithy and just-informative-enough, like
> BOOST_PROVEN()
> or BOOST_CHECKED().
If you want to go that route, why not just BOOST_AXIOM? (Apologies in
advance to those who've already rejected "axiom" for whatever reason. From
my slightly earlier post, I am, a Priori, a fence-sitter on that issue <g>.
But since this thread verges on being a code Jihad, why not just interject
the divine outright, and use BOOST_FIRST_PRINCIPLE, or
BOOST_RATIONES_SEMINALES (ah, the advantages of a Classical education <g>).
No, but seriously, folks, BOOST_AXIOM works for me, although, as Dave points
out, it doesn't capture the compile-time nature of the assert, and
BOOST_COMPILE_TIME_AXIOM is just as bad as BOOST_COMPILE_TIME_ASSERT. I
thought of suggesting BOOST_COMPILER_ASSERT, but then, it's the user code,
not the compiler that's asserting, so the semiotics are wrong (BTW, I use
"semiotics" merely because "semantics" is already overloaded in this
context).
One question: why does this assert have to include the prefix BOOST_?
Merely for consistency with other library usage? If it's in the Boost
namespace, couldn't this merely be assumed? Or, for that matter, why
require such a lengthy prefix throughout the library? Why not abbreviate it
to something like BST_? I know that goes against the already-stated goal of
spelling things out explicitly, but it's really getting close to the unique
length limit on identifier names some compilers have, while making the
leading six characters axiomatically non-unique. I've hit that one myself
in the past designing my own library modules, and finally ended up with a
self-imposed rule that I never use a module prefix longer than three
characters (which allows somewhat longer names in my case, since I write in
Hungarian notation, and only use underscores when necessary for
disambiguation).
Sorry if I'm treading over well-trodden acreage, so no flames, please. I
mean well, and probably like the rest of you, I've been hammering at the
problem of a good convention of succinct, communicative names for years now.
My conversion to Hungarian was solely due to McConnell's "Code Complete,"
and I effectively have my own sub-lingo of it, based on some valid
criticisms of Hungarian I've been exposed to. I don't know about the rest
of you, but my own comprehension of code is *very* much affected by naming
and formatting; so much so that when handed someone else's code to read, my
first act is to run it through a reformatter. If I make changes, I reformat
it back the way it was handed to me before returning it. Especially I find
that one thing that drops my comprehension of code drastically is identifier
length. The STL is already beastly in that regard, so I try to keep any
identifier within my control as mercifully short as possible. I have to
admit, BOOST_COMPILE_TIME_ASSERT is getting pretty close to the edge for me.
I only go to such lengths explaining this because I'm probably a lot closer
to the average *user* of Boost than the Big Brains who are hashing out the
deep issues in the library (although as Yosemite Sam said, "I'm a'thinkin'.
And my head hurts. <g>). Anyway I'm only suggesting that I'm an example of
the working programmer you're supposedly writing Boost++ for. If I have a
hard time understanding it, I may be in some sense representative.
My 0.02 Drachmas in debased currency of the later Byzantines (apropos, no?)
void * m_pReidSweatman;
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk | https://lists.boost.org/Archives/boost/2000/07/4157.php | CC-MAIN-2019-35 | refinedweb | 640 | 60.35 |
Wednesday, November 05, 2008 from 6:00 PM - 9:00 PM (CT)
Our next meeting is on Wednesday 11/5/2008, where former SQL Server MVP David Penton will lead us through a low-level, code-intensive presentation of a new caching mechanism for ASP.NET & SQL Server.
ASP.NET has a wonderful built-in framework for managing Cached items within a website in the namespace System.Web.Caching. It is accessible from HttpRuntime.Cache (among other ways, such as from System.Web.UI.Page.Cache). You have great flexibility with the data you may wish to cache. With this flexibility, there is an extremely important piece missing from HttpRuntime.Cache - and that is thread safety. Not from inside of the Cache, but from the external code that accesses it. Websites under high load could cause a cache item to be populated multiple times..
Wednesday, November 05, 2008 from 6:00 PM - 9:00 PM (CT).
MySpace
Digg
del.icio.us | http://www.eventbrite.com/event/207785492 | crawl-002 | refinedweb | 161 | 68.06 |
Example output from my test script - It just generates a set of 5 lines in 3D space as a demo of how to use this api
For the benefit of everyone, I've included the test/demo script I wrote at the end of this post. You should be able to just copy and paste it into a text editor (fingers crossed it doesn't grab any of the HTML crap in the process) and start playing around.
Use cases for being able to create Grease Pencil strokes using Python include loading in stroke data from other apps, or for providing addon developers additional ways of adding in-viewport annotations without having to hack around with bgl and draw handlers.
# Demo script to add some gpencil points manually
# NOTE: For the context stuff to work, this should be run from an editor that can have GP data
import bpy
def main(context):
# add points to new layer
bpy.ops.gpencil.layer_add()
gpl = context.active_gpencil_layer
gpl.info = "Python-Generated Demo Data"
# create new frame to host the strokes
gpf = gpl.frames.new(context.scene.frame_current)
# create some strokes
for x in range(5):
# create new stroke
stroke = gpf.strokes.new()
stroke.draw_mode = '3DSPACE'
# create the list of points - all set to defaults
stroke.points.add(count=x)
# set the stroke point coordinates
for y, pt in enumerate(stroke.points):
pt.co = [x, y+1, x*y]
pt.pressure = 1.0
class GPencilAddDataDemo(bpy.types.Operator):
"""Demo operator for adding grease pencil data"""
bl_idname = "gpencil.add_data_demo"
bl_label = "GPencil API Demo"
@classmethod
def poll(cls, context):
return context.area and context.area.type == 'VIEW_3D'
def execute(self, context):
main(context)
return {'FINISHED'}
def register():
bpy.utils.register_class(GPencilAddDataDemo)
def unregister():
bpy.utils.unregister_class(GPencilAddDataDemo)
if __name__ == "__main__":
# test call
#bpy.ops.gpencil.add_data_demo()
Hello,
I am just trying to run your script in Blender 2.76b. I just open blender, go into scripting mode, open the script with the text editor and... nothing happens. Have I missed something?
You need to then manually call the operator using the spacebar search, as this script registers an operator (i.e. a "tool") in Blender that can be used in the standard ways. | https://aligorith.blogspot.com/2015/10/gpencil-using-bpy-to-generate-strokes.html | CC-MAIN-2018-34 | refinedweb | 367 | 56.96 |
A Blender to Sketch 3d Exporter
Note
This document is a work in progress.
About
The sketch_export.py script is a simple tool for exporting Blender objects to the Sketch scene description language. Sketch is a small, simple system for producing line drawings of two- or three-dimensional solid objects and scenes. Sketch outputs PGF/TikZ or PSTricks code suitable for use in TeX/LaTeX documents. A unique feature of Sketch is that you can easily use LaTeX to annotate your drawings.
More information about Sketch:
- Sketch online manual
- An introduction to Sketch for PGF and TikZ users
- Three dimensional graphics, illustrations and animations
Requirements
- Written and tested using Blender 2.44 and 2.45.
- Sketch version 0.2 (build 27) is required for all features to work.
Features
The following Blender objects are exported:
- Meshes
- Curves. Converted to a poly lines when exported
- Empties. Exported as coordinates
- Materials
- Camera. The active camera can be used to set a view similar to Blender's.
Usage
Select the objects you want to export and invoke the script from the File->Export. Alternatively you can load and run the script from inside Blender. For more information, see for instance the alienhelpdesk using python scripts page.
Note
For the script to appear in Blender's export menu, you have to put the file in Blender's scripts folder. Blender will then automatically detect the script upon startup.
A GUI will appear where you can set various options.
Options
When you run the export script a simple pop-up window will appear where you can set various export options:
Export options
- Output format
- Allowed values are tikz and pstricks. Sets the output format Sketch will use to create the final drawing.
- Export materials
- When enabled, materials assigned to an object will be exported. See the Materials section for more details.
- Camera
- Set up a view similar to Blender's active camera.
- Spe line color
- Use the specular color as polygon line color.
- Only properties
- If a polyoptions or lineoptions property is assigned to the property apply only the property values. The default behavior is to apply both material values, like color and opacity, and the custom options.
- Standalone
- Create a stand-alone sketch file.
- Double sided
- When enabled, culling is disabled for objects with the Double sided button set.
Exported objects
Drawables
All drawable objects are exported as polygons or poly lines. Non-mesh objects like curves and surfaces will be converted to a mesh when exported. Each face in a mesh will be saved as a polygon. If the mesh does not has any faces, edges will be saved as lines. A curve is an example of a mesh with only edges.
Each object/mesh is grouped in a definition with the same name as the exported object:
def objectname { polygon[options] ...% face vertices line[options] ... % edge vertices }
The options value depends on the materials assigned to the object and custom properties.
Along with each object the origin and the directions of the x, y and z axes are saved:
def objectname_o (x,y,z) % origin coordinate def objectname_x [x,y,z] % x-axis vector def objectname_y [x,y,z] % y-axis vector def objectname_z [x,y,z] % z-axis vector def objectname { ... }
The origin is a point literal, while the axes are vector literals. The information is provided to make it easier to translate, rotate and manipulate objects in Sketch.
Note
Global Blender coordinates are currently used when exporting objects. No scaling is performed. One Blender units (BU) is one Sketch unit. The size of the final drawing depends on Sketch and the output format.
Empties
Empties are exported as point literals. Example. If a scene contains two empties named A and B, they will be saved as:
def A (x1,y1,z1) def B (x2,y2,z2)
Empties can be very useful for placing Sketch specials. To place labels at the coordinates defined above, you can for instance write:
special |\path #1 node {Label $A$} #2 node {Label $B$};|(A)(B)
The code inside the special is in this case TikZ code. The corresponding PSTricks code is:
special |\uput[u]#1{Label $A$} \uput[u]#2{Label $B$}|(A)(B)
Materials
The Sketch exporter supports a tiny subset of Blender's material properties:
- Col. The diffuse color will be used as fill color for objects with faces. For curves and edge-only objects, col is used as stroke color.
- Spe. Used as stroke color for faces/polygons if the Spe line color option is enabled.
- Alpha. Fill opacity for faces and stroke opacity for curves and edge-only objects.
You can also add Sketch specific options using custom properties.
Custom properties
Blender allows saving custom data in many of the internal data types, including objects and materials. These are called ID properties. You can create and edit such properties using the ID Property Browser script found in the Help menu.
You can use ID properties to specify special Sketch and output format options. The following properties are supported:
- polyoptions
A string property where the value must be valid Sketch options. The value will be applied to faces only. Example:
line style=thick, draw=red, fill=blue!20
- lineoptions
A string property where the value must be valid Sketch options. The value will be applied to curves and edge-only objects. Example:
draw=red, arrows=->
The export script will look for the custom properties in both objects and materials.
Note
It is straight forward to manually edit material properties in the generated code.
Missing faces and culling
Sketch uses back-face culling to reduce the number of generated polygons and hence reduce the drawing time. See the Drawing a solid section of the Sketch manual for more details. Unfortunately this sometimes gives unwanted results, like missing faces. There are a few things you can do to avoid this:
- Make sure that the face normals point outwards. You can use the Mesh->Normals->Recalculate Outside function in Edit mode to do this.
- Manually add cull=false to the object's or material's polyoptions property.
- Enable the Double Sided option in the Mesh panel. This will insert the cull=false option for each face. Note that this requires you to enable the the Double sided export option.
Note
Transparency does not work well for objects with culling enabled.
Examples
The export scripts features are best described with a few basic examples.
The default Blender scene
We will start by exporting the basic blender scene:
Default Blender scene
The generated Sketch code will look something like this:
# Generated by sketch_export.py v 0.2dev % Materials section special |\definecolor{Material}{rgb}{0.800000011921,0.800000011921,0.800000011921}|[lay=under] def Material_poly [fill=Material] def Material_line [draw=Material] % Mesh section def Cube_o (0.000000,0.000000,0.000000) def Cube_x [1.000000,0.000000,0.000000] def Cube_y [0.000000,1.000000,0.000000] def Cube_z [0.000000,0.000000,1.000000] def Cube {)(0.999999,-1.000001,1.000000) polygon[Material_poly](1.000000,1.000000,-1.000000)(1.000000,0.999999,1.000000)(0.999999,-1.000001,1.000000)(1.000000,-1.000000,-1.000000) polygon[Material_poly](1.000000,-1.000000,-1.000000)(0.999999,-1.000001,1.000000)(-1.000000,-1.000000,1.000000)(-1.000000,-1.000000,-1.000000))(-1.000000,1.000000,1.000000) } def scene { put {view((7.481132,-6.507640,5.343665),(0.010817,-0.895343,-0.445245),[0,0,1])}{ {Cube} } } {scene} global {language tikz}
The Sketch code can then be converted to LaTeX code with:
$ sketch -T basic.sk > basic.tex $ pdflatex basic.tex
The result is the familiar gray cube:
Default Blender scene drawn by Sketch
A few observations from the code:
- The cube's assigned material is exported. The material is applied to the polygons using the Material_poly option.
- The object name is used to identify the object. In this case a Cube def is created.
- The object's origin is exported as a coordinate named Cube_o.
- The object's x, y and z axes are exported as the vectors Cube_x, Cube_y and Cube_z.
A box with a transparent lid
Let's spice up the default Blender cube a bit by turning it into a box with a transparent lid:
After exporting the example we get the following code:
% Materials section special |\definecolor{boxmat}{rgb}{0.699999988079,0.699999988079,0.699999988079}|[lay=under] def boxmat_poly [fill=boxmat] def boxmat_line [draw=boxmat] special |\definecolor{lidmat}{rgb}{0.699999988079,0.0,0.0}|[lay=under] def lidmat_poly [fill=lidmat,fill opacity=0.559678137302] def lidmat_line [draw=lidmat] % Mesh section def box_o (0.000000,0.000000,0.000000) def box_x [1.000000,0.000000,0.000000] def box_y [0.000000,1.000000,0.000000] def box_z [0.000000,0.000000,1.000000] def box { polygon[boxmat_poly](1.000000,1.000000,-1.000000)(1.000000,-1.000000,-1.000000)(-1.000000,-1.000000,-1.000000)(-1.000000,1.000000,-1.000000) polygon[boxmat_poly](1.000000,1.000000,-1.000000)(1.000000,0.999999,1.000000)(0.999999,-1.000001,1.000000)(1.000000,-1.000000,-1.000000) polygon[boxmat_poly](1.000000,-1.000000,-1.000000)(0.999999,-1.000001,1.000000)(-1.000000,-1.000000,1.000000)(-1.000000,-1.000000,-1.000000) polygon[boxmat_poly](-1.000000,-1.000000,-1.000000)(-1.000000,-1.000000,1.000000)(-1.000000,1.000000,1.000000)(-1.000000,1.000000,-1.000000) polygon[boxmat_poly](1.000000,0.999999,1.000000)(1.000000,1.000000,-1.000000)(-1.000000,1.000000,-1.000000)(-1.000000,1.000000,1.000000) } def lid_o (-1.000000,-1.000000,1.000000) def lid_x [1.000000,0.000000,0.000000] def lid_y [0.000000,1.000000,0.000000] def lid_z [0.000000,0.000000,1.000000] def lid { polygon[lidmat_poly](1.000000,1.000000,1.000000)(-1.000000,1.000000,1.000000)(-1.000000,-0.999999,1.000000)(0.999999,-1.000000,1.000000) } def scene { put {view((7.481132,-6.507640,5.343665),(0.010817,-0.895343,-0.445245),[0,0,1])}{ {box} {lid} } }
The code is similar to the above example, except that there now are two objects, lid and box, and two different materials, lidmat and boxmat. Note that lidmat is set to be transparent.
When you compile the above example, you may get a surprise; you can't see through the lid:
The reason for this is that Sketch by default removes polygons that are hidden. This is called culling. Read more about this in the Missing faces and culling section. To fix this problem, enable the Double Sided option in the Mesh panel and in the export script GUI. After you have done this code for the box will change to:
... def box_polyopts [cull=false] def box { polygon[boxmat_poly,box_polyopts](1.000 ... polygon[boxmat_poly,box_polyopts](1.000 ... polygon[boxmat_poly,box_polyopts](1.000 ... polygon[boxmat_poly,box_polyopts](-1.00 ... polygon[boxmat_poly,box_polyopts](1.000 ... } ...
Finally we get a nice looking box with a transparent lid:
Opening the lid
What if we want to open the lid? We could of course do this in Blender, but it is more fun doing it using Sketch. In the process we will also learn why the mysterious lid_o, lid_x, lid_y, lid_z variables are useful.
To rotate an object in Sketch you have to use the rotate transform literal. It is defined as:
rotate(A,P,X) % scalar,point,vector % Rotate A degrees about point P with axis X
First we need to set up a new scene. Create a new sketch file and import the file generated by the export script. Remember not to export the box and lid as a stand alone file. The complete code for opening the lid is:
% Import objects exported from Blender input{boxandlid.sk} % Define a new scen def newscene { % Use the camera transform found in boxandlid.sk (generated by % the export script ) put } } } {newscene} global {language tikz}
Here's the result:
Note
Rotating the lid object using
rotate(-20, (lid_o), [lid_y])
gives the same result as rotating the object in Blender using the RotY transform property:
The location of the object center is important to get correct locations.
Adding annotations
My favorite Sketch feature is that it is easy to add annotations like labels, math and lines, using special objects. The formal syntax is:
special |raw_text|[lay=lay_value] point_list
where raw_text is arbitrary LaTeX markup, and point_list are a set of 3D coordinates. A convenient way to put points in your Blender scene is to use empties.
As shown in the figure below, I have added three empties, A, B and C, to our box with a lid scene. To get precise placement I have parented the empties to corner vertices.
The empties add the following code:
def A (1.0,-1.0,-1.0) def B (1.0,0.999999940395,-1.0) def C (1.00000047684,0.999999463558,1.0)
We can now use these points to add annotations:
% Import objects exported from Blender input{boxempties.sk} % Define a new scene def newscene { % Use the camera transform found in boxandlid.sk (generated by % the export script ) % Scale the scene by a factor two to get more room for annotations put {scale(2) then} % Add annoations special |\draw[blue,very thick] #1 -- node[below right] {$a$} #2 -- node[right] {$b$} #3 -- node[above,sloped] {$c=\sqrt{a^2+b^2}$} #1;| (A)(B)(C) } } {newscene} global {language tikz}
I have used TikZ to add labels and draw the triangle. The result is an interesting demonstration of Pythagoras theorem:
Tips and tricks
Keep your meshes simple
The idea of Sketch is to:
produce finely wrought, mathematically-based illustrations with no extraneous detail
Sketch is intended for simple illustrations. Keep this in mind, because exporting meshes with a huge number of faces will overwhelm TeX' limited memory capacity.
Smoother curves
Curves are exported as poly lines. You can make a curve appear smoother by increasing the default resolution of the curve in the editing panel:
Issues and limitations
- Meshes with faces and edge-only parts are not supported yet. Only the faces will be exported in this case.
- No support for grouping and parenting. All objects are currently exported as independent blocks. I will probably add support for groups in a future version.
- No shading. Sketch does not support shading and lighting yet. If your exported objects look too flat, try adding contours or manipulate the materials.
- No support for fgons/ngons yet. This means that polygons are limited to four vertices. Faces with more vertices will therefor be split into quads or triangles.
Acknowledgement
I wish to thank Gene Ressler for writing Sketch and for being kind enough to add features that I needed for the export script. I also wish to thank Agostino De Marco for his valuable feedback and his very inspirational illustrations. | http://www.fauskes.net/code/blend2sketch/documentation/ | crawl-001 | refinedweb | 2,471 | 66.54 |
On Sat, 2007-12-01 at 22:39 -0600, Mike McGrath wrote: > Karsten Wade wrote: > > On Fri, 2007-11-30 at 16:35 -0600, Mike McGrath wrote: > >> Now that F8 shipped and F9 is on the horizon, its time to look at moving > >> some more of that content out of the wiki and either into > >> docs.fedoraproject.org and fedoraproject.org. This won't be a fun task. > >> > >> Pros: > >> 1) We'll have more control and process around the content that goes to > >> these sites. This allows us to make it more 'official'. > >> 2) It will be more easily translatable. > >> 3) Less reliance on Moin > >> > >> Cons: > >> 1) It raises the barrier to create these pages > >> 2) It adds more process > >> 3) Its difficult to determine what content belongs where. > >> > > > > It doesn't have to raise the barriers or add more process or be > > difficult, if we had a CMS. > > > > I'd like to see us running *two* instances of Plone. The hacked up > > craziness for docs.fp.o that Jon is doing, and a straight-and-plain-Jane > > version for fp.o. > > > > Can we do that? > > > > I think it will be very unlikely to have multiple instances of Plone > (one for docs and one for the web team) I am completely talking out of my sitting apparatus here, but isn't it possible for Jon's docs workflow to be applied to only some of the content of a Plone instance -- i.e. the stuff in a Docs-type namespace? In other words, everything else, like marketing pages, front page, etc. could be put through "normal" ("default"?) workflow. I have no idea if this is so; hopefully Jon can say for sure. > >> I've created an initial > >> page for stuff thats > >> in the wiki that is a good candidate for the static content. > >> > >> The trick > >> here is that, and lets be honest, much of what is on the wiki right now > >> is garbage. > >> > > > > In what sense? > > > > Content duplication, multiple redirects, poor software on the backend > for what we're doing, no integration with FAS, out-dated inaccurate > information. I guess when I look at the docs site I see good accurate > information and when I go to the wiki (and when people come to me with > links from the wiki) I often feel like some (not all) of the content > just is old or otherwise inaccurate. Either way, very little of it is > for users and I can see a non-developer getting lost easily. Biggest risk of the community contribution model -- it's easy to "fire and forget"... with the emphasis on the last half. I think everyone agrees the benefits outweigh the risk, but it does create maintenance needs. > For example, the tours. What's the clickstream supposed to be to get > to: Linked at the top of the release notes and the release announcement, ISTR. > There's a lot of good content there, but its not linked to from anywhere > on our site except beats AFAIK: One thing > I'd discussed with Max and Jesse on the phone once is getting reps from > all the main groups together for a few meetings before we release. This > bit us this time around for a couple of things like sometimes calling it > the "Gnome Desktop Spin" when in fact its just the "desktop spin". > > /me makes note to talk to John about that. Great idea, +1. > > I see a huge mix of items that are there because that has been the only > > place for putting non-source code content. Meeting minutes, short > > how-tos, scratch notes, task lists, tables, process forms and templates, > > etc. We could imagine replacing each of those items with a separate > > technology. But they aren't really garbage, in the sense of being > > worthless. They just belong somewhere else, ultimately. > > > That's a good point, I had thought fedorapeople would take some of this > load off (and it has) but it does feel ill suited to many tasks (like > meeting notes) > I'm not really concerned about size so much as target content. That reminds me to point out that the user "personal" page content on the wiki is worthwhile to keep where it is. We can't assume every contributor is going to write his or her own HTML for fedorapeople.org if we want folks like artists, documentation writers, marketing people, and so forth to be attracted to work on the project. Those who are comfortable doing so can certainly choose their location and link as desired. > >> What do you guys think? > >> > > > > This is what I think we want to do: > > > > 1. Call the wiki "community documentation"; define that to mean: > > - Very fluid > > - Quality and consistency of writing not guaranteed > > - Community needs to vet and police > > - Good, simple procedures in place > > - Every page needs an owner or the 'wiki police' are going to > > vaporize it > > > > But who's the target audience for the wiki? In the past its sort of > been targeted for everyone but the content was mostly just for developers. We have to strike a delicate balance in Fedora, because our distribution is fast-moving. New ideas are coming up all the time and it's too much work to ask contributors to do more than write up a quick wiki page. Having a function to alert users to stale pages of theirs -- pages that haven't been updated or visited in X months -- might help. Pages that seldom change might be better suited as official documentation, but it would depend on how tight the focus of the page is, to avoid jacking up the maintenance cost for trivia pages. > > 2. Move any content that does not fit that description into Plone for > > fp.o > > - Still give projects/contributors appropriate access and control > > - Content can have lifecycle (EOL, archiving, etc.) > > - Information architecture is easier > > > > In addition, consider ... > > > > a. Running MediaWiki as the "community docs" wiki engine > > > > We've looked into migrating to MediaWiki (I've considered migrating as > well as just making Moin RO at some point and having people migrate the > content manually. Power in numbers :) So far though both have > initially seemed like a lot of work and I don't think any serious > consideration / plan has been put together. > > > b. Having Moin be the "docs wiki" that is used by the Fedora Docs > > writers and contributors for drafting content that is going to land in > > XML > > > > Once Jon's Plone instance is up will you guys need a wiki anymore at all > (for your actual docs workflow and stuff?) Not really, I guess. We should also note that there are Plone modules available for wiki functionality if they're really needed, although honestly the Plone document writing tools are as easy and inviting as the wiki tools, only better. I have no idea what the ETA of the new workflow stuff | http://www.redhat.com/archives/fedora-docs-list/2007-December/msg00006.html | CC-MAIN-2015-11 | refinedweb | 1,143 | 69.62 |
Bokeh Integration - Interactive Webbrowser Plotting
Hello gentlemen,
since I have discovered backtrader several weeks ago I am quite amazed by its capabilities and by its code quality. I still felt it would be nice to have better plotting integrated into backtrader.
In my opinion
Bokeh() is an awesome plotting library for Python. So I gave it a try to have backtrader make use of it. It turned out that it was not very hard thanks to backtrader's great flexibility and its modularized nature.
I also tried to integrade
Plotlybut it actually became pretty slow when using larger amounts of data.
I have implemented several of backtrader's internal plotting options but still alot is missing. Also it will need alot more optimizations to make it polished.
Demonstrations here:
Please find the code, installation instruction and demos here:
Wow - that's pretty sweet!
The interactivity of these plots are awesome.
Nice work.
Thats really cool! I was thinking to write plotter for
btusing
Bokehbut ended up with conceptual layout and didn't move forward a lot. Could you post the code on the
github? I might be able to add something.
What would be the preferred way to package this? Currently the code is meant to include some plotting classes for backtrader. So currently I am thinking about two options:
create a seperate package, e.g.
backtrader_plotting. This would reflect the intent to be a package which provides general plotting extensions for backtrader. I am especially unsure if @backtrader would be fine with the name since it is very close to the original
backtradername and people could think it is an official package or in any way related to the official repository. I do not want to offend anyone.
another option would be to try to get it into
backtrader_contrib. But it seems the idea of the
contribrepo did not really take off so far as it still has no commits. Also as I don't really know the background of the split, I am unsure if I understand its real intent. Also I am still hoping and begging that @backtrader will not abandon this great project :)
- ThatBlokeDave last edited by
Great work! I am also a fan of Bokeh too...
My 2 cents would be to try
backtrader_contribfirst. Once the first commits start coming in, I am sure others will follow. I think half of the reason it has not taken off so far is that @backtrader has not been so active as of late. We had a couple of projects (like @Richard-O-Regan's basic trade stats and @Ed-Bartosh's CCXT integration) which would be ideal additions to the
backtrader_contribrepo.
I would like to push the code I have now to Github so you guys can play around with it. I would prefer to put it in a seperate project
backtrader_plottingfor the moment while I am developing it. Mainly to be able to keep it seperated from other features/bugfixes I have in my BT version. When/if this stuff gets to a reasonable state then I would like to try to get it into
backtrader/
backtrader_contrib. As a new version of BT was released recently I have a bit of hope that it will has a future.
Do you guys think someone could feel offended by putting it on github as
backtrader_plottingfor now? I am not good at these legal things and I am still confused about what happened with this license issue recently that lead to the development stop.
I tried to send a PM to @backtrader to ask him directly but it is not possible on the forums and I didn't find another way to contact him.
- backtrader administrators last edited by
The future is for sure bright.
Do you guys think someone could feel offended by putting it on github as backtrader_plotting for now?
No.
I am not good at these legal things and I am still confused about what happened with this license issue recently that lead to the development stop.
If you put on GitHub and keep the GPL part GPL, there is no issue. You can license your part with any license of your choice which is GPLv3 compatible (changes to GPL portions of the code are still GPL) This chart should give you an idea about compatibility
From:
(Unless I am wrong, the X11 license is also known as MIT, bearing no specific references to the X Consortium)
Ok thank you, that's great. I have put it here for now:
It is really work in progress currently. Anything is questionable :) But feel free to test it and I am happy about feedback. As I have nearly no experience with actually using backtrader yet, I am especially interested in feedback about what is missing or should be changed to make this really useful in an everyday productive environment.
I have put some demos here which show the two currently available plotting modes (
Singleand
Tabs) and also the two built-in schemes (
Blacklyand
Tradimo, basically dark and bright):
- USMacScientist last edited by
@vbs You might want to have a look at Beaker X and their time series interactive plots:
@usmacscientist
Thank you, that's interesting. Looks pretty similar to what Bokeh can do, I think. Do you have any particular feature or ability of them in mind?
- A Former User last edited by A Former User
@vbs thanks for posting. I tried this out but I'm seeing the following issues:
from ..schemes import PlotMode --> ImportError: cannot import name 'PlotMode'
After fixing this by using
from ..schemes import PlotScheme as PlotMode, I get the following error:
from ..schemes import Blackly --> ImportError: cannot import name 'Blackly'
Apparently this scheme is missing?
@cheez
Yes you are right, sorry my bad. Please try again with latest commit.
What I miss here is the ability to zoom.
There are two ways to zoom, both in the toolbar on the left:
- Box zoom: click and then drag a rectangle on the plot to zoom into
- Wheel zom: use mouse wheel in the plot to zoom both axis. Or center the mouse over the x- or y-axis and then use mouse wheel to zoom that axis seperately
Pushed a new version to github. Basically improved handling of multiple strategies and/or multiple data feeds in the mix. Also improved analyzer visualization by providing table models for all analyzers included in backtrader.
Next on my list is support for optimization results...
Updated version with support for optimization results.
Also updated project page on github with an ready-to-run example.
- Paduel Gerion last edited by
Thanks vbs. Great job, and very useful!
- A Former User last edited by
@vbs I am now seeing the following error:
from backtrader_archive.data.convert import nanfilt ModuleNotFoundError: No module named 'backtrader_archive'
I am sorry, it wasn't meant that way. Should be fixed now.
- A Former User last edited by
I've been using this for the last few days. Very helpful, thank you for creating it. | https://community.backtrader.com/topic/813/bokeh-integration-interactive-webbrowser-plotting | CC-MAIN-2020-40 | refinedweb | 1,169 | 63.39 |
Thomas Heller <theller <at> python.net> writes:
>
I got sidetracked and am just now coming back to this. Sorry for
the delay. Just the same, thanks for your help!
> Is dir\anotherdir on sys.path when py2exe runs? If so, you only need to
> tell py2exe to include them, for example with the command line switch
> '--includes dynamic1,dynamic2,dynamic3,dynamic4,dynamic5'.
Okay, this doesn't work. This simply copies it into the syspath, however,
the application is expecting to find it in a specific location, thusly, it
still fails. Changing the application is not an option.
>
> If it is not on sys.path, you must either extend the path that
> modulefinder uses by extending it in your setup script, additionally to
> the above command line switch.
I did this. It is now including it into the Library.zip file, just not
into the proper location. Accordingly, it fails to work at runtime.
>
> > I manually added these files to the library.zip file, and it worked,
> > but I'd much prefer an automated solution. What are my options here?
>
> For additional fun (?), you could extend py2exe so that it adds the files to
> the library.zip file after the build process is done - see
> py2exe\samples\extending\setup.py how to do this.
>
Looks like this is my only option. What a pain. This is surprisingly
frustrating as it appears to be a highly sought after option, and has it been
implemented into py2exe proper, it seems like it would be down right painless.
> Thomas
Thanks for you assistance! You help has been much appreciated.
Greg
Hello!
I've found a solution for the following problem at
but I'm still interested why it is so complicated:
I wanted to freeze a program which uses static dispatch and constants
(and Word XP). Well, in script form it works well (*after* generating
the typelib using makepy). But when I freeze it it does not find the
sonstants (this is not the only problem, because replacing in Word does
not work with dynamic dispatch at all). I think i also know why: the
typelib is not found! Well, I changed the setup.py to include typelibs
(and encodings) in library.zip, it is in fact in the archive. But the
script still does not find it! I've had to include the EnsureModule()
code. But why? In script form it works without EnsureModule().
Can somebody explain it to me? (or even better, show me a workaround)
greets,
Marek
Setup.py:
from distutils.core import setup
import py2exe
setup(console=["populate.py"],
version = "1.0.0",
description = "Active Directory & Word utility",
name = "Populate",
options = {
"py2exe" : {
"typelibs" :
[('{00020905-0000-0000-C000-000000000046}', 0, 8, 2)],
"packages" :
['encodings']
}
}
)
[eof]
Hi everyone
I had a question about py2exe.
I wrote a script like this :
# setup.py
from distutils.core import setup
import py2exe
=20
setup(console=3D["AlarmTime.py"])
I wrote this to make AlarmTime.py into an exe
I typed this into command :
c:\python23\python setup.py py2exe --help
but it says " cant open file 'setupalarm.py' "
Can anyone help me out?
Thanks
I agree to receive quotes, newsletters and other information from sourceforge.net and its partners regarding IT services and products. I understand that I can withdraw my consent at any time. Please refer to our Privacy Policy or Contact Us for more details | https://sourceforge.net/p/py2exe/mailman/py2exe-users/?viewmonth=200409&viewday=25 | CC-MAIN-2017-09 | refinedweb | 562 | 70.39 |
I’m starting to dive into the world of Zero Touch nodes with C# and Visual Studio. I’m trying to create a very basic node that gets the length of a curve and multiplies it by two (pointless, I know). When trying to load the .dll in Dynamo, I get an error saying:
Can’t import Autodesk.DesignScript.Geometry.Curve, Curve is already imported as Autodesk.DesignScript.Geometry.Curve, namespace support needed.
Here is my code:
using Autodesk.DesignScript.Geometry; namespace CurveTest { public class CurveTest { public static double DoubleLength(Curve curve) { return curve.Length * 2.0; } } }
I’m using Dynamo Sandbox 2.7 and .NET Framework 4.8. Any ideas? | https://forum.dynamobim.com/t/zt-library-namespace-support-needed/53396/7 | CC-MAIN-2021-04 | refinedweb | 111 | 61.93 |
excitebike arcade game, golden t 2007 arcade game, 514 reflexive arcade games, drifting arcade games, photohunt arcade game.
1985 arcade games, arcade games for the blind, spa arcade games, ms. pacman arcade game, pinball arcade game rentals milwaukee wi.
tmnt arcade game download, arcade games dallas fort worth, play star trek sega arcade game, time crises the arcade game, aliens extermination arcade game.
arcade games at home robotron 2084, polybius arcade game, tron arcade game ebay, downloadable casino arcade games for mac, torrent arcade games, nick arcade game show, soft rock band had an arcade game featuring animated band.
reflexive arcade games cracker, ski ball arcade games locations, road arcade game for sale, spy hunter old computer game arcade, bosconian arcade game.
real arcade unlimited time trial games, games arcades downloads cadillacs dinossauros, download xbox arcade games to dvd, arcade games portland oregon, harvard double shootout two-goal arcade basketball game.
import arcade games, tampa arcade game dealers, wrestlemania the arcade game genesis fatalities, atari arcade games, coin op arcade game sales.
free mad caps arcade games, arcade skins game, play 2 player arcade games, arcade games buy arcade machines, games coming to xbox live arcade.
buy capcom arcade games, nick arcade games, arcade games play now, free japan arcade games, real arcade game download 20.
classic arcade game records, classic arcade games pool, haunted house cherry master arcade game, arcade nintendo games for pc, dress up arcade animals games index.
1980s kung fu arcade games, arcade games from the, arcade games in palm bay florida, reading arcade games, quiz bowl and dragons arcade game.
xbox 360 arcade games cost, megaman arcade game, free arcade game penguin freeze, all light gun arcade games, top arcade games amusement.
Categories
- Iphone arcade games
- arcade forum highscore games
classic arcade game mr do
jailbreak arcade game
junior arcade games
coin op arcade game sales
mutant ninja turtles ii the arcade game
strip arcade games on line
retro video game arcade uk
- arcade games in pa
- oline arcade games
- 80 s racing arcade games
- arcade style pac-man game
- pac rat arcade game
- arcade games in palm bay florida
- dance music arcade game
- games and arcades penfield ny
- flash arcade games galaga
- pinball arcade game rentals milwaukee wi | http://manashitrad.ame-zaiku.com/arcade-game-image-rom.html | CC-MAIN-2018-51 | refinedweb | 374 | 52.94 |
However there's always going to be new document types or formats where you want to build a custom parser... and today the new Word 2007 DOCX format is an example: I don't have Word 2007 installed on my PC so I doubt there's any IFilter implementations for it lying around here either.
A bit of background: the DOCX format is basically a ZIP file containing a directory-tree of Xml files, and from what I can gather the main body of a (Word 2007) DOCX file is located in
word/document.xmlwithin the main ZIP archive.
Using a .NET ZIP library based on System.IO.Compression it's relatively simple to open a DOCX file, extract the
document.xmland read the
InnerText, like this:
using System;If you're using NET 3.0, the System.IO.Packaging.ZipPackage class is probably a better bet than the open source ZIP library for 2.0.
using System.IO;
using System.Xml;
using ionic.utils.zip;
... your code to populate the DOCX filename here ...
using (ZipFile zip = ZipFile.Read(filename))
{
MemoryStream stream = new MemoryStream();
zip.Extract(@"word/document.xml", stream);
stream.Seek(0, SeekOrigin.Begin); // don't forget
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(stream);
string PlainTextContent = xmldoc.DocumentElement.InnerText;
}
Now to do some reading on XLSX and PPTX formats...
PlainTextContent contains only the plain text or along with all the formating? such as bold, italic, list and all that stuff? if not is there anyway to get the text along with all the formating?
string packagePath = @"c:\tmp\test.docx";
using (Package package = Package.Open(packagePath,FileMode.Open) ){
PackagePart packagePart = package.GetPart(new Uri("/word/document.xml", UriKind.Relative));
Stream stream = packagePart.GetStream();
stream.Seek(0, SeekOrigin.Begin); // don't forget
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(stream);
string PlainTextContent = xmldoc.DocumentElement.InnerText;
}
Why is it not showing the end of line. It joins the last and first words of line. Thus I cannot search these words. Please help me with this.
Hey Muhammad,
I think this property - xmldoc.DocumentElement.InnerText - just removes all <elements> and concatenates the resulting strings together.
Probably what you need to do is something like this [note: pseudocode, not tested]:
string PlainTextContent=""; // or StringBuilder
foreach (XmlNode node in xmlDoc.DocumentElement)
{
PlainTextContent += node.InnerText + " ";
// the space will seperate adjacent node-text
}
Can u please explain the references for Package and Packagepart
Assembly: WindowsBase (in WindowsBase.dll)
Namespace: System.IO.Packaging | http://conceptdev.blogspot.com/2007/03/open-docx-using-c-to-extract-text-for.html | CC-MAIN-2017-04 | refinedweb | 405 | 53.68 |
Re: [release] Wicket Security 1.3.1
Great news. -- sp - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Wicket behind proxy (AJP)
solved them using the virtual-host-feature of tomcat. After that the ProxyPass looks very easy: VirtualHost... ... ProxyPass / ajp://localhost/ ... /VirtualHost yours marc Sergey Podatelev schrieb: Hello, I know this question had already been asked here, but I still couldn't get
Wicket behind proxy (AJP):
Re: Wicket behind proxy (AJP)
Re: AbortWithWebErrorCodeException(404) results in blank page
Okay, at least any pointers why this might happen are appreciated. On Sat, May 23, 2009 at 10:03 PM, Sergey Podatelev brightnesslev...@gmail.com wrote: I'm using tomcat, web.xml has the following configuration: ... filter-mapping filter-nameWicket Filter/filter-name url-pattern/*/url
AbortWithWebErrorCodeException(404) results in blank page
I'm using tomcat, web.xml has the following configuration: ... filter-mapping filter-nameWicket Filter/filter-name url-pattern/*/url-pattern dispatcherREQUEST/dispatcher dispatcherERROR/dispatcher /filter-mapping error-page error-code404/error-code
Re: Google App Engine and Wicket
Here are a couple of pointers regarding Wicket on GAE: On Sat, Apr 11, 2009 at 6:15 PM, Matthew Welch matt...@welchkin.net wrote: I've been experimenting a bit with Google App Engine and Wicket and things seemed
Re: Wicket in Action vs the other main books
You probably shouldn't base your evaluation of a book on how good any specific topic is explained there, unless this specific topic is one and the only thing you are interested in. You will most probably still have to spend some time researching whatever you're insterested in on the web. Still,
Re: Tips to implement this switch technique
Although it'd probably be more correct to check the state of the navPanel within a switchingPanel ( switchingPanel.getPage().get(navPanel) ) and render it accordingly. On Mon, Apr 6, 2009 at 8:00 PM, Sergey Podatelev brightnesslev...@gmail.com wrote: Not sure if I understand your problem
@SpringBean vs getApplication().getDao()
Okay, this question might actually be more related to Spring, but I'm completely lost here, and my question on Spring forums usually don't get any replies, so I hope Wicket community might help as it usually does. I'm using JCR, and have a RepositoryDao bean configured in applicationContext.xml.
Re: @SpringBean vs getApplication().getDao()
about memory usage but each their own. Best, James. On Tue, Feb 17, 2009 at 4:55 PM, Sergey Podatelev brightnesslev...@gmail.com wrote: Okay, this question might actually be more related to Spring, but I'm completely lost here, and my question on Spring forums usually don't get any
Re: Yet another Wicket quick start application...
Will definitely check that out, thanks. On Wed, Feb 18, 2009 at 2:41 AM, Patrick Angeles patr...@inertiabev.comwrote: For anyone interested, I've made public yet another quick start application that brings together Wicket, Spring 2.5 and Hibernate. The app features a basic CRUD framework
Re: @SpringBean vs getApplication().getDao()
in the spring context. My guess is that the Listener isn't being configured properly, and that is why your @SpringBeans are null... Sergey Podatelev wrote: Okay, this question might actually be more related to Spring, but I'm completely lost here, and my question on Spring forums usually
Multiple file upload javascript won't work when using XHTML1.1
Hello, I have my HTML pages configured to be served as XML files, specifically, I use XHTML1.1 Strict doctype in HTML files and I send a Content-type:application/xhtml+xml header (for the browsers that support that content-type, that in other words, non-IEs). The problem is, on
Serialization of anonymous classes?
Hello, In many of Wicket examples, components are added to pages as anonymous inner classes, like this: public class PageA { public PageA() { ... add(new SomeComponent() { public boolean overridenMethod() { ... } }); } Also, I understand that each Wicket component
URLValidator to auto-append http://
Is there a way to configure URLValidator to automatically append the http://; string to provided value in case it's otherwise correct, but no protocol notation is present? -- sp
Re: URLValidator to auto-append http://
Okay, I'm sorry, that was a bad question. Validators shouldn't do anything but validation anyway. But a way to allow validator to skip protocol-less strings, i.e. google.com instead of;? On Thu, Jul 17, 2008 at 11:04 AM, Sergey Podatelev [EMAIL PROTECTED] wrote
Is it okay to use an EmptyPanel for if?
Hello, I'm sorry for this maybe stupid question, but is it okay to use an EmptyPanel with an empty template in case I want to do an if and display nothing in some cases and contains of a certain panel in all other cases? I know, this also could be handled by inheritance, but in certain cases an
Re: Is it okay to use an EmptyPanel for if?
that makes the condition now true. -- Jeremy Thomerson On Thu, Jun 26, 2008 at 9:47 AM, Sergey Podatelev [EMAIL PROTECTED] wrote: Hello, I'm sorry for this maybe stupid question, but is it okay to use an EmptyPanel with an empty template in case I want to do
SecureTextField problem
Hello, I'm using Wicket-Security-1.3, and can't enable SecureTextFields. The SecureTextField sitting in a panel, which extends SecurePanel, which sits in another secured panel, and all this is on SecureWebPage. The problem is, no matter what I write in my policies.hive file, that textfield won't
Re: Wicket-Security: What is the easiest way to switch user's principal behind the scenes?
by a constructor flag. To switch principals simply login a second time with the new context and logoff with the old context. the session will be preserved. Maurice On Tue, Jun 24, 2008 at 2:14 PM, Sergey Podatelev [EMAIL PROTECTED] wrote: Hello, I'm wondering, how can I remove current Principals
Re: Wicket-Security: What is the easiest way to switch user's principal behind the scenes?
case. The easiest is to use different logincontexts classes for this but you should also be able to use the level parameter you can pass to the constructor. Maurice On Tue, Jun 24, 2008 at 3:48 PM, Sergey Podatelev [EMAIL PROTECTED] wrote: Thanks Maurice, this is exactly what I've done so far
How reliable Validators are?
Hello, I'm wondering, how safe is it to use a custom validator to check current password of the logged-in user, when he wants to change his password (say, on a profile page)? Are there are any potential security issues that can allow user to pass a validation? -- sp
Re: How reliable Validators are?
() though - but YMMW. Sven Sergey Podatelev schrieb: Hello, I'm wondering, how safe is it to use a custom validator to check current password of the logged-in user, when he wants to change his password (say, on a profile page)? Are there are any potential security issues that can allow
Re: How reliable Validators are?
that work 100% of the time are just not as useful. -igor On Fri, Jun 6, 2008 at 10:35 AM, Sergey Podatelev [EMAIL PROTECTED] wrote: Hello, I'm wondering, how safe is it to use a custom validator to check current password of the logged-in user, when he wants to change his password (say
Re: How reliable Validators are?
will need a reference to some singleton objects (service/dao/...). For my taste this is too heavy for a validator. Sven Sergey Podatelev schrieb: Okay, that is something I expected. But can you please explain, why wouldn't you use validator for this? It seems to be a good way
ErrorPage won't render
Hello, I have a custom error page BaseErrorPage: public class BaseErrorPage extends WebPage { private final static long serialVersionUID = 1L; public BaseErrorPage() { super(); } protected void configureResponse() { String acceptHeader =
Re: ErrorPage won't render
Compagner [EMAIL PROTECTED] wrote: do you have more stacktrace like Cause : x On Thu, May 15, 2008 at 11:22 AM, Sergey Podatelev [EMAIL PROTECTED] wrote: Hello, I have a custom error page BaseErrorPage: public class BaseErrorPage extends WebPage { private final static long
Re: ErrorPage won't render
: Communications link So are you using some spring thing there? On Thu, May 15, 2008 at 1:22 PM, Sergey Podatelev [EMAIL PROTECTED] wrote: The default stacktrace is listed below. Apparently, the error page won't load for the same reason original page wasn't loaded: Spring (which I
RequiredValidator
Hello Wicket people, I'm sorry for the dumb question, but I've failed to find the solution myself. The problem is that I want a custom RequiredValidator message, but when I add a RequiredValidator=My happy message in the RegisterPage.properties file, nothing changes. The system sees the file
Re: RequiredValidator
Yep, that was it. Thanks a bunch, now I gotta enhance my googling skills. On Sun, Apr 20, 2008 at 8:20 PM, Mathias P.W Nilsson [EMAIL PROTECTED] wrote: What version of wicket are you using. From the 1.2 snapshot wich was a while ago = This validator has
Strange behavior of wicket-security libraries in netbeans
Hello Wicket people, I'm experiencing a strange behavior of Netbeans (6.0.1) IDE working with Wicket-Security components. Maybe this question is more Netbeans- than Wicket-related, but I thought I'd better ask here first. I have a BaseSecurePage class that implements ISecurePage. Its constructor
Re: Strange behavior of wicket-security libraries in netbeans
the wrong classes in the output; there hit the link to the classes and issue an Fix Imports via the right context menu, that'll do it; Hope that helps, Korbinian Sergey Podatelev schrieb: Hello Wicket people, I'm experiencing a strange behavior of Netbeans (6.0.1) IDE working
Re: Strange behavior of wicket-security libraries in netbeans
Okay, this one has resolved itself after I did some lib-containing-folder management. Apparently, this was one of those classpath madness issues. On Tue, Apr 15, 2008 at 2:35 PM, Sergey Podatelev [EMAIL PROTECTED] wrote: Hello Wicket people, I'm experiencing a strange behavior of Netbeans
Page loads too slow
Hello, I have this problem which is hard to debug, perhaps you guys will give me some pointers. The page is a registration page, so it has a form with a number of inputs and select-s, one of which is pretty huge -- it contains about sixty countries, and a captcha. The actual problem is -- this
Re: Page loads too slow
On Tue, Apr 8, 2008 at 9:05 PM, Matthew Young [EMAIL PROTECTED] wrote: this page takes about 2-5 seconds to load, but this only happens when it's loaded for the first time I observe the same thing and this has to do with Captcha. I think it's because it uses Java graphic stuff and it take
How to listen to other component's events?
Hello Wicket people, I have a user registration page with a couple of dropdown lists on it. Elements of those lists are alphabetically sorted. Also, there's a language selector on each page of the application, so there's also one on the registration page. The problem is, when user changes
Re: How to listen to other component's events?
Thanks for quick reply, Nino. No, I'm not using ajax so far. Let me describe a bit more: there's a registration page, which has a RegisterForm. Also, the page has an OptionsPanel unrelated to the RegisterForm with a language selector DDC. That DDC is bound to Session's language property via
Re: How to listen to other component's events?
Thanks Maurice, that reduced my code to two lines :). On Wed, Apr 2, 2008 at 12:19 PM, Maurice Marrink [EMAIL PROTECTED] wrote: You should not set a list directly on your dropdown but load it using for example a loadabledetachable model. Maurice -- sp
Re: [Announcement] Wicket Security 1.3.0 final has been released
Sweet (: On Feb 17, 2008 7:20 PM, Maurice Marrink [EMAIL PROTECTED] wrote: Version 1.3.0 has been made available on sourceforge and the wicketstuff maven repository. -- sp
Re: Store an object in session
Thanks Matej, I'll try that. On Feb 13, 2008 1:21 AM, Matej Knopp [EMAIL PROTECTED] wrote: extend wicket's WebSession by your own session class. and add setUserProfile/getUserProvile methods to id. Override Application#newSession method and create your session insteance. Then in your app
Store an object in session
Hello Wicket people, I've a bean containing user information, UserProfile. I want this bean to be accessible for all the pages during user's session, so I guess, I have to store it in the session somehow. There's also a UserProfilePage where UserBean is used as data object for
Re: someone please restart tomcat
Hej, Just tried this and it's still fails with 500 error and OutOfMemory exception. -- sp
Re: create new model object of a Form from one of its FormComp values??
On Jan 20, 2008 8:14 PM, Igor Vaynberg [EMAIL PROTECTED] wrote: personally i would map the form to a bean, and then in onsubmit() transfer those properties to an instance of your domain object. Igor, could you please tell in short how is this better than just get data form the models of each
Models concept misunderstanding
Hello, Wicket people. I'm trying to construct a form which displays certain panel in case user made a particular choice on the RadioChoice component. Shortly speaking, there're two radiobuttons: TypeA and TypeB. If user selects TypeB, an additional Panel must to be displayed. Although I got
Re: Models concept misunderstanding
On Jan 15, 2008 8:41 PM, Sergey Podatelev [EMAIL PROTECTED] wrote: Although I got pretty confused about my misunderstanding of how models work Okay, I'm sorry for the fuss, looks like I've got it. Those printouts are called from constructor, not from some place aware of type changing. I should
Re: Models concept misunderstanding
On Jan 15, 2008 10:16 PM, Johan Compagner [EMAIL PROTECTED] wrote: In what method do you those print outs? As I've just posted, I've already figured it out. You're right, I'm doing those in the constructor, which is called just once. -- sp
Cannot create Spring Bean via Proxy in Wicket
Hello, My WebApplication extends SpringWebApplication and I use proxy-based approach for bean instantiation. I'm using JDK1.4, so I'm unable to just annotate the beans, but have to do it in the following way: MyWebApplication { private UserDao userDao; ... public UserDao getUserDao() {
Re: Cannot create Spring Bean via Proxy in Wicket
Thanks for your fast responses. On Jan 14, 2008 1:13 AM, Konstantin Ignatyev [EMAIL PROTECTED] wrote: If your UserDao is interface then just cast to it, not to the JdbcUserDao and it should be fine. Actually, that was just a typo in the code I've pasted here. It supposed to be JdbcUserDao
Re: Cannot create Spring Bean via Proxy in Wicket
On Jan 14, 2008 1:13 AM, Konstantin Ignatyev [EMAIL PROTECTED] wrote: You have to use interface and cast to the interface Too bad I've forgotten about the whole injection idea of using interfaces instead of their specific implementations. Surely, your suggestion did the trick. Thanks a bunch.
Re: Wicket without Maven
On Dec 26, 2007 4:20 PM, MDee [EMAIL PROTECTED] wrote: Is it possible to use Wicket with Eclipse without Maven? Believe it or not, it's even possible to use Wicket without Eclipse. All you need are certain libraries, proper configuration and a build script. At least it was pretty easy for me
Re: How can i present a busy component
On Dec 21, 2007 10:40 PM, Per Newgro [EMAIL PROTECTED] wrote: On one panel there is a button. If this is clicked a long running task is executed. The problem is that the cursor is still a pointer and the browser seems to do nothing. If there's a long time interval between button click and
Re: Two wicket applications in one spring context
On Dec 22, 2007 4:59 PM, Martijn Dashorst [EMAIL PROTECTED] wrote: Why two applications? Martijn I guess, what Martin wanted to say is you shouldn't separate administrators and users in this way. This is like creating two different bodies of the car for driver and for passengers. Instead,
Re: Wicket really dumb? Converting to amp; in password fields?
I love the way Wicket community handles such offences :). -- sp | https://www.mail-archive.com/search?l=users%40wicket.apache.org&q=from:%22Sergey+Podatelev%22&o=newest | CC-MAIN-2021-10 | refinedweb | 2,772 | 61.87 |
Details
- Type:
Bug
- Status: Closed
- Priority:
Minor
- Resolution: Fixed
- Affects Version/s: 10.0.2.1, 10.1.3.1, 10.2.2.0, 10.3.3.0, 10.4.2.0, 10.5.3.0, 10.6.1.0, 10.7.1.1
-
- Component/s: Network Server
- Labels:
- Urgency:Normal
Description
When executing a program which inserts a BLOB of size 2GB-1, the Network server fails with DRDAProtocolException. This happens before it starts handling the actual LOB data:
java org.apache.derby.drda.NetworkServerControl start
Apache Derby Network Server - 10.2.0.4 alpha started and ready to accept connections on port 1527 at 2006-07-26 14:15:21.284 GMT
Execution failed because of a Distributed Protocol Error: DRDA_Proto_SYNTAXRM; CODPNT arg = 0; Error Code Value = c)
null)
Issue Links
- depends upon
DERBY-4706 Remove stale and potentially unused code Request.writeEncryptedScalarStream
- Closed
Activity
- All
- Work Log
- History
- Activity
- Transitions
The exception in my comment was caused by the lack of disk space. I had started the derby with traceAll and run out of disk space very fast...
Julius, were you ever able to reproduce this issue? Are you actively working on it.
Yes, I was able to reproduce the bug, I tried also other size near 2GB-1 but just 2GB-1 exploits the bug.
I moved my attention away and wanted to return back after some time. I am unassigning the issue from myself to leave it for others who may want to work on that.
Triaged for 10.5.2.
The fix for this bug consists of two parts:
- make the client and the server agree on how the length is represented.
Currently the client writes a long (8 bytes), whereas the server expects 6 bytes.
- switch to using long instead of int where appropriate in the client.
There are several places where using int may result in an overflow (i.e. user data length + overhead).
I hope to post the first patch tomorrow.
Attaching patch 1a, which is client change only.
The number of extended length bytes depends on the length of the value to be transferred. The code is capable of choosing between 2, 4, 6 or 8 bytes. At some point an invalid change was introduced into the client, where a long (8 bytes) was written onto the wire when only 6 bytes were required for the length. The server expected 6 bytes, and this disagreement resulted in a protocol error.
I'm not sure using 6 instead of 8 bytes matters regarding performance, but I chose to use 6 bytes because:
o the DRDA spec may mandate this (I haven't checked)
o the server already expects 6 bytes, using 8 would require server side changes as well and would lead to incompatibilities when using the new client driver with old server versions
Note that this patch itself doesn't necessarily solve the reported problem, as the client code is likely to run into an int overflow. I'll address this in a separate patch.
suites.All ran without failures, I'm running derbyall now
Patch ready for review. I expect to commit the patch tomorrow.
The 1a patch looks fine to me. Two questions, though:
1) Is the value of MAX_LONG_6_BYTES_SIGNED correct? Looking at the corresponding code at the server side, it seems like it should have been 0xFFFFFFFFFFFFL, not 0x7FFFFFFFFFFFL. See for example DDMWriter.calculateExtendedLengthByteCount():
else if (ddmSize <= 0xffffffffffffL)
return 6;
And DDMReader.readNetworkSixByteLong() is also coded to handle that extra bit:
return (
((buffer[pos++] & 0xffL) << 40) +
...
2) Are you planning to internationalize the new error message that was added?
Hi Knut,
1) Here's what I got:
a) DRDA vol 3, page 300:
.
2) No, I'm not. This is more like an assert, and I'd rather have it fail than to silently ignore the most significant parts of the long.
1) I agree that it won't cause any problems since the server knows how to handle the values both when sent as a 6-byte value and as an 8-byte value (given that the type specifier matches the actual length). It's probably fine to leave it as it is. I see that NetStatementRequest.buildPlaceholderLength() also uses 0x7F(...) so I think it's true that a higher value won't ever be attempted written as a 6-byte integer.
2) Sounds OK, although I think the established pattern is to exclude asserts in production jars.
Thanks, Knut Anders.
I committed patch 1a to trunk with revision 955540.
If it turns out that the length field should be unsigned, we have to change more code and that's better addressed as a separate issue.
Linked
DERBY-4706, since that issue removes some code that would otherwise have to be changed with regards to the switch from int to long.
Attached patch 2a, which fixes the int overflow issues.
Since CLOBs that aren't transferred using layer B streaming are represented as UTF-16, this results in a maximum length of ~4 GB.
Running regression tests.
Patch ready for review.
Regression tests ran without failures.
I plan to commit this patch shortly.
Committed patch 2a to trunk with revision 958939.
After the fix has seen some more testing, I'll backport it. The fix is client-side only, which means that older client versions can make use of it (assuming the merge is clean).
Backported to 10.6 with revision 963673.
Since the merge isn't clean for older versions, I don't plan more backports.
Closing issue.
reopen for backport_reject label
I was able to reproduce this but when I decreased the size of LOB to 2GB-2, I got a different exception only on client::345)
at org.apache.derby.client.am.PreparedStatement.execute(PreparedStatement.java:1565)
at com.sun.stroffek.Main.main(Main.java:45)88)
at org.apache.derby.client.net.NetStatementReply.parseExecuteError(NetStatementReply.java:661)
at org.apache.derby.client.net.NetStatementReply.parseEXCSQLSTTreply(NetStatementReply.java:332)
at org.apache.derby.client.net.NetStatementReply.readExecute(NetStatementReply.java:70)
at org.apache.derby.client.net.StatementReply.readExecute(StatementReply.java:55)
at org.apache.derby.client.net.NetPreparedStatement.readExecute_(NetPreparedStatement.java:183)
at org.apache.derby.client.am.PreparedStatement.readExecute(PreparedStatement.java:1788)
at org.apache.derby.client.am.PreparedStatement.flowExecute(PreparedStatement.java:2108)
at org.apache.derby.client.am.PreparedStatement.executeX(PreparedStatement.java:1571)
at org.apache.derby.client.am.PreparedStatement.execute(PreparedStatement.java:1556)
... 1 more | https://issues.apache.org/jira/browse/DERBY-1595 | CC-MAIN-2016-50 | refinedweb | 1,075 | 50.33 |
Kernel dies when working with hyperplane arrangement
Following function causes kernel restart on any usage of "ha" (Sage 7.4, VirtualBox in Windows7 x64):
def f(n): pos_vectors = [[1, 1, 1, 1], [1, -1, 1, 1], [1, 1, -1, 1], [1, -1, -1, 1], [1, 1, 1, -1], [1, -1, 1, -1], [1, 1, -1, -1], [1, -1, -1, -1]] HA = HyperplaneArrangements(QQ, tuple("x" + str(i) for i in range(n))) ha = HA([[tuple(vector), 0] for vector in pos_vectors]) print(ha.n_regions()) f(4)
Too simple use case for bug. Is there something that I miss?
I can't reproduce this (Sage 7.4beta, on Mac). Did you do anything else before this? It went pretty fast, too, less than 100 ms.
No, only this function. I made mistake, version of Sage is 7.4 | https://ask.sagemath.org/question/35827/kernel-dies-when-working-with-hyperplane-arrangement/ | CC-MAIN-2018-39 | refinedweb | 137 | 84.37 |
Answered
Hi, I am building plugin that will allow our consultants to develop scripts with business logic that is then executed in our cloud application.
These are just simple groovy scripts and consultants can use predefined variable "api" that has type e.g. MyAPI that provide white-listed public API that consultants are "allowed" to use.
To make consultants life easier, I would like to provide code-complete assistant that will show them all public methods available in MyAPI class.
Question is how to do that - I don't want to add "MyAPI api = new MyAPI();" to each script just to make auto-complete available.
Any ideas?
See example below:
def rawMatrix = api.datamartLookup("CustTX","CustomerName","CustomerID","NetMargin%+")
def resultMatrix = api.newMatrix("Margin Status","Customer Id","Name","Net Margin %")
if(rawMatrix == null) return 0
Are you talking about IDEA plugin?
Correct, I am talking about IDEA plugin.
There are 3 ways:
Qualifier type will be the type corresponding to the script class and results are to be fed to the processor.
IDEA can pick gdsls from its plugins or from user libraries.
If you want your gdsl to be in your plugin then register org.jetbrains.plugins.groovy.dsl.GdslScriptProvider extension and make sure the gdsl file is under /standardDsls. The plugin needs to be deployed as the second way in the. For example layout see Groovy plugin in your IDEA distribution.
Another way is to package the gdsl into some jar (probably along with MyApi class) and add it as a dependency to user project (AFAIU this dependency should already be added). This is much simpler and does not require to create an IDEA plugin at all.
The example gdls which adds foobar property of pckg.MyApi type to all groovy scripts:
Just type `api`, alt+enter, 'Add dynamic property'.
This approach is out-of-the-box feaure, hence no need for plugin. These properties can be shared between users if you include .idea/dynamic.xml in your VCS.
From most to less preferable:
Thank you! Will try and let you know.
I used #1 approach using Gdsl in library and works fine. Really pleased to see how easy was to solve this. IDEA architecture and you guys really rock!
Hi Milan/Daniil,
I am trying to do a similar thing but I just cannot get it to work in IntelliJ 2016.1.3...
I have a set of static functions that I want available by default from short versions, or a standard object, e.g.:
static def com.blah.groovy.api.OrderFunctions.createOrder(...)
static def com.blah.groovy.api.OrderFunctions.cancelOrder(...)
I want to register this through GDSL in a way it would be accessible as e.g. orderapi.createOrder(), orderapi.cancelOrder()
I've tried various permutations of GDSL and although I can get the autocomplete to work, I can't get orderapi available as a property in all scripts...
Am I missing the point here somewhere?
Cheers,
Si | https://intellij-support.jetbrains.com/hc/en-us/community/posts/206907729-Extending-Groovy-Editor-injecting-global-variable-to-script?page=1 | CC-MAIN-2020-50 | refinedweb | 491 | 66.64 |
By: Rick Proctor
Abstract: A Basic Socket Processing How To. Learn to build a simple socket client, a socket server that handles one connection at a time, and a socket server that can handle mulitple socket connections..
package bdn;
/* The java.net package contains the basics needed for network operations. */
import java.net.*;
/* The java.io package contains the basics needed for IO operations. */
import java.io.*;
/** The SocketClient class is a simple example of a TCP/IP Socket Client.
*
*/
public class SocketClient {
Let’s start by creating a class called SocketClient. We’ll put
this into a package called bdn. The only packages that we’re going to
need in this example are java.net and java.io. If you’ve not dealt with
the java.net. package before, as it’s name implies, it contains the basic
classes and methods you’ll need for network programming (see your JBuilder
help files or
for more information).
One of the cool things about java is the consistent use of InputStreams and
OutputStreams to read and write I/O, regardless of the device. In other words,
you can almost always be assured that if you are reading from any input source,
you will use an InputStream...when writing to output sources you'll use an OutputStream.
This means reading and writing across a network is almost the same as reading
and writing files. For this reason, we need import that java.io package into
our program.
public static void main(String[] args) {
/** Define a host server */
String host = "localhost";
/** Define a port */
int port = 19999;
StringBuffer instr = new StringBuffer();
String TimeStamp;
System.out.println("SocketClient initialized");
In order to make a socket connection, you need to know a couple of pieces of
information. First you need a host to connect to. In this example we’re
going to be running the client(s) and the server on the same machine. We define
a String host as localhost.
Note: we could have used the TCP/IP address 127.0.0.1
instead of localhost.
The next piece of information we need to know is the TCP/IP port that the program
is going to be communicating on. TCP/IP uses ports because it is assumed that
servers will be doing more than one network function at a time and ports provide
a way to maange this. For example: a server may be serving up web pages (port
80), it may have a FTP (port 21) server, and it may be handling a SMTP mail
server (port 25). Ports are assigned by the server. The client needs to know
what port to use for a particular service. In the TCP/IP world, each computer
with a TCP/IP address has access to 65,535 ports. Keep in mind that ports are
not physical devices like a serial, parallel, or USB port. They are an abstraction
in the computer’s memory running under the TCP/IP transport layer protocol.
Note: Ports 1 – 1023 are reserved for services such as HTTP, FTP, email,
and Telnet.
Now back to the code. We create an int called port. The server
we’re going to build later in the article will be listening on port 19999.
As a result we initialize port to 19999.
A couple of other items that we define here are a StringBuffer instr
to be used for reading our InputStream. We also define a String TimeStamp
that we’ll use to communicate with the server. Lastly, we System.out.println()
a message to let us know the program has begun…this kind of stuff is certainly
not necessary, but I’ve found occasionally logging a program status message
gives people a peace of mind that a program’s actually doing something..
Note: You should spend some time reviewing the various javadocs on the classes
and methods you use. There are often specific exceptions that you want to catch
and deal with. Example: had we built an applet that allowed a person to enter
the servers and ports they wanted to connect to, we would have wanted to deal
with UnknownHostException in the event they keyed an invalid host..
We’ve established our connection. Now we want to write some information
to the server. As mentioned previously, Java treats reading and writing sockets
is much like reading and writing files. Subsequently we start by establishing
an OutputStream object. In general TCP stacks use buffers to improve performance
within the network. And, although it’s not necessary, we might as well
use BufferedInputStreams and BufferedOutputStreams when reading and writing
data across the network. We instantiate a BufferedOutputStream object bos
by requesting an OutputStream from our socket connection.
BufferedOutputStream bos = new BufferedOutputStream(connection.
getOutputStream());
/** Instantiate an OutputStreamWriter object with the optional character
* encoding.
*/
OutputStreamWriter osw = new OutputStreamWriter(bos, "US-ASCII");
We could use the BufferedOutputStream.write() method to write bytes across
the socket. I prefer to use OutputStreamWriter objects to write on because I’m
usually dealing in multiple platforms and like to control the character encoding.
Also, with OutputStreamWriter you can pass objects such as Strings without converting
to byte, byte arrays, or int values…ok I’m lazy…so what.
Note: If you don’t handle the character encoding and
are reading and writing to an IBM mainframe from a Windows platform, you’ll
probably end up with garbage because IBM mainframes tend to encode characters
as EBCDIC and Windows encodes characters as ASCII.
We create an OutputStreamWriter osw by instantiating it with
our BufferedOutputStream bos and optionally the character encoding
US-ASCII.
TimeStamp = new java.util.Date().toString();
String process = "Calling the Socket Server on "+ host + " port " + port +
" at " + TimeStamp + (char) 13;
/** Write across the socket connection and flush the buffer */
osw.write(process);
osw.flush();
As shown above, we’re creating two Strings TimeStamp and process to be
written to the server. We call the osw.write() method from our OutputStreamWriter
object, passing the String process to it. Please note that we placed a char(13)
at the end of process...we’ll use this to let the server know we’re
at the end of the data we’re sending. The last item we need to take care
of is flushing the buffer. If we don’t do this, then we can’t guarantee
that the data will be written across the socket in a timely manner.
/** Instantiate a BufferedInputStream object for reading
/**;
while ( (c = isr.read()) != 13)
instr.append( (char) c);
/** Close the socket connection. */
connection.close();
System.out.println(instr);
}
catch (IOException f) {
System.out.println("IOException: " + f);
}
catch (Exception g) {
System.out.println("Exception: " + g);
}
}
}
The last thing we want to do is read the server’s response. As mentioned
before, most networks buffer socket traffic to improve performance. For this
reason we’re using the BufferedInputStream class. We start by instantiating
a BufferInputStream object bis, calling the getInputStream()
method of our Socket object connection. We instantiate an InputStreamReader
object isr, passing our BufferedInputStream object bis
and an optional character encoding of US-ASCII.
We create an int c that will be used for reading bytes from
the BufferedInputStream. We create a while…loop reading bytes and stuffing
them into a StringBuffer object instr until we encounter a
char(13), signaling the end of our stream. Once we’ve read the socket,
we close the socket and process the information…in this example we’re
just going to send it to the console. The last thing we do is create code in
our catch block to deal with exceptions.
Now that we’ve created the client, what do we do with it? Compiling and
running it will give us the following message:
Figure 1: SocketClient Running without Server
We get this message because we don’t have a server listening on port
19999 and therefore can’t establish a connection with it.
Now it’s time to create the server…
package bdn;
import java.net.*;
import java.io.*;
import java.util.*;
public class SingleSocketServer {
static ServerSocket socket1;
protected final static int port = 19999;
static Socket connection;
static boolean first;
static StringBuffer process;
static String TimeStamp;
We start by importing the same packages we did with our SocketClient class.
We set up a few variables. Of note, this time we’re setting up a ServerSocket
object called socket1. As its name implies, we use the ServerSocket
class to set up a new server. As we’ll see later, ServerSockets can be
created to listen on a particular port and accept and deal with incoming sockets.
Depending on the type of server we build, we can also process InputStreams and
OutputStreams.
public static void main(String[] args) {
try{
socket1 = new ServerSocket(port);
System.out.println("SingleSocketServer Initialized");
int character;
In the main() method, we start with a try…catch block. Next we instantiate
a new ServerSocket object socket1 using the port value of 19999…the
same port that we were looking to connect to with our SocketClient class. Finally,
we send a message to the console to let the world know we’re running.
while (true) {
connection = socket1.accept();
BufferedInputStream is = new BufferedInputStream(connection.getInputStream());
InputStreamReader isr = new InputStreamReader(is);
process = new StringBuffer();
while((character = isr.read()) != 13) {
process.append((char)character);
}
System.out.println(process);
//need to wait 10 seconds for the app to update database
try {
Thread.sleep(10000);
}
catch (Exception e){}
TimeStamp = new java.util.Date().toString();
String returnCode = "SingleSocketServer repsonded at "+ TimeStamp + (char) 13;
BufferedOutputStream os = new BufferedOutputStream(connection.getOutputStream());
OutputStreamWriter osw = new OutputStreamWriter(os, "US-ASCII");
osw.write(returnCode);
osw.flush();
}
}
catch (IOException e) {}
try {
connection.close();
}
catch (IOException e) {}
}
}
Since we’re running a server, we can assume that it’s always ready
to accept and process socket connections. Using a while(true)…loop helps
us accomplish this task. Within this block of code, we start with the ServerSocket
socket1’s accept() method. The accept() method basically
stops the flow of the program and waits for an incoming socket connection. When
a client connects, our Socket object connection is instantiated.
Once this is done, our program continues through the code.
We start by processing the InputStream coming from our socket. (For details
on this see the explanation for InputStreams in the Reading from the Socket
section of this article).
Note: I’ve thrown a line of code that says Thread.sleep(10000). All I’m
doing here is putting the current thread to sleep for 10 seconds. I added this
piece of code is purely for the purpose of demonstrating socket connections.
It would not be used in a real-world server application.
After we’ve processed the information in the incoming socket, we want
to return some information, in the form of an OutputStream, back to the client.
The process here is the same process we used in the SocketClient class (see
the section entitled: Writing to the Socket). Once the OutputStream is written,
the server is now ready to accept another socket.
Let’s look at what happens when we run SingleSocketServer and SocketClient
together. Executing the programs in JBuilder X will look like this:
Figure 2: SingleSocketServer After One SocketClient Connection
Figure 3: SocketClient After Connecting with SingleSocketServer
Notice the results. Figure 2 shows messages for the SingleSocketServer class.
From the message, we can see that the SockeClient called the server at 20:36:33.
Looking at Figure 3 we see the messages for the SocketClient class. The message
tells us that the server responded at 20:36:43...10 seconds later. SocketClient
has ended and SocketServer is waiting for another connection.
Let’s take the same scenario and add a second instance of SocketClient
to the mix (to do this, start SocketClient, and while it’s running start
a second instance).
Figure 4: SingleSocketServer with Two SocketClient Instances
Figure 5: First Instance of SocketClient
Figure 6: Second Instance of SocketClient
This time look at the results. Figure 4 shows that SingleSocketServer logs
two messages, showing the TimeStamp that each instance of SocketClient. Figure
5 shows the first instance of SocketClient we executed. Notice that the time
in Figure 5 (20:38:54) is 10 seconds later than the time in the first message
in Figure 4 (20:38:44)...as expected
Now let’s look at the second instance of SocketClient. From the time
in Figure 4 we see that the second instance was launched 5 seconds after the
first one. However, looking at the time in Figure 6, we can see that SingleSocketServer
didn’t respond to the second instance until 10 seconds after it responded
to the first instance of SocketClient…13 seconds later. The reason for
this is simple. SingleSocketServer is running in a single thread and each incoming
socket connection must be completed before the next one can start.
Now, you might be asking, “Why in the world would someone want process
only one socket at a time?” Recently I was working on a project where
a non-java program had to be launched across a network from a java program.
And, only one instance of the non-java program could be running at a time. I
used a similar solution to solve that problem. Also, it can be a handy way of
keeping multiple instances of the same java program from being launched at the
same time. “That’s fine” you say, “but I want my server
to accept multiple sockets. How do you do that?”
Well, let’s take a look.
package bdn;
import java.net.*;
import java.io.*;
import java.util.*;
public class MultipleSocketServer implements Runnable {
private Socket connection;
private String TimeStamp;
private int ID;
public static void main(String[] args) {
int port = 19999;
int count = 0;
try{
ServerSocket socket1 = new ServerSocket(port);
System.out.println("MultipleSocketServer Initialized");
while (true) {
Socket connection = socket1.accept();
Runnable runnable = new MultipleSocketServer(connection, ++count);
Thread thread = new Thread(runnable);
thread.start();
}
}
catch (Exception e) {}
}
MultipleSocketServer(Socket s, int i) {
this.connection = s;
this.ID = i;
}
We’re not going to spend much time examining all the code here since
we’ve already been through most of it. But, I do want to highlight some
things for you. Let’s start with the class statement. We’re introducing
a new concept here. This time we’re implementing the Runnable interface.
Without diving deep into the details of threads, suffice it to say that a thread
represents a single execution of a sequential block of code.
In our previous example, the SingleSocketServer class had a while(true) block
that started out by accepting an incoming socket connection. After a connection
was received, another connection could not happen until the code looped back
to the connection = socket1.accept(); statement. This block code represents
a single thread…or at least part of a single thread of code. If we want
to take this block of code and make it into many threads…allowing for
multiple socket connections...we have a couple of options: extending the implementing
the Runnable interface or extending the Thread class. How you decide which one
to use is entirely up to your needs. The Thread class has a lot of methods to
do various things like control thread behavior. The Runnable interface has a
single method run() (Thread has this method too). In this example, we’re
only concerned with the run() method…we’ll stick with the Runnable
interface.
Looking through the main() method, we still have to set up our server to allow
for connections on Port 19999, there’s still a while(true) block, and
we’re still accepting connections. Now comes the difference. After the
connection is made, we instantiate a Runnable object runnable
using a constructor for MultipleSocketServer that has 2 arguments: a Socket
object connection for the socket that we’ve just accepted,
and an int count, representing the count of open sockets. The
concept here is simple: we create a new socket object for each socket connection,
and we keep a count of the number of open connections. Although we’re
not going to worry about the number of connections in this example, you could
easily use count to limit the number of sockets that could be open at once.
Once we’ve instantiated runnable, we instantiate a new
Thread thread by passing runnable to the Thread
class. We call the start() method of thread and we’re ready go. Invoking
the start() method spawns a new thread and invokes the object’s run()
method. The actual work within the thread happens within the run() method. Let’s
take a quick look at that now.
public void run() {
try {
BufferedInputStream is = new BufferedInputStream(connection.getInputStream());
InputStreamReader isr = new InputStreamReader(is);
int character;
StringBuffer process = new StringBuffer();
while((character = isr.read()) != 13) {
process.append((char)character);
}
System.out.println(process);
//need to wait 10 seconds to pretend that we're processing something
try {
Thread.sleep(10000);
}
catch (Exception e){}
TimeStamp = new java.util.Date().toString();
String returnCode = "MultipleSocketServer repsonded at "+ TimeStamp + (char) 13;
BufferedOutputStream os = new BufferedOutputStream(connection.getOutputStream());
OutputStreamWriter osw = new OutputStreamWriter(os, "US-ASCII");
osw.write(returnCode);
osw.flush();
}
catch (Exception e) {
System.out.println(e);
}
finally {
try {
connection.close();
}
catch (IOException e){}
}
}
}
The run() method’s responsibility is to run the block of code that we
want threaded. In our example the run() method executes the same block of code
we built in the SingleSocketServer class. Once again, we read the BufferedInputStream,
pretend to process the information, and write a BufferedOutputStream. At the
end of the run() method, the thread dies.
Now it’s time to run our MultipleSocketServer. Using the same scenario
we did previously. Let’s look at what happens when we run the MultipleSocketServer
and two instances of SocketClient.
Figure 7: MultipleSocketServer with Two Instances of SocketClient
Figure 8: First Instance of SocketClient
Figure 9: Second Instance of SocketClient
Looking at the messages in Figure 7 that come from the MultipleSocketServer
class, we can see that requests for socket connections were sent by the SocketClient
programs within a few seconds of each other. According to the console messages
on the first instance of SocketClient in Figure 8, the server responded 10 seconds
after the request was sent. Figure 9 shows that the second instance of SocketClient
receives a response 10 seconds after it sent the request also, thus allowing
us the capability of processing multiple socket connections simultaneously.
Network programming in Java revolves around sockets. Sockets allow us to communicate
between programs across the network. Java’s approach to socket programming
allows us to treat socket I/O the same as we do any other I/O…utilizing
InputStreams and OutputStreams. Although, the examples presented here are relatively
simple, they give you an idea of the power of Java in the Client-Server world.
Next time, we’ll move a level up from socket programming and deal with
the basics of calling objects across a network using Java’s Remote Method
Invocation (RMI) facility.
Rick Proctor has over 20 years experience in the IT industry. He's developed
applications on more platforms than he cares to remember. Since 2001 Rick has
been Vice President of Information Technology for Thomas Nelson Publishers,
Inc. (NYSE: TNM). Rick can be reached at tech_dude@yahoo.com.
The source code for the programs in this article can be found at CodeCentral.
Server Response from: SC4 | http://edn.embarcadero.com/article/31995 | crawl-002 | refinedweb | 3,224 | 56.66 |
Coding a Linear Congruential Generator
This tutorial shows how to generate random numbers using a Linear Congruential Sequences. Most PRNGs used in programming languages use an LCG so you might as well just use rand() to generate your random data. However, maybe you are just interested in how these things work. Maybe you don’t trust the programmers who wrote that library. Maybe you are just a plane old-fashioned do-it-yourselfer.
I. Theory
The heart of an LCG is the following formula
X(i+1) = (a * X(i) + c) mod M
where
M is the modulus. M > 0.
a is the multiplier, 0 <= a < M.
c is the increment, 0 <= c < M.
X(0) is the seed value, 0 <= X(0) < M.
i is the iterator. i < M
Suppose we were to use the following:
#include <iostream> using namespace std; int main() { int M = 8; int a = 5; int c = 3; int X = 1; int i; for(i=0; i<8; i++) { X = (a * X + c) % M; cout << X << “ “; } return 0; }
Output: 0 3 2 5 4 7 6 1
This generates a sequence of numbers from 0 to 7 in a fairly scrambled way. If we were to extend the loop we would find that this sequence would repeat over and over. This sequence happens to have a period of M, but other choices for a, and c could have smaller periods (a=3, c=3 has a period of 4).
To make our LCG useful we will need a large period. To do this we have to choose appropriate values for M, a, and c.
To have a maximum period of M the following conditions must be met:
1. M and c are Relatively Prime so the gcd(M, c) = 1.
2. (a-1) is divisible by all prime factors of M.
3. (a-1) mod 4 = 0 if (M mod 4) = 0
The first condition is the hardest to check. This is a link to a good GCD algorithm written in C/C++, however, there is no need to add this to our code unless we want to generate c and M on the fly. For the most part once we select a good set of values for c and M we can leave them since there are some really bad choices for c and M.
The second condition can be difficult for large values of M since there is no fast way to factor a large number. However if we manufacture M from prime numbers then we can easily find a value for a. In point of fact for ease of calculation M is often chosen to be a power of 2 and so this condition becomes “a is an odd number greater then 1 and less then M.” Easy enough.
The last condition is the easiest to verify. We simply need to divide M by 4 and if it divides evenly then we need to see if (a-1) also divides evenly by 4. Which is exactly what the Mod (%) operator does for us.
II. Failings
Armed with knowledge lets make a sequence 256 elements long. So M=2^8. This makes choosing c simple as it can be any odd number less than M. Lets choose c=27. Now choosing a value for a is also easy, choose a multiple of 4 and add 1. a = 65.
#include <iostream> using namespace std; int main() { int M = 256; int a = 65; int c = 27; int X = 1; int i; for(i=0; i<256; i++) { X=(a * X + c) % M; cout << X << " "; } return 0; }
Some of the output:
92 119 82 237 72 99 62 217 52 79 42 197 32 59 22 177 12 39 2 157 248 19 238 137 228 255 218 117 208 235
Now if you are astute you will notice that this would not make a very good random number generator. Do you see it? The sequence is even, odd, even, odd, etc.. This is not a very *random* sequence. If we were to look at the numbers in binary we would notice other patterns. This is due to our choices of a, c, and M. Most importantly, if we choose a power of 2 for M then the least significant digits will have an even period less then M.
Another statistical anomaly of LCGs is found when we use the LCG to generate triplets in a 3-dimensional space. We find will find the points arrange themselves into planes.
At this point you are probably not sold on LGCs. There are however a few tricks that can be used to ameliorate many of these shortcomings.
1. Chose our constant wisely! A list of values used in some classical random number generators. (Such as the one used in ASCII-C’s rand() function). Some are good, some are bad!
2. Only use a few of the most significant bits X. This hides all of the high frequency patterns found in the sequence. If we choose a large value for M then we can be assured that we have a period that is larger than our expected data set.
3. Use obfuscation methods such as choosing variable numbers of bits or re-seeding.
Even with all of these it should be noted that LCG’s are not fit for cryptographic use, nor should they be used in statistical tests (yes, that’s right, all of those “coin-flipping” programs you wrote were using an unfair coin).
III Implementation
Here is a basic LCG random number generator:
/********************************************** /* A Basic Linear Congruential Generator /* --------------------------------------- /* Program By: NickDMax for Dreamincode.net /* 02/23/2007 /* /* You may use this code as you see fit /**********************************************/ #include <iostream> #include <ctime> using namespace std; //This class will give satisfy basic // random number considerations for // games an general apps. // WARNING: Not for Cryprographic use // Not for statistical methods. class BasicLCG { private: unsigned long iCurrent; public: BasicLCG(); BasicLCG(unsigned long); void seed(unsigned long iSeed); unsigned long nextNumber(); //get the next random number unsigned short int nextInt(); unsigned char nextChar(); int nextBit(); double nextDouble(); int inRange(int min, int max); }; //Just a little test code to print some numbers int main() { BasicLCG rng(time(NULL)); int i; //Lets see some bits... for( i=1; i<81; i++) { cout << rng.nextBit() <<"\t"; } cout <<"\n"; for( i=1; i<41; i++) { cout << (int)rng.nextChar() <<"\t"; } cout <<"\n"; for( i=1; i<41; i++) { cout << rng.nextInt() <<"\t"; } cout <<"\n"; for( i=1; i<41; i++) { cout << rng.nextNumber() <<"\t"; } cout <<"\n\n"; for( i=1; i<41; i++) { cout << rng.nextDouble() <<"\t"; } cout <<"\n\n"; for( i=1; i<41; i++) { cout << rng.inRange(10, 5) <<"\t"; } return 0; } BasicLCG::BasicLCG() { iCurrent = 0; //Chose a default seed } BasicLCG::BasicLCG(unsigned long iSeed) { iCurrent = iSeed; } void BasicLCG::seed(unsigned long iSeed) { iCurrent = iSeed; } //NOTE: a and c are selected for no particular properties // and I have not run statistical tests on this number gernerator // it is was written for demonstration purposes only. unsigned long BasicLCG::nextNumber() { unsigned long iOutput; unsigned long iTemp; int i; //I only want to take the top two bits //This will shorten our period to (2^32)/16=268,435,456 //Which seems like plenty to me. for(i=0; i<16; i++) { //Since this is mod 2^32 and our data type is 32 bits long // there is no need for the MOD operator. iCurrent = (3039177861 * iCurrent + 1); iTemp = iCurrent >> 30; iOutput = iOutput << 2; iOutput = iOutput + iTemp; } return iOutput; } unsigned short int BasicLCG::nextInt() { unsigned short int iOutput; unsigned long iTemp; int i; //No need to limit ourselves... for(i=0; i<8; i++) { //Since this is mod 2^32 and our data type is 32 bits long // there is no need for the MOD operator. iCurrent = (3039177861 * iCurrent + 1); iTemp = iCurrent >> 30; iOutput = iOutput << 2; iOutput = iOutput + (short int)iTemp; } return iOutput; } unsigned char BasicLCG::nextChar() { unsigned char cOutput; unsigned long iTemp; int i; for(i=0; i<4; i++) { iCurrent = (3039177861 * iCurrent + 1); iTemp = iCurrent >> 30; cOutput = cOutput << 2; cOutput = cOutput + (char)iTemp; } return cOutput; } int BasicLCG::nextBit() { iCurrent = (3039177861 * iCurrent + 1); return iCurrent >> 31; } double BasicLCG::nextDouble() { return (double)nextNumber()/0xFFFFFFFF; } int BasicLCG::inRange(int iMin, int iMax) { int Diff; //IF the user put them in backwards then swap them if (iMax<iMin) { //Integer swap iMax = iMax ^ iMin; //iMax holds iMax ^ iMin iMin = iMax ^ iMin; //iMin= (iMax ^ iMin) ^ iMin = iMax (original) iMax = iMax ^ iMin; //iMax= (iMax ^ iMin) ^ iMax = iMin (original) } Diff = iMax - iMin + 1; return (int) (nextDouble()*Diff)+iMin; }
IV Topics
*This is just a side note. I know that slot machines and online games tend use LCG's to do thier random numbers and I wonder if the LCGs' inherent patterns arn't senced by the people who play these games. In MMRPG's people have 'superstitions' about how to do this or that based upon patterns... very often these people seem to have a statistical advantage (though that is not a scientific statment). Could it be that these users have found a way to catch a bit wave? to sync into a pattern in the LCG? My brain tells me that those random number generators are working pretty hard to keep up with the demand of the users and 1 user falling into a pattern seems unlikely.
V Referances
Knuth, Donald E., The Art of Computer Programming V2 Seminumerical Algorithms 3rd Ed., Addison-Wesley, pp10-11, 170-173, 1997.
Stephen K. Park and Keith W. Miller, Random Number Generators: Good Ones Are Hard To Find, Communications of the ACM, 31(10):1192-1201, 1988.
Linear congruential generator. Wikipedia,
-------------------------------------------------------------------
Hope someone finds this interesting/helpful
If there is interest next time I will tackle the Mersenne twister which is a faster slightly more secure algorithm.
This post has been edited by NickDMax: 16 June 2009 - 08:29 PM | https://www.dreamincode.net/forums/topic/24225-random-number-generation-102/ | CC-MAIN-2020-40 | refinedweb | 1,647 | 69.11 |
The Dynamic Integrated model of Climate and the Economy (DICE) model family are a popular and capable type of simple Integrated Assessment Model (IAM) of climate-change economics pioneered by William Nordhaus: the Sterling Professor of Economics at Yale University.
Economists, financiers and chemical engineers seem to love using the GAMS IDE to solve their optimisation problems, and as such DICE runs either in GAMS or Excel, so long as one purchases an expensive NLP solver on top of the initial (arguably already too expensive) price of the parent software. Since there are a number of perfectly capable open source non-linear solvers in existence, this repository holds various DICE implementations that require no money down to operate.
Implemented
In testing phase
Planned
Suggestions and additions welcomed.
Prerequisites for using this package are JuMP and a NLP solver.
We use Ipopt here, but it's possible to use one of your choice. If you don't have these packages on your system, they will be installed when you add this package.
The current recommendation however, is to use the latest version of the Ipopt solver (at time of writing: 3.12.13).
If you use a rolling-release OS like Arch Linux, the coin-or-ipopt package will keep your system updated.
Then, add the following to your
~/.julia/config/startup.jl file (create one if it doesn't exist)
ENV["JULIA_IPOPT_LIBRARY_PATH"] = "/usr/lib" ENV["JULIA_IPOPT_EXECUTABLE_PATH"] = "/usr/bin"
Other distributions may use a different path, so it would be useful to check
which ipopt to verify the correct path here.
If you've already built Ipopt.jl with the bundled version, simply build it again once your environment is set
julia> import Pkg; Pkg.build("Ipopt")
Detailed instructions of setting up other solvers on your machine can be viewed in the JuMP Documentation.
Self contained notebooks can be found in a separate DICE.jl-notebooks repository that run default instances of each model, plot the major results and compare the output with original source data (where available).
The best way to use these is to run a notebook server from a cloned copy of this repository:
$ git clone git@github.com:Libbum/DICE.jl-notebooks.git $ cd DICE.jl-notebooks $ julia julia> ] (v1.1) pkg> activate . (DICE.jl-notebooks) pkg> instantiate (DICE.jl-notebooks) pkg> precompile $ jupyter lab
and follow the generated link to your browser.
The final command can also be
jupyter notebook if you don't have
lab installed.
This process is only needed once.
After that you can just run the
jupyter lab command in the
DICE.jl-notebooks directory.
If you don't need to interact with the notebook and are just curious about the output then github renders notebooks natively. You can just click on them and read through the output. All notebooks are stored in a previously executed state, with all outputs rendered.
Using the module gives your greater control over the inputs of the system, and ultimately allows you to compare different versions of the model with the same input data (if possible and permitted).
Create a new project and install the DICE module. For the moment it is not in METADATA, so add it via the repository directly:
$ cd /path/to/projects/ $ julia julia> ] (v1.1) pkg> generate MyProject julia> ; shell> cd MyProject (v1.1) pkg> activate . (MyProject) pkg> add
The simplest of files to run the default solution looks like this:
using DICE; dice = solve(OptimalPrice, v2013R()); dice.results.UTILITY
A more fleshed out example, enabling you to alter the configuration is also simple enough:
using DICE; import JuMP; using Ipopt; using Plots; unicodeplots() version = v2013R(); #Vanilla flavour conf = options(version, limμ = 1.1); #Alter the upper limit on the control rate after 2150 ipopt = JuMP.with_optimizer(Ipopt.Optimizer, print_level=0) #Don't print output when optimising solution dice = solve(BasePrice, version, config = conf, optimizer = ipopt); r = dice.results; plot(r.years,r.scc,ylabel="\$ (trillion)",xlabel="Years",title="SCC",legend=false)
yielding the estimated global cost of carbon emissions out to 2300 without an optimal carbon price
SCC ┌─────────────────────────────────────────────────────────────────────────┐ 400⠖⠉⠉⠉ $ (trillion)│ │⠀⠀⢀⣠│ 0 │⠀│ └─────────────────────────────────────────────────────────────────────────┘ 2000 2400 Years
The code herein is distributed under the MIT license, so feel free to distribute it as you will under its terms. The solver listed in the source is Ipopt: the codebase of which is under EPL. As we do not include the solver in this repository, there is no need to distribute this license here. EPL is compatible with MIT for this use case (GPL for instance is not). One is welcomed to use an alternate solver to suit their needs as the JuMP framework integrates with several. Please remain aware of the licensing restrictions for each, as many license choices in this domain are incompatible.
05/31/2018
3 months ago
105 commits | https://juliaobserver.com/packages/DICE | CC-MAIN-2021-21 | refinedweb | 798 | 54.73 |
I am teaching mysef a little about
numpy and I have dusted off some of my old undergraduate texts to use for examples. So, I wrote a function without
numpy to calculate the deflection in a cantilever beam due to a single point load at any point. Pretty straight forward, except that the deflection equation changes depending on what side of the point force you are on, so I will split the beam into two ranges, calculate the deflection values at each interval in the ranges and append the result to a list. Here's the code.
def deflection(l, P, a, E, I): """ Calculate the deflection of a cantilever beam due to a simple point load. Calculates the deflection at equal one inch intervals along the beam and returns the deflection as a list along with the the length range. Parameters ---------- l : float beam length (in) P : float Point Force (lbs) a : float distance from fixed end to force (in) E : float modulus of elasticity (psi) I : float moment of inertia (in**4) Returns ------- list x : distance along beam (in) list of floats y : deflection of beam (in) Raises ------ ValueError If a < 0 or a > l (denoting force location is off the beam) """ if (a < 0) or (a > l): raise ValueError('force location is off beam') x1 = range(0, a) x2 = range(a, l + 1) deflects = [] for x in x1: y = (3 * a - x) * (P * x**2) / (6 * E * I) deflects.append(y) for x in x2: y = (3 * x - a) * (P * a**2) / (6 * E * I) deflects.append(y) return list(x1) + list(x2), deflects
Now I want to do the same thing using numpy, so I wrote the following function:
def np_deflection(l, P, a, E, I): """To Do. Write me.""" if (a < 0) or (a > l): raise ValueError('force location is off beam') x1 = np.arange(0, a) x2 = np.arange(a, l + 1) y1 = (3 * a - x1) * (P * x1**2) / (6 * E * I) y2 = (3 * x2 - a) * (P * a**2) / (6 * E * I) return np.hstack([x1, x2]), np.hstack([y1, y2])
Here's the issue, at some point in the calculations, the value of y1 changes sign. Here's an example.
if __name__ == '__main__': import matplotlib.pyplot as plt l, P, a, E, I = 120, 1200, 100, 30000000, 926 x, y = deflection(l, P, a, E, I) print(max(y)) np_x, np_y = np_deflection(l, P, a, E, I) print(max(np_y)) plt.subplot(2, 1, 1) plt.plot(x, y, 'b.-') plt.xlabel('dist from fixed end (in)') plt.ylabel('using a range/list') plt.subplot(2, 1, 2) plt.plot(np_x, np_y, 'r.-') plt.xlabel('dist from fixed end (in)') plt.ylabel('using numpy range') plt.show()
If you run the plot, you'll see that at point
x = 93 which is in
x1, there is a dislocation in the curve where the value seems to change sign.
Can anyone explain a) what is happening? and b) what I did wrong? | http://www.howtobuildsoftware.com/index.php/how-do/3yG/python-python-3x-numpy-numpy-arange-values-are-changing-signs-unexpectedly | CC-MAIN-2019-22 | refinedweb | 498 | 80.72 |
React Native Tutorial: Building iOS and Android Apps with JavaScript
React Native Tutorial: Build native iOS applications with JavaScript.
Update note: This tutorial has been updated to React Native 0.46, Xcode 9, and iOS 11 by Christine Abernathy. The previous tutorial was written by iOS Team member Tom Elliot..:
brew install node
Next, use
homebrew to install watchman, a file watcher from Facebook:
brew install watchman
This is used by React Native to figure out when your code changes and rebuild accordingly. It’s like having Xcode do a build each time you save your file.
Next use npm to install the React Native Command Line Interface (CLI) tool:
npm install -g react-native-cli
This uses the Node Package Manager to fetch the CLI tool and install it globally;.ios.js is the skeletal app created by the CLI tool
- ios is a folder containing an Xcode project and the code required to bootstrap
your application
- Android counterparts to the above, although the React Native packager, running under node. index.ios.js in your text editor of choice and take a look at the structure of the code in the file:
import React, { Component } from 'react'; // 1 import { AppRegistry, StyleSheet, Text, View } from 'react-native'; export default class PropertyFinder extends Component { ... } // 2 const styles = StyleSheet.create({ ... }); // 3 AppRegistry.registerComponent('PropertyFinder', () => PropertyFinder); // 4
Let’s go through the code step-by-step:
- Import the required modules.
- Defines the component that represents the UI.
- Creates a style object that controls the component’s layout and appearance.
- Registers the component that handles the app’s entry point.
Take a closer look at this import statement:
import React, { Component } from 'react';
This uses the ECMAScript 6 (ES6) import syntax to load the
react module and assign it to a variable called
React. This is roughly equivalent to linking and importing libraries in Swift.. Apple has supported ES6 since iOS 10, but older browsers may not be compatible with it. React Native uses a tool called Babel to automatically translate modern JavaScript into compatible legacy JavaScript where necessary.
Back to index.ios.js, check out the class definition:
export default class PropertyFinder extends Component
This defines a class which extends a React
Component. The
export default class modifier makes the class “public”, allowing it to be used in other files.
It’s time to start building your app.
In index.ios.js, add the following at the top of the file, just before the import statements:
'use strict';
This enables Strict Mode, which adds improved error handling and disables some less-than-ideal JavaScript language features. In simple terms, it makes JavaScript better!
Inside the
PropertyFinder class replace
render() with the following:
render() { return React.createElement(Text, {style: styles.description}, "Search for houses to buy!"); }
PropertyFinder extends.
Save your changes to index.ios.js and return to the simulator. Press Cmd+R, and you’ll see your fledgling property search app starting to take shape:.ios
PropertyFinder component, then constructs the native UIKit: index.ios index.ios.js, find the import statements near the top and add a comma following the
View destructuring assignment. Then add the following below it:
NavigatorIOS,
This brings in
NavigatorIOS that you’ll use for navigation.
Next, replace the
PropertyFinder class definition with the following:
class SearchPage extends Component {
You’ve just renamed the class. You’ll see an error as a result, but will clean that up next.
Add the following class below the
SearchPage component:
class PropertyFinder index.ios:
export default class SearchPage extends Component { Interface Builder, but it’s better than setting view properties one by one in your
viewDidLoad() methods! :]
Save your changes.
Open index.ios.js and add the following just after the current
import statements near the top of the file:
import SearchPage from './SearchPage';
This imports
SearchPage from the file you just created – which will temporarily break your app! This is because SearchPage is now declared twice – once in SearchPage.js, and again in the current file.
Remove the
SearchPage class and its associated
description style from index.ios.js. You won’t be needing that code any longer.
Save your changes and return to the simulator Swift, Objective-C, Java (for Android), and C# (for .NET).
Generally you use a combination of
flexDirection,
alignItems, and
justifyContent Yoga simulator.:
react-native startcommand you have in the terminal). simulator.
You should see the text input’s initial value set to london. You should also see Xcode console logs when editing the text:
2017-07-04 00:05:48.642 [info][tid:com.facebook.React.JavaScript] SearchPage.render 2017-07-04 00:06:04.229 [info][tid:com.facebook.React.JavaScript] _onSearchTextChanged 2017-07-04 00:06:04.230 [info][tid:com.facebook.React.JavaScript] Current: london, Next: londona 2017-07-04 00:06:04.231 [info][tid:com.facebook.React.JavaScript].
Note: You may see frequent log messages related to
nw_connection_get_connected_socket.. an example of the latter, see this article on implementing the MVVM pattern with ReactiveCocoa., since it’s no longer necessary. simulator and press Go. You’ll see the activity indicator spin:
Your Xcode console should show something like this:
2017-07-04 00:23:23.769 [info][tid:com.facebook.React.JavaScript] simulator and press Go. You should see an Xcode console log message saying that 20 properties (the default result size) were found:
2017-07-04 00:34:12.425 [info][tid:com.facebook.React.JavaScript]: simulator, press Go, and check out your results:
That looks a lot better — although it’s a wonder anyone can afford to live in London!
Tap the first row and check that the Xcode console reflects the selection:
2017-07-04 01:29:19.799 [info][tid:com.facebook.React.JavaScript].
npm installvia the Terminal in the root folder of the project.
Check out the React Native’s source code if you’re curious. I suggest taking a look at this ES6 resource to continue brushing up on modern JavaScript. Swift, I hope you’ve learned some interesting principles to apply to your next project.
If you have any questions or comments on this React Native tutorial, feel free to join the discussion in the forums below!
Team
Each tutorial at is created by a team of dedicated developers so that it meets our high quality standards. The team members who worked on this tutorial are:
- Author
Christine Abernathy
- Tech Editor
Marin Bencevic
- Final Pass Editor
Jeff Rames
- Team Lead
Andy Obusek | https://www.raywenderlich.com/165140/react-native-tutorial-building-ios-android-apps-javascript | CC-MAIN-2017-43 | refinedweb | 1,079 | 57.27 |
Episode #86: Make your NoSQL async and await-able with uMongo
Published Fri, Jul 13, 2018, recorded Wed, Jul 11, 2018.
Sponsored by DigitalOcean: pythonbytes.fm/digitalocean
Special guest Bob Belderbos: @bbelderbos
- “A utility for mocking out the Python Requests library.”
- From Sentry
Example:
import responses import requests @responses.activate def test_simple(): responses.add(responses.GET, '', json={'error': 'not found'}, status=404) resp = requests.get('') assert resp.json() == {"error": "not found"} assert len(responses.calls) == 1 assert responses.calls[0].request.url == '' assert responses.calls[0].response.text == '{"error": "not found"}'
Bob #2: 29 common beginner Python errors on one page
- Decision trees / graphics are nice to digest and concise, it wraps a lot of experience on one slide
- Knowing about common errors can safe you a lot of time (the guide I wish I had when I started coding in Python)
- Reminded me of struggles I had when I started in Python, for example TypeErrors when converting suspected ints to strings, regexes before discovering raw strings
- It made me think of related issues newer Pythonistas face, for example “I am reading a file but getting no input” can be translated to “I am looping over a generator for the second time and don’t get any output”
- Made me realize that some things are subtle, like comparing 3 == “3” or require good knowledge of stdlib (sorted returning new sequence vs inplace sort() for example)
- Made me reflect on how much hand holding you would give your students when teaching. Part of the learning is in the struggle.
- About the source, I like seeing Python being taught in all different kind of domains, in this case biology.
- μMongo is a Python MongoDB ODM.
- It inception comes from two needs:
- the lack of async ODM
- the difficulty to do document (un)serialization with existing ODMs.
- a few design choices:
- Stay close to the standards MongoDB driver to keep the same API when possible: use
find({"field": "value"})like usual but retrieve your data nicely OO wrapped !
- Work with multiple drivers (PyMongo, TxMongo, motor_asyncio and mongomock for the moment)
- Tight integration with Marshmallow serialization library to easily dump and load your data with the outside world
- i18n integration to localize validation error messages
- Free software: MIT license
- Test with 90%+ coverage ;-)
- async / await support through Motor
Brian #4: Basic Statistics in Python: Descriptive Statistics
- Cool use of Python to teach basic statistics topics.
- Includes code snippets to explain different concepts like min, max, mean, median, mode, …
- However, after you understand the math, DON’T write your own functions.
- use built in Python functions and the statistics library built in to Python (or numpy if you are on older Python versions).
Example from article:
sum_score = sum(scores) num_score = len(scores) avg_score = sum_score/num_score avg_score >>> 87.8884184721394
Using built in:
>>> x = (2, 2, 3, 100) >>> min(x), max(x) (2, 100) >>> import statistics as s >>> s.mean(x), s.median(x), s.mode(x) (26.75, 2.5, 2) >>> s.pstdev(x), s.pvariance(x) (42.29287765097097, 1788.6875) >>> s.stdev(x), s.variance(x) (48.835608593184, 2384.9166666666665)
Bob #5: Strings and Character Data in Python
- Everything you need to know to work with strings and more …
- Similar to that great itertools article you shared some weeks ago: exhaustive overview
- Nice re-usable code snippets and explanation of basic concepts, ideal for beginners but you likely will get something out of it, few useful bites:
- Instead of
try int(…) except, you can use
isdigit()on a string
- You can use
isspace()to see if all characters of a nonempty string are whitespace characters (
' ', tab
'\t', and newline
'\n')
- It’s easy to make a header in your Python scripts:
>>>> 'bar'.center(10, '-') '---bar----'
- Replace up till n occurrences:
>>>> 'foo bar foo baz foo qux'.replace('foo', 'grault', 2) 'grault bar grault baz foo qux'
- Strip multiple characters from both ends of a string:
>>>> ''.strip('w.moc') 'realpython'
- Add leading padding to a string with `zfill`:
>>>> '42'.zfill(5) '00042'
- This also reminded me of Python’s polymorphism, for example str.find and str.index work on both strings as well as lists
>>> 'foo bar foo baz foo qux'.index('baz') 12 >>> 'foo bar foo baz foo qux'.split().index('baz') 3 >>> 'foo bar foo baz foo qux'.count('foo') 3 >>> 'foo bar foo baz foo qux'.split().count('foo') 3
Michael #6: PEP 572: Assignment expressions accepted
- Whoa, check out that twitter conversation
- Splits 2 statements into an expressions (so they can be part of list comprehensions, etc).
- Not sure I like it but here you go:
Example:
# Handle a matched regex if (match := pattern.search(data)) is not None: ...
Contrast old and new:
# old if self._is_special: ans = self._check_nans(context=context) if ans: return ans # new if self._is_special and (ans := self._check_nans(context=context)): return ans
Our news:
- Michael: New course coming! Data-driven web apps in Pyramid
- Bob: Be sure to visit PyBites Code Challenges
- Brian: More Test and Code episodes coming! | https://pythonbytes.fm/episodes/show/86/make-your-nosql-async-and-await-able-with-umongo | CC-MAIN-2018-30 | refinedweb | 833 | 61.46 |
Flash.
The ‘f’ word. At least it feels like a dirty word right?
Flash really spiralled out of fashion since Steve Jobs’ famous “Thoughts on Flash” open letter five years ago. Wired posted an article last month titled “Flash.Must.Die”, the Facebook security chief called for its termination, the Occupy Flash movement called for us to eliminate it from our browsers, while the big name browsers themselves starting eliminating it for us.
Well known and respected Flash evangelists took to the wilderness to escape the public Flash-hunt. Others went underground, transitioning to HTML5 and JavaScript, Android or iOS, while hiding their Flash skills deep in their CVs and just occasionally – when they’re sure no-one’s looking – opening up Flash as a little guilty pleasure.
Flash developers who stuck by Flash face the possibility of career skills becoming redundant. You face two options – wait until it’s in demand again (Cobol style!) or reskill now!
I’ll admit my decision a couple of years ago to reskill in Swift wasn’t an easy decision at the time. It felt like I was leaving behind my expertise and starting over.
I have a Flash developer friend Paul, who tells me: “Yeah things are pretty bleak on the Flash front… I am very tempted to get stuck into Swift but have a fear at the back of my head in 5 years time it will become redundant just like happened with Authorware, Director, Flash etc… My other fear is it is too steep a learning curve.”
If you’ve found your way here as a Flash guy, on the run, trying other things and thinking about getting into Swift but perhaps you’re scared, confused, fearful of change, don’t worry, you’re in a safe space. And this is the tutorial for you…
In this tutorial, we’re going to port an ActionScript game called “Flashy Bird” to Swift. You can download the Flash source code for Flashy Bird here. Go ahead, download and run it to see what we’re dealing with.
For simplicity and to keep everything feeling as familiar as possible as we move into new territory, we’re going to use a framework I’ve built called “ActionSwift3”. This framework enables you to use some of the familiar AS3 API, but from built on top of what’s called the `SpriteKit` framework, within Swift.
In ActionSwift3 you’ll find familiar classes such as `MovieClip`, `Sprite`, `SimpleButton`, `TextField`, `Sound`, `EventDispatcher`, the list goes on.
In addition to the API, ActionSwift3 has incorporated much of the syntax and data types of ActionScript. For example, you can use ActionScript’s `int`, `Number`, `Boolean`, as they are simply interpreted as Swift datatypes `Int`, `CGFloat` and `Bool`. Similarly, ActionScript’s `trace’ is simply interpreted as Swift’s global function `print`. You can find more info on ActionSwift3 at its github page and API documentation here.
Now, all of this is intended to help make the transition easier for you initially in a familiar environment and I imagine in time you’ll challenge yourself to become familiar with Swift classes, datatype names and approaches, and potentially leave ActionSwift3 behind. But for now, let’s see how easy it is to port an ActionScript project over to Swift.
Create a new project
If you haven’t downloaded Xcode yet, go ahead and do that, you can find it in the App Store. Open up Xcode and familiarize yourself with the interface.
Go to File>New>Project, iOS>Application>Game and fill in the project fields. Be sure to select Swift and SpriteKit, select Next, choose a path, select Next and your project is ready.
A little housekeeping before we start. The template automatically set up a GameScene.swift and GameScene.sks(sprite kit scene) file. You can go ahead and delete these and select ‘Move to Trash’. Now in the GameViewController file, you can replace everything with a more bare bones approach:
import SpriteKit class GameViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() } override func shouldAutorotate() -> Bool { return false } override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask { return .Portrait } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Release any cached data, images, etc that aren't in use. } override func prefersStatusBarHidden() -> Bool { return true } }
Before we get too deep into coding, quickly set up the same resources used in the Flash file. Here are the resources. Drag the audio files to the `FlappySwift` group, and ensure ‘Copy items if needed’ is checked. Select ‘New Group from Selection’, and purely to keep your files organized, group the audio into a group named ‘Audio’.
Next drag in the ‘images.atlas’ folder into the ‘FlappySwift’ group. This time, this isn’t just for organizational purposes and the folder name isn’t random. Xcode automagically creates a texture atlas for folders with the extension `atlas`, and the `images.atlas` folder is the default texture atlas. Texture atlases are more commonly known as sprite sheets in Flash.
CocoaPods
CocoaPods is a tool for managing third party libraries in your Xcode project. You’re going to use it to import the ActionSwift3 library to the project. Follow the CocoaPods installation instructions here.
Now you have CocoaPods installed, install ActionSwift3:
- Close your FlappySwift project in Xcode.
- Create a file in your main FlappySwift folder(not the inner folder) called ‘Podfile’, and include the following:
source '' use_frameworks! platform :ios, '8.0' pod 'ActionSwift3'
- From the Finder, drag the whole FlappySwift folder(not the inner folder) to Terminal, and type in `pod install`. Give it a few minutes. In addition to installing ActionSwift3 it’s building what’s called a ‘workspace’ for your project that you will need to open from here-on instead of your ‘project’ file.
- That’s it! You should now find a ‘`FlappySwift.xcworkspace` file in your project folder. Open it up.
Now, you’re set to use ActionSwift3!
Find your `GameViewController.swift` file again, and add
import ActionSwift3 to the import statements. You might need to rebuild your project again(⌘ B) for Xcode to recognize this module. Now at the bottom of the viewDidLoad method, add
let stage = Stage(self.view as! SKView) and you’re ready to start adding children to Stage, ActionSwift3 style!
Have a look at the `GameViewController.swift` in the github example app here, to see what sort of familiar classes are available to you, and how you can build up a simple app in ActionSwift3.
Create a Swift class
Let’s return to Flappy Bird now, to look at building something a little more complex in ActionSwift3.
Start off by creating a Swift file to represent the ‘root’ class, called FlappyBird.swift.
Select File>New>File, CocoaTouch Class(which actually means you’re creating a class that subclasses another class) and Next. Type `FlappyBird` in the Class field, subclass `MovieClip` and Language `Swift`.
Now a skeleton of your FlappyBird class should auto-generate. The first thing you may notice is there are no packages. Everything in a target is assumed to be in the same namespace. As ActionSwift3 is stored in a different target, you’ll want to import this target:
import ActionSwift3
…and that’s it! It’s not necessary(nor possible) to import every class.
Do the same for all six classes of the FlappyBird game.
Convert code
Now to convert your code across from ActionScript. Now, much of ActionScript syntax has been ported into ActionSwift3, but there are obviously some obvious differences remain:
- ; The semi-colon is gone in Swift! In fact, it’s just ignored. You can choose to leave them in, but it’s probably a good idea to start training yourself to leave them out.
- new The `new` keyword is not necessary to instantiate a class.
- function->func This is abbreviated as `func` in Swift.
- this->self `this` is called `self` in Swift.
I would suggest that you perform a find and replace on these syntactic differences before copying over code from ActionScript.
More differences require some finesse, here are some to be wary of:
- const Constants in Swift are defined with `let`.
- extends In Swift classes are subclassed using a colon rather than the keyword ‘extends’
- init The constructor of a class in Swift is called the initializer. Replace your constructors with just the keyword `init`.
- strict typing Swift is a type-safe language, meaning that variables must strictly adhere to their data type definition. This even excludes the value of nil – variables must be initialized by the end of the initializer method, or the superclass’s initializer method. (this can take some mental adjustment.)
- optionals How can a variable contain nil then, I hear you ask – this is achieved through a special datatype called an Optional. An Optional is indicated by a question mark (?) after the definition of the variable.
- non-implicit type conversion You’ll find when performing arithmetic between integers and floating point numbers. Leading on from its strict typing philosophy, you’ll need to explicitly convert a data type to be able to perform arithmetic between different data types.
- brackets in if statements In if statements in Swift, round brackets surrounding the condition are optional, and curly brackets around the code block are mandatory(no implicit single line code blocks).
- Return values of functions Are specified with `->` instead of a colon `:`.
- for-loops The c-style for-loop is no longer. Instead, either use a for-in loop looping over every element of an array:
var names = ["Craig","Jemaine","Bret"] for name in names { trace(name) }
Or, if it’s necessary to loop over a range of values, you can instead use a special type called a range:
for i in 0...3 { trace(i) }
- RIP ++ You can no longer increment or decrement a value with the ++ or — operators. Replace these in your code with the clearer +=1 or -=1 operators.
- function parameters Whereas in Flash parameters are identified by the order they’re in and have no external name, the default in Swift is that parameters have an external name. Example in Flash:
var array:Array = ["a","b","c","c","e"]; array.splice(3,1,"d"); trace(array); //a,b,c,d,e
In ActionSwift3, it’s actually much clearer what’s going on:
var array = ["a","b","c","c","e"] array.splice(3,deleteCount:1,values:"d") trace(array) //a,b,c,d,e
You may have noticed the first parameter of splice doesn’t have a parameter name – there is a way in Swift to prevent an obligatory parameter name if it makes more sense, with an underscore before the parameter name in the function definition. eg:
func distanceTo(_ x:Int, _ y:Int) … distanceTo(0,10)
ActionSwift3 uses a combination of the Swift and ActionScript approaches. You can read more about function parameters in Swift here.
Well you’ve just skimmed the surface of some technical differences between Swift and ActionScript. If you’d like to know about some more philosophical differences between the two languages, click here.
Feel free to work through the .as files, converting to Swift as you go. In most cases it’s just a case of slight tweaks to syntax. Or – using the magic of github, here’s one I prepared earlier. You’ll need to run `pod install` to install ActionSwift into the project.
So that’s it Flash guy, you’re on your way to becoming a Swift guy.
And Paul, it might be time to update that old superhero costume!
Thank you Craig,
it’s an amazing, helpful post.
Actually, as a 15 years long Flash developer and artist, my reason no to move to Swift is not that it may be redundant one day, but it’s because it is tied to Apple platforms only. I personally consider Apple one of the worse corporations today. This has nothing to do with their products, but with their policies. They invented closed platforms. They invented fees for developers to release their products. They lied to keep their browser experience lame, in order to cut 30% for each piece of rich experience that must go through the store. The most authoritarian, fascist, exploitative company in IT I have ever witnessed. Of course this is a personal opinion, I do not believe in objectivity. But as such, I will not put my effort, creative power and love for quality on a language that will force me to release my creations on Apple stores only.
All the best for you, and thank you for the generosity in your posts.
Filippo
Thanks for the candour in giving your perspective Pippo, that’s fair enough if you have aversions to the Apple infrastructure! Have you seen by the way that Swift is going open source?
All the best
Interesting. Hopefully it will become a cross-platform development tool. In that case I will start to check it out, since it’s elegance (especially compared to stone-age objective c) it’s evident. So far I keep working in ActionScript for cross-platform apps, and rarely I downgrade myself to JavaScript/Canvas…
Anyway I am subscribed to your blog, you never know what’s going to happen in the future 🙂
Thank you Craig – this is a super blog post and has inspired me to give this Swift malarkey a try though I also seem to be dipping my toes in a few other technologies at the same time.
Awesome, glad you liked it. Enjoy the learning!
Bookmarked this sick page!!
[…] SDK comes with a tutorial for porting your first Flash game, called “Flashy Bird”, into Swift. This is a clever trick: while you remain wrapped in cosy and familiar ActionScript 3 working on […] | https://craiggrummitt.com/2015/08/11/swift-api-for-the-flash-guy/ | CC-MAIN-2020-29 | refinedweb | 2,272 | 64.61 |
In Groovy we can omit the
return keyword at the end of a method, it is optional. It is no problem to leave it in, but we can leave it out without any problems. Since Groovy 1.6 this is even true when the last statement of a method is a conditional statement or a try-catch block.
def simple() { "Hello world" } assert 'Hello world' == simple() def doIt(b) { if (b) { "You are true" } else { "You are false" } } assert 'You are true' == doIt(true) assert 'You are false' == doIt(false) def tryIt(file) { try { new File(file).text } catch (e) { "Received exception: ${e.message}" } finally { println 'Finally is executed but nothing is returned.' 'Finally reached' } } assert 'Received exception: invalidfilename (The system cannot find the file specified)' == tryIt('invalidfilename') // Create new file with the name test. def newFile = new FileWriter('test').withWriter { it.write('file contents') } assert 'file contents' == tryIt('test') | https://blog.mrhaki.com/2009/09/groovy-goodness-optional-return-keyword.html | CC-MAIN-2020-50 | refinedweb | 150 | 66.23 |
Split an email address into its local and domain parts
This was built to grab the name used off of an email address. This library does not perform validation as we retrieve our email addresses from a trusted source.
This was initially written in JavaScript and has been ported to Python.
Install the module with: pip install email_split
from email_split import email_split email = email_split('todd@underdog.io') email.local # todd email.domain # underdog.io
We export the function email_split from our module email_split.
Function that extracts local and domain parts of email address.
Returns:
We chose the names local and domain based off of the RFC specification for mailto.
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Test and lint via ./test.sh.
Licensed under the. | https://pypi.org/project/email_split/ | CC-MAIN-2017-09 | refinedweb | 141 | 68.57 |
Tue Jan 23 15:49:47 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) * dbxread.c (define_symbol): Deal with deftype 'X'. * convex-dep.c (wait): Make it pid_t. * convex-dep.c (comm_registers_info): accept decimal comm register specification, as "i comm 32768". * dbxread.c (process_one_symbol): Make VARIABLES_INSIDE_BLOCK macro say by itself where variables are. Pass it desc. m-convex.h (VARIABLES_INSIDE_BLOCK): Nonzero for native compiler. * m-convex.h (SET_STACK_LIMIT_HUGE): Define. (IGNORE_SYMBOL): Take out #ifdef N_MONPT and put in 0xc4. Fri Jan 19 20:04:15 1990 Jim Kingdon (kingdon at albert.ai.mit.edu) * printcmd.c (print_frame_args): Always set highest_offset to current_offset when former is -1. * dbxread.c (read_struct_type): Print nice error message when encountering multiple inheritance. Thu Jan 18 13:43:30 1990 Jim Kingdon (kingdon at mole.ai.mit.edu) * dbxread.c (read_dbx_symtab): Always treat N_FN as a potential source for a x.o or -lx symbol, ignoring OFILE_FN_FLAGGED. * printcmd.c (print_frame_args): Cast -1 to (CORE_ADDR). * hp300bsd-dep.c (_initialize_hp300_dep): Get kernel_u_addr. m-hp300bsd.h (KERNEL_U_ADDR): Use kernel_u_addr. * infcmd.c (run_command): #if 0 out call to breakpoint_clear_ignore_counts. Thu Jan 11 12:58:12 1990 Jim Kingdon (kingdon at mole) * printcmd.c (print_frame_args) [STRUCT_ARG_SYM_GARBAGE]: Try looking up name of var before giving up & printing '?'. Wed Jan 10 14:00:14 1990 Jim Kingdon (kingdon at pogo) * many files: Move stdio.h before param.h. * sun3-dep.c (store_inferior_registers): Only try to write FP regs #ifdef FP0_REGNUM. Mon Jan 8 17:56:15 1990 Jim Kingdon (kingdon at pogo) * symtab.c: #if 0 out "info methods" code. Sat Jan 6 12:33:04 1990 Jim Kingdon (kingdon at pogo) * dbxread.c (read_struct_type): Set TYPE_NFN_FIELDS_TOTAL from all baseclasses; remove vestigial variable baseclass. * findvar.c (read_var_value): Check REG_STRUCT_HAS_ADDR. printcmd.c (print_frame_args): Check STRUCT_ARG_SYM_GARBAGE. m-sparc.h: Define REG_STRUCT_HAS_ADDR and STRUCT_ARG_SYM_GARBAGE. * blockframe.c (get_frame_block): Subtract one from pc if not innermost frame. Fri Dec 29 15:26:33 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * printcmd.c (print_frame_args): check highest_offset != -1, not i. Thu Dec 28 16:21:02 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * valops.c (value_struct_elt): Clean up error msg. * breakpoint.c (describe_other_breakpoints): Delete extra space before "also set at" and add period at end. Tue Dec 19 10:28:42 1989 Jim Kingdon (kingdon at pogo) * source.c (print_source_lines): Tell user which line number was out of range when printing error message. Sun Dec 17 14:14:09 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * blockframe.c (find_pc_partial_function): Use BLOCK_START (SYMBOL_BLOCK_VALUE (f)) instead of SYMBOL_VALUE (f) to get start of function. * dbxread.c: Make xxmalloc just a #define for xmalloc. Thu Dec 14 16:13:16 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * m68k-opcode.h (fseq & following fp instructions): Change @ to $. Fri Dec 8 19:06:44 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * breakpoint.c (breakpoint_clear_ignore_counts): New function. infcmd.c (run_command): Call it. Wed Dec 6 15:03:38 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * valprint.c: Change it so "array-max 0" means there is no limit. * expread.y (yylex): Change error message "invalid token in expression" to "invalid character '%c' in expression". Mon Dec 4 16:12:54 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * blockframe.c (find_pc_partial_function): Always return 1 for success, 0 for failure, and set *NAME and *ADDRESS to match the return value. * dbxread.c (symbol_file_command): Use perror_with_name on error from stat. (psymtab_to_symtab, add_file_command), core.c (validate_files), source.c (find_source_lines), default-dep.c (exec_file_command): Check for errors from stat, fstat, and myread. Fri Dec 1 05:16:42 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * valops.c (check_field): When following pointers, just get their types; don't call value_ind. Thu Nov 30 14:45:29 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * config.gdb (pyr): New machine. core.c [REG_STACK_SEGMENT]: New code. dbxread.c (process_one_symbol): Cast return from copy_pending to long before casting to enum namespace. infrun.c: Split registers_info into DO_REGISTERS_INFO and registers_info. m-pyr.h, pyr-{dep.c,opcode.h,pinsn.c}: New files. * hp300bsd-dep.c: Stay in sync with default-dep.c. * m-hp300bsd.h (IN_SIGTRAMP): Define. Mon Nov 27 23:48:21 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * m-sparc.h (EXTRACT_RETURN_VALUE, STORE_RETURN_VALUE): Return floating point values in %f0. Tue Nov 21 00:34:46 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * dbxread.c (read_type): #if 0 out code which skips to comma following x-ref. Sat Nov 18 20:10:54 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * valprint.c (val_print): Undo changes of Nov 11 & 16. (print_string): Add parameter force_ellipses. (val_print): Pass force_ellipses true when we stop fetching string before we get to the end, else pass false. Thu Nov 16 11:59:50 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * infrun.c (restore_inferior_status): Don't try to restore selected frame if the inferior no longer exists. * valprint.c (val_print): Rewrite string printing code not to call print_string. * Makefile.dist (clean): Remove xgdb and xgdb.o. Tue Nov 14 12:41:47 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * Makefile.dist (XGDB, bindir, xbindir, install, all): New stuff. Sat Nov 11 15:29:38 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * valprint.c (val_print): chars_to_get: New variable. Thu Nov 9 12:31:47 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * main.c (main): Process "-help" as a switch that doesn't take an argument. Wed Nov 8 13:07:02 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * Makefile.dist (gdb.tar.Z): Add "else true". Tue Nov 7 12:25:14 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * infrun.c (restore_inferior_status): Don't dereference fid if NULL. * config.gdb (sun3, sun4): Accept "sun3" and "sun4". Mon Nov 6 09:49:23 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * Makefile.dist (Makefile): Move comments after commands. * *-dep.c [READ_COFF_SYMTAB]: Pass optional header size to read_section_hdr(). * inflow.c: Include <fcntl.h> regardless of USG. * coffread.c (read_section_hdr): Add optional_header_size. (symbol_file_command): Pass optional header size to read_section_hdr(). (read_coff_symtab): Initialize filestring. * version.c: Change version to 3.4.xxx. * GDB 3.4 released. Sun Nov 5 11:39:01 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * version.c: Change version to 3.4. * symtab.c (decode_line_1): Only skip past "struct" if it is there. * valops.c (value_ind), eval.c (evaluate_subexp, case UNOP_IND): Have "*" <int-valued-exp> return an int, not a LONGEST. * utils.c (fprintf_filtered): Pass arg{4,5,6} to sprintf. * printcmd.c (x_command): Use variable itself rather than treating it as a pointer only if it is a function. (See comment "this makes x/i main work"). * coffread.c (symbol_file_command): Use error for "%s does not have a symbol-table.\n". Wed Nov 1 19:56:18 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * dbxread.c [BELIEVE_PCC_PROMOTION_TYPE]: New code. m-sparc.h: Define BELIEVE_PCC_PROMOTION_TYPE. Thu Oct 26 12:45:00 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * infrun.c: Include <sys/dir.h>. * dbxread.c (read_dbx_symtab, case N_LSYM, case 'T'): Check for enum types and put constants in psymtab. Mon Oct 23 15:02:25 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * dbxread.c (define_symbol, read_dbx_symtab): Handle enum constants (e.g. "b:c=e6,0"). Thu Oct 19 14:57:26 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * stack.c (frame_info): Use FRAME_ARGS_ADDRESS_CORRECT m-vax.h (FRAME_ARGS_ADDRESS_CORRECT): New macro. (FRAME_ARGS_ADDRESS): Restore old meaning. * frame.h (Frame_unknown): New macro. stack.c (frame_info): Check for Frame_unknown return from FRAME_ARGS_ADDRESS. m-vax.h (FRAME_ARGS_ADDRESS): Sometimes return Frame_unknown. * utils.c (fatal_dump_core): Add "internal error" to message. * infrun.c (IN_SIGTRAMP): New macro. (wait_for_inferior): Use IN_SIGTRAMP. m-vax.h (IN_SIGTRAMP): New macro. Wed Oct 18 15:09:22 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * config.gdb, Makefile.dist: Shorten m-i386-sv32.h. * coffread.c (symbol_file_command): Pass 0 to select_source_symtab. Tue Oct 17 12:24:41 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * i386-dep.c (i386_frame_num_args): Take function from m-i386.h file. Check for pfi null. m-i386.h (FRAME_NUM_ARGS): Use i386_frame_num_args. * infrun.c (wait_for_inferior): set stop_func_name to 0 before calling find_pc_partial_function. Thu Oct 12 01:08:50 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * breakpoint.c (_initialize_breakpoint): Add "disa". * Makefile.dist: Add GLOBAL_CFLAGS and pass to readline. * config.gdb (various): "$machine =" -> "machine =". Wed Oct 11 11:54:31 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * inflow.c (try_writing_regs): #if 0 out this function. * main.c (main): Add "-help" option. * dbxread.c (read_dbx_symtab): Merge code for N_FUN with N_STSYM, etc. Mon Oct 9 14:21:55 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * inflow.c (try_writing_regs_command): Don't write past end of struct user. * dbxread.c (read_struct_type): #if 0 out code which checks for bitpos and bitsize 0. * config.gdb: Accept sequent-i386 (not seq386). (symmetry): Set depfile and paramfile. * m-convex.h (IGNORE_SYMBOL): Check for N_MONPT if defined. Thu Oct 5 10:14:26 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * default-dep.c (read_inferior_memory): Put #if 0'd out comment within /* */. Wed Oct 4 18:44:41 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * config.gdb: Change /dev/null to m-i386.h for various 386 machine "opcodefile" entries. * config.gdb: Accept seq386 for sequent symmetry. Mon Oct 2 09:59:50 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * hp300bsd-dep.c: Fix copyright notice. Sun Oct 1 16:25:30 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * Makefile.dist (DEPFILES): Add isi-dep.c. * default-dep.c (read_inferior_memory): Move #endif after else. Sat Sep 30 12:50:16 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * version.c: Change version number to 3.3.xxx. * GDB 3.3 released. * version.c: Change version number to 3.3. * Makefile.dist (READLINE): Add vi_mode.c * config.gdb (i386): Change /dev/null to m-i386.h * config.gdb: Add ';;' before 'esac'. * Makefile.dist (gdb.tar.Z): Move comment above dependency. * dbxread.c (read_ofile_symtab): Check symbol before start of source file for GCC_COMPILED_FLAG_SYMBOL. (start_symtab): Don't clear processing_gcc_compilation. Thu Sep 28 22:30:23 1989 Roland McGrath (roland at hobbes.ai.mit.edu) * valprint.c (print_string): If LENGTH is zero, print "". Wed Sep 27 10:15:10 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * config.gdb: "rm tmp.c" -> "rm -f tmp.c". Tue Sep 26 13:02:10 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * utils.c (_initialize_utils): Use termcap to set lines_per_page and chars_per_line. Mon Sep 25 10:06:43 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * dbxread.c (read_dbx_symtab, N_SOL): Do not add the same file more than once. Thu Sep 21 12:43:18 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * infcmd.c (unset_environment_command): Delete all variables if called with no arg. * remote.c, inferior.h (remote_{read,write}_inferior_memory): New functions. core.c ({read,write}_memory): Use remote_{read,write}_inferior_memory. * valops.c (call_function): When reserving stack space for arguments, call value_arg_coerce. * m-hp9k320.h: define BROKEN_LARGE_ALLOCA. * breakpoint.c (delete_command): Ask for confirmation only when there are breakpoints. * dbxread.c (read_struct_type): If lookup_basetype_type has copied a stub type, call add_undefined_type. * sparc_pinsn.c (compare_opcodes): Check for "1+i" anywhere in args. * val_print.c (type_print_base): Print stub types as "<incomplete type>". Wed Sep 20 07:32:00 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * sparc-opcode.h (swapa): Remove i bit from match. (all alternate space instructions): Delete surplus "foo rs1+0" patterns. * Makefile.dist (LDFLAGS): Set to $(CFLAGS). * remote-multi.shar (remote_utils.c, putpkt): Change csum to unsigned. Tue Sep 19 14:15:16 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * sparc-opcode.h: Set i bit in lose for many instructions which aren't immediate. * stack.c (print_frame_info): add "func = 0". Mon Sep 18 16:19:48 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * sparc-opcode.h (mov): Add mov to/from %tbr, %psr, %wim. * sparc-opcode.h (rett): Fix notation to use suggested assembler syntax from architecture manual. * symmetry-dep.c (I386_REGNO_TO_SYMMETRY): New macro. (i386_frame_find_saved_regs): Use I386_REGNO_TO_SYMMETRY. Sat Sep 16 22:21:17 1989 Jim Kingdon (kingdon at spiff) * remote.c (remote_close): Set remote_desc to -1. * gdb.texinfo (Output): Fix description of echo to match reality and ANSI C. Fri Sep 15 14:28:59 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * symtab.c (lookup_symbol): Add comment about "asm". * sparc-pinsn.c: Use NUMOPCODES. * sparc-opcode.h (NUMOPCODES): Use sparc_opcodes[0] not *sparc_opcodes. Thu Sep 14 15:25:20 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * dbxread.c (xxmalloc): Print error message before calling abort(). * infrun.c (wait_for_inferior): Check for {stop,prev}_func_name null before passing to strcmp. Wed Sep 13 12:34:15 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * sparc-opcode.h: New field delayed. sparc-pinsn.c (is_delayed_branch): New function. (print_insn): Check for delayed branches. * stack.c (print_frame_info): Use misc_function_vector in case where ar truncates file names. Tue Sep 12 00:16:14 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * convex-dep.c (psw_info): Move "struct pswbit *p" with declarations. Mon Sep 11 14:59:57 1989 Jim Kingdon (kingdon at spiff) * convex-dep.c (core_file_command): Delete redundant printing of "Program %s". * m-convex.h (ENTRY_POINT): New macro. * m-convex.h (FRAME_CHAIN_VALID): Change outside_first_object_file to outside_startup_file * main.c: #if 0 out catch_termination and related code. * command.c (lookup_cmd_1): Consider underscores part of command names. Sun Sep 10 09:20:12 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * printcmd.c: Change asdump_command to disassemble_command (_initialize_printcmd): Change asdump to diassemble. * main.c (main): Exit with code 0 if we hit the end of a batch file. * Makefile.dist (libreadline.a): Fix syntax of "CC=${CC}". Sat Sep 9 01:07:18 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * values.c (history_info): Renamed to value_history_info. Command renamed to "info value" (with "info history" still accepted). * sparc-pinsn.c (print_insn): Extend symbolic address printing to cover "sethi" following by an insn which uses 1+i. Fri Sep 8 14:24:01 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * m-hp9k320.h, m-hp300bsd.h, m-altos.h, m-sparc.h, m-sun3.h (READ_GDB_SYMSEGS): Remove. dbxread.c [READ_GDB_SYMSEGS]: Remove code to read symsegs. * sparc-pinsn.c (print_insn): Detect "sethi-or" pairs and print symbolic address. * sparc-opcode.h (sethi, set): Change lose from 0xc0000000 to 0xc0c00000000. * remote.c (remote_desc): Initialize to -1. * Makefile.dist (libreadline.a): Pass CC='${CC}' to readline makefile. Thu Sep 7 00:07:17 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * dbxread.c (read_struct_type): Check for static member functions. values.c, eval.c, valarith.c, valprint.c, valops.c: Merge changes from Tiemann for static member functions. * sparc-opcode.h (tst): Fix all 3 patterns. * Makefile.dist (gdb1): New rule. * sparc-opcode.h: Change comment about what the disassembler does with the order of the opcodes. * sparc-pinsn.c (compare_opcodes): Put 1+i before i+1. Also fix mistaken comment about preserving order of original table. * sparc-opcode.h (clr, mov): Fix incorrect lose entries. * m-symmetry.h (FRAME_NUM_ARGS): Add check to deal with code that GCC sometimes generates. * config.gdb: Change all occurances of "skip" to "/dev/null". * README (about languages other than C): Update comments about Pascal and FORTRAN. * sparc-opcode.h (nop): Change lose from 0xae3fffff to 0xfe3fffff. * values.c (value_virtual_fn_field): #if 0-out assignment to VALUE_TYPE(vtbl). Wed Sep 6 12:19:22 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * utils.c (fatal_dump_core): New function. Makefile.dist (MALLOC_FLAGS): use -Dbotch=fatal_dump_core Tue Sep 5 15:47:18 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * breakpoint.c (enable_command): With no arg, enable all bkpts. * Makefile.dist (Makefile): Remove \"'s around $(MD). * Makefile.dist: In "cd readline; make . . ." change first SYSV_DEFINE to SYSV. * m68k-pinsn.c (_initialize_pinsn): Use alternate assembler syntax #ifdef HPUX_ASM Sat Sep 2 23:24:43 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * values.c (history_info): Don't check num_exp[0] if num_exp is nil (just like recent editing_info change). Fri Sep 1 19:19:01 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * gdb.texinfo (inc-history, inc-readline): Copy in the inc-* files because people might not have makeinfo. * README (xgdb): Strengthen nasty comments. * gdb.texinfo: Change @setfilename to "gdb.info". Thu Aug 31 17:23:50 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * main.c (editing_info): Don't check arg[0] if arg is null. * m-vax.h: Add comment about known sigtramp bug. * sun3-dep.c, sparc-dep.c (IS_OBJECT_FILE, exec_file_command): Get right text & data addresses for .o files. Wed Aug 30 13:54:19 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * utils.c (tilde_expand): Remove function (it's in readline). * sparc-opcode.h (call): Change "8" to "9" in first two patterns (%g7->%o7). Tue Aug 29 16:44:41 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * printcmd.c (whatis_command): Change 4th arg to type_print from 1 to -1. Mon Aug 28 12:22:41 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * dbxread.c (psymtab_to_symtab_1): In "and %s ..." change pst->filename to pst->dependencies[i]->filename. * blockframe.c (FRAMELESS_LOOK_FOR_PROLOGUE): New macro made from FRAMELESS_FUNCTION_INVOCATION from m-sun3.h except that it checks for zero return from get_pc_function_start. m-hp9k320.h, m-hp300bsd.h, m-i386.h, m-isi.h, m-altos.h, m-news.h, m-sparc.h, m-sun2.h, m-sun3.h, m-symmetry.h (FRAMELESS_FUNCTION_INVOCATION): Use FRAMELESS_LOOK_FOR_PROLOGUE. * dbxread.c (read_struct_type): Give warning and ignore field if bitpos and bitsize are zero. Sun Aug 27 04:55:20 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * dbxread.c (psymtab_to_symtab{,_1}): Print message about reading in symbols before reading stringtab, not after. Sat Aug 26 02:01:53 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * dbxread.c (IS_OBJECT_FILE, ADDR_OF_TEXT_SEGMENT): New macros. (read_dbx_symtab): Use text_addr & text_size to set end_of_text_addr. (symbol_file_command): pass text_addr & text_size to read_dbx_symtab. Fri Aug 25 23:08:13 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * valprint.c (value_print): Try to give the name of function pointed to when printing a function pointer. Thu Aug 24 23:18:40 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * core.c (xfer_core_file): In cases where MEMADDR is above the largest address that makes sense, set i to len. Thu Aug 24 16:04:17 1989 Roland McGrath (roland at hobbes.ai.mit.edu) * valprint.c (print_string): New function to print a character string, doing array-max limiting and repeat count processing. (val_print, value_print): Use print_string. (REPEAT_COUNT_THRESHOLD): New #define, the max number of elts to print without using a repeat count. Set to ten. (value_print, val_print): Use REPEAT_COUNT_THRESHOLD. * utils.c (printchar): Use {fputs,fprintf}_filtered. * valprint.c (val_print): Pass the repeat count arg to the fprintf_filtered call for "<repeats N times>" messages. Wed Aug 23 22:53:47 1989 Roland McGrath (roland at hobbes.ai.mit.edu) * utils.c: Include <pwd.h>. * main.c: Declare free. Wed Aug 23 05:05:59 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * utils.c, defs.h: Add tilde_expand. source.c (directory_command), main.c (cd_command), main.c (set_history_filename), dbxread.c (symbol_file_command), coffread.c (symbol_file_command), dbxread.c (add_file_command), symmisc.c (print_symtabs), *-dep.c (exec_file_command, core_file_command), main.c (source_command): Use tilde_expand. * dbxread.c (read_type): When we get a cross-reference, resolve it immediately if possible, only calling add_undefined_type if necessary. * gdb.texinfo: Uncomment @includes and put comment at start of file telling people to use makeinfo. * valprint.c (type_print_base): Print the right thing for bitfields. * config.gdb (sun3os3): Set paramfile and depfile. Tue Aug 22 05:38:36 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * dbxread.c (symbol_file_command): Pass string table size to read_dbx_symtab(). (read_dbx_symtab): Before indexing into string table, check string table index for reasonableness. (psymtab_to_symtab{,_1}, read_ofile_symtab): Same. Tue Aug 22 04:04:39 1989 Roland McGrath (roland at hobbes.ai.mit.edu) * m68k-pinsn.c: Replaced many calls to fprintf and fputs with calls to fprintf_filtered and fputs_filtered. (print_insn_arg): Use normal MIT 68k syntax for postincrement, predecrement, and register indirect addressing modes. Mon Aug 21 10:08:02 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * main.c (initialize_signals): Set signal handler for SIGQUIT and SIGHUP to do_nothing. * ns32k-opcode.h (ord): Change 1D1D to 1D2D. * ns32k-pinsn.c (print_insn_arg, print_insn): Handle index bytes correctly. * ns32k-opcode.h: Add comments. * dbxread.c (read_type): Put enum fields in type.fields in order that they were found in the debugging symbols (not reverse order). Sun Aug 20 21:17:13 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * main.c (source_command): Read .gdbinit if run without argument. * source.c (directory_command): Only print "foo already in path" if from_tty. * version.c: Change version number to 3.2.xxx Sat Aug 19 00:24:08 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * m-news.h: Define HAVE_WAIT_STRUCT. * m-isi.h, isi-dep.c: Replace with new version from Adam de Boor. config.gdb: Remove isibsd43. * main.c (catch_termination): Don't say we have written .gdb_history until after we really have. * convex-dep.c (attach): Add "sleep (1)". (write_vector_register): Use "LL" with long long constant. (wait): Close comment. (wait): Change "unix 7.1 bug" to "unix 7.1 feature" & related changes in comment. (scan_stack): And fp with 0x80000000 in while loop test. (core_file_command): Move code to set COREFILE. (many places): Change printf to printf_filtered. (psw_info): Allow argument giving value to print as a psw. (_initialize_convex_dep): Update docstrings. * m-convex.h (WORDS_BIG_ENDIAN): Correct typo ("WRODS") define NO_SIGINTERRUPT. define SET_STACK_LIMIT_HUGE. add "undef BUILTIN_TYPE_LONGEST" before defining it. Use "LL" after constants in CALL_DUMMY. * dbxread.c: In the 3 places it says error "ridiculous string table size"... delete extra parameter to error. * dbxread.c (scan_file_globals): Check for FORTRAN common block. Allow multiple references for the sake of common blocks. * main.c (initialize_main): Set history_filename to include current directory. * valprint.c (decode_format): Don't return a defaulted size field if osize is zero. * gdb.texinfo (Compilation): Update information on -gg symbols. Document problem with ar. Fri Aug 18 19:45:20 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * valprint.c (val_print, value_print): Add "<repeats %d times>" code. Also put "..." outside quotes for strings. * main.c (initialize_main): Add comment about history output file being different from history input file. * m-newsos3.h: Undefine NO_SIGINTERRUPT. Rearrange a few comments. * m-newsos3.h (REGISTER_U_ADDR): Use new version from Hikichi. * sparc-opcode.h: Add comment clarifying meaning of the order of the entries in sparc_opcodes. * eval.c (evaluate_subexp, case UNOP_IND): Deal with deferencing things that are not pointers. * valops.c (value_ind): Make dereferencing an int give a LONGEST. * expprint.c (print_subexp): Add (int) cast in OP_LAST case. * dbxread.c (read_array_type): Set lower and upper if adjustable. * symtab.c (lookup_symbol): Don't abort if symbol found in psymtab but not in symtab. Thu Aug 17 15:51:20 1989 Randy Smith (randy at hobbes.ai.mit.edu) * config.gdb: Changed "Makefile.c" to "Makefile.dist". Thu Aug 17 01:58:04 1989 Roland McGrath (roland at apple-gunkies.ai.mit.edu) * sparc-opcode.h (or): Removed incorrect lose bit 0x08000000. [many]: Changed many `lose' entries to have the 0x10 bit set, so they don't think %l0 is %g0. Wed Aug 16 00:30:44 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * m-symmetry.h (STORE_STRUCT_RETURN): Also write reg 0. (EXTRACT_RETURN_VALUE): Call symmetry_extract_return_value. symmetry-dep.c (symmetry_extract_return_value): New fn. * main.c (symbol_completion_function): Deal with changed result_list from lookup_cmd_1 for ambiguous return. command.c (lookup_cmd): Same. * inflow.c [TIOCGETC]: Move #include "param.h" back before system #includes. Change all #ifdef TIOCGETC to #if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN) m-i386-sysv3.2.h, m-i386gas-sysv3.2.h: Remove "#undef TIOCGETC" and add "#define TIOCGETC_BROKEN". * command.c (lookup_cmd_1): Give the correct result_list in the case of an ambiguous return where there is a partial match (e.g. "info a"). Add comment clarifying what is the correct result_list. * gdb.texinfo (GDB History): Document the two changes below. * main.c (command_line_input): Make history expansion not just occur at the beginning of a line. * main.c (initialize_main): Make history expansion off by default. * inflow.c: Move #include "param.h" after system #includes. * i386-dep.c (i386_float_info): Use U_FPSTATE macro. * m-i386-sysv3.2.h, m-i386gas-sysv3.2.h: New files. Makefile.dist, config.gdb: Know about these new files. Tue Aug 15 21:36:11 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * symtab.c (lookup_struct_elt_type): Use type_print rather than assuming type has a name. Tue Aug 15 02:25:43 1989 Roland McGrath (roland at apple-gunkies.ai.mit.edu) * sparc-opcode.h (mov): Removed bogus "or i,0,d" pattern. * sparc-opcode.h (mov, or): Fixed incorrect `lose' members. * sparc-dep.c: Don't include "sparc-opcode.h". (skip_prologue, isanulled): Declare special types to recognize instructions, and use them. * sparc-pinsn.c (print_insn): Sign-extend 13-bit immediate args. If they are less than +9, print them in signed decimal instead of unsigned hex. * sparc-opcode.h, sparc-pinsn.c: Completely rewritten to share an opcode table with gas, and thus produce disassembly that looks like what the assembler accepts. Tue Aug 15 16:20:52 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * symtab.c (find_pc_psymbol): Move best_pc=psymtab->textlow-1 after test for psymtab null. * main.c (editing_info): Remove variable retval. * config.gdb (sun3, isi): Comment out obsolete message about telling it whether you have an FPU (now that it detects it). * config.gdb (sun3): Accept sun3os3. * m68k-insn.h: Include <signal.h>. * m68k-pinsn.h (convert_{to,from}_68881): Add have_fpu code * m-newsos3.h: Undefine USE_PCB. That code didn't seem to work. * sparc-dep.c: Put in insn_fmt and other stuff from the old sparc-opcode.h. * sparc-opcode.h, sparc-pinsn.c: Correct copyright notice. * sparc-opcode.h, sparc-pinsn.c: Replace the old ones with the new ones by roland. Tue Aug 15 02:25:43 1989 Roland McGrath (roland at apple-gunkies.ai.mit.edu) * Makefile.dist: Don't define CC at all. * Makefile.dist (Makefile): Remove tmp.c after preprocessing. Use $(MD) instead of M_MAKEDEFINE in the cc command. * Makefile.dist: Don't define RL_LIB as "${READLINE}/libreadline.a", since READLINE is a list of files. Mon Aug 14 23:49:29 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * main.c (print_version): Change 1988 to 1989. * main.c (copying_info, initialize_main): Remove #if 0'd code. Tue Aug 1 14:44:56 1989 Hikichi (hikichi at sran203) * m-newsos3.h (NO_SIGINTERRUPT): have SIGINTERRUPT on NEWS os 3. * m-news.h(FRAME_FIND_SAVED_REGS): use the sun3's instead of old one. Mon Aug 14 15:27:01 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * m-news.h, m-newsos3.h, news-dep.c: Merge additional changes by Hikichi (ChangeLog entries above). * Makefile.dist (READLINE): List readline files individually so we don't accidently get random files from the readline directory. * m-news.h (STORE_RETURN_VALUE, EXTRACT_RETURN_VALUE): Expect floating point returns to be in fp0. * gdb.texinfo (Format options): New node. * gdb.texinfo: Comment out "@include"s until bfox fixes the readline & history docs. * dbxread.c (read_addl_syms): Set startup_file_* if necessary at the end (as well as when we hit ".o"). * printcmd.c (decode_format): Set val.format & val.size to '?' at start and set defaults at end. * symtab.c (decode_line_1): Check for class_name null. * valops.c: Each place where it compares against field names, check for null field names. (new t_field_name variables). * utils.c (fputs_filtered): Check for linebuffer null before checking whether to call fputs. Remove later check for linebuffer null. Sun Aug 13 15:56:50 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * m-isi.h, m-sun3.h ({PUSH,POP}_FP_REGS): New macros. m-sun3.h (NUM_REGS): Conditionalize on FPU. config.gdb (sun3, isi): Add message about support for machines without FPU. * main.c (catch_termination, initialize_signals): new functions. * main.c (editing_info): Add "info editing n" and "info editing +". Rewrite much of this function. gdb.texinfo (GDB Readline): Document it. * values.c (history_info): Add "info history +". Also add code to do "info history +" when command is repeated. gdb.texinfo (Value History): Document "info history +". * expprint.c (print_subexp): Add OP_THIS to case stmt. * config.gdb (sun4os4): Put quotes around make define. * config.gdb: Canonicalize machine name at beginning. Sat Aug 12 00:50:59 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * config.gdb: define M_MAKEDEFINE Makefile (Makefile, MD): Be able to re-make Makefile. * main.c (command_line_input): Add comments to the command history. * Makefile.dist (Makefile): Add /bin/false. Fri Aug 11 14:35:33 1989 Jim Kingdon (kingdon at spiff) * Makefile.dist: Comment out .c.o rule and add TARGET_ARCH. * m-altos.h: Include sys/page.h & sys/net.h * m-altos.h (FRAME_CHAIN{,_VALID}): Use outside_startup_file. * config.gdb (altos, altosgas): Add M_SYSV & M_BSD_NM and remove M_ALLOCA=alloca.o from makedefine. * coffread.c (complete_symtab): Change a_entry to entry. * m-altosgas.h: New file. * m-symmetry (REGISTER_BYTE): Fix dumb mistake. Fri Aug 11 06:39:49 1989 Roland McGrath (roland at hobbes.ai.mit.edu) * utils.c (set_screensize_command): Check for ARG being nil, since that's what execute_command will pass if there's no argument. * expread.y (yylex): Recognize "0x" or "0X" as the beginning of a number. Thu Aug 10 15:43:12 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * config.gdb, Makefile.dist: Rename Makefile.c to Makefile.dist. * m-altos.h: Add comment about porting to USGR2. * config.gdb (sparc): Add -Usparc. Wed Aug 9 14:20:39 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * m-sun3os4.h: Define BROKEN_LARGE_ALLOCA. * values.c (modify_field): Check for value too large to fit in bitfield. * utils.c (fputs_filtered): Allow LINEBUFFER to be NULL. * breakpoint.c (condition_command): Check for attempt to specify non-numeric breakpoint number. * config.gdb, Makefile, m-altos.h, altos-dep.c: Merge Altos port. * README: Change message about editing Makefile. * config.gdb: Edit Makefile. Copied Makefile to Makefile.c and changed to let config.gdb run us through the C preprocessor. * expread.y (yylex): Test correctly for definition of number. Wed Aug 9 11:56:05 1989 Randy Smith (randy at hobbes.ai.mit.edu) * dbxread.c (read_dbx_symtab): Put bracketing of entry point in test case for .o symbols so that it will be correct even without debugging symbols. (end_psymtab): Took bracketing out. * blockframe.c (outside_startup_file): Reverse the sense of the return value to make the functionality implied by the name correct. Tue Aug 8 11:48:38 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * coffread.c (symbol_file_command): Do not assume presence of a.out header. * blockframe.c: Replace first_object_file_end with startup_file_{start,end} (outside_startup_file): New function. dbxread.c (read_addl_syms, read_dbx_symtab, end_psymbol): set startup_file_*. Delete first_object_file_end code. Add entry_point and ENTRY_POINT coffread.c (complete_symtab): Set startup_file_*. (first_object_file_end): Add as static. m-*.h (FRAME_CHAIN, FRAME_CHAIN_VALID): Call outside_startup_file instead of comparing with first_object_file_end. * breakpoint.c (breakpoint_1): Change -1 to (CORE_ADDR)-1. * config.gdb (i386, i386gas): Add missing quotes at end of "echo" * source.c (directory_command): Add dont_repeat (); Mon Aug 7 18:03:51 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * dbxread.c (read_addl_syms): Change strcmp to strncmp and put 3rd arg back. * command.h (struct cmd_list_element): Add comment clarifying purpose of abbrev_flag. Mon Aug 7 12:51:03 1989 Randy Smith (randy at hobbes.ai.mit.edu) * printcmd.c (_initialize_printcmd): Changed "undisplay" not to have abbrev flag set; it isn't an abbreviation of "delete display", it's an alias. Mon Aug 7 00:25:15 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * symtab.c (lookup_symtab_1): Remove filematch (never used). * expread.y [type]: Add second argument to 2 calls to lookup_member_type which were missing them. * dbxread.c (symbol_file_command): Add from_tty arg. Check it before calling query. * infcmd.c (tty_command): Add from_tty arg. * eval.c (evaluate_subexp): Remove 3rd argument from calls to value_x_unop. * dbxread.c (read_addl_syms): Remove 3rd argument from call to strcmp. * gdb.texinfo (Command editing): @include inc-readline.texinfo and inc-history.texinfo and reorganize GDB-specific stuff. * Makefile: Add line MAKE=make. * README (second paragraph): Fix trivial errors. * dbxread.c (read_struct_type): Make sure p is initialized. * main.c (symbol_completion_function): Complete correctly on the empty string. Sun Aug 6 21:01:59 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * symmetry-dep.c: Remove "long" from definition of i386_follow_jump. * gdb.texinfo (Backtrace): Document "where" and "info stack". * dbxread.c (cleanup_undefined_types): Strip off "struct " or "union " from type names before doing comparison Sat Aug 5 02:05:36 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * config.gdb (i386, i386gas): Improve makefile editing instructions. * Makefile: Fix typo in CLIBS for SYSV. * dbxread.c (read_dbx_symtab): Deal with N_GSYM typedefs. * dbxread.c (add_file_command): Do not free name. We didn't allocate it; it just points into arg_string. * Makefile, m-*.h: Change LACK_VPRINTF to HAVE_VPRINTF. Fri Jul 28 00:07:48 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * valprint.c (val_print): Made sure that all returns returned a value (usually 0, indicating no memory printed). * core.c (read_memory): Changed "return" to "return 0". * expread.y (parse_number): Handle scientific notation when the string does not contain a '.'. Thu Jul 27 15:14:03 1989 Randy Smith (randy at hobbes.ai.mit.edu) * infrun.c (signals_info): Error if signal number passed is out of bounds. * defs.h: Define alloca to be __builtin_alloca if compiling with gcc and localized inclusion of alloca.h on the sparc with the other alloca stuff. * command.c: Doesn't need to include alloca.h on the sparc; defs.h does it for you. * printcmd.c (print_frame_args): Changed test for call to print_frame_nameless_args to check i to tell if any args had been printed. Thu Jul 27 04:40:56 1989 Roland McGrath (roland at hobbes.ai.mit.edu) * blockframe.c (find_pc_partial_function): Always check that NAME and/or ADDRESS are not nil before storing into them. Wed Jul 26 23:41:21 1989 Roland McGrath (roland at hobbes.ai.mit.edu) * m-newsos3.h: Define BROKEN_LARGE_ALLOCA. * dbxread.c (symbol_file_command, psymtab_to_symtab): Use xmalloc #ifdef BROKEN_LARGE_ALLOCA. Tue Jul 25 16:28:18 1989 Jay Fenlason (hack at apple-gunkies.ai.mit.edu) * m68k-opcode.h: moved some of the fmovem entries so they're all consecutive. This way the assembler doesn't bomb. Mon Jul 24 22:45:54 1989 Randy Smith (randy at hobbes.ai.mit.edu) * symtab.c (lookup_symbol): Changed error to an informational (if not very comforting) message about internal problems. This will get a null symbol returned to decode_line_1, which should force things to be looked up in the misc function vector. Wed Jul 19 13:47:34 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * symtab.c (lookup_symbol): Changed "fatal" to "error" in external symbol not found in symtab in which it was supposed to be found. This can be reached because of a bug in ar. Tue Jul 18 22:57:43 1989 Randy Smith (roland at hobbes.ai.mit.edu) * m-news.h [REGISTER_U_ADDR]: Decreased the assumed offset of fp0 by 4 to bring it into (apparently) appropriate alignment with reality. Tue Jul 18 18:14:42 1989 Randy Smith (randy at hobbes.ai.mit.edu) * Makefile: pinsn.o should depend on opcode.h * m68k-opcode.h: Moved fmovemx with register lists to before other fmovemx. Tue Jul 18 11:21:42 1989 Jim Kingdon (kingdon at susie) * Makefile, m*.h: Only #define vprintf (to _doprnt or printf, depends on the system) if the library lacks it (controlled by LACK_VPRINTF_DEFINE in makefile). Unpleasant, but necessary to make this work with the GNU C library. Mon Jul 17 15:17:48 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * breakpoint.c (breakpoint_1): Change addr-b->address to b->address-addr. Sun Jul 16 16:23:39 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * eval.c (evaluate_subexp): Change error message printed when right operand of '@' is not an integer to English. * infcmd.c (registers_info): Fix call to print_spaces_filtered to specify right # of arguments. * gdb.texinfo (Command Editing): Document info editing command. * coffread.c (read_file_hdr): Add MC68MAGIC. * source.c (select_source_symtab): Change MAX to max. Fri Jul 14 21:19:11 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * infcmd.c (registers_info): Clean up display to look good with long register names, to say "register" instead of "reg", and to put the "relative to selected stack frame" bit at the top. Fri Jul 14 18:23:09 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * dbxread.c (record_misc_function): Put parens around | to force correct evaluation. Wed Jul 12 12:25:53 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * m-newsos3, m-news, infrun.c, Makefile, config.gdb, news-dep.c: Merge in Hikichi's changes for Sony/News-OS 3 support. Tue Jul 11 21:41:32 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * utils.c (fputs_filtered): Don't do any filtering if output is not to stdout, or if stdout is not a tty. (fprintf_filtered): Rely on fputs_filtered's check for whether to do filtering. Tue Jul 11 00:33:58 1989 Randy Smith (randy at hobbes.ai.mit.edu) * GDB 3.2 Released. * valprint.h: Deleted. * utils.c (fputs_filtered): Don't do any filtering if filtering is disabled (lines_per_page == 0). Mon Jul 10 22:27:53 1989 Randy Smith (roland at hobbes.ai.mit.edu) * expread.y [typebase]: Added "unsigned long int" and "unsigned short int" to specs. Mon Jul 10 21:44:55 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * main.c (main): Make -cd use cd_command to avoid current_directory with non-absolute pathname. Mon Jul 10 00:34:29 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * dbxread.c (symbol_file_command): Catch errors from stat (even though they should never happen). * source.c (openp): If the path is null, use the current directory. * dbxread.c (read_dbx_symtab): Put N_SETV symbols into the misc function vector ... (record_misc_function): ... as data symbols. * utils.c (fprintf_filtered): Return after printing if we aren't going to do filtering. * Makefile: Added several things for make clean to take care of. * expread.y: Lowered "@" in precedence below +,-,*,/,%. * eval.c (evaluate_subexp): Return an error if the rhs of "@" isn't integral. * Makefile: Added removal of core and gdb[0-9] files to clean target. * Makefile: Made a new target "distclean", which cleans things up correctly for making a distribution. Sun Jul 9 23:21:27 1989 Randy Smith (randy at hobbes.ai.mit.edu) * dbxread.c: Surrounded define of gnu symbols with an #ifndef NO_GNU_STABS in case you don't want them on some machines. * m-npl.h, m-pn.h: Defined NO_GNU_STABS. Sun Jul 9 19:25:22 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * utils.c (fputs_filtered): New function. (fprintf_filtered): Use fputs_filtered. utils.c (print_spaces_filtered), command.c (help_cmd,help_cmd_list), printcmd.c (print_frame_args), stack.c (print_block_frame_locals, print_frame_arg_vars), valprint.c (many functions): Use fputs_filtered instead of fprintf_filtered to avoid arbitrary limit. * utils.c (fprintf_filtered): Fix incorrect comment. Sat Jul 8 18:12:01 1989 Randy Smith (randy at hobbes.ai.mit.edu) * valprint.c (val_print): Changed assignment of pretty to use prettyprint as a conditional rather than rely on values of the enum. * Projects: Cleaned up a little for release. * main.c (initialize_main): Initialize rl_completion_entry_function instead of completion_entry_function. * Makefile: Modified to use the new readline library setup. * breakpoint.c (break_command_1, delete_breakpoint, enable_breakpoint, disable_breakpoint): Put in new printouts for xgdb usage triggered off of xgdb_verbose. * main.c (main): Added check for flag to set xgdb_verbose. * stack.c (frame_command): Set frame_changed when frame command used. Fri Jul 7 16:20:58 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * Remove valprint.h and move contents to value.h (more logical). Fri Jul 7 02:28:06 1989 Randall Smith (randy at rice-chex) * m68k-pinsn.c (print_insn): Included a check for register list; if there is one, make sure to start p after it. * breakpoint.c (break_command_1, delete_breakpoint, enable_breakpoint, disable_breakpoint): #ifdef'd out changes below; they produce unwanted output in gdb mode in gnu-emacs. * gdb.texinfo: Spelled. Also removed index references from command editing section; the relevance/volume ratio was too low. Removed all references to the function index. * ns32k-opcode.h, ns32k-pinsn.c: Backed out changes of June 24th; haven't yet received legal papers. * .gdbinit: Included message telling the user what it is doing. * symmetry-dep.c: Added static decls for i386_get_frame_setup, i386_follow_jump. * values.c (unpack_double): Added a return (double)0 at the end to silence a compiler warning. * printcmd.c (containing_function_bounds, asdump_command): Created to dump the assembly code of a function (support for xgdb and a useful hack). (_initialize_printcmd): Added this to command list. * gdb.texinfo [Memory]: Added documentation for the asdump command. * breakpoint.c (break_command_1, delete_breakpoint, enable_breakpoint, disable_breakpoint): Added extra verbosity for xgdb conditionalized on the new external frame_full_file_name. * source.c (identify_source_line): Increase verbosity of fullname prointout to include pc value. * stack.c: Added a new variable; "frame_changed" to indicate when a frame has been changed so that gdb can print out a frame change message when the frame only changes implicitly. (print_frame_info): Check the new variable in determining when to print out a new message and set it to zero when done. (up_command): Increment it. (down_command): Decrement it. * m68k-pinsn.c (print_insn_arg [lL]): Modified cases for register lists to reset the point to point to after the word from which the list is grabbed *if* that would cause point to point farther than it currently is. Thu Jul 6 14:28:11 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * valprint.c (val_print, value_print): Add parameter to control prettyprinting. valprint.h: New file containing constants used for passing prettyprinting parameter to val{,ue}_print. expprint.c, infcmd.c, printcmd.c, valprint.c, values.c: Change all calls to val{,ue}_print to use new parameter. Mon Jul 3 22:38:11 1989 Randy Smith (randy at apple-gunkies.ai.mit.edu) * dbxread.c (,process_one_symbol): Moved extern declaration for index out of function to beginning of file. Mon Jul 3 18:40:14 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) * gdb.texinfo (Registers): Add "ps" to list of standard registers. Sun Jul 2 23:13:03 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * printcmd.c (enable_display): Change d->next to d = d->next so that "enable display" without args works. Fri Jun 30 23:42:04 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * source.c (list_command): Made error message given when no symtab is loaded clearer. * valops.c (value_assign): Make it so that when assigning to an internal variable, the type of the assignment exp is the type of the value being assigned. Fri Jun 30 12:12:43 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * main.c (verbose_info): Created. (initialize_main): Put "info verbose" into command list. * utils.c (screensize_info): Created. (_initialize_utils): Defined "info screensize" as a normal command. * valprint.c (format_info): Added information about maximum number of array elements to function. * blockframe.c (find_pc_partial_function): Again. * blockframe.c (find_pc_partial_function): Replaced a "shouldn't happen" (which does) with a zero return. * main.c (dont_repeat): Moved ahead of first use. Thu Jun 29 19:15:08 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * vax-opcode.h: Made minor modifications (moved an instruction and removed a typo) to bring this into accord with gas' table; also changed copyright to reflect it being part of both gdb and gas. * m68k-opcode.h: Added whole scads and bunches of new stuff for the m68851 and changed the coptyrightto recognize that the file was shared between gdb and gas. * main.c (stop_sig): Use "dont_repeat ()" instead of *line = 0; * core.c (read_memory): Don't do anything if length is 0. * Makefile: Added readline.c to the list of files screwed by having the ansi ioctl.h compilation with gcc. * config.gdb: Added sun4os3 & sun4-os3 as availible options. Wed Jun 28 02:01:26 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) * command.c (lookup_cmd): Add ignore_help_classes argument. (lookup_cmd_1): Add ignore_help_classes argument. command.c, main.c: Change callers of lookup_cmd{,_1} to supply value for ignore_help_classes. Tue Jun 27 18:01:31 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * utils.c (print_spaces_filtered): Made more efficient. * defs.h: Declaration. * valprint.c (val_print): Used in a couple of new places. Mon Jun 26 18:27:28 1989 Randall Smith (randy at gluteus.ai.mit.edu) * m68k-pinsn.c (print_insn_arg ['#', '^']): Combined them into one case which always gets the argument from the word immediately following the instruction. (print_insn_arg ["[lL]w"]): Make sure to always get the register mask from the word immediately following the instruction. Sun Jun 25 19:14:56 1989 Randall Smith (randy at galapas.ai.mit.edu) * Makefile: Added hp-include back in as something to distribute. * stack.c (print_block_frame_locals): Return value changed from void to int; return 1 if values printed. Use _filtered. (print_frame_local_vars): Use return value from print_block_frame_locals to mention if nothing printed; mention lack of symbol table, use _filtered. (print_frame_arg_vars): Tell the user if no symbol table or no values printed. Use fprintf_filtered instead of fprintf. * blockframe.c (get_prev_frame_info): Check for no inferior or core file before crashing. * inflow.c (inferior_died): Set current frame to zero to keep from looking like we're in start. Sat Jun 24 15:50:53 1989 Randall Smith (randy at gluteus.ai.mit.edu) * stack.c (frame_command): Added a check to make sure that there was an inferior or a core file. * expread.y (yylex): Allow floating point numbers of the form ".5" to be parsed. Changes by David Taylor at TMC: * ns32k-pinsn.c: Added define for ?floating point coprocessor? and tables for register names to be used for each of the possibilities. (list_search): Created; searches a list of options for a specific value. (print_insn_arg): Added 'Q', 'b', 'M', 'P', 'g', and 'G' options to the value location switch. * ns32k-opcode.h: Added several new location flags. [addr, enter, exit, ext[bwd], exts[bwd], lmr, lpr[bwd], restore, rett, spr[bwd], smr]: Improved insn format output. * symtab.c (list_symbols): Rearrange printing to produce readable output for "info types". * eval.c (evaluate_subexp_for_address): Fixed typo. * dbxread.c (read_type): Don't output an error message when there isn't a ',' after a cross-reference. * dbxread.c (read_dbx_symtab): #if'd out N_FN case in read_dbx_symtab if it has the EXT bit set (otherwise multiple cases with the same value). Fri Jun 23 13:12:08 1989 Randall Smith (randy at plantaris.ai.mit.edu) * symmisc.c: Changed decl of print_spaces from static to extern (since it's defined in utils.c). * remote.c (remote_open): Close remote_desc if it's already been opened. * Remote_Makefile, remote_gutils.c, remote_inflow.c, remote_server.c, remote_utils.c: Combined into remote-multi.shar. * remote-multi.shar: Created (Vikram Koka's remote stub). * remote-sa.m68k.shar: Created (Glenn Engel's remcom.c). * README: Updated to reflect new organization of remote stubs. * dbxread.c (read_dbx_symtab): Put an N_FN in with N_FN | N_EXT to account for those machines which don't use the external bit here. Sigh. * m-symmetry.h: Defined NO_SIGINTERRUPT. Thu Jun 22 12:51:37 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * printcmd.c (decode_format): Make sure characters are printed using a byte size. * utils.c (error): Added a terminal_ours here. * stack.c (locals_info): Added check for selected frame. * dbxread.c (read_type): Checked to make sure that a "," was actually found in the symbol to end a cross reference. Wed Jun 21 10:30:01 1989 Randy Smith (randy at tartarus.uchicago.edu) * expread.y (parse_number, [exp]): Allowed for the return of a number marked as unsigned; this will allow inclusion of unsigned constants. * symtab.h: Put in default definitions for BUILTIN_TYPE_LONGEST and BUILTIN_TYPE_UNSIGNED_LONGEST. * expread.y (parse_number): Will now accept integers suffixed with a 'u' (though does nothing special with it). * valarith.c (value_binop): Added cases to deal with unsigned arithmetic correctly. Tue Jun 20 14:25:54 1989 Randy Smith (randy at tartarus.uchicago.edu) * dbxread.c (psymtab_to_symtab_1): Changed reading in info message to go through printf_filtered. * symtab.c (list_symbols): Placed header message after all calls to psymtab_to_symtab. * symtab.c (smash_to_{function, reference, pointer}_type): Carried attribute of permanence for the type being smashed over the bzero and allowed any type to point at this one if it is permanent. * symtab.c (smash_to_{function, reference, pointer}_type): Fix typo: check flags of to_type instead of type. * m-hp9k320.h: Changed check on __GNU__ predefine to __GNUC__. * Makefile: Made MUNCH_DEFINE seperate and based on SYSV_DEFINE; they aren't the same on hp's. Mon Jun 19 17:10:16 1989 Randy Smith (randy at tartarus.uchicago.edu) * Makefile: Fixed typo. * valops.c (call_function): Error if the inferior has not been started. * ns32k-opcode.h [check[wc], cmpm[bwd], movm[bwd], skpsb]: Fixed typos. Fri Jun 9 16:23:04 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * m-news.h [NO_SIGINTERRUPT]: Defined. * dbxread.c (read_type): Start copy of undefined structure name past [sue] defining type of cross ref. * dbxread.c (process_one_symbol): Changed strchr to index. * ns32k-opcode.h, ns32k-pinsn.c: More changes to number of operands, addition of all of the set condition opcodes, addition of several flag letters, all patterned after the gas code. * ns32k-opcode.h [mov{su,us}[bwd], or[bwd]]: Changed number of operands from 1 to 2. Wed Jun 7 15:04:24 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * symseg.h [TYPE_FLAG_STUB]: Created. * dbxread.c (read_type): Set flag bit if type is stub. (cleanup_undefined_types): Don't mark it as a stub if it's been defined since we first learned about it. * valprint.c (val_print): Print out a message to that effect if this type is encountered. * symseg.h, symtab.h: Moved the definition of TYPE_FLAG_PERM over to symseg.h so that all such definitions would be in the same place. * valprint.c (val_print): Print out <No data fields> for a structure if there aren't any. * dbxread.c (read_type): Set type name of a cross reference type to "struct whatever" or something. Tue Jun 6 19:40:52 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * breakpoint.c (breakpoint_1): Print out symbolic location of breakpoints for which there are no debugging symbols. Mon Jun 5 15:14:51 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * command.c (help_cmd_list): Made line_size static. Sat Jun 3 17:33:45 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * Makefile: Don't include the binutils hp-include directory in the distribution anymore; refer the users to the binutils distribution. Thu Jun 1 16:33:07 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * printcmd.c (disable_display_command): Fixed loop iteration for no arg case. * printcmd.c (disable_display_command): Added from_tty parameter to function. * valops.c (value_of_variable): Call read_var_value with 0 cast to FRAME instead of CORE_ADDR. * eval.c (evaluate_subexp): Corrected number of args passed to value_subscript (to 2). * infrun.c (wait_for_inferior), symtab.c (decode_line_1), m-convex.h: Changed name of FIRSTLINE_DEBUG_BROKEN to PROLOGUE_FIRSTLINE_OVERLAP. * m-merlin.h: Fixed typo. * ns32k-opcode.h: Added ns32381 opcodes and "cinv" insn, and fixed errors in movm[wd], rett, and sfsr. * eval.c (evaluate_subexp, evaluate_subexp_for_address), valops.c (value_zero): Change value_zero over to taking two arguments instead of three. * eval.c (evaluate_subexp) [OP_VAR_VALUE]: Get correct lval type for AVOID_SIDE_EFFECTS for all types of symbols. [BINOP_DIV]: Don't divide if avoiding side effects; just return an object of the correct type. [BINOP_REPEAT]: Don't call value_repeat, just allocate a repeated value. (evaluete_subexp_for_address) [OP_VAR_VALUE]: Just return a thing of the right type (after checking to make sure that we are allowed to take the address of whatever variable has been passed). Mon May 29 11:01:02 1989 Randall Smith (randy at galapas.ai.mit.edu) * breakpoint.c (until_break_command): Set the breakpoint with a frame specification so that it won't trip in inferior calls to the function. Also set things up so that it works based on selected frame, not current one. Sun May 28 15:05:33 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * eval.c (evalue_subexp): Change subscript case to use value_zero in EVAL_AVOID_SIDE_EFFECTS case. Fri May 26 12:03:56 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * dbxread.c (read_addl_syms, psymtab_to_symtab): Removed cleanup_undefined_types; this needs to be done on a symtab basis. (end_symtab): Called cleanup_undefined_types from here. (cleanup_undefined_types): No longer uses lookup_symbol (brain dead idea; oh, well), now it searches through file_symbols. Wed May 24 15:52:43 1989 Randall Smith (randy at galapas) * source.c (select_source_symtab): Only run through partial_symtab_list if it exists. * coffread.c (read_coff_symtab): Don't unrecord a misc function when a function symbol is seen for it. * expread.y [variable]: Make sure to write a type for memvals if you don't get a mft you recognize. Tue May 23 12:15:57 1989 Randall Smith (randy at plantaris.ai.mit.edu) * dbxread.c (read_ofile_symtab, psymtab_to_symtab): Moved cleanup of undefined types to psymtab_to_symtab. That way it will be called once for all readins (which will, among other things, help reduce infinite loops). * symtab.h [misc_function_type]: Forced mf_unknown to 0. * dbxread.c (record_misc_function): Cast enum to unsigned char (to fit). * expread.y [variable]: Cast unsigned char back to enum to test. Mon May 22 13:08:25 1989 Randall Smith (randy at gluteus.ai.mit.edu) Patches by John Gilmore for dealing well with floating point: * findvar.c (value_from_register, locate_var_value): Used BYTES_BIG_ENDIAN instead of an inline test. * m-sparc.h [IEEE_FLOAT]: Created to indicate that the sparc is IEEE compatible. * printcmd.c (print_scalar_formatted): Use BYTES_BIG_ENDIAN and the stream argument for printing; also modify default type for 'f'. Change handling of invalid floats; changed call syntax for is_nan. (print_command): Don't print out anything indicating that something was recorded on the history list if it wasn't. * valprint.c (val_print): Fixed to deal properley with new format of is_nan and unpacking doubles without errors occuring. (is_nan): Changed argument list and how it figures big endianness (uses macros). * values.c (record_latest_value): Return -1 and don't record if it's an invalid float. (value_as_double): Changed to use new unpack_double calling convention. (unpack_double): Changed not to call error if the float was invalid; simply to set invp and return. Changed calling syntax. (unpack_field_as_long, modify_field): Changed to use BITS_BIG_ENDIAN to determine correct action. * m-hp9k320.h [HP_OS_BUG]: Created; deals with problem where a trap happens after a continue. * infrun.c (wait_for_inferior): Used. * m-convex.h [FIRSTLINE_DEBUG_BROKEN]: Defined a flag to indicate that the debugging symbols output by the compiler for the first line of a function were broken. * infrun.c (wait_for_inferior), symtab.c (decode_line_1): Used. * gdb.texinfo [Data, Memory]: Minor cleanups of phrasing. Fri May 19 00:16:59 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * dbxread.c (add_undefined_type, cleanup_undefined_types): Created to keep a list of cross references to as yet undefined types. (read_type): Call add_undefined_type when we run into such a case. (read_addl_syms, read_ofile_symtab): Call cleanup_undefined_types when we're done. * dbxread.c (psymtab_to_symtab, psymtab_to_symtab_1): Broke psymtab_to_symtab out into two routines; made sure the string table was only readin once and the globals were only scanned once, for any number of dependencies. Thu May 18 19:59:18 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * m-*.h: Defined (or not, as appropriate per machine) BITS_BIG_ENDIAN, BYTES_BIG_ENDIAN, and WORDS_BIG_ENDIAN. Wed May 17 13:37:45 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * main.c (symbol_completion_function): Always complete on result command list, even if exact match found. If it's really an exact match, it'll find it again; if there's something longer than it, it'll get the right result. * symtab.c (make_symbol_completion_function): Fixed typo; strcmp ==> strncmp. * dbxread.c (read_dbx_symtab): Change 'G' case to mark symbols as LOC_EXTERNAL. * expread.y [variables]: Changed default type of text symbols to function returning int so that one can use, eg. strcmp. * infrun.c (wait_for_inferior): Include a special flag indicating that one shouldn't insert the breakpoints on the next step for returning from a sigtramp and forcing at least one move forward. * infrun.c (wait_for_inferior): Change test for nexting into a function to check for current stack pointer inner than previous stack pointer. * infrun.c (wait_for_inferior): Check for step resume break address before dealing with normal breakpoints. * infrun.c (wait_for_inferior): Added a case to deal with taking and passing along a signal when single stepping past breakpoints before inserting breakpoints. * infrun.c (wait_for_inferior): Inserted special case to keep going after taking a signal we are supposed to be taking. Tue May 16 12:49:55 1989 Randall Smith (randy at gluteus.ai.mit.edu) * inflow.c (terminal_ours_1): Cast result of signal to (int (*)()). * gdb.texinfo: Made sure that references to the program were in upper case. Modify description of the "set prompt" command. [Running]: Cleaned up introduction. [Attach]: Cleaned up. [Stepping]: Change "Proceed" to "Continue running" or "Execute". Minor cleanup. [Source Path]: Cleaned up intro. Cleared up distinction between the executable search path and the source path. Restated effect of the "directory" command with no arguments. [Data]: Fixed typos and trivial details. [Stepping]: Fixed up explanation of "until". * source.c (print_source_lines): Print through filter. * printcmd.c (x_command): If the format with which to print is "i", use the address of anything that isn't a pointer instead of the value. This is for, eg. "x/10i main". * gdb.texinfo: Updated last modification date on manual. Mon May 15 12:11:33 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * symtab.c (lookup_symtab): Fixed typo (name ==> copy) in call to lookup_symtab_1. * gdb.texinfo: Added documentation for "break [+-]n" and for new actions of "directory" command (taking multiple directory names at the same time). * m68k-opcode.h: Replaced the version in gdb with an up-to-date version from the assembler directory. * m68k-pinsn.c (print_insn_arg): Added cases 'l' & 'L' to switch to print register lists for movem instructions. * dbxread.c, m-convex.h: Moved convex dependent include files over from dbxread.c to m-convex.h. * printcmd.c (disable_display, disable_display_command): Changed name of first to second, and created first which takes an int as arg rather than a char pointer. Changed second to use first. (_initialize_printcmd): Changed to use second as command to call. (delete_current_display, disable_current_display): Changed name of first to second, and changed functionality to match. * infrun.c (normal_stop), main.c (return_to_top_level): Changed to call disable_current_display. * dbxread.c (process_one_symbol, read_dbx_symtab): Changed N_FN to be N_FN | N_EXT to deal with new Berkeley define; this works with either the old or the new. * Remote_Makefile, remote_gutils.c, remote_inflow.c, remote_server.c, remote_utils.c: Created. * Makefile: Included in tag and tar files. * README: Included a note about them. * printcmd.c (print_address): Use find_pc_partial_function to remove need to readin symtabs for symbolic addresses. * source.c (directory_command): Replaced function with new one that can accept lists of directories seperated by spaces or :'s. * inflow.c (new_tty): Replaced calls to dup2 with calls to dup. Sun May 14 12:33:16 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * stack.c (args_info): Make sure that you have an inferior or core file before taking action. * ns32k-opcode.h [deiw, deid]: Fixed machine code values for these opcodes. * dbxread.c (scan_file_globals): Modified to use misc function vector instead of file itself. Killed all arguments to the funciton; no longer needed. (psymtab_to_symtab): Changed call for above to reflect new (void) argument list. * dbxread.c (read_dbx_symtab, ): Moved HASH_OFFSET define out of read_dbx_symtab. * expread.y [variable]: Changed default type of misc function in text space to be (void ()). * Makefile: Modified for proper number of s/r conflicts (order is confusing; the mod that necessitated this change was on May 12th, not today). * expread.y (yylex): Added SIGNED, LONG, SHORT, and INT keywords. [typename]: Created. [typebase]: Added rules for LONG, LONG INT, SHORT, SHORT INT, SIGNED name, and UNSIGNED name (a good approximation of ansi standard). * Makefile: Included .c.o rule to avoid sun's make from throwing any curves at us. * blockframe.c: Included <obstack.h> * command.c (lookup_cmd): Clear out trailing whitespace. * command.c (lookup_cmd_1): Changed malloc to alloca. Fri May 12 12:13:12 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * printcmd.c (print_frame_args): Only print nameless args when you know how many args there are supposed to be and when you've printed fewer than them. Don't print nameless args between printed args. * symtab.c (make_symbol_completion_function): Fixed typo (= ==> ==). * remote.c (remote_open): ifdef'd out siginterrupt call by #ifndef NO_SIGINTERRUPT. * m-umax.h: Defined NO_SIGINTERRUPT. * expread.y [ptype, array_mod, func_mod, direct_abs_decl, abs_decl]: Added rules for parsing and creating arbitrarily strange types for casts and sizeofs. * symtab.c, symtab.h (create_array_type): Created. Some minor misfeatures; see comments for details (main one being that you might end up creating two arrays when you only needed one). Thu May 11 13:11:49 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * valops.c (value_zero): Add an argument for type of lval. * eval.c (evaluate_subexp_for_address): Take address properly in the avoid side affects case (ie. keep track of whether we have an lval in memory and we can take the address). (evaluate_subexp): Set the lval type of expressions created with value_zero properley. * valops.c, value.h (value_zero): Created--will return a value of any type with contents filled with zero. * symtab.c, symtab.h (lookup_struct_elt_type): Created. * eval.c (evaluate_subexp): Modified to not read memory when called with EVAL_AVOID_SIDE_EFFECTS. * Makefile: Moved dbxread.c ahead of coffread.c in the list of source files. Wed May 10 11:29:19 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * munch: Make sure that sysv version substitutes for the whole line. * symtab.h: Created an enum misc_function_type to hold the type of the misc function being recorded. * dbxread.c (record_misc_function): Branched on dbx symbols to decide which type to assign to a misc function. * coffread.c (record_misc_function): Always assign type unknown. * expread.y [variable]: Now tests based on new values. Tue May 9 13:03:54 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * symtab.c: Changed inclusion of <strings.h> (doesn't work on SYSV) to declaration of index. * Makefile: Changed last couple of READLINE_FLAGS SYSV_DEFINE * source.c ({forward, reverse}_search_command): Made a default search file similar to for the list command. Mon May 8 18:07:51 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * printcmd.c (print_frame_args): If we don't know how many arguments there are to this function, don't print the nameless arguments. We don't know enough to find them. * printcmd.c (print_frame_args): Call print_frame_nameless_args with proper arguments (start & end as offsets from addr). * dbxread.c (read_addl_syms): Removed cases to deal with global symbols; this should all be done in scan_global_symbols. Sun May 7 11:36:23 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * Makefile: Added copying.awk to ${OTHERS}. Fri May 5 16:49:01 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * valprint.c (type_print_varspec_prefix): Don't pass passed_a_pointer onto children. * valprint.c (type_print_varspec_suffix): Print "array of" with whatever the "of" is after tha array brackets. * valprint.c (type_print_varspec_{prefix,suffix}): Arrange to parenthesisze pointers to arrays as well as pointers to other objects. * valprint.c (type_print_varspec_suffix): Make sure to print subscripts of multi-dimensional arrays in the right order. * infcmd.c (run_command): Fixed improper usages of variables within remote debugging branch. * Makefile: Added Convex.notes to the list of extra files to carry around. * dbxread.c (symbol_file_command): Made use of alloca or malloc dependent on macro define. Thu May 4 15:47:04 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * Makefile: Changed READLINE_FLAGS to SYSV_DEFINE and called munch with it also. * munch: Check first argument for -DSYSV and be looser about picking up init routines if you find it. * coffread.c: Made fclose be of type int. * breakpoint.c (_initialize_breakpoint): Put "unset" into class alias. Wed May 3 14:09:12 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * m-sparc.h [STACK_END_ADDR]: Parameterized off of machine/vmparam.h (as per John Gilmore's suggestion). * blockframe.c (get_prev_frame_info): Changed this function back to checking frameless invocation first before checking frame chain. This means that a backtrace up from start will produce the wrong value, but that a backtrace from a frameless function called in main will show up correctly. * breakpoint.c (_initialize_breakpoint): Added entry in help for delete that indicates that unset is an alias for it. * main.c (symbol_completion_function): Modified recognition of being within a single command. Tue May 2 15:13:45 1989 Randy Smith (randy at gnu) * expread.y [variable]: Add some parens to get checking of the misc function vector right. Mon May 1 13:07:03 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * default-dep.c (core_file_command): Made reg_offset unsigned. * default-dep.c (core_file_command): Improved error messages for reading in registers. * expread.y: Allowed a BLOCKNAME to be ok for a variable name (as per C syntax). * dbxread.c (psymtab_to_symtab): Flushed stdout after printing starting message about reading in symbols. * printcmd.c (print_frame_args): Switched starting place for printing of frameless args to be sizeof int above last real arg printed. * printcmd.c (print_frame_args): Modified final call to print_nameless_args to not use frame slots used array if none had been used. * infrun.c (wait_for_inferior): Take FUNCTION_START_OFFSET into account when dealing with comparison of pc values to function addresses. * Makefile: Added note about compiling gdb on a Vax running 4.3. Sun Apr 30 12:59:46 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * command.c (lookup_cmd): Got correct error message on bad command. * m-sun3.h [ABOUT_TO_RETURN]: Modified to allow any of the return instructions, including trapv and return from interupt. * command.c (lookup_cmd): If a command is found, use it's values for error reporting and determination of needed subcommands. * command.c (lookup_cmd): Use null string for error if cmdtype is null; pass *line to error instead of **. * command.c (lookup_cmd_1): End of command marked by anything but alpha numeric or '-'. Included ctype.h. Fri Apr 28 18:30:49 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * source.c (select_source_symtab): Kept line number from ever being less than 1 in main decode. Wed Apr 26 13:03:20 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * default-dep.c (core_file_command): Fixed typo. * utils.c (fprintf_filtered): Don't use return value from numchars. * main.c, command.c (complete_on_cmdlist): Moved function to command.c. * command.c (lookup_cmd): Modified to use my new routine. Old version is still there, ifdef'd out. * command.c, command.h (lookup_cmd_1): Added a routine to do all of the work of lookup_cmd with no error reporting and full return of information garnered in search. Tue Apr 25 12:37:54 1989 Randall Smith (randy at gluteus.ai.mit.edu) * breakpoint.c (_initialize_breakpoint): Change "delete breakpionts" to be in class alias and not have the abbrev flag set. * main.c (symbol_completion_function): Fix to correctly complete things that correspond to multiword aliases. * main.c (complete_on_cmdlist): Don't complete on something if it isn't a command or prefix (ie. if it's just a help topic). * main.c (symbol_completion_function): Set list index to be 0 if creating a list with just one element. * main.c (complete_on_cmdlist): Don't allow things with abbrev_flag set to be completion values. (symbol_completion_function): Don't accept an exact match if the abbrev flag is set. * dbxread.c (read_type): Fixed typo in comparision to check if type number existed. * dbxread.c (read_type): Made sure to only call dbx_lookup_type on typenums if typenums were not -1. Mon Apr 24 17:52:12 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * symtab.c: Added strings.h as an include file. Fri Apr 21 15:28:38 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * symtab.c (lookup_partial_symtab): Changed to only return a match if the name match is exact (which is what I want in all cases in which this is currently used. Thu Apr 20 11:12:34 1989 Randall Smith (randy at gluteus.ai.mit.edu) * m-isi.h [REGISTER_U_ADDR]: Installed new version from net. * default-dep.c: Deleted inclusion of fcntl.h; apparently not necessary. * Makefile: Added comment about compiling on isi under 4.3. * breakpoint.c (break_command_1): Only give decode_line_1 the default_breakpoint_defaults if there's nothing better (ie. make the default be off of the current_source notes if at all possible). * blockframe.c (get_prev_frame_info): Clean up comments and delete code ifdefed out around FRAMELESS_FUNCTION_INVOCATION test. * remote.c: Added a "?" message to protocol. (remote_open): Used at startup. (putpkt): Read whatever garbage comes over the line until we see a '+' (ie. don't treat garbage as a timeout). * valops.c (call_function): Eliminated no longer appropriate comment. * infrun.c (wait_for_inferior): Changed several convex conditional compilations to be conditional on CANNOT_EXECUTE_STACK. Wed Apr 19 10:18:17 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * printcmd.c (print_frame_args): Added code to attempt to deal with arguments that are bigger than an int. Continuation of Convex/Fortran changes: * printcmd.c (print_scalar_formatted): Added leading zeros to printing of large integers. (address_info, print_frame_args): Added code to deal with LOC_REF_ARG. (print_nameless_args): Allow param file to specify a routine with which to print typeless integers. (printf_command): Deal with long long values well. * stack.c (print_frame_arg_vars): Change to deal with LOC_REF_ARG. * symmisc.c (print_symbol): Change to deal with LOC_REF_ARG. * symseg.h: Added LOC_REF_ARG to enum address_class. * symtab.c (lookup_block_symbol): Changed to deal with LOC_REF_ARG. * valarith.c (value_subscripted_rvalue): Created. (value_subscript): Used above when app. (value_less, value_equal): Change to cast to (char *) before doing comparison, for machines where that casting does something. * valops.c (call_function): Setup to deal with machines where you cannot execute code on the stack segment. * valprint.c (val_print): Make sure that array element size isn't zero before printing. Set address of default array to address of first element. Put in a couple of int cast. Removed some convex specific code. Added check for endianness of machine in case of a packed structure. Added code for printing typeless integers and for LONG LONG's. (set_maximum_command): Change to use parse_and_eval_address to get argument (so can use expressions there). * values.c (value_of_internalvar, set_internalvar_component, set_internalvar, convenience_info): Add in hooks for trapped internal vars. (unpack_long): Deal with LONG_LONG. (value_field): Remove LONGEST cast. (using_struct_return): Fixed typo ENUM ==> UNION. * xgdb.c (_initialize_xgdb): Make sure that specify_exec_file_hook is not called unless we are setting up a windowing environ. Tue Apr 18 13:43:37 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) Various changes involved in 1) getting gdb to work on the convex, and 2) Getting gdb to work with fortran (due to convex!csmith): * convex-dep.c, convex-opcode.h, m-convex.h, convex-pinsn.c: Created (or replaced with new files). * Makefile: Add convex dependent files. Changed default flags to gnu malloc to be CFLAGS. * config.gdb: Added convex to list of machines. * core.c (files_info): Added a FILES_INFO_HOOK to be used if defined. (xfer_core_file): Conditionalized compilation of xfer_core_file on the macro XFER_CORE_FILE. * coffread.c (record_misc_function): Made sure it zerod type field (which is now being used; see next). * dbxread.c: Included some convex dependent include files. (copy_pending, fix_common_blocks): Created. [STAB_REG_REGNUM, BELIEVE_PCC_PROMOTION]: Created default values; may be overridden in m-*.h. Included data structures for keeping track of common blocks. (dbx_alloc_type): Modified; if called with negative 1's will create a type without putting it into the type vector. (read_dbx_symtab, read_addl_syms): Modified calls to record_misc_function to include the new information. (symbol_file_command, psymtab_to_symtab, add_file_command): Modified reading in of string table to adapt to machines which *don't* store the size of the string table in the first four bytes of the string table. (read_dbx_symtab, scan_file_globals, read_ofile_symtab, read_addl_syms): Modified assignment of namestring to accept null index into symtab as ok. (read_addl_syms): Modified readin of a new object file to fiddle with common blocks correctly. (process_one_symbol): Fixed incorrect comment about convex. Get symbols local to a lexical context from correct spot on a per machine basis. Catch a bug in pcc which occaisionally puts an SO where there should be an SOL. Seperate sections for N_BCOMM & N_ECOMM. (define_symbol): Ignore symbols with no ":". Use STAB_REG_TO_REGNUM. Added support for function args calling by reference. (read_type): Only read type number if one is there. Remove old (#if 0'd out) array code. (read_array_type): Added code for dealing with adjustable (by parameter) arrays half-heartedly. (read_enum_type): Allow a ',' to end a list of values. (read_range_type): Added code to check for long long. * expread.y: Modified to use LONGEST instead of long where necessary. Modified to use a default type of int for objects that weren't in text space. * findvar.c (locate_var_value, read_var_value): Modified to deal with args passed by reference. * inflow.c (create_inferior): Used CREATE_INFERIOR_HOOK if it exists. * infrun.c (attach_program): Run terminal inferior when attaching. (wait_for_inferior): Removed several convex dependencies. * main.c (float_handler): Created. Made whatever signal indicates a stop configurable (via macro STOP_SIGNAL). (main): Setup use of above as a signal handler. Added check for "-nw" in args already processed. (command_line_input): SIGTSTP ==>STOP_SIGNAL. * expread.y: Added token BLOCKNAME to remove reduce/reduce conflict. * Makefile: Change message to reflect new grammar. Mon Apr 17 13:24:59 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * printcmd.c (compare_ints): Created. (print_frame_args): Modified to always print arguments in the order in which they were found in the symbol table. Figure out what apots are missing on the fly. * stack.c (up_command): Error if no inferior or core file. * m-i386.h, m-symmetry.h [FRAMELESS_FUNCTION_INVOCATION]: Created; same as m68k. * dbxread.c (define_symbol): Changed "desc==0" test to "processing_gcc_compilation", which is the correct way to do it. Sat Apr 15 17:18:38 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * expread.y: Added precedence rules for arglists, ?:, and sizeof to eliminate some shift-reduce conflicts. * Makefile: Modified "Expect" message to conform to new results. Thu Apr 13 12:29:26 1989 Randall Smith (randy at plantaris.ai.mit.edu) * inflow.c (terminal_init_inferior): Fixed typo in recent diff installation; TIOGETC ==> TIOCGETC. * m-vax.h, m-sun2.h, m-sun3.h, m-sparc.h, m-hp*.h, m-isi.h, m-news.h [FRAMELESS_FUNCTION_INVOCATION]: Created macro with appropriate definition. Wed Apr 12 15:30:29 1989 Randall Smith (randy at plantaris.ai.mit.edu) * blockframe.c (get_prev_frame_info): Added in a macro to specify when a "frame" is called without a frame pointer being setup. * Makefile [clean]: Made sure to delete gnu malloc if it was being used. Mon Apr 10 12:43:49 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * dbxread.c (process_one_symbol): Reset within_function to 0 after last RBRAC of a function. * dbxread.c (read_struct_type): Changed check for filling in of TYPE_MAIN_VARIANT of type. * inflow.c (create_inferior): Conditionalized fork so that it would be used if USG was defined and HAVE_VFORK was not defined. * defs.h: Added comment about enum command_class element class_alias. * dbxread.c (process_one_symbol): Fixed a typo with interesting implications for associative processing in the brain (':' ==> 'c'). * sparc-dep.c (isabranch): Changed name to isannulled, modified to deal with coprocessor branches, and improved comment. (single_step): Changed to trap at npc + 4 instead of pc +8 on annulled branches. Changed name in call to isabranch as above. * m-sun4os4.h (STACK_END_ADDRESS): Changed it to 0xf8000000 under os 4.0. Sat Apr 8 17:04:07 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * dbxread.c (process_one_symbol): In the case N_FUN or N_FNAME the value being refered to is sometimes just a text segment variable. Catch this case. * infrun.c (wait_for_inferior), breakpoint.c (breakpoint_stop_status): Move the selection of the frame to inside breakpoint_stop_status so that the frame only gets selected (and the symbols potentially read in) if the symbols are needed. * symtab.c (find_pc_psymbol): Fixed minor misthough (pc >= fucntion start, not >). * breakpoint.c (_initialize_breakpoint): Change "delete" internal help entry to simply refer to it being a prefix command (since the list of subcommands is right there on a "help delete"). Fri Apr 7 15:22:18 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * blockframe.c (find_pc_partial_function): Created; figures out what function pc is in (name and address) without reading in any new symbols. * symtab.h: Added decl for above. * infrun.c (wait_for_inferior): Used instead of find_pc_function_start. * stack.c (print_frame_info): Used instead of hand coding for same thing. * dbxread.c (psymtab_to_symtab): No longer patch readin pst's out of the partial_symtab_list; need them there for some checks. * blockframe.c (block_for_pc), source.c (select_source_symtab), symtab.c (lookup_symbol, find_pc_symtab, list_symbols): Made extra sure not to call psymtab_to_symtab with ->readin == 1, since these psymtab now stay on the list. * symtab.c (sources_info): Now distinguishes between psymtabs with readin set and those with it not set. * symtab.c (lookup_symtab): Added check through partial symtabs for name with .c appended. * source.c (select_source_symtab): Changed semantics a little so that the argument means something. * source.c (list_command), symtab.c (decode_line_1): Changed call to select_source_symtab to match new conventions. * dbxread.c (add_file_command): This command no longer selects a symbol table to list from. * infrun.c (wait_for_inferior): Only call find_pc_function (to find out if we have debugging symbols for a function and hence if we should step over or into it) if we are doing a "step". Thu Apr 6 12:42:28 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * main.c (command_line_input): Added a local buffer and only copied information into the global main.c buffer when it is appropriate for it to be saved (and repeated). (dont_repeat): Only nail line when we are reading from stdin (otherwise null lines won't repeat and what's in line needs to be saved). (read_command_lines): Fixed typo; you don't what to repeat when reading command lines from the input stream unless it's standard input. John Gilmore's (gnu@toad.com) mods for USG gdb: * inflow.c: Removed inclusion of sys/user.h; no longer necessary. (, terminal_init_inferior, terminal_inferior, terminal_ours_1, term_status_command, _initialize_inflow) Seperated out declaration and usage of terminal mode structures based on the existence of the individual ioctls. * utils.c (request_quit): Restore signal handler under USG. If running under USG initialize sys_siglist at run time (too much variation between systems). Wed Apr 5 13:47:24 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) John Gilmore's (gnu@toad.com) mods for USG gdb: * default-dep.c: Moved include of sys/user.h to after include of a.out.h. (store_inferior_registers): Fixed error message. (core_file_command): Improved error messages from reading in of u area in core file. Changed calculation of offset of registers to account for some machines putting it in as an offset rather than an absolute address. Changed error messages for reading of registers from core file. * coffread.c (read_file_hdr): Added final check for BADMAG macro to use if couldn't recognize magic number. * Makefile: Added explicit directions for alloca addition. Included alloca.c in list of possible library files. Cleaned up possible library usage. Included additional information on gcc and include files. * source.c, remote.c, inflow.c, dbxread.c, core.c, coffread.c: Changed include of sys/fcntl.h to an include of fcntl.h (as per posix; presumably this will break fewer machines. I hopw). * README: Added a pointer to comments at top of Makefile. * Makefile: Added a comment about machines which need fcntl.h in sys. Tue Apr 4 11:29:04 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * valprint.c (set_prettyprint_command, set_unionprint_command, format_info): Created. (_initialize_valprint): Added to lists of commands. * gdb.texinfo [Backtrace]: Added a section describing the format if symbols have not yet been read in. * valprint.c (val_print): Added code to prettyprint structures if "prettyprint" is set and only to print unions below the top level if "unionprint" is set. * infcmd.c (registers_info), valprint.c (value_print, val_print): Added argument to call to val_print indicating deptch of recursion. * symtab.[ch] (find_pc_psymbol): Created; finds static function psymbol with value nearest to but under value passed. * stack.c (print_frame_info): Used above to make sure I have best fit to pc value. * symseg.h (struct partial_symbol): Added value field. * dbxread.c (read_dbx_symtab): Set value field for partial symbols saved (so that we can lookup static symbols). * symtab.[ch] (find_pc_symtab): Changed to external. * stack.c (select_frame): Call above to make sure that symbols for a selected frame is readin. Mon Apr 3 12:48:16 1989 Randall Smith (randy at plantaris.ai.mit.edu) * stack.c (print_frame_info): Modified to only print out full stack frame info on symbols whose tables have been read in. * symtab.c, symtab.h (find_pc_psymtab): Made function external; above needed it. * main.c (,set_verbose_command, initialize_main): Created a variable "info_verbose" which says to talk it up in various and sundry places. Added command to set this variable. * gdb.texinfo (GDB Output): Added documentation on "set verbose" and changed the name of the "Screen Output" section to "GDB Output". * dbxread.c (psymtab_to_symtab): Added information message about symbol readin. Conditionalized on above. * dbxread.c (define_symbol): Made an "i" constant be of class LOC_CONST and an "r" constant be of class LOC_CONST_BYTES. * README: Made a note about modifications which may be necessary to the manual for this version of gdb. * blockframe.c (get_prev_frame_info): Now we get saved address and check for validity before we check for leafism. This means that we will catch the fact that we are in start, but we will miss any fns that start calls without an fp. This should be fine. * m-*.h (FRAME_CHAIN): Modified to return 0 if we are in start. This is usually a test for within the first object file. * m-sparc.h (FRAME_CHAIN): The test here is simply if the fp saved off the the start sp is 0. * blockframe.c (get_prev_frame_info): Removed check to see if we were in start. Screws up sparc. * m-sparc.h (FRAME_FIND_SAVED_REGISTERS): Changed test for dummy frame to not need frame to be innermost. * gdb.texinfo: Added section on frameless invocations of functions and when gdb can and can't deal with this. * stack.c (frame_info): Disallowed call if no inferior or core file; fails gracefully if truely bad stack specfication has been given (ie. parse_frame_specification returns 0). Fri Mar 31 13:59:33 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * infrun.c (normal_stop): Changed references to "unset-env" to "delete env". * infcmd.c (_initialize_infcmd): Change reference to set-args in help run to "set args". * remote.c (getpkt): Allow immediate quit when reading from device; it could be hung. * coffread.c (process_coff_symbol): Modify handling of REG parameter symbols. Thu Mar 30 15:27:23 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * dbxread.c (symbol_file_command): Use malloc to allocate the space for the string table in symbol_file_command (and setup a cleanup for this). This allows a more graceful error failure if there isn't any memory availible (and probably allows more memory to be avail, depending on the machine). Additional mods for handling GNU C++ (from Tiemann): * dbxread.c (read_type): Added case for '#' type (method type, I believe). (read_struct_type): If type code is undefined, make the main variant for the type be itself. Allow recognition of bad format in reading of structure fields. * eval.c (evaluate_subexp): Modify evaluation of a member of a structure and pointer to same to make sure that the syntax is being used correctly and that the member is being accessed correctly. * symseg.h: Added TYPE_CODE_METHOD to enum type_code. Add a pointer to an array of argument types to the type structure. * symtab.c (lookout_method_type, smash_to_method_type): Created. * symtab.h (TYPE_ARG_TYPES): Created. * valops.c (call_function): Modified handling of methods to be the same as handling of functions; no longer check for members. * valprint.c (val_print, type_print_varspec_{prefix,suffix}, type_print_base): Added code to print method args correctly. * values.c (value_virtual_fn_field): Modify access to virtual function table. Wed Mar 29 13:19:34 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * findvar.c: Special cases for REGISTER_WINDOWS: 1) Return 0 if we are the innermost frame, and 2) return the next frame in's value if the SP is being looked for. * blockframe.c (get_next_frame): Created; returns the next (inner) frame of the called frame. * frame.h: Extern delcaration for above. * main.c (command_line_input): Stick null at end before doing history expansion. Tue Mar 28 17:35:50 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * dbxread.c (read_dbx_symtab): Added namestring assignment to N_DATA/BSS/ABS case. Sigh. Sat Mar 25 17:49:07 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * expread.y: Defined YYDEBUG. Fri Mar 24 20:46:55 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * symtab.c (make_symbol_completion_list): Completely rewrote to never call psymtab_to_symtab, to do a correct search (no duplicates) through the visible symbols, and to include structure and union fields in the things that it can match. Thu Mar 23 15:27:44 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * dbxread.c (dbx_create_type): Created; allocates and inits space for a type without putting it on the type vector lists. (dbx_alloc_type): Uses above. * Makefile: xgdb.o now produced by default rules for .o.c. Fri Mar 17 14:27:50 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * infrun.c: Fixed up inclusion of aouthdr.h on UMAX_PTRACE. * Makefile, config.gdb: Added hp300bsd to potential configurations. * hp300bsd-dep.c, m-hp300bsd.h: Created. * infrun.c (wait_for_inferior): Rewrote to do no access to inferior until we make sure it's still there. * inflow.c (inferior_died): Added a select to force the selected frame to null when inferior dies. * dbxread.c (symbol_file_command): free and zero symfile when discarding symbols. * core.c (xfer_core_file): Extended and cleaned up logic in interpeting memory address. * core.c (xfer_core_file): Extended opening comment. Thu Mar 16 15:39:42 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * coffread.c (symbol_file_command): Free symfile name when freeing contents. * blockframe.c (get_prev_frame_info): Added to fatal error message to indicate that it should never happen. * stack.c (frame_info): Printed out value of "saved" sp seperately to call attention to the fact that it isn't stored in memory anywhere; the actual previous frames address is printed. * m-sparc.h (FRAME_FIND_SAVED_REGS): Set address of sp saved in frame to value of fp (rather than value of sp in current frame). * expread.y: Allow "unsigned" as a type itself, as well as a type modifier. * coffread.c: Added declaration for fclose Fri Mar 10 17:22:31 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * main.c (command_line_input): Checked for -1 return from readline; indicates EOF. Fri Mar 3 00:31:27 1989 Randall Smith (randy at gluteus.ai.mit.edu) * remote.c (remote_open): Cast return from signal to (void (*)) to avoid problems on machines where the return type of signal is (int (*)). * Makefile: Removed deletion of version control from it (users will need it for their changes). Thu Mar 2 15:32:21 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * symmetry-dep.c (print_1167_regs): Print out effective doubles on even number regs. (fetch_inferior_registers): Get the floating point regs also. * xgdb.c (do_command): Copied command before calling execute command (so that execute_command wouldn't write into text space). * copying.awk: Created (will produce copying.c as output when given COPYING as input). * Makefile: Used above to create copying.c. * main.c: Took out info_warranty and info_copying. * *.*: Changed copyright notice to use new GNU General Public License (includes necessary changes to manual). * xgdb.c (create_text_widget): Created text_widget before I create the source and sink. (print_prompt): Added fflush (stdout). * Makefile: Added -lXmu to the compilation line for xgdb. Left the old one there incase people still had R2. * README: Added note about -gg format. * remote.c (getpkt): Fixed typo; && ==> &. * Makefile: Added new variable READLINE_FLAGS so that I could force compilation of readline.c and history.c with -DSYSV on system V machines. Mentioned in Makefile comments at top. Wed Mar 1 17:01:01 1989 Randall Smith (randy at gluteus.ai.mit.edu) * hp9k320-dep.c (store_inferior_registers): Fixed typo. Fri Feb 24 14:58:45 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * hp9k320-dep.c (store_inferior_registers, fetch_inferior_registers): Added support for remote debugging. * remote.c (remote_timer): Created. (remote_open, readchar): Setup to timeout reads if they take longer than "timeout". This allows one to debug how long such things take. (putpkt): Modified to print a debugging message (if such things are enabled) each time it resends a packet. (getpkt): Modified to make the variable CSUM unsigned and read it CSUM with an & 0xff (presumably to deal with poor sign extension on some machines). Also made c1 and c2 unsigned. (remote_wait): Changed buffer to unsigned status. (remote_store_registers, remote_write_bytes): Puts a null byte at the end of the control string. * infcmd.c (attach_command, detach_command, _initialize_infcmd): Made attach_command and detach_command always availible, but modified them to only allow device file attaches if ATTACH_DETACH is not defined. * gdb.texinfo: Added cross reference from attach command to remote debugging. Thu Feb 23 12:37:59 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * remote.c (remote_close): Created to close the remote connection and set the remote_debugging flag to 0. * infcmd.c (detach_command): Now calls the above when appropriate. * gdb.texinfo: Removed references to the ``Distribution'' section in the copyright. * main.c, utils.c (ISATTY): Created default defintions of this macro which use isatty and fileno. * utils.c (fprintf_filtered, print_spaces_filtered), main.c (command_loop, command_line_input): Used this macro. * m-news.h: Created a definition to override this one. * utils.c (fprintf_filtered): Made line_size static (clueless). * utils.c (fprintf_filtered): Changed max length of line printed to be 255 chars or twice the format length. * symmetry-dep.c, m-symmetry: Fixed typo (^L ==> ). * printcmd.c (do_examine): Fixed typo (\n ==> \t). Wed Feb 22 16:00:33 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) Contributed by Jay Vosburgh (jay@mentor.cc.purdue.edu) * m-symmetry.h, symmetry-dep.c: Created. * Makefile: Added above in appropriate lists. * config.gdb: Added "symmetry" target. * utils.c (prompt_for_continue): Zero'd chars_printed also. * utils.c (fprintf_filtered): Call prompt for continue instead of doing it yourself. * dbxread.c (read_dbx_symtab): Added code to conditionalize what symbol type holds to "x.o" or "-lx" symbol that indicates the beginning of a new file. Tue Feb 21 16:22:13 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * gdb.texinfo: Deleted @ignore block at end of file. * findvar.c, stack.c: Changed comments that refered to "frame address" to "frame id". * findvar.c (locate_var_value): Modified so that taking the address of an array generates an object whose type is a pointer to the elements of the array. Sat Feb 18 16:35:14 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * gdb.texinfo: Removed reference to "!" as a shell escape character. Added a section on controling screen output (pagination); changing "Input" section to "User Interface" section. Changed many inappropriate subsubsection nodes into subsections nodes (in the readline and history expansion sections). Fri Feb 17 11:10:54 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * utils.c (set_screensize_command): Created. (_initialize_utils): Added above to setlist. * main.c (main): Added check to see if ~/.gdbinit and .gdbinit were the same file; only one gets read if so. Had to include sys/stat.h for this. * valprint.c (type_print_base): Changed calls to print_spaces to print_spaces_filtered. * main.c (command_line_input): Chaned test for command line editing to check for stdin and isatty. * main.c (command_loop): Call reinitialize_more_filter before each command (if reading from stdin and it's a tty). utils.c (initialize_more_filter): Changed name to reinitialize_more_filter; killed arguments. utils.c (_initialize_utils): Created; initialized lines_per_page and chars_per_line here. * utils.c (fprintf_filtered): Removed printing of "\\\n" after printing linesize - 1 chars; assume that the screen display will take care of that. Still watching that overflow. * main.c: Created the global variables linesize and pagesize to describe the number of chars per line and lines per page. Thu Feb 16 17:27:43 1989 Randall Smith (randy at gluteus.ai.mit.edu) * printcmd.c (do_examine, print_scalar_formatted, print_address, whatis_command, do_one_display, ptype_command), valprint.c (value_print, val_print, type_print_method_args, type_print_1, type_print_derivation_info, type_print_varspec_suffix, type_print_base), breakpoint.c (breakpoints_info, breakpoint_1), values.c (history_info), main.c (editing_info, warranty_info, copying_info), infcmd.c (registers_info), inflow.c (term_status_command), infrun.c (signals_info), stack.c (backtrace_command, print_frame_info), symtab.c (list_symbols, output_source_filename), command.c (help_cmd, help_list, help_command_list): Replaced calls to printf, fprintf, and putc with calls to [f]printf_filtered to handle more processing. Killed local more emulations where I noticed them. Wed Feb 15 15:27:36 1989 Randall Smith (randy at gluteus.ai.mit.edu) * defs.h, utils.c (initialize_more_filter, fprintf_filtered, printf_filtered): Created a printf that will also act as a more filter, prompting the user for a <return> whenever the page length is overflowed. * symtab.c (list_symbols): Elminated some code inside of an #if 0. Tue Feb 14 11:11:24 1989 Randall Smith (randy at gluteus.ai.mit.edu) * Makefile: Turned off backup versions for this file; it changes too often. * command.c (lookup_cmd, _initialize_command): Changed '!' so that it was no longer a shell escape. "sh" must be used. * main.c (command_line_input, set_history_expansion, initialize_main): Turned history expansion on, made it the default, and only execute it if the first character in the line is a '!'. * version.c, gdb.texinfo: Moved version to 3.2 (as usual, jumping the gun some time before release). * gdb.texinfo: Added sections (adapted from Brian's notes) on command line editing and history expansion. * main.c (set_command_editing, initialize_main): Modified name to set_editing and modified command to "set editing". * Makefile: Put in dependencies for READLINEOBJS. * main.c (history_info, command_info): Combined into new command info; deleted history_info. (initialize_main): Deleted "info history" command; it was interfering with the value history. * coffread.c (enter_linenos): Modified to do bit copy instead of pointer dereference, since the clipper machine can't handle having longs on short boundaries. (read_file_hdr): Added code to get number of syms for clipper. * stack.c (return_command): Fixed method for checking when all of the necessary frames had been popped. * dbxread.c (read_dbx_symtab (ADD_PSYMBOL_TO_LIST)): Fixed typo in allocation length. Mon Feb 13 10:03:27 1989 Randall Smith (randy at gluteus.ai.mit.edu) * dbxread.c (read_dbx_symtab): Split assignment to namestring into several different assignments (so that it wouldn't be done except when it had to be). Shortened switches and duplicated code to produce the lowest possible execution time. Commented (at top of switch) which code I duplicated. * dbxread.c (read_dbx_symtab): Modified which variables were register and deleted several variables which weren't used. Also eliminated 'F' choice from subswitch, broke out strcmp's, reversed compare on line 1986, and elminated test for !namestring[0]; it is caught by following test for null index of ':'. Sun Feb 12 12:57:56 1989 Randall Smith (randy at plantaris.ai.mit.edu) * main.c (gdb_completer_word_break_characters): Turned \~ into ~. Sat Feb 11 15:39:06 1989 Randall Smith (randy at plantaris.ai.mit.edu) * symtab.c (find_pc_psymtab): Created; checks all psymtab's till it finds pc. (find_pc_symtab): Used; fatal error if psymtab found is readin (should have been caught in symtab loop). (lookup_symbol): Added check before scan through partial symtab list for symbol name to be on the misc function vector (only if in VAR_NAMESPACE). Also made sure that psymtab's weren't fooled with if they had already been read in. (list_symbols): Checked through misc_function_vector for matching names if we were looking for functions. (make_symbol_completion_list): Checked through misc_function_vector for matching names. * dbxread.c (read_dbx_symtab): Don't bother to do processing on global function types; this will be taken care of by the misc_function hack. * symtab.h: Modified comment on misc_function structure. Fri Feb 10 18:09:33 1989 Randall Smith (randy at plantaris.ai.mit.edu) * symseg.h, dbxread.c (read_dbx_symtab, init_psymbol_list, start_psymtab, end_psymtab), coffread.c (_initialize_coff), symtab.c (lookup_partial_symbol, list_symbols, make_symbol_completion_list): Changed separate variables for description of partial symbol allocation into a specific kind of structure. (read_dbx_symtab, process_symbol_for_psymtab): Moved most of process_symbol_for_psymtab up into read_dbx_symtab, moved a couple of symbol types down to the ingore section, streamlined (I hope) code some, modularized access to psymbol lists. Thu Feb 9 13:21:19 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * main.c (command_line_input): Made sure that it could recognize newlines as indications to repeat the last line. * symtab.c (_initialize_symtab): Changed size of builtin_type_void to be 1 for compatibility with gcc. * main.c (initialize_main): Made history_expansion the default when gdb is compiled with HISTORY_EXPANSION. * readline.c, readline.h, history.c, history.h, general.h, emacs_keymap.c, vi_keymap.c, keymaps.c, funmap.c: Made all of these links to /gp/gnu/bash/* to keep them updated. * main.c (initialize_main): Made default be command editing on. Wed Feb 8 13:32:04 1989 & Smith (randy at hobbes) * dbxread.c (read_dbx_symtab): Ignore N_BSLINE on first readthrough. * Makefile: Removed convex-dep.c from list of distribution files. Tue Feb 7 14:06:25 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * main.c: Added command lists sethistlist and unsethistlist to accesible command lists. (parse_binary_operation): Created to parse a on/1/yes vs. off/0/no spec. (set_command_edit, set_history, set_history_expansion, set_history_write, set_history_size, set_history_filename, command_info, history_info): Created to allow users to control various aspects of command line editing. * main.c (symbol_creation_function): Created. (command_line_input, initialize_main): Added rest of stuff necessary for calling bfox' command editing routines under run-time control. * Makefile: Included readline and history source files for command editing; also made arrangements to make sure that the termcap library was available. * symtab.c (make_symbol_completion_list): Created. Mon Feb 6 16:25:25 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * main.c: Invented variables to control command editing. command_editing_p, history_expansion_p, history_size, write_history_p, history_filename. Initialized them to default values in initialize_main. * infcmd.c (registers_info), infrun.c (signals_info), * main.c (gdb_read_line): Changed name to command_line_input. (readline): Changed name to gdb_readline; added second argument indicating that the read value shouldn't be saved (via malloc). * infcmd.c (registers_info), infrun.c (signals_info), main.c (copying_info), symtab.c (output_source_filename, MORE, list_symbols): Converted to use gdb_readline in place of gdb_read_line. Sun Feb 5 17:34:38 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * blockframe.c (get_frame_saved_regs): Removed macro expansion that had accidentally been left in the code. Sat Feb 4 17:54:14 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * main.c (gdb_read_line, readline): Added function readline and converted gdb_read_line to use it. This was a conversion to the line at a time style of input, in preparation for full command editing. Fri Feb 3 12:39:03 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * dbxread.c (read_dbx_symtab): Call end_psymtab at the end of read_dbx_symtab if any psymtab still needs to be completed. * config.gdb, sun3-dep.c: Brought these into accord with the actual sun2 status (no floating point period; sun3-dep.c unless has os > 3.0). * m-sun2os2.h: Deleted; not needed. * config.gdb: Added a couple of aliases for machines in the script. * infrun.c: Added inclusion of aouthdr.h inside of #ifdef UMAX because ptrace needs to know about the a.out header. * Makefile: Made dep.o depend on dep.c and config.status only. * expread.y: Added declarations of all of the new write_exp_elt functions at the include section in the top. * Makefile: Added a YACC definition so that people can use bison if they wish. * Makefile: Added rms' XGDB-README to the distribution. * Makefile: Added removal of init.o on a "make clean". Thu Feb 2 16:27:06 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * *-dep.c: Deleted definition of COFF_FORMAT if AOUTHDR was defined since 1) We *may* (recent mail message) want to define AOUTHDR under a basically BSD system, and 2) AOUTHDR is sometimes a typedef in coff encapsulation setups. Also removed #define's of AOUTHDR if AOUTHDR is already defined (inside of coff format). * core.c, dbxread.c: Removed #define's of AOUTHDR if AOUTHDR is already defined (inside of coff format). Tue Jan 31 12:56:01 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * GDB 3.1 released. * values.c (modify_field): Changed test for endianness to assign to integer and reference character (so that all bits would be defined). Mon Jan 30 11:41:21 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * news-dep.c: Deleted inclusion of fcntl.h; just duplicates stuff found in sys/file.h. * i386-dep.c: Included default definition of N_SET_MAGIC for COFF_FORMAT. * config.gdb: Added checks for several different operating systems. * coffread.c (read_struct_type): Put in a flag variable so that one could tell when you got to the end of a structure. * sun3-dep.c (core_file_command): Changed #ifdef based on SUNOS4 to ifdef based on FPU. * infrun.c (restore_inferior_status): Changed error message to "unable to restore previously selected frame". * dbxread.c (read_dbx_symtab): Used intermediate variable in error message reporting a bad symbol type. (scan_file_globals, read_ofile_symtab, read_addl_syms): Data type of "type" changed to unsigned char (which is what it is). * i386-dep.c: Removed define of COFF_FORMAT if AOUTHDR is defined. Removed define of a_magic to magic (taken care of by N_MAGIC). (core_file_command): Zero'd core_aouthdr instead of setting magic to zero. * i386-pinsn.c: Changed jcxz == jCcxz in jump table. (putop): Added a case for 'C'. (OP_J): Added code to handle possible masking of PC value on certain kinds of data. m-i386gas.h: Moved COFF_ENCAPSULATE to before inclusion of m-i386.h and defined NAMES_HAVE_UNDERSCORE. * coffread.c (unrecrod_misc_function, read_coff_symtab): Added symbol number on which error occured to error output. Fri Jan 27 11:55:04 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * Makefile: Removed init.c in make clean. Removed it without -f and with leading - in make ?gdb. Thu Jan 26 15:08:03 1989 Randall Smith (randy at gluteus.ai.mit.edu) Changes to get it to work on gould NP1. * dbxread.c (read_dbx_symtab): Included cases for N_NBDATA and N_NBBSS. (psymtab_to_symtab): Changed declaration of hdr to DECLARE_FILE_HEADERS. Changed access to use STRING_TABLE_SIZE and SYMBOL_TABLE_SIZE. * gld-pinsn.c (findframe): Added declaration of framechain() as FRAME_ADDR. * coffread.c (read_coff_symtab): Avoided treating typedefs as external symbol definitions. Wed Jan 25 14:45:43 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * Makefile: Removed reference to alloca.c. If they need it, they can pull alloca.o from the gnu-emacs directory. * version.c, gdb.texinfo: Updated version to 3.1 (jumping the gun a bit so that I won't forget when I release). * m-sun2.h, m-sun2os2.h, m-sun3os4.h, config.gdb: Modified code so that default includes new sun core, ptrace, and attach-detach. Added defaults for sun 2 os 2. Modifications to reset stack limit back to what it used to be just before exec. All mods inside of #ifdef SET_STACK_LIMIT_HUGE. * main.c: Added global variable original_stack_limit. (main): Set original_stack_limit to original stack limit. * inflow.c: Added inclusion of necessary files and external reference to original_stack_limit. (create_inferior): Reset stack limit to original_stack_limit. * dbxread.c (read_dbx_symtab): Killed PROFILE_SYMBOLS ifdef. * sparc-dep.c (isabranch): Multiplied offset by 4 before adding it to addr to get target. * Makefile: Added definition of SHELL to Makefile. * m-sun2os4.h: Added code to define NEW_SUN_PTRACE, NEW_SUN_CORE, and ATTACH_DETACH. * sun3-dep.c: Added code to avoid fp regs if we are on a sun2. Tue Jan 24 17:59:14 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * dbxread.c (read_array_type): Added function. (read_type): Added call to above instead of inline code. * Makefile: Added ${GNU_MALLOC} to the list of dependencies for the executables. Mon Jan 23 15:08:51 1989 Randall Smith (randy at plantaris.ai.mit.edu) * gdb.texinfo: Added paragraph to summary describing languages with which gdb can be run. Also added descriptions of the "info-methods" and "add-file" commands. * symseg.h: Commented a range type as having TYPE_TARGET_TYPE pointing at the containing type for the range (often int). * dbxread.c (read_range_type): Added code to do actual range types if they are defined. Assumed that the length of a range type is the length of the target type; this is a lie, but will do until somebody gets back to me as to what these silly dbx symbols mean. * dbxread.c (read_range_type): Added code to be more picky about recognizing builtins as range types, to treat types defined as subranges of themselves to be subranges of int, and to recognize the char type idiom from dbx as a special case. Sun Jan 22 01:00:13 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * m-vax.h: Removed definition of FUNCTION_HAS_FRAME_POINTER. * blockframe.c (get_prev_frame_info): Removed default definition and use of above. Instead conditionalized checking for leaf nodes on FUNCTION_START_OFFSET (see comment in code). Sat Jan 21 16:59:19 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * dbxread.c (read_range_type): Fixed assumption that integer was always type 1. * gdb.texinfo: Fixed spelling mistake and added a note in the running section making it clear that users may invoke subroutines directly from gdb. * blockframe.c: Setup a default definition for the macro FUNCTION_HAS_FRAME_POINTER. (get_prev_frame_info): Used this macro instead of checking SKIP_PROLOGUE directly. * m-vax.h: Overroad definition; all functions on the vax have frame pointers. Fri Jan 20 12:25:35 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * core.c: Added default definition of N_MAGIC for COFF_FORMAT. * xgdb.c: Installed a fix to keep the thing from dying when there isn't any frame selected. * core.c: Made a change for the UMAX system; needs a different file included if using that core format. * Makefile: Deleted duplicate obstack.h in dbxread.c dependency. * munch: Modified (much simpler) to cover (I hope) all cases. * utils.c (save_cleanups, restore_cleanups): Added functions to allow you to push and pop the chain of cleanups to be done. * defs.h: Declared the new functions. * main.c (catch_errors): Made sure that the only cleanups which would be done were the ones put on the chain *after* the current location. * m-*.h (FRAME_CHAIN_VALID): Removed check on pc in the current frame being valid. * blockframe.c (get_prev_frame_info): Made the assumption that if a frame's pc value was within the first object file (presumed to be /lib/crt0.o), that we shouldn't go any higher. * infrun.c (wait_for_inferior): Do *not* execute check for stop pc at step_resume_break if we are proceeding over a breakpoint (ie. if trap_expected != 0). * Makefile: Added -g to LDFLAGS. * m-news.h (POP_FRAME) Fixed typo. * printcmd.c (print_frame_args): Modified to print out register params in order by .stabs entry, not by register number. * sparc-opcode.h: Changed declaration of (struct arith_imm_fmt).simm to be signed (as per architecture manual). * sparc-pinsn.c (fprint_addr1, print_insn): Forced a cast to an int, so that we really would get signed behaivior (default for sun cc is unsigned). * i386-dep.c (i386_get_frame_setup): Replace function with new function provided by pace to fix bug in recognizing prologue. Thu Jan 19 11:01:22 1989 Randall Smith (randy at plantaris.ai.mit.edu) * infcmd.c (run_command): Changed error message to "Program not restarted." * value.h: Changed "frame" field in value structure to be a FRAME_ADDR (actually CORE_ADDR) so that it could survive across calls. * m-sun.h (FRAME_FIND_SAVED_REGS): Fixed a typo. * value.h: Added lval: "lval_reg_frame_relative" to indicate a register that must be interpeted relative to a frame. Added single entry to value structure: "frame", used to indicate which frame a relative regnum is relative to. * findvar.c (value_from_register): Modified to correctly setup these fields when needed. Deleted section to fiddle with last register copied on little endian machine; multi register structures will always occupy an integral number of registers. (find_saved_register): Made extern. * values.c (allocate_value, allocate_repeat_value): Zero frame field on creation. * valops.c (value_assign): Added case for lval_reg_frame_relative; copy value out, modify it, and copy it back. Desclared find_saved_register as being external. * value.h: Removed addition of kludgy structure; thoroughly commented file. * values.c (free_value, free_all_values, clear_value_history, set_internalvar, clear_internavars): Killed free_value. Wed Jan 18 20:09:39 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * value.h: Deleted struct partial_storage; left over from yesterday. * findvar.c (value_from_register): Added code to create a value of type lval_reg_partsaved if a value is in seperate registers and saved in different places. Tue Jan 17 13:50:18 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * value.h: Added lval_reg_partsaved to enum lval_type and commented enum lval_type. Commented value structure. Added "struct partial_register_saved" to value struct; added macros to deal with structure to value.h. * values.c (free_value): Created; special cases lval_reg_partsaved (which has a pointer to an array which also needs to be free). (free_all_values, clear_value_history, set_internalvar, clear_internalvars): Modified to use free_values. * m-sunos4.h: Changed name to sun3os4.h. * m-sun2os4.h, m-sun4os4.h: Created. * config.gdb: Added configuration entries for each of the above. * Makefile: Added into correct lists. * Makefile: Added dependencies on a.out.encap.h. Made a.out.encap.h dependent on a.out.gnu.h and dbxread.c dependent on stab.gnu.h. * infrun.c, remote.c: Removed inclusion of any a.out.h files in these files; they aren't needed. * README: Added comment about bug reporting and comment about xgdb. * Makefile: Added note to HPUX dependent section warning about problems if compiled with gcc and mentioning the need to add -Ihp-include to CFLAGS if you compile on those systems. Added a note about needing the GNU nm with compilers *of gdb* that use the coff encapsulate feature also. * hp-include: Made symbolic link over to /gp/gnu/binutils. * Makefile: Added TSOBS NTSOBS OBSTACK and REGEX to list of things to delete in "make clean". Also changed "squeakyclean" target as "realclean". * findvar.c (value_from_register): Added assignment of VALUE_LVAL to be lval_memory when that is appropriate (original code didn't bother because it assumed that it was working with a pre lval memoried value). * expread.y (yylex): Changed to only return type THIS if the symbol "$this" is defined in some block superior or equal to the current expression context block. Mon Jan 16 13:56:44 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * m-*.h (FRAME_CHAIN_VALID): On machines which check the relation of FRAME_SAVED_PC (thisframe) to first_object_file_end (all except gould), make sure that the pc of the current frame also passes (in case someone stops in _start). * findvar.c (value_of_register): Changed error message in case of no inferior or core file. * infcmd.c (registers_info): Added a check for inferior or core file; error message if not. * main.c (gdb_read_line): Modified to take prompt as argument and output it to stdout. * infcmd.c (registers_info, signals_info), main.c (command_loop, read_command_lines, copying_info), symtab.c (decode_line_2, output_source_filename, MORE, list_symbols): Changed calling convention used to call gdb_read_line. * infcmd.c, infrun.c, main.c, symtab.c: Changed the name of the function "read_line" to "gdb_read_line". * breakpoint.c: Deleted external referenced to function "read_line" (not needed by code). Fri Jan 13 12:22:05 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * i386-dep.c: Include a.out.encap.h if COFF_ENCAPSULATE. (N_SET_MAGIC): Defined if not defined by include file. (core_file_command): Used N_SET_MAGIC instead of assignment to a_magic. (exec_file_command): Stuck in a HEADER_SEEK_FD. * config.gdb: Added i386-dep.c as depfile for i386gas choice. * munch: Added -I. to cc to pick up things included by the param file. * stab.gnu.def: Changed name to stab.def (stab.gnu.h needs this name). * Makefile: Changed name here also. * dbxread.c: Changed name of gnu-stab.h to stab.gnu.h. * gnu-stab.h: Changed name to stab.gnu.h. * stab.gnu.def: Added as link to binutils. * Makefile: Put both in in the distribution. Thu Jan 12 11:33:49 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * dbxread.c: Made which stab.h is included dependent on COFF_ENCAPSULATE; either <stab.h> or "gnu-stab.h". * Makefile: Included gnu-stab.h in the list of files to include in the distribution. * gnu-stab.h: Made a link to /gp/gnu/binutils/stab.h * Makefile: Included a.out.gnu.h and m-i386gas.h in list of distribution files. * m-i386gas.h: Changed to include m-i386.h and fiddle with it instead of being a whole new file. * a.out.gnu.h: Made a link to /gp/gnu/binutils/a.out.gnu.h. Chris Hanson's changes to gdb for hp Unix. * Makefile: Modified comments on hpux. * hp9k320-dep.c: #define'd WOPR & moved inclusion of signal.h * inflow.c: Moved around declaratiosn of <sys/fcntl.h> and <sys/ioctl.h> inside of USG depends and deleted all SYSV ifdef's (use USG instead). * munch: Modified to accept any number of spaces between the T and the symbol name. Pace's changes to gdb to work with COFF_ENCAPSULATE (robotussin): * config.gdb: Added i386gas to targets. * default-dep.c: Include a.out.encap.h if COFF_ENCAPSULATE. (N_SET_MAGIC): Defined if not defined by include file. (core_file_command): Used N_SET_MAGIC instead of assignment to a_magic. (exec_file_command): Stuck in a HEADER_SEEK_FD. * infrun.c, remote.c: Added an include of a.out.encap.h if COFF_ENCAPSULATE defined. This is commented out in these two files, I presume because the definitions aren't used. * m-i386gas.h: Created. * dbxread.c: Included defintions for USG. (READ_FILE_HEADERS): Now uses HEADER_SEEK_FD if it exists. (symbol_file_command): Deleted use of HEADER_SEEK_FD. * core.c: Deleted extra definition of COFF_FORMAT. (N_MAGIC): Defined to be a_magic if not already defined. (validate_files): USed N_MAGIC instead of reading a_magic. Wed Jan 11 12:51:00 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * remote.c: Upped PBUFSIZ. (getpkt): Added zeroing of c inside loop in case of error retry. * dbxread.c (read_dbx_symtab, process_symbol_for_psymtab): Removed code to not put stuff with debugging symbols in the misc function list. Had been ifdef'd out. * gdb.texinfo: Added the fact that the return value for a function is printed if you use return. * infrun.c (wait_for_inferior): Removed test in "Have we hit step_resume_breakpoint" for sp values in proper orientation. Was in there for recursive calls in functions without frame pointers and it was screwing up calls to alloca. * dbxread.c: Added #ifdef COFF_ENCAPSULATE to include a.out.encap.h. (symbol_file_command): Do HEADER_SEEK_FD when defined. * dbxread.c, core.c: Deleted #ifdef ROBOTUSSIN stuff. * robotussin.h: Deleted local copy (was symlink). * a.out.encap.h: Created symlink to /gp/gnu/binutils/a.out.encap.h. * Makefile: Removed robotussin.h and included a.out.encap.h in list of files. * valprint.c (val_print, print_scalar_formatted): Changed default precision of printing float value; now 6 for a float and 16 for a double. * findvar.c (value_from_register): Added code to deal with the case where a value is spread over several registers. Still don't deal with the case when some registers are saved in memory and some aren't. Tue Jan 10 17:04:04 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * xgdb.c (xgdb_create_window): Removed third arg (XtDepth) to frameArgs. * infrun.c (handle_command): Error if signal number is less or equal to 0 or greater or equal to NSIG or a signal number is not provided. * command.c (lookup_cmd): Modified to not convert command section of command line to lower case in place (in case it isn't a subcommand, but an argument to a command). Fri Jan 6 17:57:34 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * dbxread.c: Changed "text area" to "data area" in comments on N_SETV. Wed Jan 4 12:29:54 1989 Randall Smith (randy at gluteus.ai.mit.edu) * dbxread.c: Added definitions of gnu symbol types after inclusion of a.out.h and stab.h. Mon Jan 2 20:38:31 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * eval.c (evaluate_subexp): Binary logical operations needed to know type to determine whether second value should be evaluated. Modified to discover type before binup_user_defined_p branch. Also commented "enum noside". * Makefile: Changed invocations of munch to be "./munch". * gdb.texinfo: Updated to refer to current version of gdb with January 1989 last update. * coffread.c (end_symtab): Zero context stack when finishing lexical contexts. (read_coff_symtab): error if context stack 0 in ".ef" else case. * m-*.h (FRAME_SAVED_PC): Changed name of argument from "frame" to "FRAME" to avoid problems with replacement of "->frame" part of macro. * i386-dep.c (i386_get_frame_setup): Added codestream_get() to move codestream pointer up to the correct location in "subl $X, %esp" case. Sun Jan 1 14:24:35 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) * valprint.c (val_print): Rewrote routine to print string pointed to by char pointer; was producing incorrect results when print_max was 0. Fri Dec 30 12:13:35 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * dbxread.c (read_dbx_symtab, process_symbol_for_psymtab): Put everything on the misc function list. * Checkpointed distribution. * Makefile: Added expread.tab.c to the list of things slated for distribution. Thu Dec 29 10:06:41 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * stack.c (set_backtrace_limit_command, backtrace_limit_info, bactrace_command, _initialize_stack): Removed modifications for limit on backtrace. Piping the backtrace through an interuptable "more" emulation is a better way to do it. Wed Dec 28 11:43:09 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * stack.c (set_backtrace_limit_command): Added command to set a limit to the number of frames for a backtrace to print by default. (backtrace_limit_info): To print the current limit. (backtrace_command): To use the limit. (_initialize_stack): To initialize the limit to its default value (30), and add the set and info commands onto the appropriate command lists. * gdb.texinfo: Documented changes to "backtrace" and "commands" commands. * stack.c (backtrace_command): Altered so that a negative argument would show the last few frames on the stack instead of the first few. (_initialize_stack): Modified help documentation. * breakpoint.c (commands_command): Altered so that "commands" with no argument would refer to the last breakpoint set. (_initialize_breakpoint): Modified help documentation. * infrun.c (wait_for_inferior): Removed ifdef on Sun4; now you can single step through compiler generated sub calls and will die if you next off of the end of a function. * sparc-dep.c (single_step): Fixed typo; "break_insn" ==> "sizeof break_insn". * m-sparc.h (INIT_EXTRA_FRAME_INFO): Set the bottom of a stack frame to be the bottom of the stack frame inner from this, if that inner one is a leaf node. * dbxread.c (read_dbx_symtab): Check to make sure we don't add a psymtab to it's own dependency list. * dbxread.c (read_dbx_symtab): Modified check for duplicate dependencies to catch them correctly. Tue Dec 27 17:02:09 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * m-*.h (FRAME_SAVED_PC): Modified macro to take frame info pointer as argument. * stack.c (frame_info), blockframe.c (get_prev_frame_info), gld-pinsn.c (findframe), m-*.h (SAVED_PC_AFTER_CALL, FRAME_CHAIN_VALID, FRAME_NUM_ARGS): Changed usage of macros to conform to above. * m-sparc.h (FRAME_SAVED_PC), sparc-dep.c (frame_saved_pc): Changed frame_saved_pc to have a frame info pointer as an argument. * m-vax.h, m-umax.h, m-npl.h, infrun.c (wait_for_inferior), blockframe.c (get_prev_frame_info): Modified SAVED_PC_AFTER_CALL to take a frame info pointer as an argument. * blockframe.c (get_prev_frame_info): Altered the use of the macros FRAME_CHAIN, FRAME_CHAIN_VALID, and FRAME_CHAIN_COMBINE to use frame info pointers as arguments instead of frame addresses. * m-vax.h, m-umax.h, m-sun3.h, m-sun3.h, m-sparc.h, m-pn.h, m-npl.h, m-news.h, m-merlin.h, m-isi.h, m-hp9k320.h, m-i386.h: Modified definitions of the above macros to suit. * m-pn.h, m-npl.h, gould-dep.c (findframe): Modified findframe to use a frame info argument; also fixed internals (wouldn't work before). * m-sparc.h: Cosmetic changes; reordered some macros and made sure that nothing went over 80 lines. Thu Dec 22 11:49:15 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * Version 3.0 released. * README: Deleted note about changing -lobstack to obstack.o. Wed Dec 21 11:12:47 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * m-vax.h (SKIP_PROLOGUE): Now recognizes gcc prologue also. * blockframe.c (get_prev_frame_info): Added FUNCTION_START_OFFSET to result of get_pc_function_start. * infrun.c (wait_for_inferior): Same. * gdb.texinfo: Documented new "step" and "next" behavior in functions without line number information. Tue Dec 20 18:00:45 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * infcmd.c (step_1): Changed behavior of "step" or "next" in a function witout line number information. It now sets the step range around the function (to single step out of it) using the misc function vector, warns the user, and continues. * symtab.c (find_pc_line): Zero "end" subsection of returned symtab_and_line if no symtab found. Mon Dec 19 17:44:35 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * i386-pinsn.c (OP_REG): Added code from pace to streamline disassembly and corrected types. * i386-dep.c (i386_follow_jump): Code added to follow byte and word offset branches. (i386_get_frame_setup): Expanded to deal with more wide ranging function prologue. (i386_frame_find_saved_regs, i386_skip_prologue): Changed to use i386_get_frame_setup. Sun Dec 18 11:15:03 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * m-sparc.h: Deleted definition of SUN4_COMPILER_BUG; was designed to avoid something that I consider a bug in our code, not theirs, and which I fixed earlier. Also deleted definition of CANNOT_USE_ARBITRARY_FRAME; no longer used anywhere. FRAME_SPECIFICATION_DYADIC used instead. * infrun.c (wait_for_inferior): On the sun 4, if a function doesn't have a prologue, a next over it single steps into it. This gets around the problem of a "call .stret4" at the end of functions returning structures. * m-sparc.h: Defined SUN4_COMPILER_FEATURE. * main.c (copying_info): Seperated the last printf into two printfs. The 386 compiler will now handle it. * i386-pinsn.c, i386-dep.c: Moved print_387_control_word, print_387_status_word, print_387_status, and i386_float_info to dep.c Also included reg.h in dep.c. Sat Dec 17 15:31:38 1988 Randall Smith (randy at gluteus.ai.mit.edu) * main.c (source_command): Don't close instream if it's null (indicating execution of a user-defined command). (execute_command): Set instream to null before executing commands and setup clean stuff to put it back on error. * inflow.c (terminal_inferior): Went back to not checking the ioctl returns; there are some systems when this will simply fail. It seems that, on most of these systems, nothing bad will happen by that failure. * values.c (value_static_field): Fixed dereferencing of null pointer. * i386-dep.c (i386_follow_jump): Modified to deal with unconditional byte offsets also. * dbxread.c (read_type): Fixed typo in function type case of switch. * infcmd.c (run_command): Does not prompt to restart if command is not from a tty. Fri Dec 16 15:21:58 1988 Randy Smith (randy at calvin) * gdb.texinfo: Added a third option under the "Cannot Insert Breakpoints" workarounds. * printcmd.c (display_command): Don't do the display unless there is an active inferior; only set it. * findvar.c (value_of_register): Added an error check for calling this when the inferior isn't active and a core file isn't being read. * config.gdb: Added reminder about modifying REGEX in the makefile for the 386. * i386-pinsn.c, i386-dep.c: Moved m-i386.h helper functions over to i386-dep.c.b Thu Dec 15 14:04:25 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * README: Added a couple of notes about compiling gdb with itself. * breakpoint.c (set_momentary_breakpoint): Only takes FRAME_FP of frame if frame is non-zero. * printcmd.c (print_scalar_formatted): Implemented /g size for hexadecimal format on machines without an 8 byte integer type. It seems to be non-trivial to implement /g for other formats. (decode_format): Allowed hexadecimal format to make it through /g fileter. Wed Dec 14 13:27:04 1988 Randall Smith (randy at gluteus.ai.mit.edu) * expread.y: Converted all calls to write_exp_elt from the parser to calls to one of write_exp_elt_{opcode, sym, longcst, dblcst, char, type, intern}. Created all of these routines. This gets around possible problems in passing one of these things in one ear and getting something different out the other. Eliminated SUN4_COMPILER_BUG ifdef's; they are now superfluous. * symmisc.c (free_all_psymtabs): Reinited partial_symtab_list to 0. (_initialize_symmisc): Initialized both symtab_list and partial_symtab_list. * dbxread.c (start_psymtab): Didn't allocate anything on dependency list. (end_psymtab): Allocate dependency list on psymbol obstack from local list. (add_psymtab_dependency): Deleted. (read_dbx_symtab): Put dependency on local list if it isn't on it already. * symtab.c: Added definition of psymbol_obstack. * symtab.h: Added declaration of psymbol_obstack. * symmisc.c (free_all_psymtabs): Added freeing and reinitionaliztion of psymbol_obstack. * dbxread.c (free_all_psymbols): Deleted. (start_psymtab, end_psymtab, process_symbol_for_psymtab): Changed most allocation of partial symbol stuff to be off of psymbol_obstack. * symmisc.c (free_psymtab, free_all_psymtabs): Deleted free_psymtab subroutine. * symtab.h: Removed num_includes and includes from partial_symtab structure; no longer needed now that all include files have their own psymtab. * dbxread.c (start_psymtab): Eliminated initialization of above. (end_psymtab): Eliminated finalization of above; get includes from seperate list. (read_dbx_symtab): Moved includes from psymtab list to their own list; included in call to end_psymtab. * symmisc.c (free_psymtab): Don't free includes. Tue Dec 13 14:48:14 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * i386-pinsn.c: Reformatted entire file to correspond to gnu software indentation conventions. * sparc-dep.c (skip_prologue): Added capability of recognizign stores of input register parameters into stack slots. * sparc-dep.c: Added an include of sparc-opcode.h. * sparc-pinsn.c, sparc-opcode.h: Moved insn_fmt structures and unions from pinsn.c to opcode.h. * sparc-pinsn.c, sparc-dep.c (isabranch, skip_prologue): Moved this function from pinsn.c to dep.c. * Makefile: Put in warnings about compiling with gcc (non-ansi include files) and compiling with shared libs on Sunos 4.0 (can't debug something that's been compiled that way). * sparc-pinsn.c: Put in a completely new file (provided by Tiemann) to handle floating point disassembly, load and store instructions, and etc. better. Made the modifications this file (ChangeLog) list for sparc-pinsn.c again. * symtab.c (output_source_filename): Included "more" emulation hack. * symtab.c (output_source_filename): Initialized COLUMN to 0. (sources_info): Modified to not print out a line for all of the include files within a partial symtab (since they have pst's of their own now). Also modified to make a distinction between those pst's read in and those not. * infrun.c: Included void declaration of single_step() if it's going to be used. * sparc-dep.c (single_step): Moved function previous to use of it. * Makefile: Took removal of expread.tab.c out of make clean entry and put it into a new "squeakyclean" entry. Mon Dec 12 13:21:02 1988 Randall Smith (randy at gluteus.ai.mit.edu) * sparc-pinsn.c (skip_prologue): Changed a struct insn_fmt to a union insn_fmt. * inflow.c (terminal_inferior): Checked *all* return codes from ioctl's and fcntl's in routine. * inflow.c (terminal_inferior): Added check for sucess of TIOCSPGRP ioctl call. Just notifies if bad. * dbxread.c (symbol_file_command): Close was getting called twice; once directly and once through cleanup. Killed the direct call. Sun Dec 11 19:40:40 1988 & Smith (randy at hobbes.ai.mit.edu) * valprint.c (val_print): Deleted spurious printing of "=" from TYPE_CODE_REF case. Sat Dec 10 16:41:07 1988 Randall Smith (randy at gluteus.ai.mit.edu) * dbxread.c: Changed allocation of psymbols from using malloc and realloc to using obstacks. This means they aren't realloc'd out from under the pointers to them. Fri Dec 9 10:33:24 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * sparc-dep.c inflow.c core.c expread.y command.c infrun.c infcmd.c dbxread.c symmisc.c symtab.c printcmd.c valprint.c values.c source.c stack.c findvar.c breakpoint.c blockframe.c main.c: Various cleanups inspired by "gcc -Wall" (without checking for implicit declarations). * Makefile: Cleaned up some more. * valops.c, m-*.h (FIX_CALL_DUMMY): Modified to take 5 arguments as per what sparc needs (programming for a superset of needed args). * dbxread.c (process_symbol_for_psymtab): Modified to be slightly more picky about what it puts on the list of things *not* to be put on the misc function list. When/if I shift everything over to being placed on the misc_function_list, this will go away. * inferior.h, infrun.c: Added fields to save in inferior_status structure. * maketarfile: Deleted; functionality is in Makefile now. * infrun.c (wait_for_inferior): Modified algorithm for determining whether or not a single-step was through a subroutine call. See comments at top of file. * dbxread.c (read_dbx_symtab): Made sure that the IGNORE_SYMBOL macro would be checked during initial readin. * dbxread.c (read_ofile_symtab): Added macro GCC_COMPILED_FLAG_SYMBOL into dbxread.c to indicate what string in a local text symbol will indicate a file compiled with gcc. Defaults to "gcc_compiled.". Thu Dec 8 11:46:22 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * m-sparc.h (FRAME_FIND_SAVED_REGS): Cleaned up a little to take advantage of the new frame cache system. * inferior.h, infrun.c, valops.c, valops.c, infcmd.c: Changed mechanism to save inferior status over calls to inferior (eg. call_function); implemented save_inferior_info and restore_inferior_info. * blockframe.c (get_prev_frame): Simplified this by a direct call to get_prev_frame_info. * frame.h, stack.c, printcmd.c, m-sparc.h, sparc-dep.c: Removed all uses of frame_id_from_addr. There are short routines like it still in frame_saved_pc (m-sparc.h) and parse_frame_spec (stack.c). Eventually the one in frame_saved_pc will go away. * infcmd.c, sparc-dep.c: Implemented a new mechanism for re-selecting the selected frame on return from a call. * blockframe.c, stack.c, findvar.c, printcmd.c, m-*.h: Changed all routines and macros that took a "struct frame_info" as an argument to take a "struct frame_info *". Routines: findarg, framechain, print_frame_args, FRAME_ARGS_ADDRESS, FRAME_STRUCT_ARGS_ADDRESS, FRAME_LOCALS_ADDRESS, FRAME_NUM_ARGS, FRAME_FIND_SAVED_REGS. * frame.h, stack.c, printcmd.c, infcmd.c, findvar.c, breakpoint.c, blockframe.c, xgdb.c, i386-pinsn.c, gld-pinsn.c, m-umax.h, m-sun2.h, m-sun3.h, m-sparc.h, m-pn.h, m-npl.h, m-news.h, m-merlin.h, m-isi.h, m-i386.h, m-hp9k320.h: Changed routines to use "struct frame_info *" internally. Wed Dec 7 12:07:54 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * frame.h, blockframe.c, m-sparc.h, sparc-dep.c: Changed all calls to get_[prev_]frame_cache_item to get_[prev_]frame_info. * blockframe.c: Elminated get_frame_cache_item and get_prev_frame_cache_item; functionality now taken care of by get_frame_info and get_prev_frame_info. * blockframe.c: Put allocation on an obstack and eliminated fancy reallocation routines, several variables, and various nasty things. * frame.h, stack.c, infrun.c, blockframe.c, sparc-dep.c: Changed type FRAME to be a typedef to "struct frame_info *". Had to also change routines that returned frame id's to return the pointer instead of the cache index. * infcmd.c (finish_command): Used proper method of getting from function symbol to start of function. Was treating a symbol as a value. * blockframe.c, breakpoint.c, findvar.c, infcmd.c, stack.c, xgdb.c, i386-pinsn.c, frame.h, m-hp9k320.h, m-i386.h, m-isi.h, m-merlin.h, m-news.h, m-npl.h, m-pn.h, m-sparc.h, m-sun2.h, m-sun3.h, m-umax.h: Changed get_frame_info and get_prev_frame_info to return pointers instead of structures. * blockframe.c (get_pc_function_start): Modified to go to misc function table instead of bombing if pc was in a block without a containing function. * coffread.c: Dup'd descriptor passed to read_coff_symtab and fdopen'd it so that there wouldn't be multiple closes on the same fd. Also put (fclose, stream) on the cleanup list. * printcmd.c, stack.c: Changed print_frame_args to take a frame_info struct as argument instead of the address of the args to the frame. * m-i386.h (STORE_STRUCT_RETURN): Decremented sp by sizeof object to store (an address) rather than 1. * dbxread.c (read_dbx_symtab): Set first_object_file_end in read_dbx_symtab (oops). * coffread.c (fill_in_vptr_fieldno): Rewrote TYPE_BASECLASS as necessary. Tue Dec 6 13:03:43 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * coffread.c: Added fake support for partial_symtabs to allow compilation and execution without there use. * inflow.c: Added a couple of minor USG mods. * munch: Put in appropriate conditionals so that it would work on USG systems. * Makefile: Made regex.* handled same as obstack.*; made sure tar file included everything I wanted it to include (including malloc.c). * dbxread.c (end_psymtab): Create an entry in the partial_symtab_list for each subfile of the .o file just read in. This allows a "list expread.y:10" to work when we haven't read in expread.o's symbol stuff yet. * symtab.h, dbxread.c (psymtab_to_symtab): Recognize pst->ldsymlen == 0 as indicating a dummy psymtab, only in existence to cause the dependency list to be read in. * dbxread.c (sort_symtab_syms): Elminated reversal of symbols to make sure that register debug symbol decls always come before parameter symbols. After mod below, this is not needed. * symtab.c (lookup_block_symbol): Take parameter type symbols (LOC_ARG or LOC_REGPARM) after any other symbols which match. * dbxread.c (read_type): When defining a type in terms of some other type and the other type is supposed to have a pointer back to this specific kind of type (pointer, reference, or function), check to see if *that* type has been created yet. If it has, use it and fill in the appropriate slot with a pointer to it. Mon Dec 5 11:25:04 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * symmisc.c: Eliminated existence of free_inclink_symtabs and init_free_inclink_symtabs; they aren't called from anywhere, and if they were they could disrupt gdb's data structure badly (elimination of struct type's which values that stick around past elimination of inclink symtabs). * dbxread.c (symbol_file_command): Fixed a return pathway out of the routine to do_cleanups before it left. * infcmd.c (set_environment_command), gdb.texinfo: Added capability to set environmental variable values to null. * gdb.texinfo: Modified doc on "break" without args slightly. Sun Dec 4 17:03:16 1988 Randall Smith (randy at gluteus.ai.mit.edu) * dbxread.c (symbol_file_command): Added check; if there weren't any debugging symbols in the file just read, the user is warned. * infcmd.c: Commented set_environment_command (a little). * createtags: Cleaned up and commented. * Makefile: Updated dependency list and cleaned it up somewhat (used macros, didn't make .o files depend on .c files, etc.) Fri Dec 2 11:44:46 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * value.h, values.c, infcmd.c, valops.c, m-i386.h, m-sparc.h, m-merlin.h, m-npl.h, m-pn.h, m-umax.h, m-vax.h, m-hp9k320.h, m-isi.h, m-news.h, m-sun2.h, m-sun3.h: Cleaned up dealings with functions returning structures. Specifically: Added a function called using_struct_return which indicates whether the function being called is using the structure returning conventions or it is using the value returning conventions on that machine. Added a macro, STORE_STRUCT_RETURN to store the address of the structure to be copied into wherever it's supposed to go, and changed call_function to handle all of this correctly. * symseg.h, symtab.h, dbxread.c: Added hooks to recognize an N_TEXT symbol with name "*gcc-compiled*" as being a flag indicating that a file had been compiled with gcc and setting a flag in all blocks produced during processing of that file. Thu Dec 1 13:54:29 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * m-sparc.h (PUSH_DUMMY_FRAME): Saved 8 less than the current pc, as POP_FRAME and sparc return convention restore the pc to 8 more than the value saved. * valops.c, printcmd.c, findvar.c, value.h: Added the routine value_from_register, to access a specific register of a specific frame as containing a specific type, and used it in read_var_value and print_frame_args. Wed Nov 30 17:39:50 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * dbxread.c (read_number): Will accept either the argument passed as an ending character, or a null byte as an ending character. * Makefile, createtags: Added entry to create tags for gdb distribution which will make sure currently configured machine dependent files come first in the list. Wed Nov 23 13:27:34 1988 Randall Smith (randy at gluteus.ai.mit.edu) * stack.c, infcmd.c, sparc-dep.c: Modified record_selected_frame to work off of frame address. * blockframe.c (create_new_frame, get_prev_frame_cache_item): Added code to reset pointers within frame cache if it must be realloc'd. * dbxread.c (read_dbx_symtab): Added in optimization comparing last couple of characters instead of first couple to avoid strcmp's in read_dbx_symtab (recording extern syms in misc functions or not). 1 call to strlen is balanced out by many fewer calls to strcmp. Tue Nov 22 16:40:14 1988 Randall Smith (randy at cream-of-wheat.ai.mit.edu) * dbxread.c (read_dbx_symtab): Took out optimization for ignoring LSYM's; was disallowing typedefs. Silly me. * Checkpointed distribution (mostly for sending to Tiemann). * expression.h: Added BINOP_MIN and BINOP_MAX operators for C++. * symseg.h: Included flags for types having destructors and constructors, and flags being defined via public and via virtual paths. Added fields NEXT_VARIANT, N_BASECLASSES, and BASECLASSES to this type (tr: Changed types from having to be derived from a single baseclass to a multiple base class). * symtab.h: Added macros to access new fields defined in symseg.h. Added decl for lookup_basetype_type. * dbxread.c (condense_addl_misc_bunches): Function added to condense the misc function bunches added by reading in a new .o file. (read_addl_syms): Function added to read in symbols from a new .o file (incremental linking). (add_file_command): Command interface function to indicate incrmental linking of a new .o file; this now calls read_addl_syms and condense_addl_misc_bunches. (define_symbol): Modified code to handle types defined from base types which were not known when the derived class was output. (read_struct_type): Modified to better handle description of struct types as derived types. Possibly derived from several different base classes. Also added new code to mark definitions via virtual paths or via public paths. Killed seperate code to handle classes with destructors but without constructors and improved marking of classes as having destructors and constructors. * infcmd.c: Modified call to val_print (one more argument). * symtab.c (lookup_member_type): Modified to deal with new structure in symseg.h. (lookup_basetype_type): Function added to find or construct a type ?derived? from the given type. (decode_line_1): Modified to deal with new type data structures. Modified to deal with new number of args for decode_line_2. (decode_line_2): Changed number of args (?why?). (init_type): Added inits for new C++ fields from symseg.h. *valarith.c (value_x_binop, value_binop): Added cases for BINOP_MIN & BINOP_MAX. * valops.c (value_struct_elt, check_field, value_struct_elt_for_address): Changed to deal with multiple possible baseclasses. (value_of_this): Made SELECTED_FRAME an extern variable. * valprint.c (val_print): Added an argument DEREF_REF to dereference references automatically, instead of printing them like pointers. Changed number of arguments in recursive calls to itself. Changed to deal with varibale numbers of base classes. (value_print): Changed number of arguments to val_print. Print type of value also if value is a reference. (type_print_derivation_info): Added function to print out derivation info a a type. (type_print_base): Modified to use type_print_derivation_info and to handle multiple baseclasses. Mon Nov 21 10:32:07 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * inflow.c (term_status_command): Add trailing newline to output. * sparc-dep.c (do_save_insn, do_restore_insn): Saved "stop_registers" over the call for the sake of normal_stop and run_stack_dummy. * m-sparc.h (EXTRACT_RETURN_VALUE): Put in parenthesis to force addition of 8 to the int pointer, not the char pointer. * sparc-pinsn.c (print_addr1): Believe that I have gotten the syntax right for loads and stores as adb does it. * symtab.c (list_symbols): Turned search for match on rexegp into a single loop. * dbxread.c (psymtab_to_symtab): Don't read it in if it's already been read in. * dbxread.c (psymtab_to_symtab): Changed error to fatal in psymtab_to_symtab. * expread.y (parse_number): Fixed bug which treated 'l' at end of number as '0'. Fri Nov 18 13:57:33 1988 Randall Smith (randy at gluteus.ai.mit.edu) * dbxread.c (read_dbx_symtab, process_symbol_for_psymtab): Was being foolish and using pointers into an array I could realloc. Converted these pointers into integers. Wed Nov 16 11:43:10 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * m-sparc.h (POP_FRAME): Made the new frame be PC_ADJUST of the old frame. * i386-pinsn.c, m-hp9k320.h, m-isi.h, m-merlin.h, m-news.h, m-npl.h, m-pn.h, m-sparc.h, m-sun2.h, m-sun3.h, m-umax.h, m-vax.h: Modified POP_FRAME to use the current frame instead of read_register (FP_REGNUM) and to flush_cached_frames before setting the current frame. Also added a call to set the current frame in those POP_FRAMEs that didn't have it. * infrun.c (wait_for_inferior): Moved call to set_current_frame up to guarrantee that the current frame will always be set when a POP_FRAME is done. * infrun.c (normal_stop): Added something to reset the pc of the current frame (was incorrect because of DECR_PC_AFTER_BREAK). * valprint.c (val_print): Changed to check to see if a string was out of bounds when being printed and to indicate this if so. * convex-dep.c (read_inferior_memory): Changed to return the value of errno if the call failed (which will be 0 if the call suceeded). Tue Nov 15 10:17:15 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * infrun.c (wait_for_inferior): Two changes: 1) Added code to not trigger the step breakpoint on recursive calls to functions without frame info, and 2) Added calls to distinguish recursive calls within a function without a frame (which next/nexti might wish to step over) from jumps to the beginning of a function (which it generally doesn't). * m-sparc.h (INIT_EXTRA_FRAME_INFO): Bottom set correctly for leaf parents. * blockframe.c (get_prev_frame_cache_item): Put in mod to check for a leaf node (by presence or lack of function prologue). If there is a leaf node, it is assumed that SAVED_PC_AFTER_CALL is valid. Otherwise, FRAME_SAVED_PC or read_pc is used. * blockframe.c, frame.h: Did final deletion of unused routines and commented problems with getting a pointer into the frame cache in the frame_info structure comment. * blockframe.c, frame.h, stack.c: Killed use of frame_id_from_frame_info; used frame_id_from_addr instead. * blockframe.c, frame.h, stack.c, others (oops): Combined stack cache and frame info structures. * blockframe.c, sparc-dep.c, stack.c: Created the function create_new_frame and used it in place of bad calls to frame_id_from_addr. * blockframe.c, inflow.c, infrun.c, i386-pinsn.c, m-hp9k320.h, m-npl.h, m-pn.h, m-sparc.h, m-sun3.h, m-vax.h, default-dep.c, convex-dep.c, gould-dep.c, hp9k320-dep.c, news-dep.c, sparc-dep.c, sun3-dep.c, umax-dep.c: Killed use of set_current_Frame_by_address. Used set_current_frame (create_new_frame...) instead. * frame.h: Killed use of FRAME_FP_ID. * infrun.c, blockframe.c: Killed select_frame_by_address. Used select_frame (get_current_frame (), 0) (which was correct in all cases that we need to worry about. Mon Nov 14 14:19:32 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * frame.h, blockframe.c, stack.c, m-sparc.h, sparc-dep.c: Added mechanisms to deal with possible specification of frames dyadically. Sun Nov 13 16:03:32 1988 Richard Stallman (rms at sugar-bombs.ai.mit.edu) * ns32k-opcode.h: Add insns acbw, acbd. Sun Nov 13 15:09:58 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * breakpoint.c: Changed breakpoint structure to use the address of a given frame (constant across inferior runs) as the criteria for stopping instead of the frame ident (which varies across inferior calls). Fri Nov 11 13:00:22 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * gld-pinsn.c (findframe): Modified to work with the new frame id's. Actually, it looks as if this routine should be called with an address anyway. * findvar.c (find_saved_register): Altered bactrace loop to work off of frames and not frame infos. * frame.h, blockframe.c, stack.c, sparc-dep.c, m-sparc.h: Changed FRAME from being the address of the frame to being a simple ident which is an index into the frame_cache_item list. * convex-dep.c, default-dep.c, gould-dep.c, hp9k320-dep.c, i386-pinsn.c, inflow.c, infrun.c, news-dep.c, sparc-dep.c, sun3-dep.c, umax-dep.c, m-hp9k320.h, m-npl.h, m-pn.h, m-sparc.h, m-sun3.h, m-vax.h: Changed calls of the form set_current_frame (read_register (FP_REGNUM)) to set_current_frame_by_address (...). Thu Nov 10 16:57:57 1988 Randall Smith (randy at gluteus.ai.mit.edu) * frame.h, blockframe.c, gld-pinsn.c, sparc-dep.c, stack.c, infrun.c, findvar.c, m-sparc.h: Changed the FRAME type to be purely an identifier, using FRAME_FP and FRAME_FP_ID to convert back and forth between the two. The identifier is *currently* still the frame pointer value for that frame. Wed Nov 9 17:28:14 1988 Chris Hanson (cph at kleph) * m-hp9k320.h (FP_REGISTER_ADDR): Redefine this to return difference between address of given FP register, and beginning of `struct user' that it occurs in. * hp9k320-dep.c (core_file_command): Fix sign error in size argument to myread. Change buffer argument to pointer; was copying entire structure. (fetch_inferior_registers, store_inferior_registers): Replace occurrences of `FP_REGISTER_ADDR_DIFF' with `FP_REGISTER_ADDR'. Flush former definition. Wed Nov 9 12:11:37 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * xgdb.c: Killed include of initialize.h. * Pulled in xgdb.c from the net. * Checkpointed distribution (to provide to 3b2 guy). * coffread.c, dbxread.c, symmisc.c, symtab.c, symseg.h: Changed format of table of line number--pc mapping information. Can handle negative pc's now. * command.c: Deleted local copy of savestring; code in utils.c is identical. Tue Nov 8 11:12:16 1988 Randall Smith (randy at plantaris.ai.mit.edu) * gdb.texinfo: Added documentation for shell escape. Mon Nov 7 12:27:16 1988 Randall Smith (randy at sugar-bombs.ai.mit.edu) * command.c: Added commands for shell escape. * core.c, dbxread.c: Added ROBOTUSSIN mods. * Checkpointed distribution. * printcmd.c (x_command): Yanked error if there is no memory to examine (could be looking at executable straight). * sparc-pinsn.c (print_insn): Amount to leftshift sethi imm by is now 10 (matches adb in output). * printcmd.c (x_command): Don't attempt to set $_ & $__ if there is no last_examine_value (can happen if you did an x/0). Fri Nov 4 13:44:49 1988 Randall Smith (randy at gluteus.ai.mit.edu) * printcmd.c (x_command): Error if there is no memory to examine. * gdb.texinfo: Added "cont" to the command index. * sparc-dep.c (do_save_insn): Fixed typo in shift amount. * m68k-opcode.h: Fixed opcodes for 68881. * breakpoint.c, infcmd.c, source.c: Changed defaults in several places for decode_line_1 to work off of the default_breakpoint_* values instead of current_source_* values (the current_source_* values are off by 5 or so because of listing defaults). * stack.c (frame_info): ifdef'd out FRAME_SPECIFCATION_DYADIC in the stack.c module. If I can't do this right, I don't want to do it at all. Read the comment there for more info. Mon Oct 31 16:23:06 1988 Randall Smith (randy at gluteus.ai.mit.edu) * gdb.texinfo: Added documentation on the "until" command. Sat Oct 29 17:47:10 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * breakpoint.c, infcmd.c: Added UNTIL_COMMAND and subroutines of it. * breakpoint.c, infcmd.c, infrun.c: Added new field to breakpoint structure (silent, indicating a silent breakpoint), and modified breakpoint_stop_status and things that read it's return value to understand it. Fri Oct 28 17:45:33 1988 Randall Smith (randy at gluteus.ai.mit.edu) * dbxread.c, symmisc.c: Assorted speedups for readin, including special casing most common symbols, and doing buffering instead of calling malloc. Thu Oct 27 11:11:15 1988 Randall Smith (randy at gluteus.ai.mit.edu) * stack.c, sparc-dep.c, m-sparc.h: Modified to allow "info frame" to take two arguments on the sparc and do the right thing with them. * dbxread.c (read_dbx_symtab, process_symbol_for_psymtab): Put stuff to put only symbols that didn't have debugging info on the misc functions list back in. Wed Oct 26 10:10:32 1988 Randall Smith (randy at gluteus.ai.mit.edu) * valprint.c (type_print_varspec_suffix): Added check for TYPE_LENGTH(TYPE_TARGET_TYPE(type)) > 0 to prevent divide by 0. * printcmd.c (print_formatted): Added check for VALUE_REPEATED; value_print needs to be called for that. * infrun.c (wait_for_inferior): Added break when you decide to stop on a null function prologue rather than continue stepping. * m-sun3.h: Added explanatory comment to REGISTER_RAW_SIZE. * expread.y (parse_c_1): Initialized paren_depth for each parse. Tue Oct 25 14:19:38 1988 Randall Smith (randy at gluteus.ai.mit.edu) * valprint.c, coffread.c, dbxread.c: Enum constant values in enum type now accessed through TYPE_FIELD_BITPOS. * dbxread.c (process_symbol_for_psymtab): Added code to deal with possible lack of a ":" in a debugging symbol (do nothing). * symtab.c (decode_line_1): Added check in case of all numbers for complete lack of symbols. * source.c (select_source_symtab): Made sure that this wouldn't bomb on complete lack of symbols. Mon Oct 24 12:28:29 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * m-sparc.h, findvar.c: Ditched REGISTER_SAVED_UNIQUELY and based code on REGISTER_IN_WINDOW_P and HAVE_REGISTER_WINDOWS. This will break when we find a register window machine which saves the window registers within the context of an inferior frame. * sparc-dep.c (frame_saved_pc): Put PC_ADJUST return back in for frame_saved_pc. Seems correct. * findvar.c, m-sparc.h: Created the macro REGISTER_SAVED_UNIQUELY to handle register window issues (ie. that find_saved_register wasn't checking the selected frame itself for shit). * sparc-dep.c (core_file_command): Offset target of o & g register bcopy by 1 to hit correct registers. * m-sparc.h: Changed STACK_END_ADDR. Sun Oct 23 19:41:51 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * sparc-dep.c (core_file_command): Added in code to get the i & l registers from the stack in the corefile, and blew away some wrong code to get i & l from inferior. Fri Oct 21 15:09:19 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) * m-sparc.h (PUSH_DUMMY_FRAME): Saved the value of the RP register in the location reserved for i7 (in the created frame); this way the rp value won't get lost. The pc (what we put into the rp in this routine) gets saved seperately, so we loose no information. * sparc-dep.c (do_save_insn & do_restore_insn): Added a wrapper to preserve the proceed status state variables around each call to proceed (the current frame was getting munged because this wasn't being done). * m-sparc.h (FRAME_FIND_SAVED_REGS): Fix bug: saved registers addresses were being computed using absolute registers number, rather than numbers relative to each group of regs. * m-sparc.h (POP_FRAME): Fixed a bug (I hope) in the context within which saved reg numbers were being interpetted. The values to be restored were being gotten in the inferior frame, and the restoring was done in the superior frame. This means that i registers must be restored into o registers. * sparc-dep.c (do_restore_insn): Modified to take a pc as an argument, instead of a raw_buffer. This matches (at least it appears to match) usage from POP_FRAME, which is the only place from which do_restore_insn is called. * sparc-dep.c (do_save_insn and do_restore_insn): Added comments. * m-sparc.h (FRAME_FIND_SAVED_REGS): Modified my code to find the save addresses of out registers to use the in regs off the stack pointer when the current frame is 1 from the innermost. Thu Oct 20 13:56:15 1988 & Smith (randy at hobbes.ai.mit.edu) * blockframe.c, m-sparc.h: Removed code associated with GET_PREV_FRAME_FROM_CACHE_ITEM. This code was not needed for the sparc; you can always find the previous frames fp from the fp of the current frame (which is the sp of the previous). It's getting the information associated with a given frame (ie. saved registers) that's a bitch, because that stuff is saved relative to the stack pointer rather than the frame pointer. * m-sparc.h (GET_PREV_FRAME_FROM_CACHE_ITEM): Modified to return the frame pointer of the previous frame instead of the stack pointer of same. * blockframe.c (flush_cached_frames): Modified call to obstack_free to free back to frame_cache instead of back to zero. This leaves the obstack control structure in finite state (and still frees the entry allocated at frame_cache). Sat Oct 15 16:30:47 1988 & Smith (randy at tartarus.uchicago.edu) * valops.c (call_function): Suicide material here. Fixed a typo; CALL_DUMMY_STACK_ADJUST was spelled CAll_DUMMY_STACK_ADJUST on line 530 of the file. This cost me three days. I'm giving up typing for lent. Fri Oct 14 15:10:43 1988 & Smith (randy at tartarus.uchicago.edu) * m-sparc.h: Corrected a minor mistake in the dummy frame code that was getting the 5th argument and the first argument from the same place. Tue Oct 11 11:49:33 1988 & Smith (randy at tartarus.uchicago.edu) * infrun.c: Made stop_after_trap and stop_after_attach extern instead of static so that code which used proceed from machine dependent files could fiddle with them. * blockframe.c, frame.h, sparc-dep.c, m-sparc.h: Changed sense of ->prev and ->next in struct frame_cache_item to fit usage in rest of gdb (oops). Mon Oct 10 15:32:42 1988 Randy Smith (randy at gargoyle.uchicago.edu) * m-sparc.h, sparc-dep.c, blockframe.c, frame.h: Wrote get_frame_cache_item. Modified FRAME_SAVED_PC and frame_saved_pc to take only one argument and do the correct thing with it. Added the two macros I recently defined in blockframe.c to m-sparc.h. Have yet to compile this thing on a sparc, but I've now merged in everything that I received from tiemann, either exactly, or simply effectively. * source.c: Added code to allocated space to sals.sals in the case where no line was specified. * blockframe.c, infrun.c: Modified to cache stack frames requested to minimize accesses to subprocess. Tue Oct 4 15:10:39 1988 Randall Smith (randy at cream-of-wheat.ai.mit.edu) * config.gdb: Added sparc. Mon Oct 3 23:01:22 1988 Randall Smith (randy at cream-of-wheat.ai.mit.edu) * Makefile, blockframe.c, command.c, core.c, dbxread.c, defs.h, expread.y, findvar.c, infcmd.c, inflow.c, infrun.c, sparc-pinsn.c, m-sparc.h, sparc-def.c, printcmd.c, stack.c, symmisc.c, symseg.h, valops.c, values.c: Did initial merge of sparc port. This will not compile; have to do stack frame caching and finish port. * inflow.c, gdb.texinfo: `tty' now resets the controling terminal. Fri Sep 30 11:31:16 1988 Randall Smith (randy at gluteus.ai.mit.edu) * inferior.h, infcmd.c, infrun.c: Changed the variable stop_random_signal to stopped_by_random signal to fit in better with name conventions (variable is not a direction to the proceed/resume set; it is information from it). Thu Sep 29 13:30:46 1988 Randall Smith (randy at cream-of-wheat.ai.mit.edu) * infcmd.c (finish_command): Value type of return value is now whatever the function returns, not the type of the function (fixed a bug in printing said value). * dbxread.c (read_dbx_symtab, process_symbol_for_psymtab): Put *all* global symbols into misc_functions. This is what was happening anyway, and we need it for find_pc_misc_function. ** This was eventually taken out, but I didn't mark it in the ChangeLog. Oops. * dbxread.c (process_symbol_for_psymtab): Put every debugger symbol which survives the top case except for constants on the symchain. This means that all of these *won't* show up in misc functions (this will be fixed once I make sure it's broken the way it's supposed to be). * dbxread.c: Modified placement of debugger globals onto the hash list; now we exclude the stuff after the colon and don't skip the first character (debugger symbols don't have underscores). * dbxread.c: Killed debuginfo stuff with ifdef's. Wed Sep 28 14:31:51 1988 Randall Smith (randy at cream-of-wheat.ai.mit.edu) * symtab.h, dbxread.c: Modified to deal with BINCL, EINCL, and EXCL symbols produced by the sun loader by adding a list of pre-requisite partial_symtabs that each partial symtab needs. * symtab.h, dbxread.c, symtab.c, symmisc.c: Modified to avoid doing a qsort on the local (static) psymbols for each file to speed startup. This feature is not completely debugged, but it's inclusion has forced the inclusion of another feature (dealing with EINCL's, BINCL's and EXCL's) and so I'm going to go in and deal with them. * dbxread.c (process_symbol_for_psymtab): Made sure that the class of the symbol made it into the partial_symbol entry. Tue Sep 27 15:10:26 1988 Randall Smith (randy at gluteus.ai.mit.edu) * dbxread.c: Fixed bug; init_psymbol_list was not being called with the right number of arguments (1). * dbxread.c: Put ifdef's around N_MAIN, N_M2C, and N_SCOPE to allow compilation on a microvax. * config.gdb: Modified so that "config.gdb vax" would work. * dbxread.c, symtab.h, symmisc.h, symtab.c, source.c: Put in many and varied hacks to speed up gdb startup including: A complete rewrite of read_dbx_symtab, a modification of the partial_symtab data type, deletion of select_source_symtab from symbol_file_command, and optimiztion of the call to strcmp in compare_psymbols. Thu Sep 22 11:08:54 1988 Randall Smith (randy at gluteus.ai.mit.edu) * dbxread.c (psymtab_to_symtab): Removed call to init_misc_functions. * dbxread.c: Fixed enumeration type clash (used enum instead of integer constant). * breakpoint.c: Fixed typo; lack of \ at end of line in middle of string constant. * symseg.h: Fixed typo; lack of semicolon after structure definition. * command.c, breakpoint.c, printcmd.c: Added cmdlist editing functions to add commands with the abbrev flag set. Changed help_cmd_list to recognize this flag and modified unset, undisplay, and enable, disable, and delete breakpoints to have this flag set. Wed Sep 21 13:34:19 1988 Randall Smith (randy at plantaris.ai.mit.edu) * breakpoint.c, infcmd.c, gdb.texinfo: Created "unset" as an alias for delete, and changed "unset-environment" to be the "environment" subcommand of "delete". * gdb.texinfo, valprint.c: Added documentation in the manual for breaking the set-* commands into subcommands of set. Changed "set maximum" to "set array-max". * main.c, printcmd.c, breakpoint.c: Moved the declaration of command lists into main and setup a function in main initializing them to guarrantee that they would be initialized before calling any of the individual files initialize routines. * command.c (lookup_cmd): A null string subcommand is treated as an unknown subcommand rather than an ambiguous one (eg. "set $x = 1" will now work). * infrun.c (wait_for_inferior): Put in ifdef for Sony News in check for trap by INNER_THAN macro. * eval.c (evaluate_subexp): Put in catch to keep the user from attempting to call a non function as a function. Tue Sep 20 10:35:53 1988 Randall Smith (randy at oatmeal.ai.mit.edu) * dbxread.c (read_dbx_symtab): Installed code to keep track of which global symbols did not have debugger symbols refering to them, and recording these via record_misc_function. * dbxread.c: Killed code to check for extra global symbols in the debugger symbol table. * printcmd.c, breakpoint.c: Modified help entries for several commands to make sure that abbreviations were clearly marked and that the right commands showed up in the help listings. * main.c, command.c, breakpoint.c, infcmd.c, printcmd.c, valprint.c, defs.h: Modified help system to allow help on a class name to show subcommands as well as commands and help on a command to show *all* subcommands of that command. Fri Sep 16 16:51:19 1988 Randall Smith (randy at gluteus.ai.mit.edu) * breakpoint.c (_initialize_breakpoint): Made "breakpoints" subcommands of enable, disable, and delete use class 0 (ie. they show up when you do a help xxx now). * infcmd.c,printcmd,c,main.c,valprint.c: Changed the set-* commands into subcommands of set. Created "set variable" for use with variables whose names might conflict with other subcommands. * blockframe.c, dbxread.c, coffread.c, expread.y, source.c: Fixed mostly minor (and one major one in block_for_pc) bugs involving checking the partial_symtab_list when a scan through the symtab_list fails. Wed Sep 14 12:02:05 1988 Randall Smith (randy at sugar-smacks.ai.mit.edu) * breakpoint.c, gdb.texinfo: Added enable breakpoints, disable breakpoints and delete breakpoints as synonyms for enable, disable, and delete. This seemed reasonable because of the immeninent arrival of watchpoints & etc. * gdb.texinfo: Added enable display, disable display, and delete display to manual. Tue Sep 13 16:53:56 1988 Randall Smith (randy at sugar-smacks.ai.mit.edu) * inferior.h, infrun.c, infcmd.c: Added variable stop_random_signal to indicate when a proceed had been stopped by an unexpected signal. Used this to determine (in normal_stop) whether the current display point should be deleted. * valops.c: Fix to value_ind to check for reference before doing a COERCE_ARRAY. Sun Jul 31 11:42:36 1988 Richard Stallman (rms at frosted-flakes.ai.mit.edu) * breakpoint.c (_initialize_breakpoint): Clean up doc for commands that can now apply also to auto-displays. * coffread.c (record_line): Corrected a spazz in editing. Also removed the two lines that assume line-numbers appear only in increasing order. Tue Jul 26 22:19:06 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) * expression.h, eval.c, expprint.c, printcmd.c, valarith.c, valops.c, valprint.c, values.c, m-*.h: Changes for evaluating and displaying 64-bit `long long' integers. Each machine must define a LONGEST type, and a BUILTIN_TYPE_LONGEST. * symmisc.c: (print_symtab) check the status of the fopen and call perror_with_name if needed. Thu Jul 21 00:56:11 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) * Convex: core.c: changes required by Convex's SOFF format were isolated in convex-dep.c. Wed Jul 20 21:26:10 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) * coffread.c, core.c, expread.y, i386-pinsn.c, infcmd.c, inflow.c, infrun.c, m-i386.h, main.c, remote.c, source.c, valops.c: Improvements for the handling of the i386 and other machines running USG. (Several of these files just needed extra header files such as types.h.) utils.c: added bcopy, bcmp, bzero, getwd, list of signals, and queue routines for USG systems. Added vfork macro to i386 * printcmd.c, breakpoint.c: New commands to enable/disable auto-displays. Also `delete display displaynumber' works like `undisplay displaynumber'. Tue Jul 19 02:17:18 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) * coffread.c: (coff_lookup_type) Wrong portion of type_vector was being bzero'd after type_vector was reallocated. * printcmd.c: (delete_display) Check for a display chain before attempting to delete a display. * core.c, *-dep.c (*-infdep moved to *-dep): machine-dependent parts of core.c (core_file_command, exec_file_command) moved to *-dep.c. Mon Jul 18 19:45:51 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) * dbxread.c: typo in read_struct_type (missing '=') was causing a C struct to be parsed as a C++ struct, resulting in a `invalid character' message. Sun Jul 17 22:27:32 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) * printcmd.c, symtab.c, valops.c, expread.y: When an expression is read, the innermost block required to evaluate the expression is saved in the global variable `innermost_block'. This information is saved in the `block' field of an auto-display so that expressions with inactive variables can be skipped. `info display' tells the user which displays are active and which are not. New fn `contained_in' returns nonzero if one block is contained within another. Fri Jul 15 01:53:14 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) * infrun.c, m-i386.h: Use macro TRAPS_EXPECTED to set number of traps to skip when sh execs the program. Default is 2, m-i386.h overrides this and sets to 4. * coffread.c, infrun.c: minor changes for the i386. May be able to eliminate them with more general code. * default-infdep.c: #ifdef SYSTEMV, include header file types.h. Also switched the order of signal.h and user.h, since System 5 requires signal.h to come first. * core.c main.c, remote,c, source.c, inflow.c: #ifdef SYSTEMV, include various header files. Usually types.h and fcntl.h. * utils.c: added queue routines needed by the i386 (and other sys 5 machines). * sys5.c, regex.c, regex.h: new files for sys 5 systems. (The regex files are simply links to /gp/gnu/lib.) Thu Jul 14 01:47:14 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) * config.gdb, README: Provide a list of known machines when user enters an invalid machine. New second arg is operating system, currently only used with `sunos4' or `os4'. Entry for i386 added. * news-infdep.c: new file. * m-news.h: new version which deals with new bugs in news800's OS. Tue Jul 12 19:52:16 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) * Makefile, *.c, munch, config.gdb, README: New initialization scheme uses nm to find functions whose names begin with `_initialize_'. Files `initialize.h', `firstfile.c', `lastfile.c', `m-*init.h' no longer needed. * eval.c, symtab.c, valarith.c, valops.c, value.h, values.c: Bug fixes from gdb+ 2.5.4. evaluate_subexp takes a new arg, type expected. New fn value_virtual_fn_field. Mon Jul 11 00:48:49 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) * core.c (read_memory): xfer_core_file was being called with an extra argument (0) by read_memory. * core.c (read_memory), *-infdep.c (read_inferior_memory), valops.c (value_at): read_memory and read_inferior_memory now work like write_memory and write_inferior_memory in that errno is checked after each ptrace and returned to the caller. Used in value_at to detect references to addresses which are out of bounds. Also core.c (xfer_core_file): return 1 if invalid address, 0 otherwise. * inflow.c, <machine>-infdep.c: removed all calls to ptrace from inflow.c and put them in machine-dependent files *-infdep.c. Sun Jul 10 19:19:36 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) * symmisc.c: (read_symsegs) Accept only format number 2. Since the size of the type structure changed when C++ support was added, format 1 can no longer be used. * core.c, m-sunos4.h: (core_file_command) support for SunOS 4.0. Slight change in the core structure. #ifdef SUNOS4. New file m-sunos4.h. May want to change config.gdb also. Fri Jul 8 19:59:49 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) * breakpoint.c: (break_command_1) Allow `break if condition' rather than parsing `if' as a function name and returning an error. Thu Jul 7 22:22:47 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) * C++: valops.c, valprint.c, value.h, values.c: merged code to deal with C++ expressions. Wed Jul 6 03:28:18 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) * C++: dbxread.c: (read_dbx_symtab, condense_misc_bunches, add_file_command) Merged code to read symbol information from an incrementally linked file. symmisc.c: (init_free_inclink_symtabs, free_inclink_symtabs) Cleanup routines. Tue Jul 5 02:50:41 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) * C++: symtab.c, breakpoint.c, source.c: Merged code to deal with ambiguous line specifications. In C++ one can have overloaded function names, so that `list classname::overloadedfuncname' refers to several different lines, possibly in different files. Fri Jul 1 02:44:20 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) * C++: symtab.c: replaced lookup_symtab_1 and lookup_symtab_2 with a modified lookup_symbol which checks for fields of the current implied argument `this'. printcmd.c, source.c, symtab.c, valops.c: Need to change callers once callers are installed. Wed Jun 29 01:26:56 1988 Peter TerMaat (pete at frosted-flakes.ai.mit.edu) * C++: eval.c, expprint.c, expread.y, expression.h, valarith.c, Merged code to deal with evaluation of user-defined operators, member functions, and virtual functions. binop_must_be_user_defined tests for user-defined binops, value_x_binop calls the appropriate operator function. Tue Jun 28 02:56:42 1988 Peter TerMaat (pete at frosted-flakes.ai.mit.edu) * C++: Makefile: changed the echo: expect 101 shift/reduce conflicts and 1 reduce/reduce conflict. Local Variables: mode: indented-text left-margin: 8 fill-column: 74 version-control: never End: | http://opensource.apple.com/source/gdb/gdb-1344/src/gdb/ChangeLog-3.x | CC-MAIN-2016-36 | refinedweb | 28,287 | 60.92 |
Introduction
In one of the previous article on databinding, I demonstrated the use of native event binding like button click. Here in this article I will show you how to create your own custom event and listen on to it. We will create a component with a custom event that will emit or send some data and another component will listen to that event and receive that data.
Custom Event Binding
Lets create a component class and name it as
CustomEventComponent. The class will have a custom property event named
action which will be an instance of type
EventEmitter. The
EventEmitter type is used to emit or send the events and another entity or component can listen to this event. Let’s first look at the code:
import { Component, EventEmitter, Output } from '@angular/core'; @Component({ selector: 'custom-event', template: ` <button (click)="onClick()">Click Me</button> `, styles: [] }) export class CustomEventComponent { @Output() private action = new EventEmitter<string>(); onClick() { this.action.emit("This is the action"); } }
The above component class
CustomEventComponent has a property
action, an object of type
EventEmitter. The action property represents an event. The
EventEmitter class is part of Angular core package. Next we define a method named
onClick() which will use the
action event property to emit some text. Since we are emitting text, the
EventEmitter is used with generic type
<string>. You can use any other data types with the
EventEmitter to emit the value of that type. The function
onClick() will be invoked upon clicking the button which will then emit the text “This is the action”. Observe the meta data
@Output() prefixed to the
action event property. It means this event can be made listenable from another component. The
Output meta data is part of Angular core package.
Let’s create another component called
EventListenerComponent and here we will listen to the above defined
action event for any text message and display the same. We will bind the event to the
<custom-event> selector of the
CustomEventComponent component class.
import { Component} from '@angular/core'; @Component({ selector: 'event-listener', template: ` <custom-event (action)="onReceive($event)"></custom-event> `, styles: [] }) export class EventListenerComponent { onReceive(message: string) { alert(message); } }
As you can see from the above code, we are listening to the custom
action event. Once the event is triggered it will invoke the
onRecieve() method. The
onRecieve() method takes
$event object as a parameter which encapsulates the string that is emitted by the
action event. In the
onRecieve() method definition, we are simply displaying the text emitted by the
action event. The output will display an alert box with the text “This is the action”. | http://techorgan.com/javascript-framework/angularjs-2-series-custom-event-binding/ | CC-MAIN-2017-26 | refinedweb | 436 | 53.92 |
Python : Convert IEEE to IBM Floating Point
When creating code to read a SEG-Y file, I get the IEEE and IBM Floating Point format data.). You get the more information with the table below :
With this information and searching in internet, I am create a Python to Convert IEEE to IBM Floating Point. You can copy this Python Convert IEEE to IBM Floating Point at below :
''' Created on July 11, 2012 @author: toto ''' import string import sys import struct import numpy as np import math # convert floating point to ibm def ieee2ibm(x, endian): # check input data if(x > 7.236998675585915e+75): return(0x7ffffff0) if(x < -7.236998675585915e+75): return(0xfffffff0) if(x == 0): return 0 if(x == np.NAN): #check input if NAN number return (0x7fffffff) #conversion log2 from matlab F, E = math.frexp(abs(x)) e = float (E/4.0); # exponent of base 16 ec = math.ceil(e); # adjust upwards to integer p = ec + 64; # offset exponent f = F * pow(2,(-4*(ec-e))); # correct mantissa for fractional part of exponent # convert to integer. Roundoff here can be as large as # 0.5/2^20 when mantissa is close to 1/16 so that # 3 bits of signifance are lost. f1 = round(f * 0x1000000); # format hex # put exponent in first byte of psi. tmpi = p * 0x1000000; if(tmpi<=0): psi = 0 elif(tmpi>=0xFFFFFFFF): psi = 0xFFFFFFFF else: psi = tmpi # put mantissa into last 3 bytes of phi if(f1<=0): phi = 0 elif(f1>=0xFFFFFFFF): phi = 0xFFFFFFFF else: phi = f1 # make bit representation # exponent and mantissa b = int(psi) | int(phi) # sign bit if(x<0): b = b + 0x80000000 #print b b = np.uint32(b) if(endian): #big endian cval = struct.pack(">i",b) else: #litte endian cval = struct.pack("<i",b) return (cval) #MAIN PROGRAM x = 100.3 fibm = ieee2ibm(x, 1) strinfo = 'x=%i' %x + ' --> IBM Value = %f' %fibm print(strinfo)
Save this Python to Convert IEEE to IBM Floating Point source code as ieee2ibm.py. Try to running this Python to Convert IEEE to IBM Floating Point with command :
python ieee2ibm.py
This is a Python to Convert IEEE to IBM Floating Point source code, are you have other method to convert IEEE to IBM Floating Point ? Please share at hereSource : | http://toto-share.com/2012/07/python-convert-ieee-to-ibm-floating-point/ | CC-MAIN-2013-20 | refinedweb | 377 | 72.05 |
To write to a file, we need to create an object of the FileOutputStream class, which will represent the output stream.
// Create a file output stream String destFile = "test.txt"; FileOutputStream fos = new FileOutputStream(destFile);
When writing to a file, Java tries to create the file if the file does not exist. We must be ready to handle this exception by placing your code in a try-catch block, as shown:
try { FileOutputStream fos = new FileOutputStream(srcFile); }catch (FileNotFoundException e){ // Error handling code goes here }
If the file contains data, the data will be erased. To keep the existing data and append the new data to the file, we need to use another constructor of the FileOutputStream class, which accepts a boolean flag for appending the new data to the file.
To append data to the file, pass true in the second argument, use the following code.
FileOutputStream fos = new FileOutputStream(destFile, true);
The FileOutputStream class has an overloaded write() method to write data to a file. We can write one byte or multiple bytes at a time using the different versions of this method.
Typically, we write binary data using a FileOutputStream.
To write a string such as "Hello" to the output stream, convert the string to bytes.
The String class has a getBytes() method that returns an array of bytes that represents the string. We write a string to the FileOutputStream as follows:
String text = "Hello"; byte[] textBytes = text.getBytes(); fos.write(textBytes);
To insert a new line, use the line.separator system variable as follows.
String lineSeparator = System.getProperty("line.separator"); fos.write(lineSeparator.getBytes());
We need to flush the output stream using the flush() method.
fos.flush();
Flushing an output stream indicates that if any written bytes were buffered, they may be written to the data sink.
Closing an output stream is similar to closing an input stream. We need to close the output stream using its close() method.
// Close the output stream fos.close();
The close() method may throw an IOException. Use a try-with-resources to create an output stream if we want tit to be closed automatically.
The following code shows how to write Bytes to a File Output Stream.
import java.io.File; import java.io.FileOutputStream; //from www .java 2 s . c o m public class Main { public static void main(String[] args) { String destFile = "luci2.txt"; // Get the line separator for the current platform String lineSeparator = System.getProperty("line.separator"); String line1 = "test"; String line2 = "test1"; String line3 = "test2"; String line4 = "test3"; try (FileOutputStream fos = new FileOutputStream(destFile)) { fos.write(line1.getBytes()); fos.write(lineSeparator.getBytes()); fos.write(line2.getBytes()); fos.write(lineSeparator.getBytes()); fos.write(line3.getBytes()); fos.write(lineSeparator.getBytes()); fos.write(line4.getBytes()); // Flush the written bytes to the file fos.flush(); System.out.println("Text has been written to " + (new File(destFile)).getAbsolutePath()); } catch (Exception e2) { e2.printStackTrace(); } } }
The code above generates the following result. | http://www.java2s.com/Tutorials/Java/Java_io/0210__Java_io_FileOutputStream.htm | CC-MAIN-2018-34 | refinedweb | 489 | 58.18 |
This tutorial explains how Java loops are created and how did they work.
Very often you will want to execute code fragments in your programs several times until some conditions are met. This is what loops are made for.
Java “for” Loop
With the help of the for loop you can execute a sequence of code lines multiple times. The “for” loop in Java works exactly as in other programming languages like C/C++. The for loop is very powerful and yet simple to learn. It is mostly used in searching or sorting algorithms as well in all cases where you want to iterate over collections of data. Here is a simple example of a “for” loop:
public class ForLoopExample { public static void main(String[] args) { for(int i=0; i<5; i++) { System.out.println("Iteration # " + i); } } }
The output of the example is as follows:
Iteration # 0 Iteration # 1 Iteration # 2 Iteration # 3 Iteration # 4
The general form of the
for statement can be expressed as follows:
for (initialization; termination; increment) { statement(s) }
The initialization part is where you declare your loop variables. Please note the variables initialized here will be only visible in the loop and destroyed after the loop is finished. In our example we initialize a new
int variable named
i and assign the value of zero to it.
for(int i=0; i<5; i++)
Termination is the boolean statement, which tells the loop for how long to be executed. Until the termination statement is true the loop will continue. In our example we are checking if the value of
i is less than 5
for(int i=0; i<5; i++)
The third parameter – increment – is executed after each cycle of the loop. Here we can increment the values of the variables declared in the initialization part.
What we do in our example is to increase the value of
i by 1 after each loop cycle.
i++ is a short form and does exactly the same as
i=i+1.
for(int i=0; i<5; i++)
Java “while” Loop
Another loop in java is the while loop.
The general form of the
while loop can be expressed as follows:
while(condition) { // execute code here }
Condition is boolean. This means until the condition is true the while loop will be executed. To learn more about boolean expressions read this tutorial. I will recreate our first example this time using while loop instead of for loop.
public class WhileLoopExample { public static void main(String[] args) { int i=0; while(i<5) { System.out.println("Iteration # " + i); i++; } } }
Now look at the example above. The initialization of our control variable
i is done outside of our loop but the increment by 1 is done inside the loop. The output is exactly the same as in our first example:
Iteration # 0 Iteration # 1 Iteration # 2 Iteration # 3 Iteration # 4
Loops are very often used in combination with arrays. In our next tutorial Java Arrays I will explain how to create, use and iterate over arrays. | https://javatutorial.net/java-loops | CC-MAIN-2019-43 | refinedweb | 508 | 61.87 |
Any emails from our Gmail Account without purchasing any smtp server etc.
There are some limitations for sending email from Gmail Account. Please note following things.
- Gmail will have fixed number of quota for sending emails per day. So you can not send more then that emails for the day.
- Your from email address always will be your account email address which you are using for sending email.
- You can not send an email to unlimited numbers of people. Gmail ant spamming policy will restrict this.
- Gmail provide both Popup and SMTP settings both should be active in your account where you testing. You can enable that via clicking on setting link in gmail account and go to Forwarding and POP/Imap.
So if you are using mail functionality for limited emails then Gmail is Best option. But if you are sending thousand of email daily then it will not be Good Idea.
Here is the code for sending mail from Gmail Account.
using System.Net.Mail;
namespace Experiement
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender,System.EventArgs e)
{
MailMessage mailMessage = new MailMessage(new MailAddress("from@gmail.com")
,new MailAddress("to@yahoo.com"));
mailMessage.Subject = "Sending mail through gmail account";
mailMessage.IsBodyHtml = true;
mailMessage.Body = "<B>Sending mail thorugh gmail from asp.net</B>";
System.Net.NetworkCredential networkCredentials = new
System.Net.NetworkCredential("yourgmailaddress@gmail.com", "yourpassword");
SmtpClient smtpClient = new SmtpClient();
smtpClient.EnableSsl = true;
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = networkCredentials;
smtpClient.Host = "smtp.gmail.com";
smtpClient.Port = 587;
smtpClient.Send(mailMessage);
Response.Write("Mail Successfully sent");
}
}
}
That’s run this application and you will get like below in your account.
when i wrote this same code it doesnt work properly when i put break point and after debug the error occured in smtpclient.send(mailmessage) please forward correct answer to my problem and more questuion is when we send sms from our gmail or yahoo account is there any need of firewalls na please reply me to mr.srinu369@gmail.com.
I hope u sent reply for this thank u very much...
Hello Srinu
What error you are getting. To check your accessibility of gmail you need to ping smtp.gmail.com.
Please send me error then I can help you in better way.
Regards,
Jalpesh | http://www.dotnetjalps.com/2010/12/sending-mail-with-gmail-account-using.html | CC-MAIN-2015-40 | refinedweb | 381 | 61.22 |
. Some of these components have the same roles and responsibilities with some improvements in Hadoop 2.x.
In case you are new to Hadoop and you are not getting what I have talked about in above paragraph, I request you to STOP HERE…..!!!!!
First, refer to my below posts first to get the idea about Hadoop,
- Brief Introduction of Hadoop
- Hadoop Concepts
- Hadoop Core Components
- Understanding Hadoop 1.x Architecture
Fine, Now on-wards I assume that you have some bazic knowledge about Hadoop 1.x architecture and its components.
What is new in Hadoop 2.x Architecture?
- Hadoop 2.x has some common Hadoop API which can easily be integrated with any third party applications to work with Hadoop
- It has some new Java APIs and features in HDFS and MapReduce which are known as HDFS2 and MR2 respectively
- New architecture has added the architectural features like HDFS High Availability and HDFS Federation
- Hadoop 2.x not using Job Tracker and Task Tracker daemons for resource management now on-wards, it is using YARN (Yet Another Resource Negotiator) for Resource Management
You may have observed two unknown phrases HDFS High Availability and HDFS Federation in above list. Let’s know more about them.
HDFS High Availability (HA)
Problem: As you know in Hadoop 1.x architecture Name Node was a single point of failure, which means if your Name Node daemon is down somehow, you don’t have access to your Hadoop Cluster than after. How to deal with this problem?
Solution: Hadoop 2.x is featured with Name Node HA which is referred as HDFS High Availability (HA).
- Hadoop 2.x supports two Name Nodes at a time one node is active and another is standby node
- Active Name Node handles the client operations in the cluster
- StandBy Name Node manages metadata same as Secondary Name Node in Hadoop 1.x
- When Active Name Node is down, Standby Name Node takes over and will handle the client operations then after
- HDFS HA can be configured by two ways
- Using Shared NFS Directory
- Using Quorum Journal Manager
We’ll discuss more on Name Node switching scenarios with HDFS High Availability in later posts.
HDFS Federation
Problem: HDFS uses namespaces for managing directories, file and block level information in cluster. Hadoop 1.x architecture was able to manage only single namespace in a whole cluster with the help of the Name Node (which is a single point of failure in Hadoop 1.x). Once that Name Node is down you loose access of full cluster data. It was not possible for partial data availability based on name space.
Solution: Above problem is solved by HDFS Federation i Hadoop 2.x Architecture which allows to manage multiple namespaces by enabling multiple Name Nodes. So on HDFS shell you have multiple directories available but it may be possible that two different directories are managed by two active Name Nodes at a time.
HDFS Federation by default allows single Name Node to manage full cluster (same as in Hadoop 1.x)
Hadoop 2.x Architecture In Detail
Hadoop2 Architecture has mainly 2 set of daemons
- HDFS 2.x Daemons: Name Node, Secondary Name Node (not required in HA) and Data Nodes
- MapReduce 2.x Daemons (YARN): Resource Manager, Node Manager
HDFS 2.x Daemons
The working methodology of HDFS 2.x daemons is same as it was in Hadoop 1.x Architecture with following differences.
- Hadoop 2.x allows Multiple Name Nodes for HDFS Federation
- New Architecture allows HDFS High Availability mode in which it can have Active and StandBy Name Nodes (No Need of Secondary Name Node in this case)
- Hadoop 2.x Non HA mode has same Name Node and Secondary Name Node working same as in Hadoop 1.x architecture
MapReduce 2.x Daemons (YARN)
MapReduce2 has replace old daemon process Job Tracker and Task Tracker with YARN components Resource Manager and Node Manager respectively. These two components are responsible for executing distributed data computation jobs in Hadoop 2(Refer my post on YARN Architecture for further understanding).
Resource Manager
- This daemon process runs on master node (may run on the same machine as name node for smaller clusters)
- It is responsible for getting job submitted from client and schedule it on cluster, monitoring running jobs on cluster and allocating proper resources on the slave node
- It communicates with Node Manager daemon process on the slave node to track the resource utilization
- It uses two other processes named Application Manager and Scheduler for MapReduce task and resource management
Node Manager
- This daemon process runs on slave nodes (normally on HDFS Data node machines)
- It is responsible for coordinating with Resource Manager for task scheduling and tracking the resource utilization on the slave node
- It also reports the resource utilization back to the Resource Manager
- It uses other daemon process like Application Master and Container for MapReduce task scheduling and execution on the slave node
Now you can correlate how a MapReduce job will get executed on Hadoop 2.x Architecture.
Please write comment below if you like this post.
nJoy Learning…..!!!!!
March 29, 2016 at 2:43 pm
Nicely explained…!!
April 29, 2016 at 10:13 am
Thanks Subhash… Glad you like it…
June 2, 2016 at 6:02 pm
Hi Varun,
Thanks for sharing nice post…
Good work , keep it up!!!
July 8, 2016 at 10:02 am
Thanks Pradeep….
October 3, 2016 at 1:13 pm
Awesome ground work Varun :). Really good and matured
October 4, 2016 at 7:01 am
Thanks a lot Lakshman….
March 31, 2017 at 3:29 pm
This helped me a lot .
Thanks .
Please keep sharing such valuable information for newbees in Big Data and Hadoop .
July 9, 2018 at 7:47 am
Good day! Would you mind if I share your blog with my twitter group? There’s a lot of folks that I think would really enjoy your content. Please let me know. Thank you | http://backtobazics.com/big-data/hadoop/understanding-hadoop2-architecture-and-its-demons/ | CC-MAIN-2018-30 | refinedweb | 994 | 60.14 |
Geocoding with the Rails GeoKit Plugin
To retrieve a user's IP address, pass request.remote_ip into the IpGeocoder.geocode method. Doing so will return GeoKit's GeoLoc object, which includes a number of attributes, among them city, state, and even street_address. Consider the following controller method:
def ip @user_location = IpGeocoder.geocode(request.remote_ip) end
You then could access the city within the view, like so:
It appears you're located in <%= @user_location.city %>.
Keep in mind that although this feature can be very useful, it isn't foolproof. Remember,GeoKit relies on Hostip.info to determine the location based on an IP address, and even though Hostip.info's database is massive (over 8.5 million entries and counting), it is by no means complete. For instance, Hostip.info was unable to identify my location in downtown Columbus, Ohio, although tests with known IP addresses from other cities worked fine. If your IP address isn't found, be sure to take a moment and add it through the Hostip.info website.
Where to From Here?
With the geocoder component in place, you now have a complete mapping solution at your disposal. But, why stop here? In the next installment of this series, I'll show you how to add interactive features to your maps, giving your users a variety of exciting new ways to take advantage of your application!
About the Author
W. Jason Gilmore is a freelance developer, consultant, and technical writer. He's the author of several books, including the best-selling Beginning PHP and MySQL: From Novice to Professional, Third Edition (Apress, 2008. 1,080pp.).
Page 3 of 3
| http://www.developer.com/open/article.php/10930_3760066_3/Geocoding-with-the-Rails-GeoKit-Plugin.htm | CC-MAIN-2015-35 | refinedweb | 273 | 67.76 |
Invoking a business rule from a processJohn Santoro Dec 27, 2013 1:25 PM
I have a simple process with a simple rule, but I cannot get it to trigger. The process does this:
Start -> Human Task -> Rule -> Gateway ...
How can I get the process data to the rule? I know via a script activity that my process data (e.g., ProcessDataType) has values. For the rule task, I mapped my process data to an input and output variable of type ProcessDataType, but in my rule my when does not get triggered even as:
when
$data : ProcessDataType()
then
System.out.println("this rule has been triggered");
I can invoke the rule only if my when is "eval(true)", so I know that the rule is there. What step am I missing?
1. Re: Invoking a business rule from a processZahid Ahmed Prs Dec 30, 2013 2:05 AM (in response to John Santoro)
Hi Santoro,
You need to follow these steps if u want process data in rules.
IN - Code
Apporach 1
U need to put process instance in working memory so that the rule can evaluate the conditions in when part.
a. Do this In a script task just after start node kcontext.getKnowledgeRuntime().insert(kcontext.getProcessInstance())
Approach 2
Or Register a Process event listener, and in afterProcessStarted() event add this line session.insert(event.getProcessInstance())
IN - RULES
Sample Rule 1 :
import org.drools.runtime.process.WorkflowProcessInstance;
$process: WorkflowProcessInstance()
eval(Integer.parseInt((String)$process.getVariable("piAgeVariable")) > 30)
then .........
Notes :
1. I am not sure about JBPM-6, but in JBPM 5.4 if u don't fire the rule when u enter the node, then rule is not fired. Resolution to this is Be sure that u have placed this line just before u enter the rules node. ksession.fireAllRules(); .
2. Keep one thing in mind to retract the process instaces properly after rule node is executed using the kcontext.getKnowledgeRuntime().retract() or the eventListener approach. Else this process instance will remain in working memory and will be part of rules evaluation when anyother JBPM process instance triggers fireAllRules().
2. Re: Invoking a business rule from a processMaciej Swiderski Jan 2, 2014 4:16 AM (in response to Zahid Ahmed Prs)
3. Re: Invoking a business rule from a processJohn Santoro Jan 3, 2014 2:01 PM (in response to Maciej Swiderski)
Maciej,
Thank you for the blog. I was able to reproduce your process and make my own. My problem was that I named a project with mixed case, but the forms and process did not behave properly unless I used all lower case (e.g., my package was "MixedCase" but I had to refer to it as "org.jbpm.mixedcase". | https://developer.jboss.org/thread/235751 | CC-MAIN-2018-17 | refinedweb | 453 | 72.05 |
.NET 3.0 has now been released, so we should all know it by now shouldn't we. Jeez, it doesn't seem like that long ago that .NET 2.0 came along. Well for those that dont realize, .NET 3.0 actually contains quite a lot of new stuff, such as:
So as you can see there is a lot to be learned right there. I'm in the process of learning WPF/WCF but I am also interested in a little gem called LINQ, that I believe will be part of .NET 3.5 and Visual Studio "Orcas" (as its known now). LINQ will add new features to both C# and VB.NET. LINQ has three flavours:
LINQ is pretty cool, and I have been looking into it as of late, so I thought I would write an article about what I have learned in the LINQ/DLINQ/XLINQ areas, in the hopes that it may just help some of you good folk. This article will be focused on XLINQ, and is the third in a series of three articles.
The article series content is as follows:
Before I start bombarding people with even more information than they can possibly handle, let me just talk briefly about the files attached to this article.
This article contains two seperate zip files. The zip files are the two demo applications.
Is based on using Visual Studio 2005 with .NET 2.0 Framework, and the May 2006 LINQ CTP which is available here
See that the XML is syntax highlighted? This is all thanks to the free and fantastic Fireball code highlighter, available right here at Code Project.
The main window allows the user to try out various XLINQ activites such as :
The 2nd form within this 1st demo application (available from "What About A Web Query" menu), uses XLINQ to get an RSS feed from Flickr, using a Flickr API string. You should not need to download anything extra for this to work, as it is all in the code. The Flickr RSS feed is then queried (this is what LINQ is all about, Language Intergrated Query Language, remember) using XLINQ, and the results are put into a new structure, using standard LINQ projection, and then the results are then used to populate a FlowLayoutPanel with PictureBox controls that represent the gathered images. The user is also free to change the type of Flickr search being performed, and may page through the results obtained.
FlowLayoutPanel
PictureBox
Is based on using Visual Studio 2005 with The Visual Studio Designer for WPF installed, or using Expression BLEND and Visual Studio 2005 combination, or WordPad if you prefer to write stuff in that.
Obviously as it's WPF you will also need the .NET 3.0 framework, and the May 2006 LINQ CTP which is available here. The idea being that those folk that want to see how WPF/XAML will work with LINQ can have a look at this project. Don't worry to much if you dont get this code, as this application will be the subject of my next article. It's really being included for interest at this point, to show that LINQ and WPF can work quite nicely together.
This is basically doing the same thing as the 2nd form of DEMO application 1, it just looks a whole lot nicer, and showcases some cool WPF stuff like:
This application is not really that orientated to XLINQ, but it is something that I just wanted to try, so I thought, as I've done it, why not include it here. As I say if you dont get DEMO application 2, don't worry, I will be going through it in another article. It's here for interest's sake.
The full article which explains this WPF application can be found here
So what is this XLINQ stuff? Well, it's one flavour of LINQ (Language Integrated Query) that will be part of .NET 3.5, and will certainly be part of the next verison of Visual Studio (currently called Orcas).
As a recap, recall that LINQ dealt with in memory objects such as arrays and List and Dictionary objects, whilst DLINQ or LINQ over SQL dealt with entities and database interaction. So any guesses what XLINQ is all about? Well, it's actually XML over LINQ.
List
Dictionary
So what else can we say about this XLINQ stuff? We shall ask Microsoft what their marketing blurb is, as far as XLINQ is concerned. I asked them and they said this:
"XLinq was developed with Language Integrated Query over XML in mind from the beginning. It takes advantage of the Standard Query Operators and adds query extensions specific to XML. From an XML perspective XLinq provides the query and transformation power of XQuery and XPath integrated into .NET Framework languages that implement the LINQ pattern (e.g., C#, VB, etc.). This provides a consistent query experience across LINQ enabled APIs and allows you to combine XML queries and transforms with queries from other data sources. We will go in more depth on XLinq's query capability in section 3, "Querying XML with XLinq".
Just as significant as the Language Integrated Query capabilities of XLinq is the fact that XLinq represents a new, modernized in-memory XML Programming API. XLinq was designed to be a cleaner, modernized API, as well as fast and lightweight. XLinq uses modern language features (e.g., generics and nullable types) and diverges from the DOM programming model with a variety of innovations to simplify programming against XML. Even without Language Integrated Query capabilities XLinq represents a significant stride forward for XML programming. The next section of this document, "Programming XML", provides more detail on the in-memory XML Programming API aspect of XLinq."
(Taken from XLINQ overview.doc, available at the LINQ Project [1] web site)
I think that it is quite a good description of what XLINQ is and promises to be. Of course, it should be a good sales blurb, as XLINQ is a Microsoft invention. But what does this all mean to the average developer?
This is something that this article will try and demonstrate, by the use of textual comments, and code snippets and real life working examples.
Unless stated otherwise the example code shown within this article will be for discussion purposes only. But don't worry, I've gone out of my way to actually trawl the XLINQ documentation and make a nice little demo application that contains real-life working examples, of how to use XLINQ to do some of the most commonly occurring XML related tasks. So this working code is included within the DEMO application 1, and where I am specifically using the code from the DEMO application 1, I will show the following image to let you know that you can look in the code for a working example.
When you see this image, this means that I have created a worked example for you in DEMO application 1.
Obviously I have not got an example of every single thing that can be done with XLINQ, as I do have a life (not much of one, but one nonetheless). So I'll have to leave further investigation as an excercise for the reader.
The way that this article is constructed is by looking at the following items, that I would consider to be very important issues that every developer that works with xml should know.
I'm hoping that by going through this set of items, that by the end, the reader will have at least a basic appreciation of what can be done with XLINQ and how it could be used inplace of using the DOM and XPath.
So shall we continue?
The overall XLINQ class heirachy is as shown below.
Taken from XLINQ overview.doc, available at the LINQ Project [1] web site.
In order to undestand how XLINQ is different from existing XML document creation pratices, let's consider the following section of traditional DOM (Document Object Model) code, that creates a small XML document.);
Whilst this is fairly easy to do, what is not very clear is the structure that is emmitted to the actual XML document. It is possible to work it out, for this trivial example, but if this were a large XML document, it would not be so clear. Shall we have a look at how XLINQ goes about doing the same job?")
)
)
);
The first thing to say is that this is a lot less code, and the tree structure is almost self-evident from this listing - and it's almost as easy to read as an XML document. The other thing to note, is that in the actual syntax itself, nowhere do we see the methods createElement(), or AppendChild(). Instead we see new XElement, which sort of makes more sense, at least in how it actually reads. Personally, I think someone who knows XML, but has not used DOM before would probably understand this new syntax a bit better, as it seems to be a closer match in terms of the actual terminology used. An XML man knows of a new element as a new element, not as AppendChild(). I guess in the end, this is really down to preference.
createElement()
AppendChild()
new XElement
DEMO application 1, contains three menus to further demonstrate this concept, look at :
Both XDocument and XElement expose an overloaded Save() method, the options are as follows:
XDocument
XElement
XDocument.Save(string fileName)
XDocument.Save(string fileName)
This option simply saves the XElements content to the location specfied by the fileName parameter.
XDocument.Save(System.Xml.XmlWriter writer)
XDocument.Save(System.Xml.XmlWriter writer)
This option simply saves the XElements content to an XmlWriter
XDocument.Save(TextWriter textWriter)
XDocument.Save(TextWriter textWriter)
This option simply saves the XElements content to an TextWriter
XDocument.Save(string fileName, bool preserveWhitespace)
XDocument.Save(string fileName, bool preserveWhitespace)
This option simply saves the XElements content to the location specfied by the fileName parameter, and preserves any white space.
The same methods exist for XElement
Both XDocument and XElement exposes an overloaded Load() method, the options are as follows:
XDocument.Load(string uri)
XDocument.Load(string uri)
This option simply loads the XML element from the location specified by the uri into a new XDocument
XDocument.Save(System.Xml.XmlReader reader)
XDocument.Save(System.Xml.XmlReader reader)
This option simply reads the contents of an XmlReader into a new XDocument
XmlReader
XDocument.Save(TextReader textReader)
XDocument.Save(TextReader textReader)
This option simply reads the contents of a TextReader into a new XDocument
TextReader
XDocument.Save(uri fileName, bool preserveWhitespace)
XDocument.Save(uri fileName, bool preserveWhitespace)
This option simply reads the contents of the file specfied by the fileName parameter, and preserves any white space, into a new XDocument
There is also another possibility to load XML. We can parse a string by calling the XDocument.Parse method, so lets see an example of that shall we?
XDocument.Parse>
</contacts>");
Once we have loaded, or parsed a string, the full power of XLINQ may be used. We can traverse through nodes, inspect attributes, create new content, delete existing content.
DEMO application 1, contains 2 areas to further demonstrate this concept, look at :
Load()
createQuerySource()
Parse()
XLINQ provides methods for getting the children of an XElement. To get all of the children of an XElement (or XDocument), you can use the Nodes() method.
Nodes()
For example if we had the following XML
And ran the following traversal
foreach (XElement c in contacts.Nodes())
{
....
}
We would actually end up with the orginal XML.
So how about getting to sub-elements? Well, it's very simliar syntax infact. Let's see an example shall we?
foreach (XElement c in contacts.Elements("contact").Elements("address"))
{
....
}
If we are using an XDocument, this returns IEnumerable<object> because you could have text mixed with other XLINQ types, such as XDeclaration, XComment and XProcessingInstruction as well as XElement
IEnumerable<object>
XDeclaration
XComment
XProcessingInstruction
Do how do we deal with this, our foreach (XElement in .... is going to fail for non XElement cases. What do we do about that? Well, quite simply put we do the following:
foreach (XElement in ....
foreach (XElement c in contactsDoc.Nodes().OfType<XElement>())
{
....
}
Suppose that we have the following XML structure:
<!--<span class="code-comment">XLinq Contacts XML Example--></span>
<?MyApp 123-44-4444?>
<contacts numContacts="1">
<name>sacha barber</name>
<phone type="home">01273 45426</phone>
<phone type="work">01903 205557</phone>
<address>
<street1>palmeira square</street1>
<city>brighton</city>
<county>east sussex</county>
<postcode>BN3 2FA</postcode>
</address>
</contacts>
And we wish to work with the root node attributes. We would normally (if using DOM) need to obtain a reference to the document node, then use that to obtain the attribute vales. XLINQ does things a little differently.
XElement root = contactsDoc.Root;
sb.Append(
"Examining root element [" + root.Name + "] for attributes\r\n\r\n");
if (root.HasAttributes)
{
foreach (XAttribute xa in root.Attributes())
{
sb.Append(
"Found Attibute [" + xa.Name.ToString() + "] Value=" + xa.Value);
}
}
txtResults.Document.Text = sb.ToString();
And that is enough to get the attributes of the root node. This assumes that the previous XML structure has been loaded into an XDocument called contactsDoc. The result can be seen from this screenshot from DEMO application 1.
DEMO application 1, contains 1 menu to further demonstrate this concept, look at:
Appending new content is fairly trivial with XLINQ. It's all about getting a reference to a particular XDocument or XElement that you wish to add new content to. After that the work is fairly easy. Let's see an example shall we?
This example assumes that there is a pre-existing XDocument called contactsDoc.
//obtain the root
XElement root = contactsDoc.Root;
//add new contact
root.Add(new XElement("contact",
new XElement("name", "melissa george"),
new XElement("phone", "01273 999999",
new XAttribute("type", "office")),
new XElement("phone", "01903 888888",
new XAttribute("type", "work")),
new XElement("address",
new XElement("street1", "churchill square"),
new XElement("city", "brighton"),
new XElement("county", "east sussex"),
new XElement("postcode", "BN3 4RG")
)
)
);
This one bit of code created a new contact XElement which is then appended to the root element of the existing XDocument called contactsDoc. That's all you have to do, get the object you want to add content to, and add the content using the Add() method
Add()
DEMO application 1, contains 1 menu to further demonstrate this concept, look at :
Updating existing content is something that anyone that works with XML is going to need to do at some stage. This could consist of updating an entire elements content, or could be simply just updating one sub element for an existing element. Because I'm nice, i'll show you both.
Let's assume we have the following source XML that we will update.
For the case where we want to update an entire element with new content, as before we simply get the object we want to apply the replacement content to, and replace it using the ReplaceContent() method.
ReplaceContent()
//obtain a single contact
IEnumerable<XElement> singleContact = (from c in contactsDoc.Root.Elements(
where ((string) c.Element(
"name")).Equals("sarah dudee")
select c);
//update contact, should only be 1
foreach (XElement xe in singleContact)
{
//use the ReplaceContent method to do the replacement
xe.ReplaceContent(new XElement("name", "sam weasel"),
new XElement("phone", "01273 111111",
new XAttribute("type", "office")),
new XElement("phone", "01903 33333",
new XAttribute("type", "work")),
new XElement("address",
new XElement("street1", "the drive"),
new XElement("city", "brighton"),
new XElement("county", "east sussex"),
new XElement("postcode", "BN3 4RG")
)
);
}
This is enough to replace the entire Contact element where where the existing Contact element that had a name of "sarah dudee" is replaced
For the case where we ONLY want to update an portion of an existing element with new content, as before we simply get the object we want to apply the replacement content to, but this time we must manipulate the elements data directly.
//obtain the firstContact
IEnumerable<XElement> firstContact = ( from c in contactsDoc.Root.Elements(
select c).Take(1);
//update contact, should only be 1
foreach (XElement xe in firstContact)
{
//UPDATE METHOD 1
xe.Element("address").SetElement("city", "MANCHESTER");
//UPDATE METHOD 2
xe.Element("address").Element("postcode").ReplaceContent("MN1");
}
This is enough to replace the the sub element of the Contact element.
Programming LINQ\Update Only 1 Contact Detail menu (this shows how to update a sub-element of an exiting element of the current XDocument)
Deleting existing content is also going to something that anyone that works with XML is going to need to do at some stage.
Let's assume we have the following source XML that we will delete from:
So as before we simply get the object we want to delete and then delete it using the Remove() method.
Remove()
//obtain the firstContact
IEnumerable<XElement> firstContact = ( from c in contactsDoc.Root.Elements(
select c).Take(1);
//update contact, should only be 1
foreach (XElement xe in firstContact)
{
xe.Element("address").Element("county").Remove();
}
This is enough to delete the entire Contact element where the existing 1st Contact element is deleted (remember we can use any of the standard LINQ query operators, so I'm simply using Take(1) which gives us the 1st Contact element)
Recall in Part1 I introduced LINQ standard query operators, well guess what, XLINQ uses those very same standard query operators to allow programmers to query the XML tree in order to pull out certain parts of the tree for manipulation. Much the same as XPath allows.
The only limit here, is how good your standard query operator skills are. So let's see some examples shall we? I've got four little examples for you.
The following queries all work based on the same base XML, which is created within the DEMO application 1, within the createQuerySource() method.
XElement contactsElements = createQuerySource();
XElement res = new XElement("contacts",
(from c in contactsElements.Elements("contact")
select new XElement("contact",
c.Element("name"),
new XElement("phoneNumbers", c.Elements("phone"))
)).Take(1)
);
XElement contactsElements = createQuerySource();
foreach (XElement phone in contactsElements.Elements("contact").Elements(
"phone"))
{
//do something with the phone XElement
}
XElement contactsElements = createQuerySource();
....
....
//look for this Element with the correct name requested
IEnumerable<XElement> cont = (from c in contactsElements.Elements("contact")
where (string) c.Element("name") == userName
select c);
....
....
XElement contactsElements = createQuerySource();
....
....
//look for this Element with the correct name requested
IEnumerable<XElement> res = (from c in contactsElements.Elements("contact")
where (string) c.Element(
"phone").Attribute("type") == "home"
select c);
....
....
DEMO application 1, contains 4 menus to further demonstrate this concept, look at :
So how about we get XLINQ to grab some data out of an RSS Feed to show some images? After all, it should be able to cope with any XML data, even if it's not local. I decided to use Flickr as the data source, as I know that it has an API which may be used to obtain RSS Feeds with images URLs. Images are quite pretty, and are also suitable things to display in a Windows Form application. This concept is based on something that I saw in Omar Al Zabirs fantastic article which is available here
So shall we have a look at the code that does this? The class diagram is as follows:
As can be seen there is a form that has some Button (btnGo/btnPrev/btnNext) on it and a ComboBox (cmbSearchType) which are used to create the correct parametized RSS feed request from Flickr. The Flickr request is made by the RSSImageFeed class, which returns a IEnumerable<PhotoInfo> object which represents the photos found by the current RSS Feed request.
Button
ComboBox
RSSImageFeed
IEnumerable<PhotoInfo>
That's really all there is to it.
Now some code. To be honest it's very straightforward.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Query;
using System.Xml.XLinq;
using System.Data.DLinq;
namespace Linq_3
{
public partial class FlickrRSSGrabber : Form
{
private RSSImageFeed RSSImages = new RSSImageFeed();
public FlickrRSSGrabber()
{
InitializeComponent();
}
private void btnGo_Click(object sender, EventArgs e)
{
RSSImages.PageIndex = 0;
doFlickrSearch();
}
private void doFlickrSearch()
{
string searchType = cmbSearchType.SelectedItem.ToString();
string searchWord = searchType.Equals(
"By Search Word") ? this.txtSearchWord.Text : "";
if (searchType.Equals("By Search Word") && string.IsNullOrEmpty(
searchWord))
{
MessageBox.Show(
"You MUST enter a search word, to search by keyword");
}
else
{
getFlickrData(searchType, searchWord);
}
}
private void getFlickrData(string searchType, string searchWord)
{
IEnumerable<PhotoInfo> photos = (
IEnumerable<PhotoInfo>)RSSImages.LoadPictures(
searchType, searchWord);
if (photos.Count() > 0)
{
lblPageIngex.Visible = true;
int pIndex = RSSImages.PageIndex;
lblPageIngex.Text = "Page " + (++pIndex);
//show the images, clearing old ones 1st
pnlFlowPhotos.Controls.Clear();
foreach (PhotoInfo pi in photos)
{
PictureBox pb = new PictureBox();
pb.ImageLocation = @pi.PhotoUrl(true);
pb.SizeMode = PictureBoxSizeMode.AutoSize;
toolTip1.SetToolTip(pb, pi.Title);
pnlFlowPhotos.Controls.Add(pb);
}
setNextPrevStates(RSSImages.IsPrevAvail,
RSSImages.IsNextAvail);
}
else
{
lblPageIngex.Visible = false;
setNextPrevStates(false, false);
}
}
private void setNextPrevStates(bool prevEnabled, bool nextEnabled)
{
btnPrev.Enabled = prevEnabled;
string prevTT = btnPrev.Enabled ? "Click to go back a page" :
"There are no more pages";
toolTip1.SetToolTip(btnPrev, prevTT);
btnNext.Enabled = nextEnabled;
string nextTT = btnNext.Enabled ? "Click to go forward a page" :
"There are no more pages";
toolTip1.SetToolTip(btnNext, nextTT);
}
private void cmbSearchType_SelectedValueChanged(object sender,
EventArgs e)
{
string searchType = cmbSearchType.SelectedItem.ToString();
txtSearchWord.Visible = searchType.Equals(
"By Search Word") ? true : false;
lblSearchWord.Visible = txtSearchWord.Visible;
}
private void btnNext_Click(object sender, EventArgs e)
{
RSSImages.PageIndex++;
doFlickrSearch();
}
private void btnPrev_Click(object sender, EventArgs e)
{
RSSImages.PageIndex--;
doFlickrSearch();
}
private void FlickrRSSGrabber_Shown(object sender, EventArgs e)
{
cmbSearchType.SelectedItem = "Most Recent";
//getData from Flickr
getFlickrData("MOST_RECENT", "");
}
}
}
To understand how this class uses XLINQ to obtain the Flickr data, one first needs to understand what the raw XML data is, that Flickr provides. It can be seen that there are three possible URLs listed below, for :
One of these three different URLs is triggered depending on the value that the user picks from the combobox (cmbSearchType) within the FlickrRSSGrabber class shown above.
FlickrRSSGrabber
So let's examine a small subset of what Flickr gives us for one of these requests. Let's take the MOST_RECENT URL
We end up with something like this. Try it yourself in FireFox, or your favourite browser.
<rsp stat="ok">
<photos page="1" pages="10" perpage="100" total="1000">
<photo id="493415381" owner="8201860@N03" secret="dba0cae590" server="225"
farm="1" title="setting up 6" ispublic="1" isfriend="0" isfamily="0"/>
<photo id="493415375" owner="42802631@N00" secret="596a13de8e" server="226"
farm="1" title="DSC01713" ispublic="1" isfriend="0" isfamily="0"/>
<photo id="493392504" owner="59616645@N00" secret="49459bb023" server="191"
farm="1" title="IMG_0841" ispublic="1" isfriend="0" isfamily="0"/>
<photo id="493392488" owner="28532182@N00" secret="ebcdc8d2d8" server="220"
farm="1" title="img_1438" ispublic="1" isfriend="0" isfamily="0"/>
Looking at this structure, it's fairly easy to see how this small bit of XLINQ syntax (taken from the full code listing shown below) is working.
/);
There is almost a direct mapping here, and it's very easy to read. Compare this with the iterative process that one would have to do if using the DOM, or compare it to its equivalent XPath. Me personally, I prefer XPath over the iterative DOM process any day of the week, but I prefer XLINQ process to XPath process. It's just so easy to read.
Anyway, full code listing for those that want the whole picture.
using System;
using System.Collections.Generic;
using System.Text;
using System.Query;
using System.Xml.XLinq;
using System.Data.DLinq;
namespace Linq_3
{
public class RSSImageFeed
{
private const string FLICKR_API_KEY =
"c705bfbf75e8d40f584c8a946cf0834c";
private const string MOST_RECENT =
<a href=".">.</a> +
"getRecent&api_key=" + FLICKR_API_KEY;
private const string INTERESTING =
<a href=".">.</a> +
"interestingness.getList&api_key=" + FLICKR_API_KEY;
private const string ENTER_TAG = <a href=""></a> +
"/rest/?method=flickr.photos.search&api_key=" +
FLICKR_API_KEY + "&tags=";
private string url = MOST_RECENT;
private int pageIndex = 0;
private int columns = 5;
private int rows = 2;
private bool prevAvail = false;
private bool nextAvail = false;
public RSSImageFeed()
{
}
public bool IsPrevAvail
{
get { return prevAvail; }
}
public bool IsNextAvail
{
get { return nextAvail; }
}
public int PageIndex
{
set { pageIndex = value; }
get { return pageIndex; }
}
public IEnumerable<PhotoInfo> LoadPictures(string searchType,
string searchWord)
{
switch (searchType)
{
case "Most Recent":
this.url = MOST_RECENT;
break;
case "Interesting":
this.url = INTERESTING;
break;
case "By Search Word":
this.url = ENTER_TAG + searchWord;
break;
default:
this.url = MOST_RECENT;
break;
}
try
{
var xraw = XElement.Load(url);
var xroot = XElement.Parse(xraw.Xml);
/);
//set the allowable next/prev states
int count = photos.Count();
if (pageIndex == 0)
{
this.prevAvail = false;
this.nextAvail = true;
}
else
{
this.prevAvail = true;
}
//see if there are less photos than sum(Columns * Rows)
//if there are less cant allow next operation
if (count < columns * rows)
{
this.nextAvail = false;
}
return photos;
}
catch (Exception ex)
{
return null;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Linq_3
{
public; }
}
}
}
So putting these three classes together we are able to come up with a little Flickr viewer that allows users to search Most Recent/Interesting or by Key Word, and allows the user to page through the results, if there is more than 1 page worth of photos. Nice huh?
As originally stated I have also included a WPF version of this XLINQ experiment, simply beacuse I am also learning WPF, and I think it looks cool. Some folks may also like to see how WPF can work with XML bound data, as is the case for this WPF application. Like I said earlier, if you don't get the WPF version, don't worry, that will be the focus of another article.
I hope there are some of you that have read Part1 and Part2 of this article series, and can see the similarities between all the different flavours of LINQ.
I am also hoping that this article has shown that XLINQ (Or LINQ over XML as it will be known in future) is not that scary, and its actually quite easy to use, even when using RSS and 3rd party XML data sources.
As a closing note on this series, I just want to tell people, I didn't have much knowledge about LINQ when I started, I just got my head down and went for it. Some of it is a little frustrating, but to be honest I managed to get all the demo apps doing what I wanted (not the WPF one, that is a different story) inside a single day, which is fairly good for a new technology I think. So say (or think) what you will, about LINQ, I think it is set to radically change the ways in which we work with data at every level. It may be that you will choose to only use LINQ, or only XLINQ or all that LINQ has to offer. I know that I will probably be trying out all three at some stage on a live system. Happy LINQing.
I would just like to ask, if you liked the article please vote for it, and leave some comments, as it allows me to know if the article was at the right level or not, and whether it contained what people need to know.
I have quite enjoyed constructing this article, and have been quite refreshed at just how easy XLINQ is to actually use. In fact I wish I had of done this XLINQ article 1st, as I recently finished a short term contract, where we were doing lots of XML parsing which would have been far easier with XLINQ. I also think the way in which XML data is updated is far superior in XLINQ to conventional methods, it just seems more logical the way its done in XLINQ. No more iterative processes, hooray.
v1.0 10/05/07: Initial issue
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
I am lucky enough to have won a few awards for Zany Crazy code articles over the years
<Import Project="$(ProgramFiles)\LINQ Preview\Misc\Linq.targets" />
public static class Message
{
/// <summary>
/// Adds XElement to a SOAP envelope
/// </summary>
/// <returns>Returns an XML document as a string</returns>
public static string New(XElement content)
{
//SOAP namespace
XNamespace env = "";
//SOAP Envelope
XDocument soapMessage = new XDocument(
new XDeclaration("1.0", "UTF-16", "no"),
new XElement(env + "Envelope",
new XAttribute(XNamespace.Xmlns + "env", ""),
new XElement(env + "Body",
content))
);
return soapMessage.ToString();
}
}
Shaun Stewart wrote:Yet another first class article. It has clarified a number of issues for me.
Shaun Stewart wrote:Sorry I should have made myself clear. Both this and your excellent discourse on WPF have clarified a number of issues for me.
General News Suggestion Question Bug Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages. | http://www.codeproject.com/Articles/18751/XLINQ-Introduction-Part-3-Of-3 | CC-MAIN-2015-40 | refinedweb | 4,802 | 55.24 |
06 August 2012 12:45 [Source: ICIS news]
SINGAPORE (ICIS)--Crude futures prices declined on Monday, with Brent falling by more than $1/bbl at one stage amid profit taking after the sharp rally last Friday.
At 11:09 GMT, September Brent crude on ?xml:namespace>
September NYMEX light sweet crude futures (WTI) were trading at $91.04/bbl, down by 36 cents/bbl on the previous close. Earlier, the
Crude prices eased after making substantial gains last Friday which pushed September Brent futures values up by more than $3.04/bbl and September WTI futures up by $4.27/bbl at the close.
Crude values rallied on Friday following better than expected
Heightened Middle East tensions added further upside pressure with the US Congress passing over the weekend a new package of sanctions | http://www.icis.com/Articles/2012/08/06/9584424/brent-crude-falls-more-than-1bbl-on-profit-taking.html | CC-MAIN-2014-52 | refinedweb | 134 | 64.41 |
Timeline
10/08/11:
- 23:28 Ticket #5968 (phoenix bind and signals2 signal connect fails to compile) closed by
- fixed: Fixed for msvc10 with [74839], thanks for reporting.
- 23:27 Changeset [74839] by
- Fixing bug #5968 for msvc
- 22:11 Changeset [74838] by
- Spirit: Removing bogus static_assert
- 22:09 Changeset [74837] by
- typo fix
- 21:23 Changeset [74836] by
- Unordered: Correct fix for old gcc.
- 21:10 Changeset [74835] by
- Chrono:Fix bad merge
- 20:57 Changeset [74834] by
- Chrono: Fix protecting include file
- 20:55 Changeset [74833] by
- - Forgot some changes for bug #5920 - Added testcase for bug #5968, works …
- 20:47 Changeset [74832] by
- Unordered: Fix dependent type.
- 20:43 Ticket #5920 (comparison.hpp named as comparision.hpp) closed by
- fixed: Fixed on trunk with commit [74830]
- 20:42 Changeset [74831] by
- Adding safe-guards
- 20:40 Changeset [74830] by
- Fixing bug #5920
- 20:35 Changeset [74829] by
- Chrono: Fix missing include config.hpp
- 20:35 Changeset [74828] by
- Chrono: Fix missing include config.hpp
- 18:12 Changeset [74827] by
- Add latency test programs.
- 17:58 Changeset [74826] by
- Various performance improvements: * Split the task_io_service's run and …
- 17:38 Changeset [74825] by
- Fix error mapping when session is gracefully shut down.
- 17:38 Changeset [74824] by
- Initialise all OpenSSL algorithms.
- 17:36 Changeset [74823] by
- Specialise operations for buffer sequences that are arrays of exactly two …
- 17:31 Changeset [74822] by
- Fix crash due to gcc_x86_fenced_block that shows up when using the Intel …
- 17:28 Changeset [74821] by
- Disable warning due to const qualifier being applied to function type.
- 17:25 Changeset [74820] by
- Set size of select fd_set at runtime when using Windows.
- 17:21 Changeset [74819] by
- Remove unused state.
- 17:15 Changeset [74818] by
- Make sure the synchronous null_buffers operations obey the user's …
- 17:10 Changeset [74817] by
- Change the SSL buffers sizes so that they're large enough to hold a …
- 17:08 Changeset [74816] by
- Don't read the clock unless the heap is non-empty.
- 17:06 Changeset [74815] by
- Explicitly specify the signal() function from the global namespace. Refs …
- 17:03 Changeset [74814] by
- Fix compile error in regex overload of async_read_until.hpp. Refs #5688
- 13:39 Changeset [74813] by
- Unordered: Remove use of BOOST_PP_ENUM_SHIFTED. Doesn't seem to work on …
- 13:39 Changeset [74812] by
- Unordered: Move has_member into nested struct for sun.
- 12:41 Ticket #5999 (boost::asio::async_read with completion_condition strange behavior when ...) created by
- Consider […] Where inBuf was set to a max size N. …
- 12:36 Changeset [74811] by
- Update documentation.
- 12:10 Changeset [74810] by
- Add mail address. Add error's testability content. Correct typos.
- 11:26 Changeset [74809] by
- A few more tweaks from Robert.
- 11:05 Changeset [74808] by
- Reword cpu_timer specs in terms of accumulating elapsed times.
- 11:02 Changeset [74807] by
- Chrono: Add some io tests
- 10:47 Changeset [74806] by
- Chrono: Updated include.hpp and doc
- 10:26 Changeset [74805] by
- Chrono: update global include.hpp file
- 10:24 Changeset [74804] by
- Chrono: Added perf now()
- 09:47 Changeset [74803] by
- Chrono: Merge #5998 - Jamfile and clock_test were forgoten in the …
- 08:40 Ticket #5998 (Make possible to don't provide hybrid error handling.) closed by
- fixed: Merged with #74801
- 08:39 Ticket #5977 (Remove old files from Beman's version) closed by
- fixed: Merged with #74801
- 08:38 Ticket #5979 (Add chrono rounding utilities) closed by
- fixed: Merged with #74785
- 08:38 Ticket #5978 (Add BOOST_CHRONO_HAS_PROCESS_CLOCKS to know if process clocks are ...) closed by
- fixed: Merged with #74785
- 08:36 Ticket #5974 (Process real cpu clock should use clock() instead of times() in MAC which ...) closed by
- fixed: Merged with #74785
- 08:33 Ticket #5946 (Process real cpu clock returns the system steady clock) closed by
- fixed: Merged with #74785
- 08:33 Ticket #5907 (Take in account noexcept for compilers supporting it.) closed by
- fixed: Merged with #74785
- 08:32 Ticket #5906 (Take in account the constexpr as defined in the standard.) closed by
- fixed: Merged with #74785
- 08:31 Ticket #5976 (chrono_accuracy_test is not deterministic and should be removed from the ...) closed by
- fixed: Merged with #74785
- 08:30 Changeset [74802] by
- More fixes for UDT's as arguments.
- 08:28 Changeset [74801] by
- Chrono: Merge #5998
- 08:17 Changeset [74800] by
- Unordered: Stop using void_pointer. Was breaking for allocators that …
- 08:17 Changeset [74799] by
- Unordered: Just do member detection on older compilers.
- 08:11 Changeset [74798] by
- Chrono: Merge #5977
- 07:48 Ticket #5998 (Make possible to don't provide hybrid error handling.) created by
- Boost.Chrono provides by default an hybrid error handling for the …
- 07:32 Changeset [74797] by
- seek directive by TONGARI
- 07:31 Changeset [74796] by
- seek directive by TONGARI
- 07:11 Ticket #5997 (Listening on multiple endpoints (doc / acceptor group)) created by
- Could you add an example of listening on multiple endpoints? I assume this …
- 06:52 Changeset [74795] by
- Fix msvc warnings.
- 06:30 Ticket #5996 (Warnings when compiled with "-Wshadow") created by
- g++ 4.4.5 reports warnings when compiles various components with …
- 06:07 Ticket #5995 (Warnings when compiled with "-Wold-style-cast") created by
- g++ 4.4.5 reports warnings when compiles various components with …
- 06:01 Changeset [74794] by
- Fixed bug in range insertion
- 05:59 Changeset [74793] by
- Chrono: Move clock_string.hpp from chono/io to chrono directory
- 05:08 Ticket #5994 (MSVC compiler misbehaviour - .lib & .exp files build for .EXE project) created by
- There is bug in VS 2010 (and older versions) which makes EXE projects to …
- 04:54 Changeset [74792] by
- Merge from trunk
- 04:23 Changeset [74791] by
- Merge from trunk
- 02:21 Ticket #5993 (range::accumulate is missing a const in a concept check) created by
- The first overload of boost::accumulate, (const SinglePassRange?&, Value) …
- 00:53 Changeset [74790] by
- renamed unit_test_suite.ipp into test_tree.ipp moved …
- 00:50 Changeset [74789] by
- renamed unit_test_suite.ipp into test_tree.ipp moved …
10/07/11:
- 23:47 Changeset [74788] by
- Added adapter for std::tuple (only for implementations using variadic …
- 19:18 Changeset [74787] by
- Chrono: document 1.2 update
- 18:29 Changeset [74786] by
- Chrono: document 1.2 update + io improvements + stopwatches
- 18:04 Changeset [74785] by
- Chrono: Merged #5976,5979,5978,5906,5907,5909,5946,5974
- 17:54 Changeset [74784] by
- Chrono: Added BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING to avoid …
- 17:28 Changeset [74783] by
- Fixed typo
- 17:05 Changeset [74782] by
- added type trait extension to operator detection
- 14:14 Changeset [74781] by
- Added pow, exp, log, sinh, cosh and tanh support.
- 11:08 Ticket #5992 (opening wide character string paths in memory-mapped file) created by
- Without support for wide character string paths, we cannot easily open …
- 11:02 Changeset [74780] by
- More docs fixes from Robert.
- 10:22 Changeset [74779] by
- Removed entire math_toolkit folder as obsolete now that Boost.Math has …
- 09:57 Changeset [74778] by
- Change stop() to void return, supply auto_cpu_timer observers, change m_os …
- 09:43 Changeset [74777] by
- Chrono: Added BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING to avoid …
- 09:42 Changeset [74776] by
- Chrono: take care of BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
- 09:14 Ticket #5991 (find_ptr (find wrapper)) created by
- Could you add a find wrapper to multi_index that returns value_type* …
- 08:22 Ticket #5990 (shared_future<T>::get() has wrong return type) created by
- The return type of shared_future<T>::get() seems to be mixed up. The …
- 04:19 Changeset [74775] by
- Unordered: More misc. cleanup. Including removing node.hpp.
- 02:42 Ticket #5989 (path iterator appends / instead of \ on windows) created by
- In boost v1.47, filesystem\v\src\path.cpp, inside function …
- 00:21 Ticket #5988 (boost::filesystem::absolute doesn't work with ../relative_path or ...) created by
- In boost filesystem v3, boost::filesystem::absolute only appends the …
10/06/11:
- 23:26 Ticket #5987 (Error in boost-build/jam_src/build.bat) created by
- in :Start if "_%1_" == "" ( call :Guess_Toolset if not …
- 22:06 Changeset [74774] by
- operator traits: fixed all comments from review; renamed can_call_op -> …
- 21:07 Changeset [74773] by
- Apply new default scheme to docs
- 20:20 Ticket #5916 (boost::uuids::uuid is not serializable vi boost::serialization) closed by
- worksforme: Feel free to reopen this issue if boost/uuid/uuid_serialize.hpp is not …
- 20:17 Changeset [74772] by
- fix for ticket #5794
- 20:10 Changeset [74771] by
- Fix for ticket #5794
- 20:00 Changeset [74770] by
- [geometry] Silenced clang warning: unused variable check_is_small. See …
- 19:59 Ticket #5986 (clang warning: unused variable check_is_small) created by
- Current clang issues warning in floating_point_comparison.hpp: […] …
- 18:10 Changeset [74769] by
- Quickbook: Merge from trunk. - Qualify footnote and callout ids. - Close …
- 18:00 Changeset [74768] by
- Quickbook: Set the version number for release (hopefully).
- 17:31 Changeset [74767] by
- Unordered: some more formatting + namespaces
- 17:06 Changeset [74766] by
- Unordered: More cleaning up. Fix deprecated construct_impl and explicit …
- 16:50 Changeset [74765] by
- Eliminate default_format from header. This eliminates initialization …
- 15:15 Changeset [74764] by
- msvc10 infrastructure initial commit
- 13:28 Changeset [74763] by
- Added numeric.conversion update.
- 13:27 Changeset [74762] by
- Merge of numeric_cast_traits in numeric conversion library.
- 13:06 Ticket #5954 (distance_pythagoras skips sqrt() step) closed by
- fixed: (In [74761]) Fix ticket 5954, use strategy directly, not the comparable …
- 13:06 Changeset [74761] by
- Fix ticket 5954, use strategy directly, not the comparable strategy …
- 12:47 Changeset [74760] by
- Update of explicit failures markup (more platforms added, that have bad …
- 11:53 Ticket #3640 (Unmerged changes in regression tools) closed by
- fixed: Done: * Merged trunk to release (for 1.48.0) * Checked that there were no …
- 11:42 ReleasePractices/ManagerCheckList edited by
- (diff)
- 11:41 Changeset [74759] by
- Merge tools/regression from trunk
- 11:31 Changeset [74758] by
- Correct name in error message
- 11:29 Changeset [74757] by
- Merge tools/release from trunk
- 11:20 Changeset [74756] by
- Don't echo
- 11:14 Changeset [74755] by
- Initial commit
- 10:53 Ticket #3597 (Extending boost::filesystem to operate on other fs-like objects) closed by
- wontfix: Such a feature would be beyond the scope of the library at this time. …
- 10:47 Ticket #2657 (Feature request: readlink, nlink, copy_symlink, copy_directory, copy) closed by
- fixed: All of these suggestions have been implemented and are part of …
- 09:28 Changeset [74754] by
- Add <pre> color, tweak some spacing
- 08:55 Changeset [74753] by
- Add canonical() use note.
- 08:10 Changeset [74752] by
- Add tip clarifying BoostBook?, DocBook?, need to know.
- 08:09 Changeset [74751] by
- Increase cpu_timer_test fuzz
- 07:24 Ticket #5985 (Quickbook needs Users Guide documentation) created by
- Quickbook is currently a disaster to learn to use. The markup itself seems …
- 04:03 Changeset [74750] by
- Unordered: Better emplace_args implementation. And some misc. cleanup.
Note: See TracTimeline for information about the timeline view. | https://svn.boost.org/trac/boost/timeline?from=2011-10-08T08%3A39%3A48-04%3A00&precision=second | CC-MAIN-2014-15 | refinedweb | 1,779 | 60.04 |
README
remark-squeeze-paragraphsremark-squeeze-paragraphs
remark plugin to remove empty (or white space only) paragraphs.
ContentsContents
- What is this?
- When should I use this?
- Install
- Use
- API
- Types
- Compatibility
- Security
- Related
- Contribute
- License
What is this?What is this?
This package is a unified (remark) plugin to remove empty paragraphs.
unified is a project that transforms content with abstract syntax trees (ASTs). remark adds support for markdown to unified. mdast is the markdown AST that remark uses. This is a remark plugin that transforms mdast.
When should I use this?When should I use this?
This project is mostly useful when you’re using other plugins that remove things
from the AST (such as
remark-strip-badges).
You can then use this plugin afterwards to clean stray empty paragraphs.
InstallInstall
This package is ESM only. In Node.js (version 12.20+, 14.14+, or 16.0+), install with npm:
npm install remark-squeeze-paragraphs
import remarkSqueezeParagraphs from ''
In browsers with Skypack:
<script type="module"> import remarkSqueezeParagraphs from '' </script>
UseUse
import {remark} from 'remark' import remarkStripBadges from 'remark-strip-badges' import remarkSqueezeParagraphs from 'remark-squeeze-paragraphs' main() async function main() { console.log( ( await remark() .use(remarkStripBadges) .process('\n\ntext') ).toString() ) // => '\n\ntext\n' console.log( ( await remark() .use(remarkStripBadges) .use(remarkSqueezeParagraphs) .process('\n\ntext') ).toString() ) // => 'text\n' }
APIAPI
This package exports no identifiers.
The default export is
remarkSqueezeParagraphs.
unified().use(remarkSqueezeParagraphs)
Remove empty (or white space only) paragraphs. There are no options.
TypesTypes
This package is fully typed with TypeScript. There are no extra exported types. 3+ and
remark version 4+.
SecuritySecurity
Use of
remark-squeeze-paragraphs does not involve rehype
(hast) or user content so there are no openings for
cross-site scripting (XSS) attacks.
RelatedRelated
mdast-squeeze-paragraphs— mdast utility with similar functionality
ContributeContribute
See
contributing.md in
remarkjs/.github for ways
to get started.
See
support.md for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms. | https://www.skypack.dev/view/remark-squeeze-paragraphs | CC-MAIN-2021-49 | refinedweb | 337 | 54.49 |
Your Passion. Your Potential.
In this article, I would like to share my test lab in using IBF (Information Bridge Framework) to access WebMethod in XML Web Service. You might have seen the beauty of IBF in Office, what you might haven't seen is the process on getting IBF hooked with the data source.
1. Deploy Your Web Services
Basically you can use a different kind of metadata in IBF, whether it's a Web Serice, Metadata Service, XML File or .NET Assembly. In this example, I already create a Web Service : Student.asmx
The web services has a simple GetStudent WebMethod that will give you information of certain student based on the studentId paramater. Of course, you can refer to database or any other method on how your web service getting the student information. For the sake of the lab, I intentionally hardcoded the student information result from whatever input of parameter that the webmethod given.
Here, you can see the XML result of the GetStudent using XML namespace "urn-STUDENT-Data" and all of its element (StudentNumber, StudentName, Address & City)
2. Creating an Information Bridge Metadata Project
The Information Bridge Metadata Designer tool is an Add-in for Microsoft Visual Studio.NET 2003. The key components to the Metadata Designer are Metadata Explorer and the Metadata Guidance windows. In the following steps, We will import the metadata of Student Web Services, creating metadata service and building user interfaces.
Metadata Guidance is a tools that you'll likely use to perform most of IBF configuration. You can activate the guidance in View - Others Windows - Metadata Guidance in VS 2003.
3. Importing Metadata
4. Creating Service-Level Metadata
By using Web Service WSDL (Web Service Description Language), IBF able to determine the service operations & schemas of Web Service offer. You can create the service level metadata from Metadata Guidance Windows
5. Creating the User Interface
To start building the UI, you use Region Creation Wizard in the Metadata Guidance Window. At the end of the wizard, you will have an option to use a standard HTML or a windows form based User Interface.
When the wizard finish, a new UserInterface project will be created, as you can see it's a windows form based UI based on the selection above.
IBF Metadata Designer also allows you to test and debug solution without using Microsoft Office. For more on test & debugging with IBF, refer to the “Building and Debugging a Solution” walkthrough in the Metadata Guidance window.
In IBF Metadata Explorer, navigate to the ShowStudentDetails action node and perform the Build and Execute from right click. Following is the input reference. Remember, since my webmethod always return the same information, no matter what parameter I pass through - the result remain the same. In reality, this is not the common scenario/behaviours.
The Result : | http://blogs.msdn.com/marioha/articles/IBFGlance.aspx | crawl-002 | refinedweb | 473 | 52.7 |
# SLAE — SecurityTube Linux Assembly Exam

SecurityTube Linux Assembly Exam (SLAE) — is a final part of course:
[securitytube-training.com/online-courses/securitytube-linux-assembly-expert](http://securitytube-training.com/online-courses/securitytube-linux-assembly-expert/)
This course focuses on teaching the basics of 32-bit assembly language for the Intel Architecture (IA-32) family of processors on the Linux platform and applying it to Infosec and can be useful for security engineers, penetrations testers and everyone who wants to understand how to write simple shellcodes.
This blog post have been created for completing requirements of the Security Tube Linux Assembly Expert certification.
Exam consists of 7 tasks:
1. TCP Bind Shell
2. Reverse TCP Shell
3. Egghunter
4. Custom encoder
5. Analysis of 3 msfvenom generated shellcodes with GDB/ndisasm/libemu
6. Modifying 3 shellcodes from shell-storm
7. Creating custom encryptor
Student ID: SLAE-12034
#### Preparation
Before I start to describe 7 tasks of this exam, I should explain some scripts, which help a lot in exam automatization.
**nasm32.sh**
```
#!/bin/bash
if [ -z $1 ]; then
echo "Usage ./nasm32 (no extension)"
exit
fi
if [ ! -e "$1.asm" ]; then
echo "Error, $1.asm not found."
echo "Note, do not enter file extensions"
exit
fi
nasm -f elf $1.asm -o $1.o
ld -m elf\_i386 -o $1 $1.o
```
Usually I use this command for fast compiling and linking .asm files.
**popcode.sh**
PrintOpcode
```
#!/bin/bash
target=$1
objdump -D -M intel "$target" | grep '[0-9a-f]:' | grep -v 'file' | cut -f2 -d: | cut -f1-7 -d' ' | tr -s ' ' | tr '\t' ' ' | sed 's/ $//g' | sed 's/ /\\x/g' | paste -d '' -s
```
Prints opcode of program in format "\x..\x...."
**hexopcode.sh**
HexOpcode
```
#!/bin/bash
target=$1
objdump -D -M intel "$target" | grep '[0-9a-f]:' | grep -v 'file' | cut -f2 -d: | cut -f1-7 -d' ' | tr -s ' ' | tr '\t' ' ' | sed 's/ $//g' | sed 's/ /\\x/g' | paste -d '' -s | sed -e 's!\\x!!g'
```
Prints opcode without "\x". Useful for using with next python script
**hex2stack.py**
hex to stack
```
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
if __name__ == '__main__':
if len(sys.argv) != 2:
print("Enter opcode in hex")
sys.exit(0)
string = sys.argv[1]
reversed = [string[i:i+2] for i in range(0,len(string),2)][::-1]
l = len(reversed) % 4
if l:
print("\tpush 0x" + "90"*(4-l) + "".join(reversed[0:l]))
for p in range(l, len(reversed[l:]), 4):
print("\tpush 0x" + "".join(reversed[p:p+4]))
```
This python script recieves opcode in hex-format and prints *push* commands for assembly file.
Example:
```
$./stack_shell.py 31c0506a68682f626173682f62696e89e35089c25389e1b00bcd80
out:
push 0x9080cd0b
push 0xb0e18953
push 0xc28950e3
push 0x896e6962
push 0x2f687361
push 0x622f6868
push 0x6a50c031
```
This is comfortable for placing our shellcode in stack for future executing.
**uscompile.sh**
UnSafeCompile. Another alias for compiling C files, usually with shellcode.
```
#!/bin/bash
if [ -z $1 ]; then
echo "Usage ./compile (no extension)"
exit
fi
if [ ! -e "$1.c" ]; then
echo "Error, $1.c not found."
echo "Note, do not enter file extensions"
exit
fi
gcc -masm=intel -m32 -ggdb -fno-stack-protector -z execstack -mpreferred-stack-boundary=2 -o $1 $1.c
```
**shellcode.c**
```
#include
#include
unsigned char code[] =
"";
int main()
{
printf("Shellcode Length: %d\n", strlen(code));
int (\*ret)() = (int(\*)())code;
ret();
}
```
It's a template for checking shellcodes. Length will be calculated until first '\x00'.
### Tasks
#### 1. TCP Bind Shell
Common algorithm of creating Linux TCP Socket is:
1. Create socket with socket() call
2. Set properties for created socket: protocol, address, port and execute bind() call
3. Execute listen() call for connections
4. accept() for accepting clients
5. Duplicate standard file descriptors in client's file descriptor
6. execve() shell
It's better for understanding to start with C TCP Bind Shell program.
```
#include
#include
#include
#include
#include
#include
int main(void)
{
int clientfd, sockfd;
int port = 1234;
struct sockaddr\_in mysockaddr;
// AF\_INET - IPv4, SOCK\_STREAM - TCP, 0 - most suitable protocol
// AF\_INET = 2, SOCK\_STREAM = 1
// create socket, save socket file descriptor in sockfd variable
sockfd = socket(AF\_INET, SOCK\_STREAM, 0);
// fill structure
mysockaddr.sin\_family = AF\_INET; //--> can be represented in numeric as 2
mysockaddr.sin\_port = htons(port);
//mysockaddr.sin\_addr.s\_addr = INADDR\_ANY;// --> can be represented in numeric as 0 which means to bind to all interfaces
mysockaddr.sin\_addr.s\_addr = inet\_addr("192.168.0.106");
// size of this array is 16 bytes
//printf("size of mysockaddr: %lu\n", sizeof(mysockaddr));
// executing bind() call
bind(sockfd, (struct sockaddr \*) &mysockaddr, sizeof(mysockaddr));
// listen()
listen(sockfd, 1);
// accept()
clientfd = accept(sockfd, NULL, NULL);
// duplicate standard file descriptors in client file descriptor
dup2(clientfd, 0);
dup2(clientfd, 1);
dup2(clientfd, 2);
// and last: execute /bin/sh. All input and ouput of /bin/sh will translated via TCP connection
char \* const argv[] = {"sh",NULL, NULL};
execve("/bin/sh", argv, NULL);
return 0;
}
```
Now, lets write same program on assembly language.
0. Prepare registers
```
section .text
global _start
_start:
xor eax, eax
xor ebx, ebx
xor esi, esi
```
1. Create socket
In x86 linux syscalls there is no direct socket() call. All socket calls can be executed via socketcall() method. socketcall() method recieves 2 arguments: number of socket call and pointer to it's arguments. List of socket calls you can find in /usr/include/linux/net.h file.
```
; creating socket. 3 args
push esi ; 3rd arg, choose default proto
push 0x1 ; 2nd arg, 1 equal SOCK_STREAM, TCP
push 0x2 ; 1st arg, 2 means Internet family proto
; calling socket call for socket creating
mov al, 102 ; socketcall
mov bl, 1 ; 1 = socket()
mov ecx, esp ; pointer to args of socket()
int 0x80
; in eax socket file descriptor. Save it
mov edx, eax
```
2. Creating sockaddr\_in addr struct and bind()
In sockaddr\_in structure PORT has WORD size, as Protocol family number

```
; creating sockaddr_in addr struct for bind
push esi ; address, 0 - all interfaces
push WORD 0xd204 ; port 1234.
push WORD 2 ; AF_INET
mov ecx, esp ; pointer to sockaddr_in struct
push 0x16 ; size of struct
push ecx ; pushing pointer to struct
push edx ; pushing socket descriptor
; socketcall
mov al, 102
mov bl, 2 ; bind()
mov ecx, esp
int 0x80
```
If you want to set another port:
```
$python3 -c "import socket; print(hex(socket.htons()))"
```
And if you want to set address directly:
```
$python3 -c 'import ipaddress; d = hex(int(ipaddress.IPv4Address(""))); print("0x"+"".join([d[i:i+2] for i in range(0,len(d),2)][1:][::-1]))'
```
3. listen() call
```
; creating listen
push 1
push edx
; calling socketcall
mov al, 102
mov bl, 4 ; listen()
mov ecx, esp
int 0x80
```
4. Accept()
```
; creating accept()
push esi
push esi
push edx
; calling socketcall
mov al, 102
mov bl, 5 ; accept()
mov ecx, esp
int 0x80
mov edx, eax ; saving client file descriptor
```
5. Duplicating file descriptors
```
; dup2 STDIN, STDOUT, STDERR
xor ecx, ecx
mov cl, 3
mov ebx, edx
dup: dec ecx
mov al, 63
int 0x80
jns dup
```
6. Executing /bin/sh via execve()
```
; execve /bin/sh
xor eax, eax
push eax
push 0x68732f2f
push 0x6e69622f
mov ebx, esp
push eax
mov edx, esp
push ebx
mov ecx, esp
mov al, 11
int 0x80
```
All information about system calls you can read from Linux manuals. For example:
```
$man 2 bind
```
Put it all together
```
section .text
global _start
_start:
; clear registers
xor eax, eax
xor ebx, ebx
xor esi, esi
; creating socket. 3 args
push esi ; 3rd arg, choose default proto
push 0x1 ; 2nd arg, 1 equal SOCK_STREAM, TCP
push 0x2 ; 1st arg, 2 means Internet family proto
; calling socket call for socket creating
mov al, 102 ; socketcall
mov bl, 1 ; 1 = socket()
mov ecx, esp ; pointer to args of socket()
int 0x80
; in eax socket file descriptor. Save it
mov edx, eax
; creating sockaddr_in addr struct for bind
push esi ; address, 0 - all interfaces
push WORD 0xd204 ; port 1234.
push WORD 2 ; AF_INET
mov ecx, esp ; pointer to sockaddr_in struct
push 0x16 ; size of struct
push ecx ; pushing pointer to struct
push edx ; pushing socket descriptor
; socketcall
mov al, 102 ; socketcall() number
mov bl, 2 ; bind()
mov ecx, esp ; 2nd argument - pointer to args
int 0x80
; creating listen
push 1 ; listen for 1 client
push edx ; clients queue size
; calling socketcall
mov al, 102
mov bl, 4 ; listen()
mov ecx, esp
int 0x80
; creating accept()
push esi ; use default value
push esi ; use default value
push edx ; sockfd
; calling socketcall
mov al, 102
mov bl, 5 ; accept()
mov ecx, esp
int 0x80
mov edx, eax ; saving client file descriptor
; dup2 STDIN, STDOUT, STDERR
xor ecx, ecx ; clear ecx
mov cl, 3 ; number of loops
mov ebx, edx ; socketfd
dup: dec ecx
mov al, 63 ; number of dup2 syscall()
int 0x80
jns dup ; repeat for 1,0
; execve /bin/bash
xor eax, eax ; clear eax
push eax ; string terminator
push 0x68732f2f ; //bin/sh
push 0x6e69622f
mov ebx, esp ; 1st arg - address of //bin/sh
push eax ;
mov edx, eax ; last argument is zero
push ebx ; 2nd arg - pointer to all args of command
mov ecx, esp ; pointer to args
mov al, 11 ; execve syscall number
int 0x80
```
Check it

#### 2. Reverse TCP Shell
This task is quite similar with previous one. The difference is in replacing bind(), listen(), accept() with connect() method.
Algorithm:
1. Create socket with socket() call
2. Set properties for created socket: protocol, address, port and execute connect() call
3. Duplicate sockfd into standard file descriptors (STDIN, STDOUT, STDERR)
4. execve() shell
C code
```
#include
#include
#include
#include
#include
int main ()
{
const char\* ip = "192.168.0.106"; // place your address here
struct sockaddr\_in addr;
addr.sin\_family = AF\_INET;
addr.sin\_port = htons(4444); // port
inet\_aton(ip, &addr.sin\_addr);
int sockfd = socket(AF\_INET, SOCK\_STREAM, 0);
connect(sockfd, (struct sockaddr \*)&addr, sizeof(addr));
/\* duplicating standard file descriptors \*/
for (int i = 0; i < 3; i++)
{
dup2(sockfd, i);
}
execve("/bin/sh", NULL, NULL);
return 0;
}
```
Translate it into assembly:
```
section .text
global _start
_start:
; creating socket
xor eax, eax
xor esi, esi
xor ebx, ebx
push esi
push 0x1
push 0x2
; calling socket call for socket creating
mov al, 102
mov bl, 1
mov ecx, esp
int 0x80
mov edx, eax
; creating sockaddr_in and connect()
push esi
push esi
push 0x6a00a8c0 ; IPv4 address to connect
push WORD 0x5c11 ; port
push WORD 2
mov ecx, esp
push 0x16
push ecx
push edx
; socketcall()
mov al, 102
mov bl, 3 ; connect()
mov ecx, esp
int 0x80
; dup2 STDIN, STDOUT, STDERR
xor ecx, ecx
mov cl, 3
mov ebx, edx
dup: dec ecx
mov al, 63
int 0x80
jns dup
; execve /bin/sh
xor eax, eax
push eax
push 0x68732f2f
push 0x6e69622f
mov ebx, esp
push eax
mov edx, esp
push ebx
mov ecx, esp
mov al, 11
int 0x80
```
Then
```
$nasm32 reverse_tcp_shell.asm
```
You can set custom IP address to connect and port with python commands above (Task 1)
Result

#### 3. Egg hunter technique
The purpose of an egg hunter is to search the entire memory range (stack/heap/..) for final stage shellcode and redirect execution flow to it.
For imitation this technique in assembly language I decided to:
1. Push some trash in stack
2. Push shellcode in stack
3. Push egg which we will search for
4. Push another trash
Let's generate some trash with python script
```
#!/usr/bin/python3
import random
rdm = bytearray(random.getrandbits(8) for _ in range(96))
for i in range(0,len(rdm),4):
bts = rdm[i:i+4]
print("\tpush 0x" + ''.join('{:02x}'.format(x) for x in bts))
```
I want to find shellcode of execute execve() with /bin/sh.
```
; execve_sh
global _start
section .text
_start:
; PUSH 0
xor eax, eax
push eax
; PUSH //bin/sh (8 bytes)
push 0x68732f2f
push 0x6e69622f
mov ebx, esp
push eax
mov edx, eax
push ebx
mov ecx, esp
mov al, 11
int 0x80
```
Generate push commands for this:
```
$nasm32 execve_sh; ./hex2stack.py $(hexopcode execve_sh)
```
Put it all together
```
section .text
global _start
_start:
; trash
push 0x94047484
push 0x8c35f24a
push 0x5a449067
push 0xf5a651ed
push 0x7161d058
push 0x3b7b4e10
push 0x9f93c06e
; shellcode execve() /bin/sh
push 0x9080cd0b
push 0xb0e18953
push 0xe28950e3
push 0x896e6962
push 0x2f687361
push 0x622f6868
push 0x6a50c031
; egg
push 0xdeadbeef
; trash
push 0xd213a92d
push 0x9e3a066b
push 0xeb8cb927
push 0xddbaec55
push 0x43a73283
push 0x89f447de
push 0xacfb220f
mov ebx, 0xefbeadde ; egg in reverse order
mov esi, esp
mov cl, 200 ; change this value for deeper or less searching
find: lodsb ; read byte from source - esi
cmp eax, ebx ; is it egg?
jz equal ; if so, give control to shellcode
shl eax, 8 ; if not, shift one byte left
loop find ; repeat
xor eax, eax ; if there is no egg - exit
mov al, 1
xor ebx, ebx
mov bl, 10
int 0x80
equal: jmp esi ; jmp to shellcode
```

You can replace instruction *loop find* with *jmp find* but it can crash program.
There are cases when your shellcode can be in lower address than your egghunter code. In this case reverse reading with Direction flag (std) can help you to perform search for egg. When you found shellcode, clear direction flag and jump to esi+offset.
#### 4. Encoder
In this exercise I've made insertion encoder with small trick: there is random value of «trash» bytes. Encoder looks:
```
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
import random
if len(sys.argv) != 2:
print("Enter opcode in hex")
sys.exit(0)
opcode = sys.argv[1]
encoded = ""
b1 = bytearray.fromhex(opcode)
# Generates random value from 1 to 5 of 'aa' string
for x in b1:
t = 'aa' * random.randint(1,5)
encoded += '%02x' % x + t
print(encoded)
```
As always, place this code into stack:
```
$./hex2stack.py $(./encoder.py $(hexopcode execve_sh))
```
Output:
```
push 0x909090aa
push 0xaaaaaaaa
push 0x80aaaaaa
push 0xaacdaaaa
push 0xaaaa0baa
push 0xaaaaaaaa
push 0xb0aaaaaa
push 0xaae1aaaa
push 0xaaaaaa89
push 0xaaaaaa53
push 0xaaaaaac2
push 0xaa89aaaa
push 0xaaaa50aa
push 0xaaaaaaaa
push 0xe3aaaa89
push 0xaaaa6eaa
push 0xaa69aaaa
push 0xaaaa62aa
push 0xaaaaaa2f
push 0xaa68aaaa
push 0x68aaaaaa
push 0xaaaa73aa
push 0xaaaa2faa
push 0xaa2faaaa
push 0xaa68aaaa
push 0x50aaaaaa
push 0xaaaac0aa
push 0xaaaaaa31
```
Pay attention at first part: 0x909090aa. 90 will be end-of-shellcode byte in decoder.
Code of decoder.asm
```
section .text
global _start
_start:
; encoded shellcode
push 0x909090aa
push 0xaaaaaaaa
push 0x80aaaaaa
push 0xaacdaaaa
push 0xaaaa0baa
push 0xaaaaaaaa
push 0xb0aaaaaa
push 0xaae1aaaa
push 0xaaaaaa89
push 0xaaaaaa53
push 0xaaaaaac2
push 0xaa89aaaa
push 0xaaaa50aa
push 0xaaaaaaaa
push 0xe3aaaa89
push 0xaaaa6eaa
push 0xaa69aaaa
push 0xaaaa62aa
push 0xaaaaaa2f
push 0xaa68aaaa
push 0x68aaaaaa
push 0xaaaa73aa
push 0xaaaa2faa
push 0xaa2faaaa
push 0xaa68aaaa
push 0x50aaaaaa
push 0xaaaac0aa
push 0xaaaaaa31
; prepare registers for decoding
mov esi, esp
mov edi, esp
mov bl, 0xaa
decoder:
lodsb ; read byte from stack
cmp al, bl ; check: is it trash byte?
jz loopy ; if so, repeat
cmp al, 0x90 ; is it end of shellcode?
jz exec ; if so, go to start of shellcode
stosb ; if not, place byte of shellcode into stack
loopy: jmp decoder ; repeat
exec: jmp esp ; give flow control to shellcode
```
When shellcode has no nop instructions it is normal to choose this byte as stop-marker. You can choose any another value as stop-marker — push this byte(s) first.
Result

#### 5. Analyzing msfvenom generated shellcodes with GDB/libemu/ndisasm
**1. Add user**
Command for generating shellcode
```
msfvenom -a x86 --platform linux -p linux/x86/adduser -f c > adduser.c
```
There are several ways to analyze this code with GDB, I decided to place this code into stack and execute it:
```
$ cat adduser.c | grep -Po "\\\x.." | tr -d '\n' | sed -e 's!\\x!!g' ; echo
31c989cb6a4658cd806a055831c9516873737764682f2f7061682f65746389e341b504cd8093e8280000006d65746173706c6f69743a417a2f6449736a3470344952633a303a303a3a2f3a2f62696e2f73680a598b51fc6a0458cd806a0158cd80
$ python3 hex2stack.py 31c989cb6a4658cd806a055831c9516873737764682f2f7061682f65746389e341b504cd8093e8280000006d65746173706c6f69743a417a2f6449736a3470344952633a303a303a3a2f3a2f62696e2f73680a598b51fc6a0458cd806a0158cd80
out:
push 0x90909080
push 0xcd58016a
push 0x80cd5804
...
```
And make .asm file:
```
section .text
global _start
_start:
push 0x90909080
push 0xcd58016a
push 0x80cd5804
push 0x6afc518b
push 0x590a6873
push 0x2f6e6962
push 0x2f3a2f3a
push 0x3a303a30
push 0x3a635249
push 0x3470346a
push 0x7349642f
push 0x7a413a74
push 0x696f6c70
push 0x73617465
push 0x6d000000
push 0x28e89380
push 0xcd04b541
push 0xe3896374
push 0x652f6861
push 0x702f2f68
push 0x64777373
push 0x6851c931
push 0x58056a80
push 0xcd58466a
push 0xcb89c931
jmp esp
```

First, setreuid(0,0) syscall is executing. It sets root privileges to program.
```
xor ecx, ecx ; ecx = 0
mov ebx, ecx ; ebx = 0
; setreuid(0,0) - set root as owner of this process
push 0x46
pop eax
int 0x80
```
Then open /etc/passwd file and go to address with call instruction. Call instruction places address of next instruction onto stack. In our case it is string «metasploit...» which program adds into opened file. This picture clarifies number values which is used with files.

```
; Executing open() sys call
push 0x5
pop eax
xor ecx, ecx
push ecx ; push 0, end of filename path
; pushing /etc/passwd string
push 0x64777373
push 0x61702f2f
push 0x6374652f
mov ebx, esp ; placing address of filename as argument
inc ecx
mov ch,0x4 ; ecx is 0x401 - 02001 - open file in write only access and append
int 0x80
xchg ebx, eax
call 0x80480a7
```
And last step is writing our string into /etc/passwd file.
```
pop ecx ; string metasploit:Az/dIsj4p4IRc:0:0::/:/bin/sh\nY\213Q\374j\004X̀j\001X̀\220\220\220\001
mov edx, DWORT PTR [ecx-0x4] ; length of string
push ecx
push 0x4
pop eax
int 0x80 ; write string into file
push 0x1
pop eax
int 0x80 ; exit
```
Instructions after call

Due to call instruction we can set any pair username:password easily.
**2. Exec whoami**
Generate shellcode
```
$msfvenom -a x86 --platform linux -p linux/x86/exec CMD="whoami" -f raw> exec_whoami.bin
```
This payload execute /bin/sh -c whoami, using call instruction. In case of call next instruction is placing into stack, that's why it's easily to create any command for executing.
To analyze shellcode with libemu:
```
$sctest -vv -S -s 10000 -G shell.dot < exec_whoami.bin
```
```
[emu 0x0x16c8100 debug ] 6A0B push byte 0xb
; execve()
[emu 0x0x16c8100 debug ] 58 pop eax
[emu 0x0x16c8100 debug ] 99 cwd
; in this case - set to 0 due to cwd and small eax
[emu 0x0x16c8100 debug ] 52 push edx
; "-c"
[emu 0x0x16c8100 debug ] 66682D63 push word 0x632d
; address of "-c"
[emu 0x0x16c8100 debug ] 89E7 mov edi,esp
; /bin/sh
[emu 0x0x16c8100 debug ] 682F736800 push dword 0x68732f
[emu 0x0x16c8100 debug ] 682F62696E push dword 0x6e69622f
; 1st arg of execve()
[emu 0x0x16c8100 debug ] 89E3 mov ebx,esp
; null
[emu 0x0x16c8100 debug ] 52 push edx
; place "whoami" in stack
[emu 0x0x16c8100 debug ] E8 call 0x1
; push "-c"
[emu 0x0x16c8100 debug ] 57 push edi
; push "/bin/sh"
[emu 0x0x16c8100 debug ] 53 push ebx
; 2nd argument of execve()
; pointer to args
[emu 0x0x16c8100 debug ] 89E1 mov ecx,esp
; execute execve()
[emu 0x0x16c8100 debug ] CD80 int 0x80
```

**3. Reverse Meterpreter TCP**
command to generate payload
```
msfvenom -a x86 --platform linux -p linux/x86/meterpreter/reverse_tcp LHOST=192.168.0.102 LPORT=4444 -f raw > meter_revtcp.bin
```
Then
```
ndisasm -u meter_revtcp.bin
```
Code with comments
```
00000000 6A0A push byte +0xa
00000002 5E pop esi ; place 10 in esi
00000003 31DB xor ebx,ebx ; nullify ebx
00000005 F7E3 mul ebx
00000007 53 push ebx ; push 0
00000008 43 inc ebx ; 1 in ebx
00000009 53 push ebx ; push 1
0000000A 6A02 push byte +0x2 ; push 2
0000000C B066 mov al,0x66 ; mov socketcall
0000000E 89E1 mov ecx,esp ; address of argument
00000010 CD80 int 0x80 ; calling socketcall() with socket()
00000012 97 xchg eax,edi ; place sockfd in edi
00000013 5B pop ebx ; in ebx 1
00000014 68C0A80066 push dword 0x6600a8c0 ; place IPv4 address connect to
00000019 680200115C push dword 0x5c110002 ; place port and proto family
0000001E 89E1 mov ecx,esp
00000020 6A66 push byte +0x66
00000022 58 pop eax ; socketcall()
00000023 50 push eax
00000024 51 push ecx ; addresss of sockaddr_in structure
00000025 57 push edi ; sockfd
00000026 89E1 mov ecx,esp ; address of arguments
00000028 43 inc ebx
00000029 CD80 int 0x80 ; call connect()
0000002B 85C0 test eax,eax ;
0000002D 7919 jns 0x48 ; if connect successful - jmp
0000002F 4E dec esi ; in esi 10 - number of attempts to connect
00000030 743D jz 0x6f ; if zero attempts left - exit
00000032 68A2000000 push dword 0xa2
00000037 58 pop eax
00000038 6A00 push byte +0x0
0000003A 6A05 push byte +0x5
0000003C 89E3 mov ebx,esp
0000003E 31C9 xor ecx,ecx
00000040 CD80 int 0x80 ; wait 5 seconds
00000042 85C0 test eax,eax
00000044 79BD jns 0x3
00000046 EB27 jmp short 0x6f
00000048 B207 mov dl,0x7 ; mov dl 7 - read, write, execute for mprotect() memory area
0000004A B900100000 mov ecx,0x1000 ; 4096 bytes
0000004F 89E3 mov ebx,esp
00000051 C1EB0C shr ebx,byte 0xc
00000054 C1E30C shl ebx,byte 0xc ; nullify 12 lowest bits
00000057 B07D mov al,0x7d ; mprotect syscall
00000059 CD80 int 0x80
0000005B 85C0 test eax,eax
0000005D 7810 js 0x6f ; if no success with mprotect -> exit
0000005F 5B pop ebx ; if success put sockfd in ebx
00000060 89E1 mov ecx,esp
00000062 99 cdq
00000063 B60C mov dh,0xc
00000065 B003 mov al,0x3 ; read data from socket
00000067 CD80 int 0x80
00000069 85C0 test eax,eax
0000006B 7802 js 0x6f
0000006D FFE1 jmp ecx ; jmp to 2nd part of shell
0000006F B801000000 mov eax,0x1
00000074 BB01000000 mov ebx,0x1
00000079 CD80 int 0x80
```
This code is creating socket, trying to connect to the specified IP address, call mprotect for creating memory area and read 2nd part of shellcode from socket. If it can't connect to destination address, program waits 5 seconds and then is trying to reconnect. In case of fall on any stage it exits.
#### 6. Three polymorphic shellcodes from shell-storm
**1. chmod /etc/shadow**
```
; http://shell-storm.org/shellcode/files/shellcode-608.php
; Title: linux/x86 setuid(0) + chmod("/etc/shadow", 0666) Shellcode 37 Bytes
; length - 40 bytes
section .text
global _start
_start:
sub ebx, ebx ; replaced
push 0x17 ; replaced
pop eax ; replaced
int 0x80
sub eax, eax ; replaced
push eax ; on success zero
push 0x776f6461
push 0x68732f63
push 0x74652f2f
mov ebx, esp
mov cl, 0xb6 ; replaced
mov ch, 0x1 ; replaced
add al, 15 ; replaced
int 0x80
add eax, 1 ; replaced
int 0x80
```
This shellcode calls setuid() with zero params (setting root privileges) and then chmod() /etc/shadow file.

In some cases this code can be executed without nullifying registers.
```
section .text
global _start
_start:
push 0x17 ; replaced
pop eax ; replaced
int 0x80
push eax ; on success zero
push 0x776f6461
push 0x68732f63
push 0x74652f2f
mov ebx, esp
mov cl, 0xb6 ; replaced
mov ch, 0x1 ; replaced
add al, 15 ; replaced
int 0x80
add eax, 1 ; replaced
int 0x80
```
This code is running well by building .asm.
**2. Execve /bin/sh**
```
; http://shell-storm.org/shellcode/files/shellcode-251.php
; (Linux/x86) setuid(0) + setgid(0) + execve("/bin/sh", ["/bin/sh", NULL]) 37 bytes
; length - 45 byte
section .text
global _start
_start:
push 0x17
mov eax, [esp] ; replaced
sub ebx, ebx ; replaced
imul edi, ebx ; replaced
int 0x80
push 0x2e
mov eax, [esp] ; replaced
push edi ; replaced
int 0x80
sub edx, edx ; replaced
push 0xb
pop eax
push edi ; replaced
push 0x68732f2f
push 0x6e69622f
lea ebx, [esp] ; replaced
push edi ; replaced
push edi ; replaced
lea esp, [ecx] ; replaced
int 0x80
```

**3. TCP bind shellcode with second stage**
```
; original: http://shell-storm.org/shellcode/files/shellcode-501.php
; linux/x86 listens for shellcode on tcp/5555 and jumps to it 83 bytes
; length 94
section .text
global _start
_start:
sub eax, eax ; replaced
imul ebx, eax ; replaced
imul edx, eax ; replaced
_socket:
push 0x6
push 0x1
push 0x2
add al, 0x66 ; replaced
add bl, 1 ; replaced
lea ecx, [esp] ; replaced
int 0x80
_bind:
mov edi, eax ; placing descriptor
push edx
push WORD 0xb315 ;/* 5555 */
push WORD 2
lea ecx, [esp] ; replaced
push 16
push ecx
push edi
xor eax, eax ; replaced
add al, 0x66 ; replaced
add bl, 1 ; replaced
lea ecx, [esp] ; replaced
int 0x80
_listen:
mov bl, 4 ; replaced
push 0x1
push edi
add al, 0x66 ; replaced
lea ecx, [esp] ; replaced
int 0x80
_accept:
push edx
push edx
push edi
add al, 0x66 ; replaced
mov bl, 5 ; replaced
lea ecx, [esp] ; replaced
int 0x80
mov ebx, eax
_read:
mov al, 0x3
lea ecx, [esp] ; replaced
mov dx, 0x7ff
mov dl, 1 ; replaced
int 0x80
jmp esp
```
Code of 2nd stage
```
section .text
global _start
_start:
xor eax, eax
mov al, 1
xor ebx, ebx
mov ebx, 100
int 0x80
```

Our 2nd stage is executed: exit code is 100.
#### 7. Crypter
This is assemby course and exam that's why I decided to realize simple substitution cipher on assembly.
crypter.py
```
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import random
if len(sys.argv) != 2:
print("Enter shellcode in hex")
sys.exit(0)
shellcode = sys.argv[1]
plain_shellcode = bytearray.fromhex(shellcode)
# Generating key
key_length = len(plain_shellcode)
r = ''.join(chr(random.randint(0,255)) for _ in range(key_length))
key = bytearray(r.encode())
encrypted_shellcode = ""
plain_key = ""
for b in range(len(plain_shellcode)):
enc_b = (plain_shellcode[b] + key[b]) & 255
encrypted_shellcode += '%02x' % enc_b
plain_key += '0x'+ '%02x' % key[b] + ','
print('*'*150)
print(encrypted_shellcode)
print('*'*150)
print(plain_key)
print('*'*150)
print(key_length)
```
First, create skeleton:
```
section .text
global _start
_start:
; push encrypted shellcode
jmp getdata
next: pop ebx
mov esi, esp
mov edi, esp
; place key length
mov ecx,
decrypt:
lodsb
sub al, byte [ebx]
inc ebx
stosb
loop decrypt
jmp esp
; exit
xor eax, eax
mov al, 1
xor ebx, ebx
int 0x80
getdata: call next
; Place key on next line
key db
```
This code requires 3 things: push instructions with encrypted shellcode, key length and cipher key itself.
Let's encrypt TCP bind shell shellcode.
```
$hexopcode bind_tcp_shell
31c031db31f6566a016a02b066b30189e1cd8089c25666680929666a0289e16a105152b066b30289e1cd806a0152b066b30489e1cd80565652b066b30589e1cd8089c231c9b10389d349b03fcd8079f931c050682f2f7368682f62696e89e35089e25389e1b00bcd80
```
Encrypt output
```
$./crypter.py 31c031db31f6566a016a02b066b30189e1cd8089c25666680929666a0289e16a105152b066b30289e1cd806a0152b066b30489e1cd80565652b066b30589e1cd8089c231c9b10389d349b03fcd8079f931c050682f2f7368682f62696e89e35089e25389e1b00bcd80
*******************************Encrypted shellcode*******************************
4af2f48df478632d902db527287245fb5d8f38accc18f7b4ccae29ffc514fc2dc614d5e12946c535068f392d921449b111c738a35042da18dd730a75c04b8719c5b93cab8b31554c7fb773fa8f0cb976f37ba483f2bf361ee5f1132c20ba09bf4b86ad4c6f72b78f13
***********************************KEY*******************************************
0x19,0x32,0xc3,0xb2,0xc3,0x82,0x0d,0xc3,0x8f,0xc3,0xb3,0x77,0xc2,0xbf,0x44,0x72,0x7c,0xc2,0xb8,0x23,0x0a,0xc2,0x91,0x4c,0xc3,0x85,0xc3,0x95,0xc3,0x8b,0x1b,0xc3,0xb6,0xc3,0x83,0x31,0xc3,0x93,0xc3,0xac,0x25,0xc2,0xb9,0xc3,0x91,0xc2,0x99,0x4b,0x5e,0xc3,0xaf,0xc2,0x83,0xc2,0x84,0xc2,0x8b,0xc3,0xa4,0xc2,0xbb,0xc2,0xa6,0x4c,0x45,0x30,0x7a,0x7a,0xc2,0x80,0x52,0xc3,0xac,0x6e,0xc3,0xbb,0xc2,0x8c,0x40,0x7d,0xc2,0xbb,0x54,0x1b,0xc3,0x90,0xc3,0xb6,0x7d,0xc2,0xb1,0xc3,0xb2,0x31,0x26,0x6f,0xc2,0xa4,0x5a,0xc3,0x8e,0xc2,0xac,0xc2,0x93,
***********************************KEY LENGTH************************************
105
```
print push instructions for our encrypted shellcode
```
$python3 hex2stack.py 4af2f48df478632d902db527287245fb5d8f38accc18f7b4ccae29ffc514fc2dc614d5e12946c535068f392d921449b111c738a35042da18dd730a75c04b8719c5b93cab8b31554c7fb773fa8f0cb976f37ba483f2bf361ee5f1132c20ba09bf4b86ad4c6f72b78f13
push 0x90909013
push 0x8fb7726f
...
```
And fill all fileds in .asm file
```
section .text
global _start
_start:
; push encrypted shellcode
push 0x90909013
push 0x8fb7726f
push 0x4cad864b
push 0xbf09ba20
push 0x2c13f1e5
push 0x1e36bff2
push 0x83a47bf3
push 0x76b90c8f
push 0xfa73b77f
push 0x4c55318b
push 0xab3cb9c5
push 0x19874bc0
push 0x750a73dd
push 0x18da4250
push 0xa338c711
push 0xb1491492
push 0x2d398f06
push 0x35c54629
push 0xe1d514c6
push 0x2dfc14c5
push 0xff29aecc
push 0xb4f718cc
push 0xac388f5d
push 0xfb457228
push 0x27b52d90
push 0x2d6378f4
push 0x8df4f24a
jmp getdata
next: pop ebx
mov esi, esp
mov edi, esp
; place key length
mov ecx, 105
decrypt:
lodsb
sub al, byte [ebx]
inc ebx
stosb
loop decrypt
jmp esp
; exit
xor eax, eax
mov al, 1
xor ebx, ebx
int 0x80
getdata: call next
; Place key on next line
key db 0x19,0x32,0xc3,0xb2,0xc3,0x82,0x0d,0xc3,0x8f,0xc3,0xb3,0x77,0xc2,0xbf,0x44,0x72,0x7c,0xc2,0xb8,0x23,0x0a,0xc2,0x91,0x4c,0xc3,0x85,0xc3,0x95,0xc3,0x8b,0x1b,0xc3,0xb6,0xc3,0x83,0x31,0xc3,0x93,0xc3,0xac,0x25,0xc2,0xb9,0xc3,0x91,0xc2,0x99,0x4b,0x5e,0xc3,0xaf,0xc2,0x83,0xc2,0x84,0xc2,0x8b,0xc3,0xa4,0xc2,0xbb,0xc2,0xa6,0x4c,0x45,0x30,0x7a,0x7a,0xc2,0x80,0x52,0xc3,0xac,0x6e,0xc3,0xbb,0xc2,0x8c,0x40,0x7d,0xc2,0xbb,0x54,0x1b,0xc3,0x90,0xc3,0xb6,0x7d,0xc2,0xb1,0xc3,0xb2,0x31,0x26,0x6f,0xc2,0xa4,0x5a,0xc3,0x8e,0xc2,0xac,0xc2,0x93,
```
Build it
```
$nasm32 encrypted_bind
```
Get opcode from file
```
$popcode encrypted_bind
```
Place output it into shellcode.c, compile and run.

### Links
Code of all files you can find at:
[github.com/2S1one/SLAE](https://github.com/2S1one/SLAE) | https://habr.com/ru/post/482334/ | null | null | 4,789 | 57.5 |
Hi! Pjotr Prins <address@hidden> skribis: > On Wed, Jan 18, 2017 at 10:42:09PM +0100, Ludovic Courtès wrote: [...] >> Also, if we look at the big picture of non-root usage, this solution >> addresses the most hostile environments: no user namespaces, no >> container-spawning facility, no root guix-daemon, etc. Granted, these >> hostile environments are still commonplace in HPC, so that’s good. :-) > > Yes, if this works it will be rather good and create awareness for > Guix. Another use-case may be firefox plugins - or other software that > wants to install binaries. Maybe they'll wake up to guix too. From a > developers point of view Guix is awesome because it creates > reproducible environments that we can develop against. What more do we > need ;). We are now using it for a bug hunt on sambamba which only > segfaults on particular HPC setups. The guix relocatable installer is > going to help. Indeed. > I'll take the installer to the level that we can do one-step installs > and provide a few packages for download to reach out to certain > communities (dlang and elixir come to mind). For these “guix archive -f docker” may also be handy (and safer)? Cheers, Ludo’. | https://lists.gnu.org/archive/html/guix-devel/2017-01/msg01553.html | CC-MAIN-2020-40 | refinedweb | 199 | 64 |
With the addition of support for scripting languages in the Java platform, there has been a lot of interest in combining into web applications scripting languages such as Groovy, Java technologies such as the Java Persistence API (JPA), and databases such as MySQL. Last year I wrote a Tech Tip titled Combining JavaServer Faces Technology, Spring, and the Java Persistence API that showed how you can use JavaServer Faces Technology, Spring, and the JPA to create an application that displays an online catalog of pets. In this tip, I'll show you how to create an online catalog application using the Groovy language, the Grails framework, the MySQL database, and the Java Persistence API.
A package that contains the code for the sample application accompanies the tip. The code examples in the tip are taken from the source code of the sample (which is included in the package). In this tip, you'll use NetBeans IDE 6.5 Milestone 1 to build the application and deploy it on the GlassFish application server. The NetBeans IDE is a modular, standards-based, integrated development environment (IDE) written in the Java programming language. The latest NetBeans IDE offering, NetBeans IDE 6.5 Milestone 1 (or M1 for short), offers many new features including support for Groovy and Grails. GlassFish is a free, open source application server that implements the newest features in the Java EE 5 platform.
A Summary of the Languages, Technologies, and Frameworks in the Sample Application
If you're not familiar with Groovy, Grails, MySQL, or the Java Persistence API, here are brief descriptions:
The Sample Application
The sample application displays an online catalog of pets sold in a pet store. Figure 1 shows the Catalog Listing page, which allows a user to page through a list of items in a store.
Examining the Application
Earlier I mentioned that Grails is a Model-View-Controller based framework that simplifies the development of web applications. The online catalog application uses Grails and so it follows the MVC pattern, that is, the application isolates its data, the "Model", from the user interface, the "View", and from the code that manages the communication between the model and the view, the "Controller". Let's first look at the Model for the application.
The Model
The Model not only represents the data for the application, but it also represent persistent data, that is, data that persists beyond the life of the application. In other words, the Model represents an application's persistent business domain objects. The application uses JPA to manage that persistence. In JPA, an entity instance -- an instance of an entity object -- represents a row of data in a database table.
If you examine the source code for the application, you'll find the following two classes in the
model directory:
Item and
Address.
Item is an entity class -- a typical JPA entity object -- that
maps to an
item table in a database. The table stores information about items in the catalog. Here is part
of the source code for the
Item class:
package model; import java.io.Serializable; ... @Entity @Table(name = "item") public class Item implements Serializable { private static final long serialVersionUID = 1L; @Id private Long id; private String name; private String description; private String imageurl; private String imagethumburl; private BigDecimal price; @ManyToOne(optional = false) @JoinColumn(name = "address_id") private Address address; // getters and setters ... }
Address is an entity class that maps to an
address table in the database. The table stores
addresses associated with items in the catalog. Here is part of the source code for the
Address class:
package model; import java.io.Serializable; ... @Entity public class Address implements Serializable { private static final long serialVersionUID = 1L; @Id private Long id; private String street1; private String street2; private String city; private String state; private String zip; private BigDecimal latitude; private BigDecimal longitude; private BigInteger version; @OneToMany(fetch = FetchType.EAGER, cascade = { CascadeType.ALL }, mappedBy = "address") private Collection<Item>items = new ArrayList(); // getters and setters ... }
The
Item class has a many-to-one relationship with the
Address class, meaning that
there can be multiple items in the catalog associated with the same address, but multiple addresses cannot be associated
with the same item. This relationship is specified by the
@ManyToOne annotation in the
Item class
and the
@OneToMany(mappedBy = "address") annotation in the
Address entity class.
Using JPA Entities With Grails and MySQL
To use the JPA entities for the application with Grails and MySQL, you first need to create a Grails application and then modify some files in the Grails application directory structure.
We'll use NetBeans IDE 6.5 M1 to create a Grails application. If you haven't already done so, download NetBeans IDE 6.5 Milestone 1 and download Grails.
Start NetBeans IDE 6.5 Milestone 1. Select New Project from the File menu. Then select Groovy in the Categories window and Grails in the Projects window as shown in Figure2.
Click the Next button and name the project, for instance,
MyGrailsApp. Accept the default project location
or browse to select a different location. Leave the Set as Main Project checkbox checked and click the Finish button.
In response, NetBeans creates the Grails project and a standard directory structure for a Grails application. Figure 3 shows the Grails directory structure for the online catalog application.
After you have your directory structure in place, do the following:
Itemand
Addressentity files for the online catalog application are in the
catalog\src\java\modeldirectory.
app_name\libdirectory. You can find the
mysql-connector-java-5.1.6-bin.jarfile for the online catalog application in the
catalog\libdirectory.
DataSource.groovyfile in the
app_name\grails-app\confdirectory to use MySQL as the database and specify the
GrailsAnnotationConfigurationconfiguration class to use the annotations in the JPA entities. The code marked in bold in the following code example shows the additions and modification that I made to the
DataSource.groovyfile for the online catalog application.
hibernate.cfg.xmlfile to the
app_name\grails-app\conf\hibernatedirectory. Here is the
hibernate.cfg.xmlfile for the online catalog application. You can find it in the
catalog\grails-app\conf\hibernatedirectory.
The Controller
NetBeans IDE 6.5 M1 enables you to create domain classes and controllers, but I haven't found the menu option to generate controllers, so for now, let's use the command line as follows to generate a controller:
grails generate-controller domain-classwhere domain-class is the domain class name. For example, to generate a controller for the
Itemdomain class in the online catalog application, I entered the following command:
grails generate-controller model.Item
In response, the command generates a file named
domain-classController.groovy in the
grails-app/controllers directory. For the
Item class, the generated controller is in
grails-app/controllers/ItemController.groovy.
Figure 4 shows the controller,
ItemController.groovy, in the NetBeans IDE 6.1 M1 Groovy
editor window.
Controllers handle incoming HTTP requests, interact with the model to get data and process requests, invoke the correct
view, and direct domain data to the view for display. In Grails, HTTP requests are handled by controller classes that contain
one or more action methods that are executed on request. The action methods either render
a Groovy Server Page
(GSP) or redirect to another action. Grails routes requests to the controller action that corresponds to the URL mapping for
the request. In Grails, the default mapping from URL to action method follows the convention where host is the host name,
app_name is the name of the Grails
application, controller is the controller class, action is the action method, and id
is the id of a passed parameter. For example, the URL calls the
list action method in the item controller class. Here is code snippet in
ItemController.groovy that shows the
list method:
Grails scaffolding provides a series of standardized controller
action methods for listing, showing, creating, updating, and deleting objects of a class. These standardized actions come
with both controller logic and default view Groovy Server Pages. The
list action in
ItemController
renders a view with a paginated list of item objects.
If a URL has a controller but no action, as is the case for, Grails defaults to the
index action. In the
ItemController code, the
index action method redirects to the
list action method. The
list action method calls the
Item.list() method, which
returns an
ArrayList of
item objects retrieved from the
item table in the
database. If there are more objects in the table than the number specified in
params.max (in this case, 10),
Grails automatically creates next and previous pagination links. The Grails framework automatically makes the
itemList variable available to the view.
After executing code, actions usually render a GSP in the
views directory corresponding to the name of the
controller and action. For example the
list action renders the GSP,
list.gsp, in the
grails-app\views\item directory.
The View
The view layer uses data from domain objects provided by the controller to generate a web page. In Grails, the view is rendered using Groovy Server Pages. To generate the view, open a command prompt, navigate to the project directory for your Grails application, and enter the following command:
grails generate-views domain-class
where domain-class is the domain class. For example, to generate a view for the
Item
domain class in the online catalog application, I entered the following command:
grails generate-views model.Item
In response, the command generates GSPs for the domain class. For example, it generates
create.gsp,
edit.gsp,
list.gsp,
model.Item entity.
Here is part of the
list.gsp file for the online catalog application. Note that I modified the HTML
table format that is generated by default to display the pet images.
The view uses instance variables set by the controller to access the data it needs to render the GSP. Groovy Server Pages
use a GroovyTagLib that is similar to the JSP tag library. Notice the tags that start with
<g:
in the
list.gsp code. These are GroovyTags. Here is a brief summary of the GroovyTags and some other
elements in the
list.gsp code:
<g:sortableColumn>
<g:each
itemListvariable, which is an ordered
ArrayListof
Itemmodel objects, and assigns each
Itemmodel object to the
itemvariable.
<g:link${item.name?.encodeAsHTML()}</g:link>
hrefbased on the specified action, id, and controller parameters specified. In this example, it generates a link to the
item/show/idaction. This action will display the corresponding item details. Here, the line generates the following HTML for the variable
item:
<a href="/catalog/item/show/2">Friendly Cat</a>
<img src="${createLinkTo(dir:'images',file:item.imagethumburl)}"/>
${item.price?.encodeAsHTML()}
<g:paginate
The Show Action Method
Recall that in Grails, the default mapping from URL to action method follows the convention where host is the host name,
app_name is the name of the Grails
application, controller is the controller class, action is the action method, and id
is the id of the passed parameter. This means that in the online catalog application, a URL of
will route to the show action in the
ItemController, passing 1 to the method as the id of the parameter.
The
show action of the
ItemController class is shown below. The
ItemController
show action renders a view showing the details of the
item object corresponding to the
id parameter.
The
show action method calls the
Item.get() method. That method, in turn, queries
the
items table, and returns an
item instance variable that corresponds to the
item whose attribute id (that is, its primary key) is equal to the
id parameter.
This is the equivalent to the following SQL statement:
select * from items where id='1'
The Grails framework automatically makes the
item variable available to the
Show view.
The Show Item GSP
After executing the appropriate code, the
show action renders the
show.gsp file
in the applications's
views/item directory. Here is the part of the
show.gsp file
for the online catalog application, presenting the item show view:
Here are some important parts of the item show view:
${item.description}
<img src="${createLinkTo(dir:'images',file:item.imageurl)}" /> ${item.description}
imageurlattribute.
${item?.address?.city}
Running the Sample Code
These instructions assume that you have NetBeans IDE 6.1, GlassFish v2ur2, and MySQL installed. You can download all three in a single bundle. Another option is to download a bundle that includes Sun Java System Application Server 9.1 Update 1 with MySQL Community Server.
GF_install\updatecenter\bin\updatetool
<sample_install_dir>/catalog, where
<sample_install_dir>is the directory where you unzipped the sample package. For example, if you extracted the contents to
C:\on a Windows machine, then your newly created directory should be at
C:\catalog.
catalog.sqlfile in the
catalogdirectory and paste the contents into the SQL command window.
catalog\grails-app\conf\DataSource.groovyfile are the same as the corresponding property settings in NetBeans IDE 6.5 M1 for the MySQL server database.
catalog-0.1.warfile in your the catalog project directory. You might need to change the level of Grails expected by the application -- this is the
app.grails.versionsetting in the
catalog\application.propertiesfile -- to align it with the level of Grails you have installed.
catalog-0.1.warfile to the
GF_install/domains/domain1/autodeploydirectory, where GF_install is the directory where you installed GlassFish. your browser. You should see the home page of the sample application.
Further Reading.
1 As used on this web site, the terms "Java virtual machine" or "JVM" mean a virtual machine for the Java platform.
Project SailFin and Ericsson Application Competition
Create or enhance an IMS client-server application for a chance to win USD $5,000 or a Sony Ericsson phone.
Community Code Samples
Use code samples for your own programming and add your own examples to this collection.
This is pretty much exactly what I've been looking for.
My team invested a lot of effort in learning our previous stack of Hibernate JPA and Apache Wicket but we now develop almost all of our web apps in Grails. Of course GORM is great but it was nice to see the clean separation of concerns in your example. JPA is a standard that we (and others) know well so I'm looking forward to trying this on a future project.
On an unrelated note, I hope Sun does a better job of pushing Grails and continues to encourage improvements to Groovy tooling. For us, the transparent linking and bicompilation between Groovy and Java is a huge win.
Posted by Bill Shim on August 01, 2008 at 02:25 PM PDT #
I have a question: what advantages would I have to use JPA for my domain model over using plain GORM?
Besides yours (which is very nice), I saw other presentations on how to do this, but I can't tell if this is just a convenient way to connect to a legacy (well, let's say existing) domain model, Or if there are real advantages to do so.
Thank you.
Posted by JS on August 04, 2008 at 10:18 AM PDT #
Thanks Bill, I agree that Groovy and Java is a huge win. We have been and will continue talking about and demoing Grails and Glassfish at some of our Tech Days events
Posted by carol mcdonald on August 04, 2008 at 01:19 PM PDT #
If you have existing data base tables then JPA is a nice option for a Java O/R framework. JPA is a standard api for O/R mapping, it draws upon the experience of Hibernate, TopLink, and JDO.
Posted by carol mcdonald on August 04, 2008 at 01:46 PM PDT #
Thanks Carol for this great article.
I was wondering whether you have an idea of how to make the @Version field work with Grails.
I tried adding a version field and performed simultaneous updates using different browsers but didn't get any errors.
Also, would you know how to add constraints (for input validation) to JPA entities similar to how you do it in Grails domain objects?
Super thanks!
Posted by Paul on August 12, 2008 at 07:06 PM PDT #
Thanks Carol, you're great.
I can't seem to find any article or references to using EJB3.0 in Grail or Groovy applications. My team and I are handling a full enterprise application running EJBs in the middle tier and I was thinking of trying Grail out before proposing it.
All i seem to find is database-backed web application.
Posted by Michael Enudi on August 15, 2008 at 02:49 AM PDT #
Recommendation for German readers:
Visit or for more information and discussion about Groovy and Grails.
Posted by Christian on August 15, 2008 at 03:37 AM PDT #
A great article by Jason Rudolph:
Posted by JS on August 15, 2008 at 04:08 AM PDT #
very good
Posted by diana on August 15, 2008 at 07:14 AM PDT #
JPA 1.0 persistence providers must support optimistic locking where a numeric or timestamp column tracks the version. Since the persistence provider takes care of this it should work with Grails too. This article has an example of using this:
With JPA 1.0 you can specify uniqueness and nullable constraints on columns. With JPA 2.0 you can use bean validation on entities (JSR 303). The url I mentioned above has an example of doing validation using @prepersist.
Posted by carol mcdonald on August 15, 2008 at 07:55 AM PDT #
yes for more info on grails and ejb3 see
Posted by carol mcdonald on August 15, 2008 at 08:59 AM PDT #
Just to be clear EJB3 and JPA are separate specs, and JPA entities are not EJBs
Posted by carol mcdonald on August 15, 2008 at 09:02 AM PDT #
TOO GOOD !!!!! well done , java is the best ...
Posted by indy on August 16, 2008 at 08:44 AM PDT #
muy bueno
Posted by cristina carrete on August 16, 2008 at 02:37 PM PDT #
TOO GOOD !!!!! well done , java is the best ...
Posted by cristina carrete on August 16, 2008 at 02:39 PM PDT #
I wonder if Amazon SimpleDB together with SimpleJPA () would be feasible?
Posted by Roshan Shrestha on August 21, 2008 at 11:55 AM PDT #
In response to the question of Gorm over JPA. Gorm ties you to grails. If you wanted to write a Swing admin interface in addition to a client web interface you would have to learn a lot of advanced tricks to use Gorm outside of Grails with Swing. If you use JPA then you don't have that problem. Most people will read this and think "I don't need Swing" however it is interesting to think about using JUnit and other "out of container tools" such as if you need to write a batch update java programs that might need to act on your data at regular intevals using 'normal java' outside of Grails. If you are just writing a pure website on Grails then just use Gorm. If you are writing a database that is more than a website then consider JPA mixed with Grails so that you can use Grails for its website power.
Posted by simbo on August 21, 2008 at 12:48 PM PDT #
when i run the above project it show the below error. How can i resolve it. if any body please reply me......
Application expects grails version [1.0.2], but GRAILS_HOME is
version [1.1.1] - use the correct Grails version or run
'grails upgrade' if this Grails version is newer than the version your application expects.
Posted by Shantanu on June 21, 2009 at 10:44 PM PDT # | http://blogs.sun.com/enterprisetechtips/entry/combining_groovy_grails_mysql_and | crawl-002 | refinedweb | 3,291 | 54.42 |
The. If the specified XPath points to a node with more than one child, or if the node pointed to has a non-text node child, then Oracle returns an error. The optional
namespace_string must resolve to a
VARCHAR2 value that specifies a default mapping or namespace mapping for prefixes, which Oracle uses when evaluating the XPath expression(s).
For documents based on XML schemas, if Oracle can infer the type of the return value, then a scalar value of the appropriate type is returned. Otherwise, the result is of type
VARCHAR2. For documents that are not based on XML schemas, the return type is always
VARCHAR2.
The following example takes as input the same arguments as the example for EXTRACT (XML) . Instead of returning an XML fragment, as does the
EXTRACT function, it returns the scalar value of the XML fragment:
SELECT warehouse_name, EXTRACTVALUE(e.warehouse_spec, '/Warehouse/Docks') "Docks" FROM warehouses e WHERE warehouse_spec IS NOT NULL; WAREHOUSE_NAME Docks -------------------- ------------ Southlake, Texas 2 San Francisco 1 New Jersey Seattle, Washington 3 | http://docs.oracle.com/cd/B13789_01/server.101/b10759/functions047.htm | CC-MAIN-2016-07 | refinedweb | 171 | 50.36 |
>>>>> "vitaly" == vitaly <vitaly at synapticvision.com> writes: vitaly> Thank you a lot for pointing me to the Twisted doc-s, but we're vitaly> discussing the following snippet: [snip] vitaly> and basically, I've expected in case of exception vitaly> self.handleFailure1() to be called, but I don't see it happen. The reason you're not seeing handleFailure1 being called is that the exception is not occurring in the context of deferred processing. You've got a regular Python function call, a regular exception is raised, etc. Twisted and its deferred do not / cannot alter that behavior. What they *can* do is handle exceptions and turn them into failures and route the failure to an errback chain *in the context of calling functions that have been added to a deferred*. Because your abc1 has not been added to any deferred's call/errback chain, none of that happens when your exception is raised. If your code looked like this (pseudocode), you would see the exception return ( self.abc1(). addErrback(self.handleFailure1). addCallback(self.abc2,args). addCallback(self.abc3). addErrback(self.handleFailure2) ) def abc1(self): d = defer.Deferred() d.addCallback(raiser) d.callback(1) return d def raiser(self, _): raise Exception("Error11") Because the thing that raises is being called by Twisted's deferred class, and its exception is caught and routed to d's errback chain and winds up in the handleFailure1 method. Does that make sense? Terry | http://twistedmatrix.com/pipermail/twisted-python/2009-October/020747.html | CC-MAIN-2016-26 | refinedweb | 240 | 53.71 |
NAME
ng_frame_relay - frame relay netgraph node type
SYNOPSIS
#include <netgraph/ng_frame_relay.h>
DESCRIPTION
The frame_relay node type performs encapsulation, de-encapsulation, and multiplexing of packets using the frame relay protocol. It supports up to 1024 DLCI’s. The LMI protocol is handled by a separate node type (see ng_lmi(4)). The downstream hook should be connected to the synchronous line, i.e., the switch. Then hooks dlci0, dlci1, through dlci1023 are available to connect to each of the DLCI channels.
HOOKS
This node type supports the following hooks: downstream The connection to the synchronous line. dlciX Here X is a decimal number from 0 to 1023. This hook corresponds to the DLCI X frame relay virtual channel.
CONTROL MESSAGES
This node type supports only the generic control messages.
SHUTDOWN
This node shuts down upon receipt of a NGM_SHUTDOWN control message, or when all hooks have been disconnected.
SEE ALSO
netgraph(4), ng_lmi(4), ngctl(8)
HISTORY
The ng_frame_relay node type was implemented in FreeBSD 4.0.
AUTHORS
Julian Elischer 〈julian@FreeBSD.org〉
BUGS
Technically, frames on DLCI X should not be transmitted to the switch until the LMI protocol entity on both ends has configured DLCI X as active. The ng_frame_relay node type ignores this restriction, and will always pass data received on a DLCI hook to downstream. Instead, it should query the LMI node first. | http://manpages.ubuntu.com/manpages/karmic/man4/ng_frame_relay.4freebsd.html | CC-MAIN-2014-15 | refinedweb | 226 | 57.87 |
How to use emWin with Mbed OS
As a follow-up to my previous blog post, this tutorial will show you how to utilize the emWin graphics library for use with Mbed OS by utilizing NXP's emWin demo applications on an LPCXpresso54608 board.
NXP emWin Touch & Draw demo on an LPCXpresso54608. "emwin_examples"
- Select "emwin_touch_and_draw"
- Click Download Example (then save the
emwin_touch_and_draw.zipfile to your computer)
- Extract the
emwin_touch_and_draw
emwin_touch_and_draw example folder, open the the file
emwin_touch_and_draw/source/emwin_touch_and_draw.c. Copy the contents of this file into your Mbed OS project's
main.cpp file.
We will also need to copy the following files to our Mbed OS project, copy and paste these files as-is from the
emwin_touch_and_draw directory to your Mbed OS project root folder:
emwin_touch_and_draw/board/board.h
emwin_touch_and_draw/board/emwin_support.c
emwin_touch_and_draw/board/emwin_support.h
emwin_touch_and_draw/board/pin_mux.c
emwin_touch_and_draw/board/pin_mux.h
emwin_touch_and_draw/touchpanel/fsl_ft5406.c
emwin_touch_and_draw/touchpanel/fsl_ft5406.h
emwin_touch_and_draw/emwin/- Copy the entire folder to the root of your Mbed OS project.
In order to compile these files as part of an Mbed OS project successfully, we will also need to change the extensions of all of the
.c files above to
.cpp.
Your Mbed OS project's root directory should now look like the following:
emwin/ mbed-os/ board.h emwin_support.cpp emwin_support.h fsl_ft5406.cpp fsl_ft5406.h main.cpp mbed_settings.py mbed-os.lib pin_mux.cpp pin_mux.h
Get the correct emWin library
The emWin library (
libemWin_M4F.a) that we copied from the
emwin_touch_and_draw example folder was pre-compiled using a compiler that is incompatible with the GCC_ARM toolchain we are using in this tutorial. So in order to successfully compile the emWin demo application with Mbed CLI and GCC_ARM we will need to swap out the emWin library with a different one.
- Navigate to NXP's emWin Graphics Library Downloads page
- Under "Libraries" click on the Download button next to "emwin 5.30c Pre-Compiled Libraries for NXP ARM MCUs"
- Click "I Accept" then save the
NXP_emWin530c_libraries.exeto your computer
- Install the libraries to a location on your computer
Now that we have downloaded the emWin 5.30c pre-compiled libraries, we will need to replace the existing emWin library with the correct one in our Mbed OS project:
- Within the
NXP_emWin530c_librariesfolder, copy the file from the following location:
NXP_emWin530c_libraries/emWin_library/LPCXpresso/libemWin_M4F.a
- With the file copied, navigate to the following folder within your Mbed OS Project:
/emwin/emWin_library/ARMGCC/
- Paste/replace the copied file over the existing
libemWin_M4F.afile
Creating a safe printf
Because the NXP examples use a special "debug console", we will also need to create the following files within our Mbed OS project:
Create a new file
stdio_thread.cpp with the following files (i.e. delete the line:
#include "fsl_debug_console.h"):
fsl_ft5406.cpp
emwin_support.h
main.c "board.h" #include "emwin_support.h" #include "GUI.h" #include "GUIDRV_Lin.h" #include "BUTTON.h" #include "pin_mux.h" #include "fsl_sctimer.h"
Next, use find/replace to remove the following lines of code:
BOARD_InitDebugConsole();
CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
Because we will be disabling the APP LCD IRQ handler in the next section, in order for the GUI to properly update and display the user's touchscreen drawings on the LCD screen we need to remove the calls to the GUI's multi-buffering functions. Use find/replace to remove the following lines of code:
GUI_MULTIBUF_Begin();
GUI_MULTIBUF_End();
Modifying emwin_support.cpp for Mbed OS
First, add an
#include statement to the top of the
emwin_support.cpp file so the code can successfully use our new
safe_printf function:
#include "stdio_thread.h"
Your
#include statements should now look like the following:
#include "GUI.h" #include "WM.h" #include "GUIDRV_Lin.h" #include "emwin_support.h" #include "stdio_thread.h" #include "fsl_gpio.h" #include "fsl_lcdc.h" #include "fsl_i2c.h" #include "fsl_ft5406.h"
Next, use find/replace to remove the following line of code:
NVIC_EnableIRQ(APP_LCD_IRQn);
We will also need to redirect all
PRINTF statements to our new
safe_printf method. Use find/replace to change all calls to
PRINTF with
safe_printf. For example: change
PRINTF("LCD init failed\n"); to
safe_printf("LCD init failed\n");.
To view the output of the
safe_printf() calls we added to the
emwin_support.cpp file, you will need to open your board's serial port in a) to view the
safe_printf() output.
An emWin drawing on the LPCXpresso54608 board.
The demo application should now be running, and you're done! | https://os.mbed.com/blog/entry/How-to-use-emWin-with-Mbed-OS/ | CC-MAIN-2022-05 | refinedweb | 734 | 57.77 |
wikiHow to Become a Facebook Developer. Just follow the simple steps given below and become an app developer. Remember you must have a Facebook account to follow these steps.
Steps
- 1Navigate to the Facebook developers website using a web browser of your choice
- 2Look at the new page that opens, where you'll see the latest information on developing for Facebook like the Latest Updates, Showcase, etc. Somewhere on the top you'll see a "Get started" button. Just click on that button.
- 3Look at the following dialogue box (see image below) after you click on that button. Tick on the 'I accept the Facebook Platform.......' and click on Continue.
- 4Look at the following dialogue box (see image below) in the next step. Tick on the answers to the questions asked (correctly).
- Only tick the option which are true i your case. Ticking on the incorrect ones will only land you up in trouble in the future.
- Click on 'Continue'.
- 5Look at the following dialogue box (see image below) which says 'Congratulations ! You are now a Facebook developer. You'll receive a confirmation e-mail... '
- 6Click on 'Done'. You'll then be taken to the dashboard page.
- 7Look at confirmation e-mail. It should appear in the inbox of the e-mail ID which you used to sign up on Facebook. You should see a message from Facebook that should be somewhat like shown in the image below ...
- Click on 'Get Started'
- 8You'll now be redirected to the Facebook developers page. On the navigation bar you'll see some links.. Click on the link that says 'Apps'. Where you'll see a button 'Create New App'. Click on it.
- 9The following dialogue box should appear.
- In the form provided you must fill out the form with the name of the app that you're going to create, the App namespace, tick on the option that says "Yes, I'd like free web hosting ..." and finally click on 'Continue'.
- 10Answer the captcha in the next dialogue box and click on 'Continue.'
- 11Fill out the form according to the app that you want or according to your expertise in the next dialogue box. If you don't have a Heroku account, Facebook will create an account right way. So click on the 'Create' button.
- 12Congratulations! Your app has been created and you are now also an official app developer. Now, you can just start creating the app that you've been wanting to.
- Your app can be more functional and effective if you tick on the following option in your app page.
Community Q&A
- Does it cost money to be an app developer?wikiHow ContributorIt depends. If you're making apps yourself, and not using any services that you have to pay for, it's free.
- What is the advantages that developers will give me if I make a facebook page?
- How to unsub developer?
Tips
- You can ask other Facebook app developers on your friends list if you want some help.
- You must always tick the real answers according to you.
- In the navigation bar you'll see some links that might be helpful to you. Take for example the 'Support' link. You'll get help from Facebook from there and in the 'Tools' you'll get various tools to help you create your own app on Facebook.
- If you have any problems related to app development, always contact Facebook for detailed solutions.
Warnings
- Do not create app that are bad (humiliating races, religions, countries, caste, etc)
- Do not sign up if you have no programming expertise in the ones that Facebook asks your expertise on.
- Do not sign up if you are not interested in becoming a Facebook app developer.
Sources and Citations
Article Info
In other languages:
Español: convertirse en un desarrollador en Facebook, Português: se Tornar um Desenvolvedor de Aplicativos para o Facebook
Thanks to all authors for creating a page that has been read 52,801 times. | https://www.wikihow.com/Become-a-Facebook-Developer | CC-MAIN-2017-43 | refinedweb | 662 | 67.25 |
Creating Static Proxy Classes
This chapter discusses how to generate static proxy objects, which are precompiled and stored in the class library just like any other class. See the previous chapter, Using Dynamic Object Gateways, for information about dynamic proxies, which are created at runtime. The following topics are covered here:
Using the Studio .NET Gateway Wizard — The simplest way to generate proxy classes for a .NET assembly is to use the .NET Object Gateway Wizard plug-in supplied with Studio.
Generating Proxy Classes Programmatically — You can also generate proxy classes from within an ObjectScript program. The %Net.Remote.Gateway
Opens in a new window class contains the methods used to import class definitions from .NET assemblies and generate Object Gateway proxy classes.
See Using Wrapper Classes with .NET APIs for a description of the preferred method for importing third-party DLLs. See the Mapping Specification chapter for a detailed description of how .NET classes are mapped to InterSystems IRIS® proxy classes.
The Object Gateway cannot generate proxy classes for .NET generic classes. It similarly cannot import .NET classes with generic subclasses or subinterfaces.
Using the Studio .NET Object Gateway Wizard
The following steps summarize the procedure:
Start a .NET Object Gateway server. The server must be running before the Wizard can be used.
In Studio, select Tools > Add-ins > Add-ins... to display the list of available add-ins.
Select .Net Gateway Wizard from the Add-ins dialog and click OK. The .Net Gateway Wizard Studio template is displayed:The .NET Gateway Wizard Studio Template
Fill out the form. The following items can be defined:
Enter the path and name of a DLL assembly file: — Required. DLL name.
.NET Gateway server name / IP address: — Required. IP address or name of the machine where the .NET Object Gateway server executable is located. The default is "127.0.0.1".
.NET Gateway server port: — Required. Server port.
Additional paths\assemblies to be used in finding dependent classes: — Optional. Specify a list of assembly .dll files or directories, separated by semicolons.
Exclude dependent classes matching the following prefixes: — Optional. Specify a list of namespaces and class name prefixes, separated by semicolons.
The Wizard displays a list of available classes:Selecting Classes to Import
Check the classes that you want to use, then click Finish.
Generating Proxy Classes Programmatically
This section discusses the following methods of the %Net.Remote.Gateway
Opens in a new window class:
%Import() — imports .NET classes or assemblies from the .NET side and generates all the necessary proxy classes for the InterSystems IRIS side.
%GetAllClasses() — returns a list of all public classes available in the specified assembly DLL.
%ExpressImport() — combines calls to %Connect(), %Import(), and %Disconnect().
See the %Net.Remote.Gateway
Opens in a new window InterSystems IRIS class documentation for a complete listing of all Object Gateway methods.
The %Import() method of the Gateway class sets off the following chain of sequential events: generates new proxy classes for them.
%Import() Method
The %Import() method imports the given class and all its dependencies by creating and compiling all the necessary proxy classes. The %Import() method returns (in the ByRef argument imported) a list of generated InterSystems IRIS proxy classes. For details of how .NET class definitions are mapped to InterSystems IRIS proxy classes, see the “Mapping Specification” chapter in this guide.
%Import() is a onetime, startup operation. It only needs to be called the first time you wish to generate the InterSystems IRIS proxy classes. It is necessary again only if you recompile your .NET code and wish to regenerate the proxies.
Before you invoke %Import(), prepare the additionalClassPaths and exclusions arguments. That is, for each argument, create a new %ListOfDataTypes
Opens in a new window object and call its Insert() method to fill the list. The optional additionalClassPaths argument can be used to supply additional path arguments, such as the names of additional assembly DLLs that contain the classes you are importing via the Object Gateway. List elements should correspond to individual additional assembly DLL entries, which require the following format:
" rootdir\...\mydll.dll "
You can try to load an assembly from a directory outside of where InterSystems.Data.Gateway.exe is running, but you might experience a load error for your assembly when you try to use a class in the assembly. InterSystems recommends that you put all local assemblies in the same directory as InterSystems.Data.Gateway.exe. You can also specify assemblies in the GAC by using partial names for them, System.Data, for example.
While mapping a .NET class into an InterSystems IRIS proxy class and importing it into InterSystems IRIS, the Object Gateway loops over all class dependencies discovered in the given .NET class, including all classes referenced as properties and in argument lists. In other words, the Object Gateway collects a list of all class dependencies needed for a successful import of the given class, then walks that dependency list and generates all necessary proxy classes.
You can control this process by specifying a list of assembly and class name prefixes to exclude from this process. While this situation would be rare, it does give you some flexibility to control what classes get imported. The Object Gateway automatically excludes a small subset of assemblies such as Microsoft.* assemblies.
%GetAllClasses() Method
This method returns, in the ByRef argument allClasses, a list of all public classes available in the assembly DLL specified by the first argument, jarFileOrDirectoryName.
%ExpressImport() Method
%ExpressImport() is a one-step convenience class method that combines calls to %Connect(), %Import(), and %Disconnect(). It returns a list of generated proxies. It also logs that list, if the silent argument is set to 0. The name argument is a semicolon-delimited list of classes or assembly DLLs. | https://docs.intersystems.com/healthconnectlatest/csp/docbook/DocBook.UI.Page.cls?KEY=BGNT_MAKEPROXIES | CC-MAIN-2021-25 | refinedweb | 954 | 50.63 |
How to Create a Program in C Sharp
Three Parts:Set up (Windows way)Create your first program.Set up (Free software way)Questions and Answers.
Steps
Part 1
Set up (Windows way)
- 1Go here to download your free copy of Visual C# 2010 Express Edition. Also available are the 2012 express products, but go with 2010 if you are looking for general c# development.
- Also, 2012 does not work without Windows 7/8.
- 2Run the downloaded executable and follow these steps:
- I agree → Next.
- Select MSDN, not SQL → Next.
- Install.
Part 2
Create your first program.
- 1Run Visual C# 2010 ExpressIt should look like this:
using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.WriteLine("Hello, World!"); Console.ReadLine(); } } }
- 7Click the Run [►] button on the toolbar.
Congratulations! You created your first C# program!
- This should have produced a console windows, reading Hello World!
- if it did not, then you did something incorrectly.
Part 3
Set up (Free software way)
- 1You need CVS and GNU build tools. This should be included into the majority of Linux distributions.
- 2Go to the DotGNU project () that provides FOSS implementation of C#. Read the chapter about the installation. These instructions are simple to follow even for beginners.
- 3You can choose to get the source code and build you C# environment from scratch or you may try pre-compiled distributions first. The project is relatively easy to build from the source so we suggest to try this way first.
- 4Try).
- 5Under Linux, you can use!
Give us 3 minutes of knowledge!
Tips
- If installing Visual C# 2010/2012 express, it will either automatically download or give you the option to do this.
-.
- There are more good C# implementations than the two described here. Mono project may be interesting for you as well.
Recommended Books
- ISBN 0-7645-8955-5: Visual C# 2005 Express Edition Starter Kit - Newbie
- ISBN 0-7645-7847-2: Beginning Visual C# 2005 - Novice
- ISBN 0-7645-7534-1: Professional C# 2005 - Intermediate+
Article Info
Categories: C Programming Languages
Thanks to all authors for creating a page that has been read 130,579 times.
About this wikiHow | http://www.wikihow.com/Create-a-Program-in-C-Sharp | CC-MAIN-2016-07 | refinedweb | 365 | 67.96 |
Hello and thank you for using Just Answer,Sale of real estate by a foreign person (non resident alien of the US) would be 30% withholding rate. Any US sourced real property is subject to withholding. This would include an individual or a company.Capital gains rates are set for Nonresident aliens. IRC section 871(a)(2) imposes a flat tax of 30 percent on U.S. source capital gains in the hands of nonresident alien individuals physically present in the United States for 183 days or more during the taxable year.
The withholding is on the sales price so if the non US person or entity has a lower gain they could file a US tax return, show the true gain and request refund of any amount that was withheld but more than the true tax.
My goal is to give you excellent service. If you are satisfied, please rate me. If you have follow-up questions on this same topic, use the reply box below. To start a new conversation with me on a new topic request me again.
Hi Robin, thanks a lot for your prompt response. I need some clarification on your response however, so in the following example:
Example 1.
I bought a house for $100,000.
I sell it for $150,000
a) Following your explanation, there is 30% withholding tax applicable for NRAs on the full $150,000.
b) In addition, Capital Gains of 30% of $50,000 is also applicable ONLY IF I have been physically present in the US for 183 days or more during the tax year.
1. So if I am not physically present in the US for 183 days or more, then only (a) will apply?
2. If I buy through an offshore company, then am I right in assuming that only (a) will apply since it is an offshore company?
3. Who is responsible for withholding both (a) and (b) when I sell my house? The escrow agent?
Example 2:
I bought the house for $100,000
I sold it for $50,000
(a) The 30% withholding on $50,000 would still be applicable?
(b) There would be no capital gains tax even if I had been present for 183 days or more since there was a realised loss on the asset?
(c) In accordance to your second response, would I be eligible for any refund due to the loss, and is so, how would the refund be calculated?
Thanks and regards
Kathy
Hi Robin thanks so much for that. I understand the scenario where the true gain is $50,000.
In my second example where I bought at $100,000 and sold at $50,000, am I correct that even if I file a NR tax return (assuming I was not present for more 183 days or more), then I will still be liable for withholding on the entire sale price of $50,000. But if I were present for 183 days or more (ie no longer classified as Non-Resident for tax purposes), then I can file for a refund due to a capital loss?
Robin, thank you so much, it is very clear to me now. Wish it were easier but I am learning as I go along. Very grateful for your help and will rate and finish this conversation immediately.
Hi Robin, sorry to re-start this conversation but I was just told in conversation with a friend's friend that under the FIRPTA, the withholding tax rate on the disposal of real assets by non residents is 10%. I am a little confused as you mentioned it was 30%, which is the standard rate for interest or income for non-residents.
Do you have anyway to verify the information?
Hi Robin, thanks for clarifying. I am a resident in both Singapore and Hong Kong for tax purposes, but am pretty sure neither territory has no Double Tax Treaty with the United States. However it is good to know that it is 10% for real assets not 30%, and also I can at least report a loss if need be.
Thanks again | http://www.justanswer.com/tax/7yupe-hi-robin-questions-relation-sale-real.html | CC-MAIN-2014-23 | refinedweb | 689 | 69.52 |
I got a bit disappointed with my little bus pirate yesterday. I'll investigate how to update it to fix the odd SPI behaviour another time, but for now, its on to trying to read the MCP3002 SPI ADC chip directly using the Raspberry Pi. However, this one I'm going to do a bit differently. My desk is filling up with breadboards and floating wires, and working out each time which wire to connect to which header pin is becoming annoying. So I have decided to wire up a simple plugin board with the MCP3002 connected to the correct SPI pins on a 26-way header. That way I can just plug it in when I want to use it, and unplug it if I want to use the rspberry Pi for something else.
I have a fairly diverse collection of prototype boards, some with strips, some with grouped pads and some with just a grid (a.k.a. "pegboard", "pad per hole", etc.) of tinned holes. For this little project I thought I'd have a go at using one of the "pad per hole" boards. They are very cheap, particularly when ordered from China, so I'm not too worried if I mess it up. One of my collection has a grid of 14 x 20 holes. This is almost exactly the right width for the 2x13 Raspberry Pi GPIO header and it looks like it will sit nicely on top of the Raspberry Pi. My plan is to add a socket for the MCP3002 (just in case I suddenly want to use it for something else) and wire the socket and the GPIO header together.
While thinking about how to lay out the board, I found that if I put the IC socket on the "header" side of the board, and arrange it in the right way, the MOSI, MISO and CLK pins line up with each other. That certainly makes wiring simpler, so that's the way I have decided to do it.
Of course, I can't resist adding a little bit of extra. The Raspberry Pi provides two SPI /CS lines (labelled CE0 and CE1). Although I only plan to use CE0 at the moment, I thought I might as well add a little pin-and-jumper switch to allow me to choose which one to use without re-soldering. Also, I guess it makes sense to add a header to connect whatever the ADC will be reading. This one will provide GND, Vcc and a signal input pin. Other than that, the circuit is very simple, mainly a matter of connecting the right Raspberry Pi headers to the right MCP3002 pins.
When it comes to putting it together, that's a different matter. I learned my soldering and circuit-building in the late 1970s and early 1980s when Veroboard was king and only the rich kids who read "elektor" magazine would dream of using a printed circuit board. I never encountered any of these pad-per-hole boards at that time, though, and I quickly realized that I was unsure how to use it! Luckily the internet is full of helpful people, and this video gave me enough confidence to give it a go.
After soldering and double-checking all the connections (by eye, and also with a multimeter to check for accidental shorts and bridges) I was ready to try it out. I plugged the MCP3002 chip into its socket, added the jumper to select CE0 and connected my resistor divider (still on the breadboard) to the analogue input connector. However, I hit a problem straight away. Although I had checked the heights of components on the board to make sure that they did not foul the Raspberry Pi main board, I had not allowed for the extra height of the connectors I was using to wire the analogue input. They were only a few mm too high, but it was enough to prevent the expansion board from sitting properly on the Raspberry Pi. As a quick and dirty fix I just plugged in another header which boosted the height by about 1cm. If this board seems useful, I'll probably replace the analogue input header with a right-angle one for the future.
The next step was to try out the software. To start with I just re-used some of the software bits I had built for driving a 7219 LED matrix from a Raspberry Pi and sent the intended 0x60 0x00 to the board, while monitoring the traffic on the logic analyser. This looked like plausible SPI traffic, so I changed one of the resistors and tried again. Reassuringly different!
Now that I was fairly comfortable that the hardware was working, I just needed to tweak the software to not only send the right SPI data, but also to retrieve and interpret the response:
Note that the SPI protocol "returns" the same number of bits as sent, and in this case the 10-bit ADC data is encoded in the last two bits of the first byte and the eight bits of the second byte. I chose to retrieve the data in MSB-first order, so the result is the sum of (the bottom two bits of the first byte shifted up by eight bits) + the second byte.
#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <errno.h> #include <wiringPiSPI.h> #define CHANNEL 0 uint8_t buf[2]; unsigned int sample(int channel) { buf[0] = 0x60 + channel; buf[1] = 0x00; wiringPiSPIDataRW(CHANNEL, buf, 2); return buf[1] + (buf[0] & 0x03) << 8; } void main(int argc, char** argv) { if (wiringPiSPISetup(CHANNEL, 4000000) < 0) { fprintf (stderr, "SPI Setup failed: %s\n", strerror (errno)); exit(errno); } printf("sample=%04x\n", sample(0)); }
That should do for now. Next time I'll take a look at what I can do to use this chip to read changing signals rather than a fixed voltage.
As usual, all code, including a makefile to build it, can be found on our github.
Pingback: Build an ‘Arduino’ on a Raspberry Pi | Raspberry Alpha Omega | http://raspberryalphaomega.org.uk/2013/06/23/reading-analogue-data-on-a-raspberry-pi-using-mcp3002/ | CC-MAIN-2014-35 | refinedweb | 1,025 | 76.15 |
Hey guys need some help on this program. I am simply trying to write a program that does the following....
There is an appliance store that is offering 1% (0.01) financing for 12 months on any purchase.
I need to use constants for the finance rate and number of months (which i think i got)
Have the user enter their purchase price
Formatting ALL numeric output with two decimals, tell the user how much their monthly payment
will be (using the formula below) and the total amount to be paid.
monthly payment = ( (purchase price* financing rate) + purchase price) / months
here is my code so far....
import java.util.Scanner;
public class rate
{
public static final int RATE = 0.01;
public static final int MONTH = 12;
public static void main(String[] args)
{
System.out.println(RATE);
System.out.println(MONTH);
Scanner s = new Scanner(System.in); // create a Scanner object
String input; // read in user input as a string
int qty; // number of items purchased
System.out.print("Price of purchased item: "); // user prompt
input = s.nextLine(); // read input as a string
purchase price = Integer.parseInt(input);
System.out.print("Your monthly payment: "); // user prompt
input = s.nextLine(); // read input as a string
financing rate = Integer.parseInt(input); // convert to int
System.out.println("Total purchase order = $" ( (purchase price* financing rate) + purchase price) / months);
} // end main
} // end class Lab1
It doesn't want to compile I get errors for having 0.01 and also i recieve numerous errors with
System.out.println("Total purchase order = $" ( (purchase price* financing rate) + purchase price) / months);
Any help is appreciated!
Have a nice day | http://www.javaprogrammingforums.com/%20whats-wrong-my-code/13606-pretty-basic-java-program-need-some-help-printingthethread.html | CC-MAIN-2014-15 | refinedweb | 270 | 58.79 |
set obj {...} set result [obj arg1 arg2 arg3]... would behave as if it had been written as follows in Tcl 8.5:
set obj {...} set result [{*}$obj arg1 arg2 arg3]It obviously wouldn't be Tcl, since the variable and command namespace get mixed up when you start doing this.But suppose you didn't care (Tcl 3000!) - would it be useful? convenient? worth looking into?MJ: I am not seeing the use for the implicit $, is it so much trouble to write $obj arg1 arg2 arg3? Autoexpansion of the leading word would be very useful however (especially in OO type constructs and functional programming).It seems you are suggesting unification of variables and procs, which sounds a lot like the concept of slots in Self, in that case $ will become unnecessary. Getting the value of a var is simply [var].DKF: This idea ("auto expand leading word") has been known about and discussed (on and off, when we've nothing else to do) for years.JJS: Isn't this a lot like interp alias?
interp alias {} obj {} ... ;# instead of set obj {...} set result [obj arg1 arg2 arg3] ;# works like {*}$objNEM: The difference is that variables can be local to a procedure whereas aliases can't. With apply you can now have procedures that are stored in local variables, but not commands in general, and the syntax could be better. I wrote some thoughts about ways to accomplish the same thing in a hypothetical Tcl 3000 here [1
RS: See Let unknown know how to tweak Tcl that it does auto-expansion of leading word... :^) | http://wiki.tcl.tk/19897 | CC-MAIN-2017-04 | refinedweb | 265 | 74.19 |
This question already has an answer here:
Parameters to numpy's fromfunction
4 answers
Numpy's
fromfunction method creates two arrays, one where the value at every cell is that cell's x index, and one where every cell is that cell's y index. It then applies the function you have passed in.
In your first call to the function, it does something like this:
x=[[0 0 0] [1 1 1] [2 2 2]] y=[[0 1 2] [0 1 2] [0 1 2]] result = fn(x,y)
where fn is your lambda function. Addition of numpy arrays is equivalent to element-wise addition, so this behaves how you would expect. However, in your second example, you are using max as your function, and the python builtin max function is not defined on numpy arrays. This is because the way the python max is defined is something like this:
def max(x,y): if x>y: return x return y
However,
x>y is a numpy array if both x and y are numpy arrays, and
if <numpy array> doesn't make much sense, which is why we get the error message :
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
In short, the function you are passing into
numpy.fromfunction is not being performed on each individual pair of numbers, but rather the matrices as a whole, generated as explained above. Numpy's method for computing element-wise maxima is
numpy.maximum, so replace
max with
numpy.maximum and your code will work as expected.
One last note:
lambda x,y: max(x,y) is equivalent to just
max, since both represent a function that takes two arguments and returns their max. so when you rewrite that line of your code, you can write:
B=numpy.fromfunction(numpy.maximum,(3,3),dtype=int) | http://m.dlxedu.com/m/askdetail/3/783ac08558b343008b24d26a6b01f3ba.html | CC-MAIN-2018-22 | refinedweb | 317 | 67.69 |
Fullscreen Pygame issue on Windows
Problem Statement
I am encountering a frustrating issue on some of our Windows 7 machines. For some machines, the experiment I have created runs normally.
On others, however, the fullscreen display is never shown, instead, the pygame logo is displayed in the taskbar. If you click on the pygame logo, the screen flashes black and then you are returned to the Windows desktop. No errors are shown and the program appears to be running in the background. If I turn on windowed mode (or set develop_mode) then the experiment runs as expected. I would rather not do this though.
Request
Is there any information that I have missed that could solve this problem, or help me to further diagnose it?
Example Code (That displays problem behaviour)
import expyriment as xpy xpy.control.initialize() xpy.control.start() xpy.control.end()
Output from get_system_info
pygame 1.9.4 Hello from the pygame community. Expyriment 0.9.0 (Python 3.6.5) -m System Info hardware_audio_card: hardware_cpu_architecture: AMD64 hardware_cpu_details: Intel(R) Core(TM) i5-4670 CPU @ 3.40GHz hardware_cpu_type: Intel64 Family 6 Model 60 Stepping 3, GenuineInt el hardware_disk_space_free: 233927 MB hardware_disk_space_total: 476438 MB hardware_internet_connection: Yes hardware_memory_free: 3273 MB hardware_memory_total: 8100 MB hardware_ports_parallel: [] hardware_ports_parallel_driver: None hardware_ports_serial: [<serial.tools.list_ports_common.ListPortInfo ob ject at 0x08559C70>, <serial.tools.list_ports_common.ListPortInfo object at 0x08 559BF0>] hardware_video_card: RDPDD Chained DD os_architecture: 32bit os_details: SP1 os_name: Windows os_platform: Windows os_release: 7 os_version: 6.1.7601 python_expyriment_build_date: Thu Mar 9 13:48:59 2017 +0100 python_expyriment_revision: c4963ac python_expyriment_version: 0.9.0 python_mediadecoder_version: 0.1.5 python_numpy_version: 1.15.1 python_pil_version: 1.1.7 python_pygame_version: 1.9.4 python_pyopengl_version: 3.1.0 python_pyparallel_version: python_pyserial_version: 3.4 python_sounddevice_version: 0.3.12 python_version: 3.6.5 settings_folder: None
Hi there,
that is strange. One thing I noticed in your system info is that your video card is noted as "RDPDD Chained DD". I think RDPDD is usually reported when using remote desktop. Are you using remote desktop on those machines? Using remote desktop on Windows in combination with Expyriment will as far as I know not work correctly.
Hmm, hadn't noticed that.
There are no current remote desktop connections to one system I just tested that is failing to display fullscreen, but TeamViewer was waiting for connections (but no active connections).
On the two machines that I can reliably get to work the same video card is reported - so it is possibly not that alone, running a system info-dump through a diff utility only shows disk space and memory free differences, and none of those numbers is significantly low.
Unfortunately, this Uni's locked down systems policy prevents me from digging too far into the sysadmin side of things, but I'll see if this thread of inquiry gets me anywhere today.
Well, if you are not using the machine via remote desktop, then the problem probably is elsewhere.
Maybe you can talk to the technicians at your university about this. It seems to be a machine specific issue (e.g. Windows settings, different drivers, etc.) that is unrelated to Expyriment (or at least out of our control). | http://forum.cogsci.nl/index.php?p=/discussion/comment/14480/ | CC-MAIN-2020-05 | refinedweb | 523 | 50.63 |
Felgo and Qt provide you with tools to connect to basically anything, like services, servers and other devices.
We have a dedicated doc for this use-case, you can find it here: Access a REST Service
It also includes how to read and parse JSON data.
The easiest way to work with XML data is by using the XmlListModel type. After we set the XML source and add some queries to identify the items and item attributes, we can directly use this model to display the items with components like AppListView or Repeater.
The following example sets up a XmlListModel to load data from a local XML file and displays the items in a ListPage:
data.xml
<?xml version="1.0" encoding="UTF-8" ?> <data> <item>Item 1</item> <item>Item 2</item> <item>Item 3</item> <item>Item 4</item> <item>Item 5</item> <item>Item 6</item> <item>Item 7</item> <item>Item 8</item> <item>Item 9</item> </data>
Main.qml
import Felgo 3.0 import QtQuick.XmlListModel 2.0 App { // model for loading and parsing xml data XmlListModel { id: xmlModel // set xml source to load data from local file or web service source: Qt.resolvedUrl("data.xml") // set query that returns items query: "/data/item" // specify roles to access item data XmlRole { name: "itemText"; query: "string()" } } NavigationStack { // we display the xml model in a list ListPage { id: page title: "Parse XML" model: xmlModel delegate: SimpleRow { text: itemText } } } }
You can use the full range of Qt Connectivity and Networking features with Felgo.
This includes: HttpRequest Element asynchronously. The following on the property, so the AppImage will automatically update
and show the image as soon as the data arrives - nothing more to do.
Find more examples for frequently asked development questions and important concepts in the following guides:
Voted #1 for: | https://felgo.com/doc/apps-howto-connectivity-and-networking/ | CC-MAIN-2019-47 | refinedweb | 303 | 58.82 |
I am calling a stored procedure that inserts data in to a sql server database from c#. I have a number of constraints on the table such as unique column etc. At present I have the following code:
try
{
// inset data
}
catch (SqlException ex)
{
if (ex.Message.ToLower().Contains("duplicate key"))
{
if (ex.Message.ToLower().Contains("url"))
{
return 1;
}
if (ex.Message.ToLower().Contains("email"))
{
return 2;
}
}
return 3;
}
Is it better practise to check if column is unique etc before inserting the data in C#, or in store procedure or let an exception occur and handle like above? I am not a fan of the above but looking for best practise in this area.
I view database constraints as a last resort kind of thing. (I.e. by all means they should be present in your schema as a backup way of maintaining data integrity.) But I'd say the data should really be valid before you try to save it in the database. If for no other reason, then because providing feedback about invalid input is a UI concern, and a data validity error really shouldn't bubble up and down the entire tier stack every single time.
Furthermore, there are many sorts of assertions you want to make about the shape of your data that can't be expressed using constraints easily. (E.g. state transitions of an order. "An order can only go to
SHIPPED from
PAID" or more complex scenarios.) That is, you'd need to use involving procedural-language based checks, ones that duplicate even more of your business logic, and then have those report some sort of error code as well, and include yet more complexity in your app just for the sake of doing all your data validation in the schema definition.
Validation is inherently hard to place in an app since it concerns both the UI and is coupled to the model schema, but I veer on the side of doing it near the UI.
I see two questions here, and here's my take...
Are database constraints good? For large systems they're indepensible. Most large systems have more than one front end, and not always in compatible languages where middle-tier or UI data-checking logic can be shared. They may also have batch processes in Transact-SQL or PL/SQL only. It's fine to duplicate the checking on the front end, but in a multi-user app the only way to truly check uniqueness is to insert the record and see what the database says. Same with foreign key constraints - you don't truly know until you try to insert/update/delete.
Should exceptions be allowed to throw, or should return values be substituted? Here's the code from the question:
try { // inset data } catch (SqlException ex) { if (ex.Message.ToLower().Contains("duplicate key")) { if (ex.Message.ToLower().Contains("url")) { return 1; // Sure, that's one good way to do it } if (ex.Message.ToLower().Contains("email")) { return 2; // Sure, that's one good way to do it } } return 3; // EVIL! Or at least quasi-evil :) }
If you can guarantee that the calling program will actually act based on the return value, I think the
return 1 and
return 2 are best left to your judgement. I prefer to rethrow a custom exception for cases like this (for example
DuplicateEmailException) but that's just me - the return values will do the trick too. After all, consumer classes can ignore exceptions just as easily as they can ignore return values.
I'm against the
return 3. This means there was an unexpected exception (database down, bad connection, whatever). Here you have an unspecified error, and the only diagnostic information you have is this: "3". Imagine posting a question on SO that says I tried to insert a row but the system said '3'. Please advise. It would be closed within seconds :)
If you don't know how to handle an exception in the data class, there's no way a consumer of the data class can handle it. At this point you're pretty much hosed so I say log the error, then exit as gracefully as possible with an "Unexpected error" message.
I know I ranted a bit about the unexpected exception, but I've handled too many support incidents where the programmer just sequelched database exceptions, and when something unexpected came up the app either failed silently or failed downstream, leaving zero diagnostic information. Very naughty.
I would prefer a stored procedure that checks for potential violations before just throwing the data at SQL Server and letting the constraint bubble up an error. The reasons for this are performance-related:
Some people will advocate that constraints at the database layer are unnecessary since your program can do everything. The reason I wouldn't rely solely on your C# program to detect duplicates is that people will find ways to affect the data without going through your C# program. You may introduce other programs later. You may have people writing their own scripts or interacting with the database directly. Do you really want to leave the table unprotected because they don't honor your business rules? And I don't think the C# program should just throw data at the table and hope for the best, either.
If your business rules change, do you really want to have to re-compile your app (or all of multiple apps)? I guess that depends on how well-protected your database is and how likely/often your business rules are to change.
I did something like this:
public class SqlExceptionHelper { public SqlExceptionHelper(SqlException sqlException) { // Do Nothing. } public static string GetSqlDescription(SqlException sqlException) { switch (sqlException.Number) { case 21: return "Fatal Error Occurred: Error Code 21."; case 53: return "Error in Establishing a Database Connection: 53."; default return ("Unexpected Error: " + sqlException.Message.ToString()); } } }
Which allows it to be reusable, and it will allow you to get the Error Codes from SQL.
Then just implement:
public class SiteHandler : ISiteHandler { public string InsertDataToDatabase(Handler siteInfo) { try { // Open Database Connection, Run Commands, Some additional Checks. } catch(SqlException exception) { SqlExceptionHelper errorCompare = new SqlExceptionHelper(exception); return errorCompare.ToString(); } } }
Then it is providing some specific errors for common occurrences. But as mentioned above; you really should ensure that you've tested your data before you just input it into your database. That way no mismatched constraints surface or exists.
Hope it points you in a good direction.
Depends on what you're trying to do. Some things to think about:
Also -- constraints can be good -- I don't 100% agree with millimoose's answer on that point -- I mean, I do in the should be this way / better performance ideal -- but practically speaking, if you don't have control over your developers / qc, and especially when it comes to enforcing rules that could blow your database up (or otherwise, break dependent objects like reports, etc. if a duplicate key were to turn-up somewhere, you need some barrier against (for example) the duplicate key entry. | http://www.dlxedu.com/askdetail/3/17dcf14ca708454eadc0d1ac8fd255d5.html | CC-MAIN-2018-51 | refinedweb | 1,177 | 61.87 |
CodePlexProject Hosting for Open Source Software
Hello all
I have blogengine.net running in a separate application in a subdirectory of the root application, and I was glad to learn about inheritInChildApplications to solve the web.config problem, but now I am struggling with the following:
<urlMappings enabled="true">
<add url="Default.aspx" mappedUrl="Blog/Default.aspx" />
…
When I navigate to the root application, I want to show the blog by default. The above urlmapping, however, results in a server error "The type or namespace name 'BlogEngine' could not be found".
Does anyone know how to accomplish the mapping in a maintainable and SEO friendly way?
Are you sure you want to delete this post? You will not be able to recover it later.
Are you sure you want to delete this thread? You will not be able to recover it later. | http://blogengine.codeplex.com/discussions/208254 | CC-MAIN-2017-26 | refinedweb | 142 | 66.33 |
Suppose we have an array called nums and another value x. In one operation, we can either delete the leftmost or the rightmost element from the array and subtract the value from x. We have to find the minimum number of operations required to reduce x to exactly 0. If it is not possible then return -1.
So, if the input is like nums = [4,2,9,1,4,2,3] x = 9, then the output will be 3 because at first we have to delete left most element 4, so array will be [2,9,1,4,2,3] and x will be 5, then remove right most element 3, so array will be [2,9,1,4,2], and x = 2, then again either left from left or from right to make x = 0, and array will be either [2,9,1,4] or [9,1,4,2].
To solve this, we will follow these steps −
Let us see the following implementation to get better understanding −
def solve(nums, x): n = len(nums) leftMap = dict() leftMap[0] = -1 left = 0 for i in range(n): left += nums[i] if left not in leftMap: leftMap[left] = i right = 0 ans = n + 1 for i in range(n, -1, -1): if i < n: right += nums[i] left = x - right if left in leftMap: ans = min(ans, leftMap[left] + 1 + n - i) if ans == n + 1: return -1 return ans nums = [4,2,9,1,4,2,3] x = 9 print(solve(nums, x))
[4,2,9,1,4,2,3], 9
3 | https://www.tutorialspoint.com/program-to-find-minimum-operations-to-reduce-x-to-zero-in-python | CC-MAIN-2022-21 | refinedweb | 262 | 60.11 |
Today for my 30 day challenge, I decided to learn a framework called Ember.
What is Ember?
Ember is a client side JavaScript MV* framework for building ambitious web applications. Ember has dependencies on the jQuery and Handlebars libraries. If you have worked with Backbone, then you will find Ember as an opinionated Backbone or Backbone++.
So far in this series I’ve looked at several JavaScript technologies you might be be interested in:
Ember can get lot of things done for you if you follow its naming conventions. Ember.js strongly follows naming conventions. If we have a url route /stories in the app, then we will have:
- a stories template
- a StoriesRoute
- a StoriesController
To understand Ember naming conventions, please refer to the documentation on naming conventions.
Ember Core Concepts
In this section we will cover the four main core concepts in EmberJS which we will use in today’s demo application.
Model : Models represents the application domain object which we present to the user. In the application use case discussed above, a story represents a model. Story along with its attributes like title, url, etc. makes the model. Models can be retrieved and updated either by using jQuery to load JSON data from the server or apps can use Ember Data. Ember Data is the client side ORM implementation which make it easy to perform CRUD operations on the underlying persistent storage. Ember Data provides a repository interface, which can be configured with a range of provided Adapters. The two core adapters provided with Ember Data are RESTAdapter and FixtureAdapter. In this blog, we will use LocalStorage adapter which persists data into HTML 5 LocalStorage. Please refer to the documentation for more details.
Router and Route : A Router is used to specify all the application routes. Router maps a url to a route. For example, when user goes to ‘/#/story/new’, then newstory template is rendered. The newstory template represents an HTML form. Users can customise the routes by creating an Ember.Route subclass. In the above mentioned example, suppose when the user navigates to ‘/#/story/new’, user want to render a default model in newstory template. The NewStoryRoute will responsible for giving a default model to the newstory template. Please refer to the documentation for more details.
Controller : Controller can do two things — first it can decorate model returned by the route and second it can listen to actions performed by user. For example, when a user submit the story form with the relevant data, then the NewStoryController is responsible for persisting the story data into the underlying storage using Ember Data API. Please refer to the documentation for more details.
Template : Templates represent the user interface of the application. Every application has one default template called application. This is be rendered when the application starts. The header, footer, navigation, and other common content should be placed in this template. Ember.js uses the Handlebars templating library to power the application user interface.
Ember Chrome Extension
EmberJS also provides a chrome extension which makes it very easy to debug the ember application. The extension is available in the chrome web store. To learn more about chrome extension, please refer to these short videos by the Ember team.
Application Usecase
In this blog post, we will learn how to build a single page social bookmarking site using Ember. This tutorial is covered in two posts. The first post covers the client side and save data to HTML 5 Local Storage. The second post uses a RESTful backend deployed on OpenShift. Look for the second post in next few days.
This post develops a social bookmarking application allowing users to post and share links. You can view the live application here. The application does the following :
- When a user goes to the ‘/’ url of the application, then the user will see a list of stories sorted by their submission date.
- When a user clicks on any story i.e. #/stories/d6p88, the user can view the content of the story like who submitted the story, when the story was submitted, and an excerpt of the story.
- Finally, a user can submit a new story by navigating to #/story/new. This will store the story in the user’s browser local storage.
Github Repository
The code for today’s demo application is available on github: day19-emberjs-demo.
Step 1 : Download the starter kit
The ember framework provides a starter kit which makes it very easy to get started with the framework. The starter kit contains required javascript files(ember-*.js, jquery-*.js, and handlerbars-*.js) and a sample application. Download the starter kit, then unzip it, and finally rename the folder to getbookmarks as shown below. The getbookmarks is the name of the application.
$ wget $ unzip v1.1.2.zip $ mv starter-kit-1.1.2/ getbookmarks
Open the index.html in your favourite modern browser(Chrome or Firefox), and you will see the sample application.
Step 2 : Enable GruntJS Watch(Optional)
This step is optional but if you follow it, then it will make your life awesome. If you decide to not follow this step, then open the index.html in your browser and ever time we will make a change please reload the browser. In day 7 blog, I talked about using GruntJS live reload functionality to automatically reload the changes. I did not found any auto reload functionality in EmberJS so I decided to use GruntJS livereload to make me more productive. You will need Node, NPM , Grunt-CLI installed on your machine. Please refer to my day 5 and day 7 blogs where I covered them in detail.
Create a new file called package.json in getbookmarks folder and paste the following content into it.
{ "name": "getbookmarks", "version": "0.0.1", "description": "GetBookMarks application", "devDependencies": { "grunt": "~0.4.1", "grunt-contrib-watch": "~0.5.3" } }
Create another file called Gruntfile.js in getbookmarks folder and paste the following content into it.
module.exports = function(grunt) { grunt.initConfig({ watch :{ scripts :{ files : ['js/app.js','css/*.css','index.html'], options : { livereload : 9090, } } } }); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.registerTask('default', []); };
Install the dependencies using npm.
$ npm install grunt --save-dev $ npm install grunt-contrib-watch --save-dev
In the index.html, add the
<script src=""></script> to the head of html.
Then invoke the grunt watch command, and open the index.html in your favourite modern browser.
$ grunt watch Running "watch" task Waiting...OK
Make a change to index.html and without any browser reload you will see the change applied.
Step 3 : Understand starter template application
In the starter template, there are two application related files(apart from css) — index.html and app.js. To understand what template application does, we have to understand the app.js file.
App = Ember.Application.create(); App.Router.map(function() { // put your routes here }); App.IndexRoute = Ember.Route.extend({ model: function() { return ['red', 'yellow', 'blue']; } });
The code shown above does the following:
The first line
App = Ember.Application.create();creates an instance of the Ember application. This will create a new instance of Ember.Application and make it available as a variable within the browser’s JavaScript environment.
The
App.Router.mapis used to define the application route. Every Ember application has one default route called Index which is available at ‘/’ url. So, when the index ‘/’ route is invoked then index template is rendered. Based on the application url template is rendered. Lot of convention over configuration. The index template is defined in index.html.
- In Ember, every template is backed by a model. A Route responsible for specifying which template should be backed by which model. In the app.js shown above, IndexRoute returns a String array as the model for index template. The index template just iterates over this array and renders a list.
Step 4 : Remove starter template code
Please remove all the content from js/app.js file and paste the following content to it.
App = Ember.Application.create(); App.Router.map(function() { // put your routes here });
Similarly replace the index.html with the following content.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>GetBookMarks -- Share your favorite links online</title> <link rel="stylesheet" href="css/normalize.css"> <link rel="stylesheet" href="css/style.css"> <script src=""></script> </head> <body> <script type="text/x-handlebars"> {{outlet}} <>
Step 5 : Adding Twitter Bootstrap
We will use twitter bootstrap to style the application. Download the latest twitter bootstrap package from the official website, and copy the bootstrap.css to css folder and fonts folder to the getbookmarks folder.
Next we will add the bootstrap.css stylesheet to the index.html, and use fixed navigation bar on the top of the page.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>GetBookMarks -- Share your favorite links online</title> <link rel="stylesheet" href="css/normalize.css"> <link rel="stylesheet" type="text/css" href="css/bootstrap.css"> <link rel="stylesheet" href="css/style.css"> <script src=""></script> </head> <body> <script type="text/x-handlebars"> <nav class="navbar navbar-default navbar-fixed-top" role="navigation"> <div class="container"> <div class="navbar-header"> <a class="navbar-brand" href="#">GetBookMarks</a> </div> </div> </nav> <div id="main" class="container"> {{outlet}} </div> <>
In the html shown above, the
<script type="text/x-handlebars"> represents our application template. The application template has {{outlet}} tag that holds all other templates and will change depending on the url.
Also add following css to css/style.css. This will add a top padding of 40px for body. This is required to properly render the body with fixed top navigation bar.
body{ padding-top: 40px; }
Step 5 : Submit New Story
We will start by implementing the submit new story functionality. In Ember, it is recommended that you think in terms of URL(s). When a user views the ‘#/story/new’ url, then a form should be displayed to the user.
Add a new route in App.Router.Map for ‘#/story/new’ as shown below:
App.Router.map(function() { this.resource('newstory' , {path : 'story/new'}); });
Next we will add a ‘newstory’ template in index.html to render a form.
<script type="text/x-handlebars" id="newstory"> <form class="form-horizontal" role="form"> <div class="form-group"> <label for="title" class="col-sm-2 control-label">Title</label> <div class="col-sm-10"> <input type="title" class="form-control" id="title" name="title" placeholder="Title of the link" required> </div> </div> <div class="form-group"> <label for="excerpt" class="col-sm-2 control-label">Excerpt</label> <div class="col-sm-10"> <textarea class="form-control" id="excerpt" name="excerpt" placeholder="Short description of the link" required></textarea> </div> </div> <div class="form-group"> <label for="url" class="col-sm-2 control-label">Url</label> <div class="col-sm-10"> <input type="url" class="form-control" id="url" name="url" placeholder="Url of the link" required> </div> </div> <div class="form-group"> <label for="tags" class="col-sm-2 control-label">Tags</label> <div class="col-sm-10"> <textarea id="tags" class="form-control" name="tags" placeholder="Comma seperated list of tags" rows="3" required></textarea> </div> </div> <div class="form-group"> <label for="fullname" class="col-sm-2 control-label">Full Name</label> <div class="col-sm-10"> <input type="text" class="form-control" id="fullname" name="fullname" placeholder="Enter your Full Name like Shekhar Gulati" required> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <button type="submit" class="btn btn-success" {{action 'save'}}>Submit Story</button> </div> </div> </form> </script>
To see the form just go to ‘#/story/new’.
Next we will add a link in the navbar to make it easy for us to navigate to story submission form. Replace the nav element with the one mentioned below.
<nav class="navbar navbar-default navbar-fixed-top navbar-inverse" role="navigation"> <div class="container"> <div class="navbar-header"> <a class="navbar-brand" href="#">GetBookMarks</a> </div> <ul class="nav navbar-nav pull-right"> <li>{{#link-to 'newstory'}}<span class="glyphicon glyphicon-plus"></span> Submit Story{{/link-to}}</li> </ul> </div> </nav>
The important thing to notice in the above snippet is the use of
{{#link-to}}helper. The
{{#link-to}} helper is used to create a link to a route. Please refer to documentation for more information.
Now that we can view the form, let us add the functionality to store the story in HTML 5 Local Storage. To add local storage support, we will have to first download the Ember Data and Local Storage Adapter JavaScript files. Place these files in js/libs folder. Next, add these script tags to the index.html.
<script src="js/libs/jquery-1.9.1.js"></script> <script src="js/libs/handlebars-1.0.0.js"></script> <script src="js/libs/ember-1.1.2.js"></script> <script src="js/libs/ember-data.js"></script> <script src="js/libs/localstorage_adapter.js"></script> <script src="js/app.js"></script>
As discussed before, Ember Data is the client side ORM implementation which make it easy to perform CRUD operations on the underlying store. Here, we are going to use the LSAdapter(Local Storage Adapter). Add the following line to app.js.
App.ApplicationAdapter = DS.LSAdapter.extend({ namespace: 'stories' });
Next let use define our model. A story would have a url, title, fullname of the user who submitted the story, excerpt of the story, and submittedOn i.e. date on which story was submitted. We can also specify the type of the property. In the model shown below, we have used string and date types. The default adapter supports attribute types of string, number, boolean, and date.
App.Story = DS.Model.extend({ url : DS.attr('string'), tags : DS.attr('string'), fullname : DS.attr('string'), title : DS.attr('string'), excerpt : DS.attr('string'), submittedOn : DS.attr('date') });
Next we will write the NewstoryController which will persist the user when save action is made.
App.NewstoryController = Ember.ObjectController.extend({ actions :{ save : function(){ var url = $('#url').val(); var tags = $('#tags').val(); var fullname = $('#fullname').val(); var title = $('#title').val(); var excerpt = $('#excerpt').val(); var submittedOn = new Date(); var store = this.get('store'); var story = store.createRecord('story',{ url : url, tags : tags, fullname : fullname, title : title, excerpt : excerpt, submittedOn : submittedOn }); story.save(); this.transitionToRoute('index'); } } });
The code shown above gets all the form values and then create an in-memory record using the store API. To store that record in the localstorage we will have to call save method on the Story object. Finally, we will redirect the user to index route.
Now you can test the application, create new story and then go to Chrome Developer tools and in the resources section you can view the story.
Step 6 : Show All Stories
The next logical step is to show all the stories when user view the home page.
As I mentioned before, a route is responsible for querying the model. We will add the IndexRoute which will find all the stories persisted in the local storage.
App.IndexRoute = Ember.Route.extend({ model : function(){ var stories = this.get('store').findAll('story'); return stories; } });
Every route backs a template. In this IndexRoute backs the index template. So add index template in index.html
<script type="text/x-handlebars" id="index"> <div class="row"> <div class="col-md-4"> <table class='table'> <thead> <tr><th>Recent Stories</th></tr> </thead> {{#each controller}} <tr><td> {{title}} </td></tr> {{/each}} </table> </div> <div class="col-md-8"> {{outlet}} </div> </div> </script>
If we visit your app at the URL ‘/’ , we will see list of stories. The each loop iterates over the stories collection; here, controller equals IndexController.
Now you will see the stories on the ‘/’ route.
There is one issue, stories are not sorted by date. To sort them by submittedOn date, we will create IndexController which is responsible for sorting the model. We specified that we want to sort on submittedOn property and it should in descending order to make sure new stories are on top.
App.IndexController = Ember.ArrayController.extend({ sortProperties : ['submittedOn'], sortAscending : false });
After making this change, we will see stories sorted by submittedOn property.
Step 7 : Viewing the individual story
The last functionality that we have to implement in this application is that when a user click on a story then user should see all the details related to the story. To achieve that, we will add the following route.
App.Router.map(function() { this.resource('index',{path : '/'},function(){ this.resource('story', { path:'/stories/:story_id' }); }); this.resource('newstory' , {path : 'story/new'}); });
The code shown above is an example of nested route.
The :story_id part is called a dynamic segment because the corresponding story id is be injected into the URL.
Next we will add StoryRoute which will find the story corresponding to the story id.
App.StoryRoute = Ember.Route.extend({ model : function(params){ var store = this.get('store'); return store.find('story',params.story_id); } });
Lastly, we will update the index.html to link to each story from the index template. We will use the {{#link-to}} block helper inside the each loop.
<script type="text/x-handlebars" id="index"> <div class="row"> <div class="col-md-4"> <table class='table'> <thead> <tr><th>Recent Stories</th></tr> </thead> {{#each controller}} <tr><td> {{#link-to 'story' this}} {{title}} {{/link-to}} </td></tr> {{/each}} </table> </div> <div class="col-md-8"> {{outlet}} </div> </div> </script> <script type="text/x-handlebars" id="story"> <h1>{{title}}</h1> <h2> by {{fullname}} <small class="muted">{{submittedOn}}</small></h2> {{#each tagnames}} <span class="label label-primary">{{this}}</span> {{/each}} <hr> <p class="lead"> {{excerpt}} </p> </script>
Once you have made the changes, you can view the changes in the app by visiting your browser.
Step 8 : Formatting the submittedOn date
Ember has concept of helpers. The helpers are functions that can be invoked from any Handlebars template.
We will format the date using moment.js library. Add the following to index.html.
<script src=""></script>
Then, we’ll define our first helper which will format the date to human readable format.
Ember.Handlebars.helper('format-date', function(date){ return moment(date).fromNow(); });
Finally we will add
format-date helper in the story template as shown below.
<script type="text/x-handlebars" id="story"> <h1>{{title}}</h1> <h2> by {{fullname}} <small class="muted">{{format-date submittedOn}}</small></h2> {{#each tagnames}} <span class="label label-primary">{{this}}</span> {{/each}} <hr> <p class="lead"> {{excerpt}} </p> </script>
You can view the updated story
>>IMAGE. | https://blog.openshift.com/day-19-ember-the-missing-emberjs-tutorial/ | CC-MAIN-2015-32 | refinedweb | 3,081 | 50.53 |
utils.CheckViewPortSelect bugs
On 16/06/2013 at 05:46, xxxxxxxx wrote:
Hi,
sorry for the second thread, but I am pretty sure now that this a python specific problem.
1. When you do invoke Init() on a ViewPortSelect instance multiple times with different
objects as the ops parameter list the instance produces memory leaks. This of course
assumes the case where the ViewPortSelect object is a class member.
2. The same goes for a ViewPortSelect instance which is initialized right away for multiple
objects. The method that triggers the whole mess seems to be then the PickObject() method.
3. Freeing the ViewPortSelect class member by overwriting it with None when freeing the
tool does not free the associated memory. The crucial part seems to be somehow the
reinitialization of the instance as described in 1.
4. ViewPortSelect.PickObject() does not respect the object list passed to Init() it will select
anything that is near to the cursor. Not sure if that is intended, but it should be at least
mentioned more clearly.
Why all that mess you might ask, simply do not make it a class member. Well, that is true,
but I think these are still major bugs and also dynamically allocating the ViewPortSelect
object is quite a performance problem in python, at least for larger objects.
def CheckViewPortSelect(self, doc, bd) : """ Tests if the vpselect object if it is till valid. :param doc : The active document. :param bd : The associated BaseDraw. :return : NYI - always True """ if not isinstance(self.vpselect, utils.ViewportSelect) : self.vpselect = utils.ViewportSelect() if self.aobject is not None: if ( bd.GetMg() != self.vpmatrix or bd.GetFrame() != self.vpframe or self.vpobject != self.aobject or bd.GetProjection() != self.vpproject ) : self.vpselect = utils.ViewportSelect() # without that line the ViewportSelect is producing leaks. self.vpmatrix = bd.GetMg() self.vpframe = bd.GetFrame() self.vpproject = bd.GetProjection() self.vpobject = self.aobject wd = self.vpframe["cr"] - self.vpframe["cl"] + 1 hg = self.vpframe["cb"] - self.vpframe["ct"] + 1 self.vpselect.Init( wd, hg, bd, [self.aobject], c4d.Mpolyedgepoint, True, c4d.VIEWPORTSELECTFLAGS_IGNORE_HIDDEN_SEL ) return True return False
Happy rendering,
Ferdinand | https://plugincafe.maxon.net/topic/7271/8405_utilscheckviewportselect-bugs | CC-MAIN-2019-22 | refinedweb | 349 | 51.55 |
Dirty page tracking patch
From:
Kimball Murray
Date:
Mon Jul 11 2005 - 08:19:30 EST ]
Hello to all.
On behalf of Stratus Technologies () I'd like to
present a patch to the i386 kernel code that will allow developers to track
dirty memory pages. Stratus uses this technique to facilitate bringing
separate cpu and memory module "nodes" into lockstep with each other, with
a minimum of OS down time. This feature could also be used to provide inputs
into memory management algorithms, or to support hot-plug memory dimm modules
for specially developed hardware.
Stratus has used this patch in kernels 2.4.2, 2.4.18, 2.6.5, and 2.6.9
with great success. Also this same technique in different forms has been
shipping in Stratus products for 25 years in many different operating systems.
Stratus would like to share this tracking capability with the community. In
particular, we'd like to hear ideas anyone may have about other uses for it,
how to improve it technically, or even if there's a better way to do this. In
its current state, it is pretty lightweight, but it's inevitable that
developers will find ways to make it better, and more versatile.
Thank in advance for those that take an interest in this discussion.
- Kimball Murray (Stratus Technologies, currently on-site at
Redhat)
Please CC comments to:
kmurray@xxxxxxxxxx
What the patch does:
-------------------
The patch adds a new _PAGE_SOFT_DIRTY bit to the pte layout. This
takes the place of a previously unused bit in the pte. The hardware will set
the _PAGE_DIRTY bit when the cpu writes to memory. The _PAGE_SOFT_DIRTY bit
will only ever be set by software that is trying to copy live memory from one
memory domain to another. Such software would clear the _PAGE_DIRTY bit while
it sets the _PAGE_SOFT_DIRTY bit. In this way, it would know that this page
has been added to a "must copy" list already. A few kernel macros are
modified by this patch so that when the kernel queries the _PAGE_DIRTY bit, it
also queries the _PAGE_SOFT_DIRTY bit. Doing this allows the kernel to run
normally whether or not a page harvest is in progress.
Another addition this patch provides, is the mm_track(void*) call,
which allows software to record that a particular page needs to be copied
later. For synchronizing memory domains on a live system, a cyclic page
harvester must not only copy all newly-dirtied pages in a given pass to the
target memory domain, it must also worry about pages that were dirtied after
the last pass, but whose reference is lost before the next pass. For this
reason, the patch adds a few calls to mm_track() in places where page
references are being retired.
Finally, tracking can be turned on and off by software at runtime.
When turned off, the impact of this patch on kernel performance is negligible.
What the patch doesn't do:
-------------------------
Pages dirtied by device DMA into memory are not captured by the
tracking mechanism provided by this patch. Stratus has constructed a special
PCI bridge which has a "snarf" mode that, when enabled, directs all DMA to
memory to each of the participating cpu/memory nodes. Further, Stratus
hardware also performs a hardware memory check before releasing new cpu/memory
nodes into lockstep service. This provides a means of evaluating both the
memory tracking patch, and also a particular harvest algorithm.
The page harvest routine is not in this patch. Stratus has a goal
that this patch have a minimal kernel footprint. Therefore, our particular
harvest routine is in a kernel module. Many implementations of the harvest
are possible as well, and we did not want to constrain that in this patch.
Below are more details about the Stratus hardware and our harvest
algorithm. Some of the discussion below may repeat things already covered
above. If you just want to have a look at the patch itself, then please
fast-forward to the word "snip" in this document.
Stratus Architecture
--------------------
Stratus Technologies builds highly available, fault-tolerant servers
by provided for redundancy of all system components, including processors
and DIMMs. It is possible to remove and replace these components in a way that
is transparent to the applications running on the system.
Below is my poor man's sketch of the system layout. The customer
replaceable units (CRUs) are usually 1-U rack-mounted slices. The PCI bridge
in the middle box is split across the backplane, but appears as a single
PCI-PCI bridge to the OS. The top and bottom halves of the bridge communicate
using a proprietary, packet-based protocol.
(below) 2 or 3 CPU CRUs
+---------------------+ +--------------------+
| CPUs and DIMMs | | CPUs and DIMMs | ... lockstep domain
+---------------------+ +--------------------+
| |
+---------------------------------+
| | PCI bridge (top) | |
| | backplane | |
| +-------------------------+ |
| | backplane | |
| | PCI bridge (bottom) | |
+---------------------------------+
| |
+---------------------+ +--------------------+
| PCI cards (IO) | | PCI cards (IO) | ... fail-over domain
+---------------------+ +--------------------+
(above) 2 or 4 IO CRUs
The fail-over domain features standard PCI devices configured in redundant
ways, like RAID1 for disk mirrors or bonded network interfaces.
Lockstep
--------
The lockstep domain requires each CPU CRU to be driven by the same clock.
Equally important, the contents of memory in each CRU must be the same.
To facilitate this, hardware is provided that can copy pages of memory
across the backplane from one CPU CRU to another. The real trick is to
copy this memory without stopping any applications that are running on
the system, thereby allowing the possibility that some pages that have
been copied from online board to offline board have become dirty again on
the online board. These pages will have to be copied over again.
The newly dirtied pages are tracked in software, and are again copied to the
offline board. This loop continues until the total number of dirty pages
is below a predetermined threshold. When that occurs, an SMI is issued on
the both boards. A Stratus SMI handler will copy the remaining
dirty pages to the offline board. During this operation the system is in
"blackout", which lasts about 300 mS, depending on the threshold value. After
the final pages are copied, a reset is issued to all boards,
caches are flushed, etc., and as the SMI handler returns, it restores all of
the processor state that existed before the SMI was issued. On return from
SMI, the new board is executing in lock with the old.
(yes, I have omitted some nitty gritty chipset details.)
Dirty Page Harvest
------------------
I'd like now to discuss how the harvest loop works. First I should mention
that the harvest code is not in the kernel proper, it is instead a GPL loadable
kernel module that uses the tracking structure created by the patch included
in this note. Here is the basic algorithm (again, some details omitted
for the sake of brevity/clarity):
1. Turn on dirty page tracking
2. Copy _all_ physical memory from online board to offline board
3. Begin harvest loop
a) Iterate over all page tables. For each pte (pmd, pgd):
If the hardware dirty bit is set
Clear it and copy it into a software dirty bit.
Add this page to the mm_track bit vector.
---- Begin processing bit vector ----
b) CPUs enter rendezvous, interrupts off (momentary blackout)
c) If number of dirty pages remaining < THRESHOLD
Break out of the harvest loop (goto step 4.)
d) Iterate over the mm_track bit vector. A bit set indicates a dirty
page was found.
Add pages to a list of pages to be copied to offline board.
e) Clear mm_track bit vector
f) Interrupts on, cpus exit rendezvous
---- End processing bit vector ----
g) Copy pages in list to offline board, using "data mover"
hardware.
h) Go back to start of loop, step a).
4. Trigger SMI, do final copy, reset boards. (Enter 300mS blackout)
5. Return from SMI, boards now in lock.
In addition to tracking pages whose hardware dirty bits are set, it is
necessary to track pages that are being retired. This is because they
may be retired outside of step 3.a above, in which case they could have
been dirty, but we just lost the reference to them. To guard against this,
we simply call mm_track for ptes leaving the system. It's better to over-
track than under-track. A single forgotten page will eventually cause the
CPU CRUs to break lockstep.
Effect of patch on non-Stratus systems
--------------------------------------
Dirty page tracking must be turned on to really do anything. It can be turned
on by a kernel loadable agent, such as the harvest module described above. On
systems which do not enable it, it has no effect, other than adding a test
to see if tracking is turned on to a few pte macros, as well as an additional
boolean test is some other pte macros (because of the hard vs soft dirty bits).
Robustness of tracking on Stratus systems
-----------------------------------------
Stratus has a failsafe operation that verifies how well the tracking system
works. After bringing an offline CPU board into lockstep with an online
board, a hardware memory check is done on both boards. If there are any
differences, the newly online board is taken out of service. Additionally,
this post sync memory check helps Stratus catch the case where a user has
loaded a binary module that was compiled without tracking support. It's
possible, though unlikely, that this module could retire pages (via calls
to set_pte, etc) and these pages would not have been tracked. The hardware
memory checker will catch these cases by not allowing CPU CRUs to be brought
into lockstep.
The following patch is against linux-2.6.9-13-rc2:
--------------------------------- snip -----------------------------------
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -37,6 +37,14 @@ source "init/Kconfig"
menu "Processor type and features"
+config MEM_MIRROR
+ bool "Memory Mirroring (memory tracking support)"
+ depends on SMP
+ Memory tracking support can be used by agents wishing to
+ keep track of changes to memory while monitoring or copying
+ memory contents.
+
choice
prompt "Subarchitecture Type"
default X86_PC
diff --git a/arch/i386/mm/init.c b/arch/i386/mm/init.c
--- a/arch/i386/mm/init.c
+++ b/arch/i386/mm/init.c
@@ -694,3 +694,33 @@ void free_initrd_mem(unsigned long start
}
}
#endif
+
+#ifdef CONFIG_MEM_MIRROR
+/*
+ * For memory-tracking purposes, see mm_track.h for details.
+ */
+struct mm_tracker mm_tracking_struct = {ATOMIC_INIT(0), ATOMIC_INIT(0), 0, 0};
+EXPORT_SYMBOL_GPL(mm_tracking_struct);
+
+/* The do_mm_track routine is needed by macros in the pgtable-2level.h
+ * and pgtable-3level.h.
+ */
+void do_mm_track(void * val)
+{
+ pte_t *ptep = (pte_t*)val;
+ unsigned long pfn;
+
+ if (!pte_present(*ptep))
+ return;
+
+ pfn = pte_pfn(*ptep);
+ pfn &= ((1LL << (PFN_BITS - PAGE_SHIFT)) - 1);
+
+ if (pfn >= mm_tracking_struct.bitcnt)
+ return;
+
+ if (!test_and_set_bit(pfn, mm_tracking_struct.vector))
+ atomic_inc(&mm_tracking_struct.count);
+}
+EXPORT_SYMBOL_GPL(do_mm_track);
+#endif
diff --git a/include/asm-i386/mm_track.h b/include/asm-i386/mm_track.h
new file mode 100644
--- /dev/null
+++ b/include/asm-i386/mm_track.h
@@ -0,0 +1,57 @@
+#ifndef __I386_MMTRACK_H__
+#define __I386_MMTRACK_H__
+
+#ifndef CONFIG_MEM_MIRROR
+
+#define mm_track(ptep)
+
+#else
+
+#include <asm/page.h>
+#include <asm/atomic.h>
+ /*
+ * For memory-tracking purposes, if active is true (non-zero), the other
+ * elements of the structure are available for use. Each time mm_track
+ * is called, it increments count and sets a bit in the bitvector table.
+ * Each bit in the bitvector represents a physical page in memory.
+ *
+ * This is declared in arch/i386/mm/init.c.
+ *
+ * The in_use element is used in the code which drives the memory tracking
+ * environment. When tracking is complete, the vector may be freed, but
+ * only after the active flag is set to zero and the in_use count goes to
+ * zero.
+ *
+ * The count element indicates how many pages have been stored in the
+ * bitvector. This is an optimization to avoid counting the bits in the
+ * vector between harvest operations.
+ */
+struct mm_tracker {
+ atomic_t active; // non-zero if this structure in use
+ atomic_t count; // number of pages tracked by mm_track()
+ unsigned long * vector; // bit vector of modified pages
+ unsigned long bitcnt; // number of bits in vector
+};
+extern struct mm_tracker mm_tracking_struct;
+
+#ifdef CONFIG_X86_PAE
+#define PFN_BITS 36
+#else /* !CONFIG_X86_PAE */
+#define PFN_BITS 32
+#endif /* !CONFIG_X86_PAE */
+
+extern void do_mm_track(void *);
+
+/* The mm_track routine is needed by macros in the pgtable-2level.h
+ * and pgtable-3level.h. The pte manipulation is all longhand below
+ * because the required order of header files makes all the useful
+ * definitions happen after the following code.
+ */
+static __inline__ void mm_track(void * val)
+{
+ if (unlikely(atomic_read(&mm_tracking_struct.active)))
+ do_mm_track(val);
+}
+#endif /* CONFIG_MEM_MIRROR */
+
+#endif /* __I386_MMTRACK_H__ */
diff --git a/include/asm-i386/pgtable-2level.h b/include/asm-i386/pgtable-2level.h
--- a/include/asm-i386/pgtable-2level.h
+++ b/include/asm-i386/pgtable-2level.h
@@ -13,12 +13,24 @@
* within a page table are directly modified. Thus, the following
* hook is made available.
*/
-#define set_pte(pteptr, pteval) (*(pteptr) = pteval)
+#define set_pte(pteptr, pteval) \
+({ \
+ mm_track(pteptr); \
+ *(pteptr) = pteval; \
+})
#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
#define set_pte_atomic(pteptr, pteval) set_pte(pteptr,pteval)
-#define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval))
-
-#define ptep_get_and_clear(mm,addr,xp) __pte(xchg(&(xp)->pte_low, 0))
+#define set_pmd(pmdptr, pmdval) \
+({ \
+ mm_track(pmdptr); \
+ *(pmdptr) = pmdval; \
+})
+
+#define ptep_get_and_clear(mm,addr,xp) \
+({ \
+ mm_track(xp); \
+ __pte(xchg(&(xp)->pte_low, 0)); \
+})
#define pte_same(a, b) ((a).pte_low == (b).pte_low)
#define pte_page(x) pfn_to_page(pte_pfn(x))
#define pte_none(x) (!(x).pte_low)
diff --git a/include/asm-i386/pgtable-3level.h b/include/asm-i386/pgtable-3level.h
--- a/include/asm-i386/pgtable-3level.h
+++ b/include/asm-i386/pgtable-3level.h
@@ -52,6 +52,7 @@ static inline int pte_exec_kernel(pte_t
*/
static inline void set_pte(pte_t *ptep, pte_t pte)
{
+ mm_track(ptep); // track the old (departing) page
ptep->pte_high = pte.pte_high;
smp_wmb();
ptep->pte_low = pte.pte_low;
@@ -59,10 +60,16 @@ static inline void set_pte(pte_t *ptep,
#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
#define __HAVE_ARCH_SET_PTE_ATOMIC
-#define set_pte_atomic(pteptr,pteval) \
- set_64bit((unsigned long long *)(pteptr),pte_val(pteval))
-#define set_pmd(pmdptr,pmdval) \
- set_64bit((unsigned long long *)(pmdptr),pmd_val(pmdval))
+#define set_pte_atomic(pteptr,pteval) \
+({ \
+ mm_track(pteptr); /* track the old page */ \
+ set_64bit((unsigned long long *)(pteptr),pte_val(pteval)); \
+})
+#define set_pmd(pmdptr,pmdval) \
+({ \
+ mm_track(pmdptr); /* track the old page */ \
+ set_64bit((unsigned long long *)(pmdptr),pmd_val(pmdval)); \
+})
#define set_pud(pudptr,pudval) \
set_64bit((unsigned long long *)(pudptr),pud_val(pudval))
@@ -94,6 +101,8 @@ static inline pte_t ptep_get_and_clear(s
{
pte_t res;
+ mm_track(ptep); // track old page before losing this reference
+
/* xchg acts as a barrier before the setting of the high bits */
res.pte_low = xchg(&ptep->pte_low, 0);
res.pte_high = ptep->pte_high;
diff --git a/include/asm-i386/pgtable.h b/include/asm-i386/pgtable.h
--- a/include/asm-i386/pgtable.h
+++ b/include/asm-i386/pgtable.h
@@ -21,6 +21,8 @@
#include <asm/bitops.h>
#endif
+#include <asm/mm_track.h>
+
#include <linux/slab.h>
#include <linux/list.h>
#include <linux/spinlock.h>
@@ -101,7 +103,7 @@ void paging_init(void);
#define _PAGE_BIT_DIRTY 6
#define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page, Pentium+, if present.. */
#define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
-#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
+#define _PAGE_BIT_SOFTDIRTY 9 /* save dirty state when hdw dirty bit cleared */
#define _PAGE_BIT_UNUSED2 10
#define _PAGE_BIT_UNUSED3 11
#define _PAGE_BIT_NX 63
@@ -115,7 +117,7 @@ void paging_init(void);
#define _PAGE_DIRTY 0x040
#define _PAGE_PSE 0x080 /* 4 MB (or 2MB) page, Pentium+, if present.. */
#define _PAGE_GLOBAL 0x100 /* Global TLB entry PPro+ */
-#define _PAGE_UNUSED1 0x200 /* available for programmer */
+#define _PAGE_SOFTDIRTY 0x200
#define _PAGE_UNUSED2 0x400
#define _PAGE_UNUSED3 0x800
@@ -129,7 +131,7 @@ void paging_init(void);
#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY)
#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
-#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY)
+#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_SOFTDIRTY | _PAGE_DIRTY)
#define PAGE_NONE \
__pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED)
@@ -206,8 +208,7 @@ extern unsigned long pg0[];
#define pmd_none(x) (!pmd_val(x))
#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT)
#define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0)
-#define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE)
-
+#define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER & ~_PAGE_SOFTDIRTY & ~_PAGE_ACCESSED)) != (_KERNPG_TABLE & ~_PAGE_ACCESSED))
#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
@@ -217,7 +218,7 @@ extern unsigned long pg0[];
*/
static inline int pte_user(pte_t pte) { return (pte).pte_low & _PAGE_USER; }
static inline int pte_read(pte_t pte) { return (pte).pte_low & _PAGE_USER; }
-static inline int pte_dirty(pte_t pte) { return (pte).pte_low & _PAGE_DIRTY; }
+static inline int pte_dirty(pte_t pte) { return (pte).pte_low & (_PAGE_DIRTY | _PAGE_SOFTDIRTY); }
static inline int pte_young(pte_t pte) { return (pte).pte_low & _PAGE_ACCESSED; }
static inline int pte_write(pte_t pte) { return (pte).pte_low & _PAGE_RW; }
@@ -228,7 +229,7 @@ static inline int pte_file(pte_t pte) {
static inline pte_t pte_rdprotect(pte_t pte) { (pte).pte_low &= ~_PAGE_USER; return pte; }
static inline pte_t pte_exprotect(pte_t pte) { (pte).pte_low &= ~_PAGE_USER; return pte; }
-static inline pte_t pte_mkclean(pte_t pte) { (pte).pte_low &= ~_PAGE_DIRTY; return pte; }
+static inline pte_t pte_mkclean(pte_t pte) { (pte).pte_low &= ~(_PAGE_SOFTDIRTY | _PAGE_DIRTY); return pte; }
static inline pte_t pte_mkold(pte_t pte) { (pte).pte_low &= ~_PAGE_ACCESSED; return pte; }
static inline pte_t pte_wrprotect(pte_t pte) { (pte).pte_low &= ~_PAGE_RW; return pte; }
static inline pte_t pte_mkread(pte_t pte) { (pte).pte_low |= _PAGE_USER; return pte; }
@@ -246,9 +247,9 @@ static inline pte_t pte_mkhuge(pte_t pte
static inline int ptep_test_and_clear_dirty(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
{
- if (!pte_dirty(*ptep))
- return 0;
- return test_and_clear_bit(_PAGE_BIT_DIRTY, &ptep->pte_low);
+ mm_track(ptep);
+ return (test_and_clear_bit(_PAGE_BIT_DIRTY, &ptep->pte_low) |
+ test_and_clear_bit(_PAGE_BIT_SOFTDIRTY, &ptep->pte_low));
}
static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at ] | http://lkml.iu.edu/hypermail/linux/kernel/0507.1/0779.html | CC-MAIN-2016-30 | refinedweb | 2,875 | 63.59 |
The System::Runtime:: InteropServices namespace contains many useful classes, structures, and attributes that you can use to access your legacy libraries and resources. The .NET Framework as a whole also provides many services for migrating existing code and resources to managed code. This article explains how to use these services to extract resources from Win32 resource files, as well as how to write icon resources to .ICO files. It also covers many of the issues surrounding resource management and interoperating with unmanaged code, memory, and binary formats.
Introduction
Every so often, I find myself needing to extract an icon from an executable or DLL (dynamic-link library), and every time I end up bending over backwards to get this done, especially if the library contains hundreds of icons and I have to sift through all of them until I find the one I want. So I decided to write a little program to make the process of extracting an icon from a library much easier. Well, it started out simple. I wrote the Icon Browser application in Managed C++ using the .NET Framework, and, in about 45 minutes, I had a really cool icon viewer. The .NET Framework provides a vast library of classes that boosts productivity immensely by providing many of the building blocks you would normally have to write yourself. Then I attempted to implement the export feature that would allow the user to choose any icon in the library and save it to an external .ICO file. I hit a brick wall. It turns out theres no simple way to save an icon to a file.
In this article, I present the Icon Browser application. It is a small desktop application that allows you to browse through the icons embedded in executables and DLLs and to save any of the icons to a .ICO file. I will use this application as a vehicle for exploring programming tasks such as reading and writing unmanaged resources and other issues related to porting or coexisting with legacy code and binaries. In addition, Ill look at taking unmanaged C++ classes employing traditional deterministic finalization and show you how to implement them as Managed C++ and C# classes, ensuring that they behave well in the .NET environment where the garbage collector reigns.
Most of the functions, classes, and structures that are mentioned in this article are documented in the MSDN Library, which is available at Microsofts website. If you want to find out more about a particular point that I mention, the MSDN Library is a good place to start.
Icon Browser
Before I get into the programming details, let me quickly introduce the Icon Browser and show you how to use it. Even if youre not too interested in resource management and interoperating with unmanaged code from .NET, you might find this application useful. Icon Browser is very easy to use (see Figure 1). You can type a filename in the edit box and click the Go button, and Icon Browser will search the given file and display any icons it finds in the list view. If youre not sure about the name or location of the file, you can click the Browse button and search for a file using the familiar Choose a File dialog box. Once the icons have been loaded into Icon Browser, you can choose any one of the icons and click the Export Icon button to save the icon to a .ICO file. You will be presented with a Save Icon As dialog box so that you can indicate where to save the new .ICO file. Ive also added a handy context menu to the list view so that you can just right click on an icon and select the Export Icon command.
If you are following along with me on your own computer, you will notice that there is a default filename in the Save Icon As dialog box, and its probably a number. That name or number is the resource name for the icon in the library. Its just a unique way to identify a resource in a library. The resource name is also used as the title for each of the icons displayed in Icon Browser (see Figure 1).
And thats the Icon Browser application, simple but effective! The application as well as its source code is available for download at <>.
What Are Icons Anyway?
Most people think of icons as the little images that represent documents and other files in the Windows shell. Technically, an icon is a group of icon images. An icon image resembles a DIB (device-independent bitmap). So an icon can be represented by a number of different images tailored for different display configurations. In fact, when designing icons for Windows XP, you are encouraged to include nine different images. Figure 2 shows the images for Microsoft Notepad in GIF Movie Gear, which is a tool you can use to assemble icon images and save to a .ICO file.
When using an icon, you will typically only deal with a handle to the icon and not the actual icon resource. In C or C++, you will use HICON, which is simply an abstract handle to the icon, and pass it to the various Win32 API calls. This is the traditional way that resources are managed in C. In the managed world of .NET, you will use the Icon class.
There are many different ways to load an icon. Two of the most common Win32 API functions you can use are ExtractIcon and LoadIcon. ExtractIcon will return an HICON given a filename and the zero-based index of the icon in the file. This is useful if you just want to enumerate all or some of the icons in a file. LoadIcon is a bit more useful in that you can identify an icon based on its resource name or identifier. In .NET, you dont generally load icons from unmanaged executables or DLLs. Instead you will normally use the ResourceManager class to load resources from resource files as defined by the .NET Framework.
So how do you read icons from unmanaged libraries? Read on.
P/Invoke
P/Invoke (Platform Invoke) is the bridge between the managed world of .NET and unmanaged code like the Win32 APIs. P/Invoke is part of the .NET Frameworks extensive interoperability layer. To call an unmanaged function, you need to use the DllImport attribute to identify the function and the DLL that implements it. You can still of course use the linker to link to a .LIB file and include the appropriate headers, as has been done by C++ programmers for years. But P/Invoke provides an alternative for C++ programmers and is the only way to accomplish this from other managed languages like C#. Here is the declaration for the LoadIcon API:
// Original declared in: winuser.h // HICON LoadIcon(HINSTANCE hInstance, // PCTSTR pName); [DllImport("User32.dll", SetLastError=true, CharSet=CharSet::Auto)] static void* LoadIcon(System::IntPtr hInstance, System::IntPtr pName);
"User32.dll" is the single parameter to the DllImportAttribute instance constructor. It identifies the DLL implementing the unmanaged function. SetLastError and CharSet are public fields for the DllImportAttribute class.
Setting the SetLastError field to true informs the CLR (Common Language Runtime) that the unmanaged function may call the SetLastError Win32 API function. In response, the CLR will cache the value returned by the GetLastError Win32 API function so that you can retrieve it later. This avoids race conditions, as it is possible for another function used by the CLR to call SetLastError before you get around to retrieving the error code. The .NET Framework exposes the cached error code through the GetLastWin32Error static method on the Marshal class. So it is a good idea to set this field if you suspect your unmanaged functions may set the last error code and you are interested in retrieving it.
Setting the CharSet field to CharSet::Auto indicates that the unmanaged function has a Unicode and an ANSI version. Most Win32 API functions that deal in any way with strings qualify. For example, a function named LoadIcon doesnt actually exist. It is actually #defined to LoadIconW if UNICODE is defined or LoadIconA if it is not. The -W, or Unicode, versions of the functions were introduced with Windows NT as Windows NT and it successors, Windows 2000 and XP, deal natively with Unicode strings. Windows 9x and its successor Windows ME mostly only support the -A, or ANSI, versions. Setting CharSet to CharSet::Auto instructs the CLR to pick the right version based on the operating system that the code is running on. If you dont explicitly set the CharSet field, it defaults to CharSet::Ansi, which wont give you the best performance on Windows XP as the operating system will have to convert any strings from ANSI to Unicode before it can use them. This is an improvement over unmanaged C++ where you had to create separate builds to optimize for ANSI and Unicode, using the _T macro to create text-generic literals.
The next thing youll notice is that Ive changed the parameter types to the IntPtr value type. You will normally use IntPtr for opaque unmanaged types that cant be represented by corresponding managed types. Although pName is a PCTSTR, which is a constant pointer to a TCHAR (in other words a string), it is more commonly used to pass an integer identifier using the MAKEINTRESOURCE macro. For this reason, pName is also declared as an IntPtr.
LoadIcon, as with many of the resource management functions, requires an instance handle. If youre programming in C++, then this is no problem. The operating system will assign your process an instance handle when it first starts up. And if you need to get resources from another DLL or executable, you simply call LoadLibraryEx and pass the LOAD_LIBRARY_AS_DATAFILE flag to indicate that you just want access to the resources within the library and dont want to execute any code it may contain. Heres an example of using the LoadLibraryEx function to load the Windows Explorer shell executable from unmanaged C++:
HMODULE hModule = ::LoadLibraryEx (_T("C:\\Windows\\Explorer.exe"), 0, // must be zero. LOAD_LIBRARY_AS_DATAFILE);
Although LoadLibraryEx returns a module handle, it is generally interchangeable with an instance handle, so you can freely pass it to functions that expect a HINSTANCE. In fact, a HMODULE is typedefed to be a HINSTANCE in windef.h. In the world of .NET however, you dont deal with instance handles but rather with assemblies. An assembly, which is usually packaged as an executable or DLL, can be loaded using the Assembly::LoadFrom method as shown here:
Assembly* assembly = Assembly::LoadFrom(S"C:\\MyResources.dll");
The Assembly class contains a host of properties and methods for accessing the various types defined in an assembly and can be used with the classes in the System::Resources namespace to retrieve any resources.
Resource Management
Lets get back to the problem at hand. To retrieve resources from unmanaged libraries, you need to declare a few of the Win32 API functions for use in .NET. I tend to put all my declarations in a single class that I call WindowsAPI. This way I can check at a glance what dependencies my project may have to ensure that they are available on any platforms that I support. You can download the WindowsAPI class at <>. Because resource management is so important (yes, even when using .NET), you should avoid using these functions directly as your code will end up getting quite messy as you try to free the various resources when youre done using them. Remember that you must always write your code to be resilient to exceptions. The best way to do this is to wrap any resource management functions inside a class. If you are a traditional C++ programmer, your first pass at writing a Managed C++ class to wrap the library functions might look something like Figure 3, with error handling code omitted for brevity. The __gc keyword indicates that the class is garbage collected, and its lifetime is managed by the CLR.
This is perfectly acceptable from an unmanaged C++ point of view, and it will even compile and work in Managed C++. Theres only one problem. The .NET Framework uses non-deterministic finalization. What this means is that .NETs garbage collector will call your objects destructor (called a finalizer in .NET speak) in a non-deterministic fashion, most likely when it notices youre low on memory. So unlike in unmanaged C++ where your destructor is guaranteed to be called when execution leaves the scope in which the object was created, in .NET you cannot rely on a destructor to free your resources in such a timely fashion. Remember that all reference types in the CLR are created on the managed heap and the managed heap is controlled by the garbage collector. Fortunately .NET defines a pattern for resource management, which if followed consistently makes resource management a breeze. The .NET Framework defines the IDisposable interface, which has a single method called Dispose. When used in conjunction with the C# using statement, it provides precise control over when your class will be disposed. So Ill rewrite the Library class to make use of the IDisposable interface, again with error handling omitted for brevity (see Figure 4). This is a simplification of the Dispose pattern, but it effectively illustrates the point without sacrificing too many trees. My new Library class can now be used as follows from C#:
using (Library library = new Library (@"C:\Windows\Explorer.exe" WindowsAPI.LOAD_LIBRARY_AS_DATAFILE)) { // use the library }
Before execution leaves the using scope, the library will be freed. But what about using it from Managed C++? Well, although managed C++ doesnt have a using keyword, you can use the __finally statement (which Visual C++ has had for many years to support Win32 structured exception handling) to call Library::Dispose as shown here. This ensures that the Library object will be freed even if an exception is thrown at any point after creating the object.
Library* library = 0; try { library = new Library (S"C:\\Windows\\Explorer.exe", WindowsAPI::LOAD_LIBRARY_AS_DATAFILE); // Use the library } __finally { if (0 != library) { library->Dispose(); } }
Note that this doesnt free the memory held by the Library object, it merely frees the resources held by that object. The memory for the object itself will still be freed by the garbage collector eventually. If youre like me, you love the elegance of C++, and looking at the code fragment above will make you feel gloomy and want to go back to unmanaged code where you can use the resource acquisition is initialization technique to release your resources deterministically and elegantly. Well dont despair, because there is a solution: templates. Even though the CLR doesnt support generics yet, you are still programming in C++, so theres nothing stopping you from employing them to solve this problem. I wrote a template class called Using that can be employed to achieve the same affect as C#s using statement (see Figure 5). The Using class is an unmanaged C++ class, so it is not controlled by the garbage collector and can be trusted to free your resources when it goes out of scope. Its basically an unmanaged wrapper for any IDisposable-derived class, such as my Library class presented above. The Using class makes use of the gcroot class that ships with the .NET Framework SDK. gcroot is basically a smart pointer for managed pointers in unmanaged C++. gcroot does nothing more than wrap the managed pointer, but it can easily be extended to provide more interesting behavior as shown here. Many of the .NET Framework classes implement IDisposable too, so the Using class is a very handy class to have in your tool chest. When the Using object goes out of scope, it ensures that the objects Dispose method gets called. This is kind of like deterministic finalization for managed objects! Now using the Library class becomes much simpler:
void UseLibrary() { Using<Library*> library = new Library (S"C:\\Windows\\Explorer.exe", WindowsAPI::LOAD_LIBRARY_AS_DATAFILE); // Use library }
And thats the basics of resource management in .NET using C# and Managed C++.
So Where Are the Icons?
Now that you know how to load an unmanaged library, you need to determine whether a library contains any icons. As I mentioned before, you can use the LoadIcon function to load an icon from a library as long as you have the name or identifier for the icon resource. If you dont know the name of a particular icon, you can enumerate all the icons until you find the one you want. This is done using the EnumResourceNames function, which is declared as follows in Kernel32.dll:
BOOL EnumResourceNames(HMODULE hModule, PCTSTR pType, ENUMRESNAMEPROC pCallback, LONG_PTR lParam);
The hModule parameter is a module handle, which you can get by calling LoadLibraryEx, so I can use my Library class for this. The pType parameter identifies the type of resource. Although you can define your own resource types, you will generally use one of the standard resource types. Two resource types of interest in this discussion are RT_GROUP_ICON and RT_ICON. An RT_GROUP_ICON resource represents an icon. It is basically just a directory of icon images. Each directory entry refers to a RT_ICON resource, which contains the actual image data (see Figure 6). So to enumerate the icons in a library, you pass RT_GROUP_ICON as the type of resource to enumerate. The next parameter is the callback function, which is the traditional way of implementing an enumerator in C. You simply pass the address of a function to EnumResourceNames, and it will call that function for each matching resource. Simple. Well not really. The problem is that .NET has no notion of a function pointer. Fortunately, the .NET Framework has a thing called a delegate, which is much more powerful and can be used to implement callback functions, too. A delegate can refer to a static or instance method. You cant pass EnumResourceNames a pointer to a function, but you certainly can pass it a delegate, assuming you declared the EnumResourceNames function appropriately and declared the matching delegate. Heres how you would do that. This discussion assumes youre using Managed C++ for everything. You could of course have simply #included Windows.h and used a callback function; however, using delegates provides benefits even for the C++ programmer.
__delegate bool EnumResNameProc(System::IntPtr hModule, System::IntPtr pType, System::IntPtr pName, System::IntPtr param); [DllImport("Kernel32.dll", SetLastError=true, CharSet=CharSet::Auto)] static bool EnumResourceNames(System::IntPtr hModule, System::IntPtr pType, EnumResNameProc* enumFunc, System::IntPtr param);
Since EnumResourceNames really operates on a library, Ive added a method to my Library class that calls this import. This saves you from having to pass it a module handle every time. And of course this is the more object-oriented way to do it. Now enumerating the icon resources in a library becomes very easy (see Figure 7). At this point, you can call LoadIcon to get a handle to an icon tailored for the current display configuration. This can then be passed to the Icon::FromHandle method to get an Icon object, which in turn can be displayed in various ways in a .NET application. If you recall, one of my objectives for the Icon Browser application is to be able to save an icon to a .ICO file. To do this, I need to dig a little deeper and get at the actual resource data.
To get the resource data, you need to use the FindResource and LoadResource functions to locate and load the resource. This is different from calling LoadIcon, which generates a displayable icon based on the icon resource. Once the resource is loaded, you call the LockResource function to get a pointer to the actual resource bytes. This pointer is valid until such time as the library containing the resource is freed. Ive declared structures to represent the resource data (see Figure 8). The __nogc keyword informs the compiler that these are unmanaged C++ structures. You wont find these data structures defined in the Platform SDK documentation. It is worth noting that although this poses no challenges to C++, you will run into a number of issues if you try to do the same thing in C# or even Managed C++. What complicates matters, when trying to use them from C#, is that MEMICONDIR is actually a variable-length structure. The length of the arEntries array is defined by wCount. In other words, arEntries is an inline array as opposed to a pointer to the first element of an array. So to get to the various elements of the array, you need to perform a bit of pointer arithmetic. Although this is no problem to a seasoned C or C++ developer, it poses a challenge as C# does not encourage the use of pointers. In addition, managed structures cannot have inline arrays. So, if I had declared the C++ structures as managed structures, the compiler would have refused to compile them. If you are dealing with this problem, there is a solution. You do however need to explicitly mark code blocks as unsafe before you can make use of pointers in C#. This can be done using the C# unsafe keyword. Please bear in mind that it is called unsafe for a reason. Misuse of pointers often leads to very buggy code. This is why even in C++ the use of pointers is discouraged and should usually be localized to C++ classes employing the resource acquisition is initialization idiom. If you use any unsafe code in a .NET assembly, the entire assembly is marked as unsafe. Figure 9 contains a simple C# console application that demonstrates how to load the icon resource for the Microsoft Notepad application and how to use pointer arithmetic to access the last entry in the arEntries array. This code assumes you declared the managed structures in C# like this:
[StructLayout(LayoutKind.Sequential, Pack=2)] public struct MEMICONDIR { public ushort wReserved; public ushort wType; public ushort wCount; public MEMICONDIRENTRY arEntries; // inline array }
Now that you know how to access these structures, lets take a closer look at them. Both MEMICONDIR and MEMICONDIRENTRY have been decorated in both the C# and C++ form. The C# structures have the StructLayout attribute applied to them. LayoutKind::Sequential is the single parameter to the StructLayoutAttribute instance constructor. It indicates that the members of the structure must be laid out sequentially in memory so as to be memory-compatible with unmanaged code. Otherwise, the CLR is free to move the objects members around in memory for efficiency. The Pack field indicates the alignment of the members in memory. The Pack field defaults to 8, which is convenient as this is what Visual C++ 6 uses. And since most unmanaged structures you might encounter were probably declared and implemented using Visual C++ 6, it is a safe default. However the icon resource uses a Pack value of 2, which is why you need to declare it explicitly. This results in a slightly smaller memory footprint, as most of the structure members are two-byte words or smaller. To put this in perspective, the same affect is achieved in C++ using the pack pragma.
The MEMICONDIRENTRY structure contains information about an individual icon image. The wID member is of particular interest as it contains the resource identifier for the RT_ICON resource within the library that contains the actual image bitmap information. You can use this identifier with the FindResource and LoadResource functions to locate and load the RT_ICON resource. Then you can use the LockResource function to get at the bitmap information. Finally, youve found the images! The RT_ICON resource data is stored in memory similar to a DIB. So much so that you can use the BITMAPINFO structure, which defines a DIB in memory, to access the RT_ICON resource data. For more information about DIBs and the BITMAPINFO structure, consult the Platform SDK documentation. Technically the icon image uses the same format as the CF_DIB clipboard format where the DIB bits follow the BITMAPINFO header and color table. You will need to know this if you want to render the image yourself using the icon resource. For the purpose of this discussion, you can ignore this fact except to remember that the BITMAPINFO is yet another variable-length structure, and you must treat it accordingly. One thing to keep in mind is that icons deviate slightly from the BITMAPINFOHEADER semantics in that the biHeight member is double the actual height. Figure 6 illustrates how the RT_GROUP_ICON and RT_ICON resources are laid out in memory.
Next, Ill show how you can wrap all this resource management code in a few well-defined classes to reduce this complexity.
Resource Management Revisited
I have written two classes: IconResource and IconImage. The IconResource class takes care of loading an RT_GROUP_ICON resource from a library and populates an array of IconImage objects. Each IconImage object represents an RT_ICON resource, which is a single image for the icon resource. As a user of the IconResource class is entitled to keep a reference to an IconResource object long after the library that it originated from has been freed, you need to be careful about the memory that gets returned by calls to LockResource. Although you dont have to worry about releasing this memory (the operating system will ensure that it is freed once its parent library is unloaded from the process), you do need to concern yourself with any pointers to this memory that you may hold on to. The IconImage class needs to hold on to its resource data so that it can be used to write it to a .ICO file. I will talk more about this later. To satisfy this requirement, the IconImage class makes a local copy of the image bits. When the IconImage object is constructed, it loads the RT_ICON resource, which is just the DIB bits for the image. It then copies these image bits into a managed byte array using the Copy method on the Marshal class. Now that the IconImage class contains its own copy of the resource data, the library where the resource was originally retrieved from can be freed without affecting the IconImage class.
Lets See What Youve Got!
Icons arent much fun if you cant see them. So lets take a look at the Icon Browsers MainWindow class and how it employs the classes that Ive discussed so far to implement icon browsing. I first wrote the Icon Browser application in C#. For this article, I rewrote the entire application in Managed C++. The MainWindow class from the original C# version was generated using the Visual Studio Forms Designer. The C++ version I wrote completely by hand. You can judge for yourself which one is cleaner. The source code for both versions is available at <>. Although I am generally weary of computer-generated code, the Visual Studio Forms Designer does a remarkable job of generating user-interface code. It is a huge boon to productivity if handled correctly. The trick is to be conscious of the code it generates and to maintain your coding and naming standards. For example, if you drag three text boxes onto a form, it will name them textBox1, textBox2, and textBox3. Be sure to give them meaningful names in the context of your application, as well as following any naming conventions you may be employing for your project. Further, for any non-trivial user-interface component, you need to employ standard design practices to ensure separation of data and presentation. This can be done using design patterns such as the Document/View pattern employed by MFC or the MVC (Model/View/Controller) pattern.
As shown in Figure 1, the Icon Browser is a simple forms-based application. Its made up of a resizable window that contains a list view for displaying the icons, as well as a toolbar of sorts exposing the functionality supported by the Icon Browser application. The code of interest is in the GoEventHandler method, which is called in response to the Click event on the Go button. This brings everything you have learnt so far together. The GoEventHandler method uses the Library class to load the user-provided file. It then calls the Library class EnumResourceNames method to enumerate the RT_GROUP_ICON resources. AddIconToList is the delegate called by EnumResourceNames for each icon resource that is found. It uses the IconResource class to load the resource data and adds an IconItem to the ListView to represent the icon to the user. IconItem is a simple class that derives from ListViewItem that is used to initialize the ListViewItem text and image index.
Exporting Icons
Theres one more thing left to do. At the beginning of this article, I mentioned that the Icon Browser would allow the user to export any icon to a .ICO file. Unfortunately, the .ICO file format is different to the format used to store icons in resource files. Figure 10 illustrates how an icon is stored in a .ICO file. It somewhat resembles the memory layout of the RT_GROUP_ICON resource. So, with a little bit of translation code, you can convert the one to the other. The major difference with the way the .ICO file format is written is that the icon image directory entry for each image stores a byte offset to the location of the image, whereas the RT_GROUP_ICON resource stores the resource name that you use to load the image. For the purposes of writing a .ICO file, I have added a Save method to the IconResource class. This method takes a single string parameter that indicates the file to write the icon data to. It uses the BinaryWriter class to write the .ICO file header information. It then delegates to the IconImage class to write the directory entry information, as well as the image bits.
A Note about Managed and Unmanaged C++
Although I have focused this article on writing Managed C++ code, one of the great advantages of C++ over other languages targeted at the CLR is that in C++ you can freely mix managed and unmanaged code. On the other hand, using managed code entirely allows you to isolate yourself from third-party source code, such as header files that you must include, which may populate the global namespace with definitions that you are not interested in and do other nasty things to your code (such as, what happens when you include a Windows header and name a method of your own with a name that is used by a Win32 API function).
Conclusion
Reading and writing Win32 resources is a non-trivial exercise in C++. Being able to pull it off entirely in managed code displays some of the power and flexibility of the .NET Framework. Resource management code should always be written carefully. Using the .NET Frameworks IDisposable class lends a helping hand by providing a common pattern for resource management. I hope that this exercise of walking through the development of the Icon Browser application helped you understand some of the services provided by the .NET Framework for writing code to interoperate with unmanaged code and resources.
About the Author
Kenny Kerr specializes in component-based development of desktop and distributed applications for the Microsoft Windows platform. He works at PlateSpin, Inc. in Toronto, Canada where he heads up the Windows development. Reach Kenny at [email protected] or visit his website: <> | http://www.drdobbs.com/icon-browser-an-exercise-in-resource-man/184403871 | CC-MAIN-2018-51 | refinedweb | 5,252 | 62.27 |
Python Programming, news on the Voidspace Python Projects and all things techie.
URLError & urllib2 the Missing Manual
I've just discovered an error (now corrected) in my popular article urllib2 - The Missing Manual.
Part of the code shows how to handle errors, when fetching the web resource you requested fails for whatever reason.
One approach I suggested was :
req = Request(someurl)
try:
handle = urlopen(req)
except URLError, e:
print 'We failed to reach a server.'
print 'Reason: ', e.reason
except HTTPError, e:
print 'The server couldn\'t fulfill the request.'
print 'Error code: ', e.code
else:
# everything is fine
This won't work, can you see why not ?
HTTPError is a subclass of URLError. That means that if urlopen raises an HTTPError it will be trapped by the first except statement. Your code will bomb out because the resulting exception object doesn't have a reason attribute.
The correct code is :
req = Request(someurl)
try:
handle = urlopen(req)
except HTTPError, e:
print 'The server couldn\'t fulfill the request.'
print 'Error code: ', e.code
except URLError, e:
print 'We failed to reach a server.'
print 'Reason: ', e.reason
else:
# everything is fine
No wonder I preferred the second approach in that section. Anyway, my apologies.
Like this post? Digg it or Del.icio.us it.
Posted by Fuzzyman on 2006-03-24 11:39:19 | |
Categories: Writing, Python
The GPL License
I don't like the GNU GPL license. If you release code that uses any GPL licensed code (or even just optionally links to any GPL code, even if it's not included in your distribution), then you are obliged to license your code with the GPL.
I think there are basically three reasons why people use the GPL, and I think two of them are valid.
- Ignorance
- Commercial
- Ideological
Ignorance
The GNU crowd have done such a good propaganda job, that some people think that Open Source means GPL. They release code under the GPL because it's the only Open Source license they are familiar with.
If you release your code under the GPL, then anyone who is working on code that will be made available commercially can't use your code. Because of legal ambiguity, many firms won't allow the use of GPL code even on internal projects that will never be released [1].
This means that less people can use your code, and I think that harms Python. We want to see high quality libraries and frameworks that encourage the use of Python in commercial environments.
Commercial Reasons
If you are working on a commercial project, you may find that part of your code could be neatly packaged as a library that may be useful to others. If this is a significant chunk of your work, you may not want to hand this over to your competitors.
In these circumstances, the GPL allows other Open Source projects to use your code; but not the competition. Unless your competition is free of course.
Ideological Reasons
Part of the ideology behind the GPL, is that software ought to be free. Instead you should earn a living offering consultancy and other software related services.
I personally think this is wrong-headed. I like free software, but I appreciate that it can take an enormous amount of effort to create and maintain complicated applications.
The bottom line is that this model isn't appropriate in all cases. I can understand people disagreeing with me though, this is especially true in individual instances.
The Alternatives
The license I use is the BSD License [2]. This requires you to include my license in your distribution, but pretty much allows anything else. (So long as you don't blame me or claim I gave you permission to do it.)
An even more liberal license is the the MIT License. This doesn't require your users maintain the original license restrictions if they relicense.
I have seen the Creative Commons by Attribution license used with code. This requires anyone who distributes your code to attribute the work to you. I like the intention, but the wording of the license is not directly applicable to program code.
Dual Licensing & Relicensing
This is sometimes a point of confusion, so it's worth a mention. A license does not indelibly mark a project with the terms of that license. A license specifies the terms you make code available under, but (if you are the sole copyright holder) you are free to relicense, or even retract the code altogether, any time you want.
If there are several contributors (more than one copyright holder) then you need permission from all of them, unless the license permits re-licensing anyway.
This allows firms to offer a GPL license for their code, with commercial licenses available for a fee.
It also means that if your project is currently GPL licensed, it's not too late to rectify.
Like this post? Digg it or Del.icio.us it.
Posted by Fuzzyman on 2006-03-24 10:29:02 | |
Categories: General Programming
SQLObject
Last night I tried to replicate the reported problems with SQLObject and Movable Python. I failed, as far as I can tell SQLObject works fine with Movable Python.
I tested with Movable Python 1.0.1 for Python 2.4.2, SQLObject 0.7, Pysqlite 2.1 and FormEncode.
If you would like this bundle of packages for Movable Python, you can download it as a single Zip file :
SQLObject Files (593k) [1]
I then ran the following test code from the SQLObject examples :
sqlhub.processConnection = connectionForURI('sqlite:/:memory:')
class Person(SQLObject):
fname = StringCol()
mi = StringCol(length=1, default=None)
lname = StringCol()
Person.createTable()
p = Person(fname="John", lname="Doe")
print p.fname
p.mi = 'Q'
p2 = Person.get(1)
print p2
print p is p2
It prints the following (correct) output :
John<Person 1True
Hopefully the user will find his problems evaporate, or he'll report back.
Like this post? Digg it or Del.icio.us it.
Posted by Fuzzyman on 2006-03-24 10:07:22 | |
Categories: Projects, Python
Back to the __future__
I recently blogged about supporting future statements in Movable Python.
When you compile Python code into a code object, in order to pass it to exec, you can specify which future statements it should be compiled with. I was worried that because I wasn't doing this, from __future__ import ... might be being ignored in user scripts.
I have just tested this with Movable Python for Python 2.4, and the future statements are honoured :
print 1/3
0.333333333333
There is a bug in Python 2.4 which allows future statements after other statements, so I need to check with other versions of Movable Python. If it works, I'll stop worrying.
Like this post? Digg it or Del.icio.us it.
Posted by Fuzzyman on 2006-03-23 12:03:37 | |
Categories: Python, Projects
Web Apps on a Stick
A user reports having cherrypy and pysqlite working with Movable Python.
There is currently an issue with SQLObject, but reports on the py2exe mailing list indicate that this should be easily resolvable.
Update
It turns out that the problem only occurs from the IPython shell.
SQLObject works fine when used within an application.
Like this post? Digg it or Del.icio.us it.
Posted by Fuzzyman on 2006-03-23 12:02:37 | |
Categories: Python, Projects
Duck Typing & Containers
I have ranted before about duck typing in Python.
Most of the time it's great, but because of the extremely loose definition of the mapping and sequence types, you can get unstuck if you ever need to know whether an object is a mapping type or a sequence type container [1].
You can't easily tell the difference, because any object that has a __getitem__ method [2] could be either.
I've come up with a quick hack to tell them apart.
It relies on the fact that if you index a sequence with anything other than an integer, you get a TypeError. If you index a mapping type object (e.g. a dictionary) with something that isn't contained in it, you get a KeyError.
My first approach used a complex number as the index :
>>> a_list = [] >>> a_dict = {} >>> index = (0+ 6j) >>> a_list[index] Traceback (most recent call last): File "<input>", line 1, in ? TypeError: list indices must be integers >>> a_dict[index] Traceback (most recent call last): File "<input>", line 1, in ? KeyError: 6j
The problem with this, is that a complex number can be a dictionary key. If the index (0+ 6j) does return a value, then it was obviously a mapping type container.
The following hack is an alternative approach. It creates an unhashable object that raises a KeyError if you use an instance to index a mapping object.
If you need to tell the difference between a mapping and a sequence container, index it with our FakeIndex. If the error raised is a TypeError then it is a sequence [3], if it is a mapping container then a KeyError will be raised.
def __hash__(self):
raise KeyError('Unhashable')
index = FakeIndex()
try:
some_object[index]
except TypeError:
# It's a sequence
except KeyError:
# It's a mapping
This only works if the mapping type container uses hashing under the hood for testing membership. It may be safer to just test for indexing a sequence. If that fails, then you can assume the object is a mapping type container.
Like this post? Digg it or Del.icio.us it.
Posted by Fuzzyman on 2006-03-22 12:02:37 | |
Categories: Python, Hacking
ConfigObj 4.3.0alpha
The Pythonutils SVN Repository now contains an alpha version of ConfigObj. This will become ConfigObj 4.3.0.
I hadn't intended to move so quickly from 4.2.0 to 4.3.0, but some interesting discussions on the configobj-develop list have led to some fairly major feature enhancements.
These are all implemented and tested, but they do raise a couple of issues and as usual I'd like to see people kicking the code before I do a new release.
The new features include :
- Support for a copy mode in validation, allowing you to create a default config file with comments from your configspec.
- Support for reading empty values (key = and key = # comment) as an empty string.
- A new write_empty_values option/attribute that will write the empty string as empty values.
- A new unrepr mode. Explained below.
I have also discovered and fixed three bugs [1] :
- Line terminators were incorrectly written on windoze.
- Last occurring comment line could be interpreted as the final comment if the last line wasn't terminated.
- Nested list values would be flattened when write was called. Now sub-lists have a string representation written instead.
Finally the encode and decode methods have been deprecated. I didn't deprecate rename as it should be used with walk to transform key and section names. encode and decode are still good examples of this by the way. [2]
copy mode for validate
Thanks to Louis Cordier for this suggestion. When you supply a configspec you can specify default values to use for any that are missing from the config file.
Normally when you call the validate method it marks any missing values as having been supplied from the default. If you then call write it doesn't write out any values supplied from defaults (unless you change them). This allows you to keep a config file with only values that are different from the defaults.
The validate method now takes an optional copy keyword argument. If this is True, then none of the values are marked as default. In addition all the comments are copied across from the configspec, as are the indentation and encoding settings.
A call to write will then write out a new config file with all the default values specified in the configspec.
This does however lead to me realise that there is currently no way to specify the encoding of a configspec file.
Update
ConfigObj 4.3.0 alpha 2 now allows you to pass in a ConfigObj instance as your configspec. This is not a total solution, but does allow you to read the configspec using ConfigObj, and specify the encoding when you do that.
In order to read a configspec file, you must use the option list_values=False.
unrepr mode
This was suggested by Kevin Dangoor the lead developer of Turbogears [3]. It mimics the unrepr mode of the CherryPy Config Module, and in fact uses the code from cptools.py.
If you pass in the unrepr=True keyword when you create your ConfigObj instance, every value is parsed using unrepr. This allows you to have the following types as values :
integers, strings, True, False, None, floats, complex numbers, lists, dictionaries, tuples
You can use multiline values with unrepr.
When writing in unrepr mode, the built in function repr is used to turn every value into a string.
Note that in unrepr mode :
The value 3.0 is a floatThe value "3.0" is a string
Quote marks take on the same significance as they have in Python syntax, which is different from normal ConfigObj syntax.
Like this post? Digg it or Del.icio.us it.
Posted by Fuzzyman on 2006-03-20 12:48:44 | |
Categories: Projects, Python
Job
Well... the unthinkable has just happened. Someone has offered me a job programming in Python.
Once I have worked my notice at my current job, I will start work with ResolverSystems. They are a small team, all seemingly good guys [1], working on something new using some radical programming techniques.
I'm a bit blown away by the news, so I think I'll shut up now.
Like this post? Digg it or Del.icio.us it.
Posted by Fuzzyman on 2006-03-20 11:12:10 | |
Movable Python & __future__
Movable Python supports running both Python scripts and .pyc bytecode files. It does this by compiling scripts to bytecode, or extracting the code object from bytecode files, and then calling exec.
When you call compile you can pass in an optional flags argument which tell Python which future statements to compile the code with. I currently don't do this, which means that from __future__ import ... statements are ignored.
For Python 2.4.2 the most significant of these is division. Code which expects integer division to yield floats is just plain broken if this future statement is ignored.
I'd like to fix this in the next release of Movable Python.
First of all, I assume that the code objects contained in bytecode files are already compiled with the relevant future statements. This would mean that no further action is necessary. Can anyone confirm if this is correct ? [1]
For Python scripts there are a couple of possible approaches.
The simplest approach would be to use a simple regular expression to find statements that look like from __future__ .... Unfortunately this could score false positives for comments and docstrings. [2]
Another alternative would be to parse the code into an abstract syntax tree using the compiler module. I would then have to recognise the import statements in the nodes. I can see that there is an Import node does anyone have any hints for me with this approach ? I would prefer a solution that works across Python versions 2.2 to 2.5 and beyond.
Ominously, the compile.compile function has unsupported options for passing in flags, so it looks like it doesn't handle it automatically from the parse tree.
Like this post? Digg it or Del.icio.us it.
Posted by Fuzzyman on 2006-03-20 10:21:58 | |
Categories: Python, Projects
Movable Python & Consoles
With the forthcoming releases of Python 2.4.3 and 2.5 alpha 1, it will soon be time to do a new Movable Python release.
The changes (mainly minor at this stage) will include the following :
- A fix to allow you to do things like movpy - pylab. This will make it easier to use matplotlib with Movable Python. [1]
- A fix so that imp.find_module works.
- Support for __future__ imports in code.
- A change to the way that consoles are launched.
I will discuss item 3 in the next entry, here I will discuss item 4.
Currently Movable Python lets you decide whether a script launched from the GUI will have a console box or not. By default scripts launched from movpyw.exe don't have a console, and scripts launched from movpy.exe do. You can override this using the console checkbox.
I'm considering changing this to following the way normal python behaves. Scripts ending with .py will have a console, scripts ending with .pyw won't. Does anyone object to this change ?
It does make it slightly more complicated, as you will no longer have a single checkbox to dictate whether a script launched from the GUI will have a console or not. I currently find it quite useful to be able to easily specify whether or not a console box will be used, so I'd be interested in any ideas as to how that could be maintained.
My current best idea involves three checkboxes. One to toggle default behaviour on and off and two to reverse defualt behaviour for .py and .pyw files.
Like this post? Digg it or Del.icio.us it.
Posted by Fuzzyman on 2006-03-20 09:50:39 | |
Categories: Projects, Python
Movable Python Review - in English
Now that there is a new issue of the c't Magazine available, I can publish an English translation of the Movable Python review.
This translation was very kindly provided by Peter Otten. Many Thanks.
Python abroad
The space saving but plentiful Python distribution Movable Python is ready. It is intended as a complete environment that you can take with you from one Windows PC to another Windows PC on a USB-Stick, for example. The uncompressed package requires only 60 MB. Without the provided libraries for programming graphical user interfaces 15 MB will suffice.
Movable Python will not interfere with other Python installations. You don't have to store anything on the hard disk, and running the distribution doesn't require administrator rights. The three versions of the distribution support Python versions 2.2, 2.3, and 2.4. With these you can check programs for backward compatibility quite easily.
Movable Python welcomes the user with a small window that lets you invoke various functions, like executing a Python script on the hard disk or the USB stick or starting one of the provided development environments, SPE, IDLE, or IPython. Four freely configurable buttons allow fast access to scripts.
Your own scripts and the provided applications can make use of an extensive collection of included libraries, like the Python accelerator psyco, the document manager firedrop2, pycrypto for encryption, pyenchant for spellchecking, or PIL for image manipulation. The wxPython library is provided for GUI programs. The win32 and ctypes extensions allow access on DLLs, ActiveX, COM and type libraries.
Movable Python costs about EUR 7.50. An evaluation version free of charge is (not yet) available.
(Torsten T. Will/ola)
[Image comment] In the simple mode of the Movable Python window captions of the controls are terse, in expert mode the user is overwhelmed by options.
The free evaluation version is now available of course.
I will do the next update of Movable Python shortly after the Python 2.5 release. This will adress a few minor issues (discussed in my next couple of posts). After that I have some fairly major ideas which will make the GUI easier to use (as well as adding functionality) - addressing the review description of the GUI as terse and overwhelming.
Several of these ideas come from Torsten the reviewer, many thanks.
Like this post? Digg it or Del.icio.us it.
Posted by Fuzzyman on 2006-03-20 09:39:53 | |
Categories: Python, Projects, Writing
It's All Happening
Python is racing ahead. Guido is setting up a new mailing list for Python 3000. This will discuss the time-scale (probably 2-3 years), implementation and migration. He is reserving a series of PEP numbers specifically for Python 3000 features. He has already set up an SVN Branch to play with implementations.
There is now a Python 2.4.3 Freeze for release this Thursday. (23rd March.)
Python 2.5 alpha 1 is set for release in a couple of weeks.
Like this post? Digg it or Del.icio.us it.
Posted by Fuzzyman on 2006-03-20 09:29:26 | |
Nanagram on Softpedia
You can now download the demo version of Nanagram from Softpedia. Yaay...
They even generated their own screenshots for it.
Like this post? Digg it or Del.icio.us it.
Posted by Fuzzyman on 2006-03-19 14:00:14 | |
Python Documentation & Epydoc
For a long time Epydoc has been virtually the only tool [1] for autgenerating API documentation from docstrings in Python code.
Unfortunately, because it worked by importing modules, it wasn't compatible with some projects (notably Twisted) and couldn't document variables. Version 2.1 of Epydoc was released around two years ago, and it seemed to be languishing.
At last it has had an update, and Epydoc 3 now supports extracting information about Python modules by parsing.
As a result, it can extract "docstrings" for variables.
This is good news.
Like this post? Digg it or Del.icio.us it.
Posted by Fuzzyman on 2006-03-19 13:43:04 | |
Categories: Python, Tools
Archives
This work is licensed under a Creative Commons Attribution-Share Alike 2.0 License.
Counter... | http://www.voidspace.org.uk/python/weblog/arch_d7_2006_03_18.shtml | CC-MAIN-2016-50 | refinedweb | 3,613 | 66.33 |
Re: User Authentication, Active Directory and more (help)
From: Joe Kaplan \(MVP - ADSI\) (joseph.e.kaplan_at_removethis.accenture.com)
Date: 06/21/04
- Previous message: Edmond Goon: "RE: forms authentication-but do not write cookie to client machine"
- In reply to: Timothy Parez: "Re: User Authentication, Active Directory and more (help)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Mon, 21 Jun 2004 09:12:23 -0500
When you are using Windows authentication in IIS and ASP.NET, the roles in
the IPrincipal that gets created will be Windows groups, so they will be of
the form Domain\Group Name.
I order to make sure you are using Windows authentication in IIS, you must
disable anonymous access and enable Basic, Digest or Integrated
authentication. Don't use Basic without SSL or you will be passing
credentials in plain text over the network. In ASP.NET, you need to make
sure the authentication tag in web.config is set to Windows (which is the
default).
In order to authenticate users in Active Directory, the IIS server must be a
member of the Active Directory domain.
If you want to build your own authentication scheme using
System.DirectoryServices or something, then you will also be responsible for
building the IPrincipal object that contains the user's roles. This sample
of Forms authentication with System.DirectoryServices is an okay starting
point.;en-us;326340
HTH,
Joe K.
"Timothy Parez" <tpsoftware@users.sourceforge.net> wrote in message
news:40D67AC6.7030502@users.sourceforge.net...
> Hey,
>
> Thnx for all the information.
>
> I would like to ask you for some more help :)
>
> I tried using the following in my web.config file but it doesn't really
work
>
> <system.web>
> <authentication mode="Windows"/>
> <authorization>
> <allow roles="Admins" />
> <deny users="*" />
> </authorization>
> </system.web>
>
> I have also played with these values, but either I get a logon screen
> but I can never logon, or I don't get a logon screen and get a page that
> I'm not authorized to view that page right away.
>
> In any case I don't think this will be the best option for me.
>
> Using the DirectoryServices namespace, can I take a username and
> password and validate it against the AD from my code
>
> ie. is there something like (I know seems stupid but I must ask)
>
> if (User.Authenticate("username","password"))
> {
> MessageBox.Show("Welcome");
> }
> else
> {
> MessageBox.Show("Try again m8");
> }
>
> This would be a lot better than the logon provided by ASP.NET (more
> compatible and usable in code)
>
> Thnx for you help.
>
> Timothy.
- Previous message: Edmond Goon: "RE: forms authentication-but do not write cookie to client machine"
- In reply to: Timothy Parez: "Re: User Authentication, Active Directory and more (help)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ] | http://www.derkeiler.com/Newsgroups/microsoft.public.dotnet.framework.aspnet.security/2004-06/0201.html | CC-MAIN-2013-48 | refinedweb | 459 | 55.95 |
copy file - Java Beginners
CopyFile{
public void copy(File src, File dst) throws IOException...copy file i want to copy file from one folder to another
...(String[] args) throws Exception{
CopyFile file=new CopyFile();
file.copy(new
FTP file copy problem? - Java Beginners
need local file time like (Today, December 29, 2009, 5:09:33 PM). Below code I am...FTP file copy problem? Hi,
Can any one tell me how to set file...-net-1.4.1.jar to copy files from local system to server.
Eg: local file name ?test.doc
Java Copy file example
Copy one file into another
Copy one file into another
In this section, you will learn how to copy content of one file into another
file. We a file to other destination and show the modification time of destination file
;
This is detailed java code that copies a source file to
destination file, this code... source file in the same directory
where java code file has been saved... Copy a file to other destination and show the modification time
How to copy a file
;}
}
The above code makes a copy of the file...How to copy a file
In this section, you will learn how to copy a file using Java IO library. For
this, we have declared a function called copyfile() which
File copy through intranet - Java Beginners
File copy through intranet Can i copy files from system A to System B connected through intranet??
Is this possible through java IO?
If yes, please let me know
Jsp error when i run this a jsp file
Jsp error when i run this a jsp file hi
I got this error when i run the jsp file in IDE and outside also
please help me...)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
Please post your code
Copy one file into another
Copy one file into another
In this section, you will learn how to copy content of one file into another
file. We will perform this operation by using... you a clear idea :
Example :
import java.io.*;
public class CopyFile
Copy Directory or File in Java
Copy Directory in Java
...
and destination directory or file name.
Here is the code of the program : ...;
Introduction
Java has
File Handling - Java Beginners
File Handling Thanks for replying me.. but i am sorry to say... datas and close the file... when i select a file for first time the program... that file i can see that text what i typed in comsole window.. If i run my program
jar file - Java Beginners
jar file jar file When creating a jar file it requires a manifest... resources associated with applets and applications.What is Manifest file?When you... specific files from a JAR filejar xf jar-file archived-file(s)* To run
Copy Files - Java Beginners
into a .txt file, importing that, and then somehow having Java read the filenames...Copy Files I saw the post on copying multiple files () and I have
... to another file. We will be declaring a function
called copyfile which copies the contents from one specified file to
another specified file.
copyfile(String
not able to run in gcj file - JDBC
not able to run in gcj file We have a java program in Linux... to run the java program it says that Classes12.Jar?s oracle Driver missing. We... the GCJ compiled Java Program. ?./Test?
When we tried the same program
take variables in text file and run in java
take variables in text file and run in java I have a text file which have variables
17 10
23 39
13 33
How to take "17"in java code
Applet run with appletviewer but not in browser, any code problem.
File Handling - Java Beginners
File Handling Q. Write a java prg which accepts a list of existing...(e.getMessage());
}
}
}
its prg of copying file Check code...;
fout3.write(ch);//copy contents of f1 to f3
if((ch>='A')&&(ch<='Z
java run time error - Java Beginners
java run time error i am getting error "main" java.lang.NullPointerException" in my program, iam sending code actually motive of program... be avoided in this program context?
my program code is
import java.io.
Run this code..plzz - Java Beginners
Run this code..plzz Hi Friend...
ERROR:
Exception in thread "main...;Hi friend,
I am sending code according to your requirement but you are defined in this example what you want to do please explain and send me full code
Setup file - Java Beginners
Setup file Hello sir ,how i can make Java Programs Set up File... and Throws,Can U give me Simple code to Differ Throw and Throws ? Hi Friend... Exception ("can't be divided by zero");
Whereas when we know that a particular
Copy file in php, How to copy file in php, PHP copy file
. It returns the true or false Value.
Copy file example code
<?php...
Learn How to copy file in php. The PHP copy file example explained here.... The copy function in PHP is used to copy the content of one file into another file
when sending the mail from java I am getting the below error - JavaMail
when sending the mail from java I am getting the below error
when sending the mail from java I am getting the below error
:
Exception... not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:/mail/mail.jar,file
how to run a .exe file in jsp
how to run a .exe file in jsp i want code for to run a .exe file in jsp
how to run - Java Beginners
how to run how to run java program...
brifely Hi... to execute or run the program. For ex, If you have the following java program... file on the command prompt using: "javac HelloWorld.java". And then run it using
FILE
related to appliances.I want to read the contents of this file and I used the code... for the error and make the code free of compilation errors.
Java Read...;Java Read content of File
import java.io.*;
public class Appliance {
public
Convert CSV to excel File - Java Beginners
to convert that CSV file to excel file and format.
Currently i am using HSSF POI api to format the excel file. Here i am unable to read the data from the CSV file. When trying to read from CSV, " Invalid header" exception is coming up Write To File Append
to run simply type as :
java
WriteToFileAppend
Output :
When you...Java Write To File Append
In this tutorial you will learn how to append the text when you are writing in a text file.
Appending a text means that the text
Copy and pasting - Java Beginners
Copy and pasting hi all, I am copying some cells from excell... JPopupMenu popup; JTable table; public BasicAction cut, copy, paste, selectAll...); copy = new CopyAction("Copy", null); paste = new PasteAction("Paste",null)
Copy multiple files
copyfile()
copies the contents of all given files to a specific file. When all...
Copy multiple files
...
is copied to another file. The java.io package provides this
facility
File I/O - Java Beginners
;Hi Arnab,
Please check the following code. Run this code at command line...File I/O Suppose a text file has 10 lines.How do I retrieve the first word of each line in java?
abc fd ds 10
fg yy6 uf ui
.
.
.
.
.
.
yt
Java Write To File From String
Java Write To File From String
In this tutorial you will learn how to write to file from string.
Write to file from string using java at first we will have... simply type as :
java WriteFileFromString
Output :
When you will execute
Executale File - Java Beginners
Executale File Plz tell me how to convert java file into .exe file... jsmooth-0.9.9-7.zip extract it.. Run the jsmoothgen.exe file And follow the instruction.. Good Luck i don;t know how to create the exe file for java
Java File - Java Beginners
Java File Hi Friend,
Thank you for the support I got previously...
Anyone please send me the Java Code for scanning a directory and print....
Output
Print the file names and size of the file to the console.
Please
Download a file - Java Beginners
Download a file Hi,
I need a java code to download a file from a website and before downloading it should give me an option to browse and select the location to put the file.
Thanks in advance
file uploading - Java Beginners
file uploading hi,
i am developing one stand alone j2se programming in that i have to upload a file to another system in the LAN and have to download from the server .i am using java.io. and java.net and swing .the task Write To File By Line
Java Write To File By Line
In this tutorial you will learn how to write to file by line
Write to a file by line using java you can use the newLine()
method... the program
And after successfully compilation to run simply type as :
java
Java File Management Example
Java File Management Example Hi,
Is there any ready made API in Java for creating and updating data into text file? How a programmer can write code for reading the text file?
What is best way to read a text file in Java
File Handling in Java
File Handling in Java Hi,
While opening a file in Java developers are using following type of code:
File myFile=new File("myfile.txt");
I was trying to find some tutorials about handling file in Java on net. I have also seen
code - Java Beginners
code hello sir
i am doing project on java
for that i want a program for deleting the files from recycle bin
can you give me that code ...
actually i written code like this.. but run time error is coming..
import java.io.
tokenizing a java file
tokenizing a java file Hi i am new to java and i am trying to build lexecal analyser for java code , I am in the beginning want to read the file... it in string then put the tokens into array of string ,but after run the code
doc file - Java Beginners
doc file i want to read .doc file ?....it is a part of my project plz help.
if possible , can anyone give me the code
Am i convetrting the code right ? - Java Beginners
Am i convetrting the code right ? C#
private void button...; sp.WriteLine("Hello World!"); sp.Close();}
Java
Enumeration pList... (IOException ex) { }// i also tried the code below// try
Java Write To File CSV
Java Write To File CSV
In this tutorial you will learn how to write to file... that
is in a tabular form. In java to create a csv file is simple, you would require...
And after successfully compilation to run simply type as :
java WriteToFileCsv
File Writing - Java Beginners
File Writing Hi... I need a syntax or logic or program by which we can write into the desired shell of the Excel file from console window... Hi friend,
I am sending you a link. This is will help you. Please
File Handling - Java Beginners
content of the file has been replaced by the new content.. I need a code...File Handling I have written one program by which we can create a file , store any information in that,and resume that file using a user
Java File Download Example
();
}
}
When you will run the example you will get the new file named...Java File Download Example
To make an application that downloads the file from.../beginners/CreateDirectory.java");
Here
Reading a file from Jar JAVA
file.
can anybody tell me how i can read that file.
actually when i am running code from eclipse i able to read it but when i am adding that jar file in to project i am unable to read it(code not throwing any Exception).
is there any
How to format text file? - Java Beginners
***(Java code)
How to open,read and format text file(notepad) or MS-word... friend,
I am sending running code. I hope that this code will help you.../example/java/io/java-read-file-line-by-line.shtml
Thanks
Java code to convert pdf file to word file
Java code to convert pdf file to word file How to convert pdf file to word file using Java
java - file delete - Java Beginners
java - file delete I will try to delete file from particular folder. My code is executed correctly in other project and main function. In same... following code to delete a file from the folder
import java.io.File;
public
How to generate build.xml file
you make a java file in
the src folder and run with ant command, the jar file... build.xml file is used to create directory, compile source code, create
jar file... the above code and give appropriate path;
then run with ant command
How can store image in server folder when deployed with a .war file?
How can store image in server folder when deployed with a .war file? Hi all;
When I am using application.getRealPath() , it return null when deployed with a .war file and when I use hard code it shows syntax error or path
java - Java Beginners
java how to write a programme in java to copy one line file to another file.name of file are entered through a keyboard Hi Friend,
Try...();
System.out.println("Destination File");
String f2=input.next();
copyfile(f1,f2
java - file delete - Java Beginners
java - file delete I will try to delete file from particular folder. My code is executed correctly in other project and main function. In same... will try to delete these files. But it doesn?t delete from this folder.
My code
java jar file - Java Beginners
java jar file How to create jar Executable File.Give me simple steps to create jar files Hi Friend,
Try the following code:
import... int buffer = 10240;
protected void createJarArchive(File jarFile, File
copy() example
Copying a file in PHP
In this example, you will learn 'how to copy a file in PHP programming language?'
For copying a file, we use copy command from source to destination within PHP code tag like
copy ($source,$destination);
Lets
Using Ant to execute class file
;
This build.xml file is used to compile and run the java file and
print the value on command prompt. Here we are using five...;; third one is used to compile the java file from
"src" directory
convert .txt file in .csv format - Java Beginners
good.
I am looking to convert .txt file in .csv format.
The contents might have... want export these contents to a .csv file. I am aware that I need to use... the name:value pair in a .csv file.
I am interested in message at console
doesnt run again - Java Beginners
error for the next line
just like i have to start a new main code
so plz tell the soltion
Hi
I am sending u again the code, this code run in my...doesnt run again the code u sent doesnt run
and the error msg says
Java error reading from file
Java error reading from file
Java error reading file are the common error occurred in java that when
the user encounter a corrupt file
Java Write To File Dom Document
Java Write To File Dom Document
In this tutorial you will learn how to write... to compile the program
And after successfully compilation to run simply type as :
java WriteToFileDomDocument
Output :
When you will execute this example a file
Java - Copying one file to another
:\nisha>java CopyFile a.java Filterfile.txt
File copied...
Java - Copying one file to another
... how to copy contents from one
file to another file. This topic is related
How to upload and save a file in a folder - Java Beginners
and save a file in a folder?
for example
Agreement.jsp
File:
So when... should be able to access the file.
Can u please tell me the code..
...,
Thanks for your code....
Do i need any jarfiles to be placed in lib?
Java
file
file how can copy the information in the file to the string?
Store file data into String
Java - Java Beginners
Java Write a program to copy the contents of one file to another...,
Try the following code:
import java.io.*;
public class CopyFile{
private static void copyfile(){
try{
File f1 = new File("data.txt | http://www.roseindia.net/tutorialhelp/comment/12559 | CC-MAIN-2015-11 | refinedweb | 2,753 | 73.98 |
Hello
I'm new to programming in general and this was one of the assignments I did. I was suppose to create a class called employee that includes three pieces of information as data members - first name, last name, monthly salary. Then was suppose to write a test program that demonstrates class Employee's capabilities. SO create two Employee objects and display each object's yearly salary. Then give each Employee a 10 percent raise and display each Employee's yearly salary again.
Heres the .cpp code
#include<iostream> #include "employee.h" using namespace std; Employee e1,e2; // create two objects for class employee char *gets(); // Function DEFINED to return a new string entered by the user void print(); // Function to print the details of the 2 employees. int main() // Main starts here { int temp; // temp variable to hold salary of employee // 1st employee details entered by user cout <<"\n Enter the first name of 1st employee:: "; e1.setName(gets()); cout <<"\n Enter the last name of 1st employee:: "; e1.setLastName(gets()); cout <<"\n Enter the salary of 1st employee:: "; cin >>temp; e1.setSalary(temp); // 2nd employee details entered by user cout <<"\n Enter the first name of 2nd employee:: "; e2.setName(gets()); cout <<"\n Enter the last name of 2nd employee:: "; e2.setLastName(gets()); cout <<"\n Enter the salary of 2nd employee:: "; cin >>temp; e2.setSalary(temp); // OUTPUT STARTS cout <<"\n\n\n \t\t\t:: Output starts here ::"; print(); // call function to print the details of the two employees e1.setSalary((int)e1.getSalary()*1.1); // Increment salary by 10% e2.setSalary((int)e2.getSalary()*1.1); cout <<"\n\n\n \t\t\t:: Salary Incremented ::"; print(); // Again print details after increment return 0; // finish main() } char *gets(){ char n[21]; scanf("%s",n); return n; } void print(){ cout <<"\n Name of 1st employee: "<<e1.getName(); cout <<"\n Last Name of 1st employee: "<<e1.getLastName(); cout <<"\n Salary of 1st employee: "<<e1.getSalary()*12; cout <<"\n\n Name of 2nd employee: "<<e2.getName(); cout <<"\n Last Name of 2nd employee: "<<e2.getLastName(); cout <<"\n Salary of 2nd employee: "<<e2.getSalary()*12 <<endl; }
and heres the employee.h code
class Employee { private: char *name,*lastname; // String of name and last name; int salary; public: Employee() // Constructor to initialize default values. { salary=0; name=""; lastname=""; } char *getName(){ return name; // return pointer to the name; } void setName(char* n){ name=n; //set name to the name passed in parameter. } char *getLastName(){ return lastname; // return pointer to the lastname; } void setLastName(char* n){ lastname=n; //set lastname to the name passed in parameter. } int getSalary(){ return salary; // return salary from object. } void setSalary(int s){ if (s<0) // check if salary is 0 or not. salary=0; else salary=s; } };
I didn't think I did anything wrong but when I run the program I get the screenshot posted. Is that something that is wrong with my code? Also I'm using Visual C++ IDE
Also hopefully this doesn't fall under your warning for homework help, I really want to learn this but don't know whats going on. | https://www.daniweb.com/programming/software-development/threads/309996/employee-class | CC-MAIN-2016-50 | refinedweb | 518 | 64.61 |
branch multi-tenancy causes confusion about ownership
Bug Description
Branch multi-tenancy undermines the primary communities ability to manage it's data. Project maintainers want to set a policy of who has access to project's private data, but it is not necessarily true that the primary contributors (the maintainers) own the project data.
The project maintainers can, and do, make their branches private, which makes all stacked branches transitively private. Thus while a policy might permit another community to create private branches, it is not possible because they do not have access to the base branch. Branch multi-tenancy assumes that all branches are public, that users have access to base branches, which has not been the case since branch stacking was introduced. It is clear that Lp does recognise that the project maintainer does have the right to control their branch data, but it implies that this is not true.
Users need to be a member of the owning or subscribing team.
I have doubts about that requirement. Branches have a dual ownership project and owner. What you are suggesting here is that one owner (the project) preempts the other (the person owning the branch).
Wouldn't this precludes use cases like a team is working on an upstream project for an under-the-radar feature (exclusive launch then merged upstream, like we do in some OEM projects). The work should be in a private branch, but the upstream project owner shouldn't necessarily have access to it until the sponsor feels it's ready to merge back.
With this constraint in place, that use case would have to be serviced by creating a 'fork project' only to manage the maybe temporary secret fork.
If that requirement only applies to private projects, I think it could work. (Since by definition, nobody else can create branches on such a project).
The underlying requirement for this bug is a statement from Canonical managers that Canonical staff should have access to Canonical's code. The subscription mechanism is a burden, see bug #474048. The goal is to minimise the number of steps and maybe their frequency so that an organisation can confidently share its code with its members.
This could apply to just private projects, but I believe Canonical would be dissatisfied. ISD and U1 will always have some public projects with private branches. Conversely, HWE will commonly be working with public projects that they do not own, but need to contribute to.
If we supported nested projects, we could build a hierarchy of projects under canonical's porject and set the policy exactly once for the Canonical team in Canonical's projects.
I don't think we should design this in a bug; I'd like to take it
offline till the thunderdome and drill in there - this seems to have a
thorny nest of issues which we're also running into in the security
bug context: shared namespaces, disclosure and visibility.
This bug can be closed when we dismantle the branch visibility policy that enables multi-tenancy on branches.
William, mark this fix released when we enter the Sharing beta.
They don't need a subscription today, do they?
On 4/01/2011 9:40 AM, "Curtis Hovey" <email address hidden> wrote:
Public bug reported:
project maintainers, drivers, bug supervisors, and security contacts
should always have access to private branches. They should not need a
subscription to access their own project's private artefacts.
** Affects: launchpad
Importance: High
Status: Triaged
** Tags: disclosure
--
/bugs.launchpad .net/bugs/ 696956
You received this bug notification because you are subscribed to
Launchpad Suite.
https:/
Title:
Allow users in project roles to access private branches | https://bugs.launchpad.net/launchpad/+bug/696956 | CC-MAIN-2017-47 | refinedweb | 611 | 60.75 |
Plant Physiol, April 2003, Vol. 131, pp. 1529-1543
Max Planck Institute of Molecular Plant Physiology, Am
Mühlenberg 1, 14476 Golm, Germany (J.T.v.D., P.G.); Institute for
Phytosphere Research, Forschungszentrum Jülich, 52425 Jülich, Germany (U.S.); and Botanisches Institut der
Universität Heidelberg, Im Neuenheimer Feld 360, 69120 Heidelberg, Germany (M.P.) µm.next to the
phloem loading sitesoxygen an increase in lactate and ethanol. Suc concentration and
translocation decreased when oxygen was decreased to 3% and 0.5%
(v/v). Falling oxygen led to a progressive increase in amino acids,
especially of alanine, -aminobutyrat, methionine, and isoleucine, a
progressive decrease in the C to N ratio, and an increase in the
succinate to malate ratio in the phloem. These results show that oxygen concentration is low inside the transport phloem in planta and that
this results in adaptive changes in phloem metabolism and function.
In contrast to animals, plants lack
specialized systems for oxygen distribution. Oxygen moves by diffusion
from the surrounding air (21% [v/v] oxygen) through apertures in the
epidermis and intercellular air spaces within the tissue (Drew,
1997). The absence of specialized systems for oxygen delivery
is not generally considered to be a problem for plant growth and
metabolism because most plant organs have a relatively high
surface-to-volume ratio, and their respiration rates per unit volume of
tissue are usually lower than in animals because plant cells usually
have large vacuoles. However, tissues with high metabolic activity do
become hypoxic, especially when they lack large intercellular air
spaces and contain cells that are poorly vacuolated or are
located in the center of organs remote from the sites where oxygen
enters the plant.
In bulky storage organs, including apples (Malus
domestica; Magness, 1920), bananas (Musa spp;
Banks, 1983), avocados (Persea americana;
Ke et al., 1995), carrots (Daucus carota;
Lushuk and Salveit, 1991), and potato (Solanum
tuberosum) tubers (Stiles, 1960;
Geigenberger et al., 2000), internal oxygen
concentrations can be quite low. In growing potato tubers, oxygen
concentrations are significantly decreased in the outer zones of the
tubers, and there is a further decline between the outer zones and the center, where oxygen concentrations fall below 5% (Geigenberger et al., 2000). This is accompanied by adaptive changes in
metabolism including a partial inhibition of respiration, a decrease in
the cellular energy status, and a parallel inhibition of a wide range of energy-consuming metabolic processes. Pyrophosphate (PPi), which is
utilized as an alternative energy donor in plants, is maintained at a
high level under hypoxic conditions, in contrast to the
progressive decrease of the energy status of the adenine, uridine, and guanine nucleotide systems. It has been proposed that these metabolic acclimations allow ATP and oxygen consumption to
be decreased and prevent the tissue of becoming anoxic
(Geigenberger et al., 2000).
Recent studies also document low oxygen tensions within seeds of
Arabidopsis (Porterfield et al., 1999; Gibon et
al., 2002), Vicia faba, and Pisum sativum
(Rolletscheck et al., 2002). In the latter case, optical
sensors were used to analyze detailed oxygen profiles across developing
seeds showing that oxygen decreases sharply to approximately 1% (v/v)
within the seed coat, which suggests that oxygen entry from the
surrounding gas space into the seed is strongly restricted by the seed
coat. There is an increase in oxygen tension upon illumination,
indicating that photosynthesis significantly contributes to internal
oxygen levels in these green seeds (Rolletscheck et al.,
2002).
Based on indirect evidence, it has been suggested frequently that
phloem tissue might be hypoxic. First, specific biochemical and
morphological characteristics could lead to oxygen deficiency within
the phloem. The phloem represents a specialized transport tissue with
high metabolic activity and high respiration rates (Willenbrink,
1957; Geigenberger et al., 1993;
van Bel and Knoblauch, 2000) to provide ATP for active
import and transport of Suc (Komor, 1977;
Bouché-Pillon et al., 1994; DeWitt
and Sussman, 1995; Stadler et al., 1995;
Kühn et al., 1996), and this will result in high local rates of oxygen consumption. Oxygen access might be restricted because it is a rather dense tissue with little intercellular spaces or
vacuoles (Parthasarathy, 1975; Behnke and
Sjolund, 1990). Second, high ethanol concentrations and alcohol
dehydrogenase activities have been reported in the vascular cambium of
trees (Kimmerer and Stringer, 1988), indicating
anaerobic conditions in tissue near the phloem. Third, in root steles,
in which the vascular tissue is embedded in, low oxygen concentrations
have been reported (Thomson and Greenway, 1991;
Ober and Sharp, 1996; Drew, 1997), and a
decrease in external oxygen leads to an inhibition of ion transport
into the xylem (Gibbs et al., 1998). However, roots
differ from shoots in the fact that the external oxygen concentration
is often low, phloem and xylem are located in the stele in the center
of the root, rather than in the periphery, and there is no oxygen
supply by photosynthesizing cells. Therefore, it remains unclear
whether a similar situation exists in the vascular bundles of shoots.
Previous studies indicated that low external oxygen concentration can
have an inhibitory effect on phloem translocation, but results were
contradictory because other workers failed to observe any
significant effect of external anoxia on phloem transport (for
review, see Milburn and Kallarackal, 1989). The
possible reason(s) for this discrepancy could not be resolved
due to the lack of knowledge concerning the impact on the internal
oxygen levels and energy metabolism inside the phloem.
In the following study, the effect of the internal oxygen concentration
on phloem function is investigated and related to a detailed study on
phloem energy metabolism. For this study, Ricinus communis
plants were used. This plant is specifically suitable because pure
phloem sap is easily sampled because the phloem continues bleeding
after it has been incised. Also, seedlings have hypogeous cotyledons
that, until approximately 10 d after germination (DAG), take up
Suc from the surrounding endosperm and load it into the phloem, where
it is transported to the growing hypocotyl and root. The endosperm can
be easily removed and replaced by a Suc solution, whereas the
cotyledons remain to function as active source, thus enabling
controlled manipulation of phloem loading, metabolism, and transport
(Kallarackal et al., 1989; Geigenberger et al.,
1993).
Several direct approaches to analyze oxygen levels and phloem energy
metabolism were used. (a) By using microsensors, in situ oxygen
concentrations were analyzed in stem transects and in phloem exudates
of adult R. communis plants. In exudates samples taken in
parallel, adenylate energy charge and ATP to ADP ratios were analyzed.
These minimal invasive techniques allowed us to investigate oxygen
tensions and energy status in the phloem of an intact plant. (b) To
assess the effect of external anoxia on phloem energy metabolism and
transport, we exposed a stem segment of the plant with gaseous nitrogen
using a plastic cuvette and analyzed phloem sap collected below the
nitrogen girdle. (c) In a complementary approach, we used germinating
R. communis seedlings to study phloem metabolism and
transport in response to oxygen in more detail. The in situ oxygen
concentration inside the endosperm and in hypocotyl transects were
determined by using oxygen microsensors. To manipulate oxygen tensions,
the endosperm was removed and the cotyledons exposed to solutions with
various oxygen concentrations (0.5%, 3%, 6%, and 21% [v/v]).
After 3 h, the hypocotyl was severed and phloem sap was collected
to analyze the concentrations of Suc, amino acids, fermentation
products, glycolytic intermediates, nucleotides, inorganic phosphate
(Pi), and PPi in the sieve tube sap. The data were used to calculate
changes in Suc translocation rates, C to N ratios, adenylate energy
charge, ATP, UTP and PPi phosphorylation potentials, and
NAD+ reduction state in response to a stepwise
decrease in oxygen. The results show that metabolism and phloem
function are modified at the oxygen levels found in the neighborhood of
the phloem in intact plants.
Oxygen Concentrations across the Stem and in the Phloem
Sap Exuding from Normoxic Plants
To determine in situ oxygen concentrations in the phloem,
a microsensor was impaled into the stem of adult R. communis plants growing in normoxic air (21% [v/v]). Oxygen
levels across the transect decreased markedly from 21% (v/v) at the
surface to 7% (v/v) in the vascular region (Fig.
1). Further toward the center of the
stem, in the inner parenchyma tissue, the oxygen concentration increased to 15% (v/v), which is also the oxygen tension in the inner
cavity of the stem. These measurements show that the cells of transport
phloem tissue are exposed to an environment with relatively low
oxygen.
To determine oxygen concentrations within the phloem symplast, phloem
sap exuding from an incision in the bark of the stem was analyzed.
Depending on the size of the droplet and the speed of exudation,
O2 tensions varied between 15% and 19% (v/v;
n = 17 measurements). Because oxygen will diffuse into
the exudate droplet directly after exposure to air, it must be expected
that all these values are overestimations of the actual oxygen
concentration in intact phloem. Small droplets seemed to be affected
more by diffusion of ambient oxygen then bigger droplets were.
Energy Status and Suc Concentration in the Phloem of
Normoxic Plants and in Plants after Application of External
Anoxia
To determine the energy status in the phloem of normoxic R. communis plants, the concentrations of ATP, ADP, and AMP were measured in the phloem sap (Fig. 2,
A-C). The ATP to ADP ratio was 4.1 (Fig. 2D), the total amount of AdN
was 860 µM (Fig. 2E), and the adenylate energy
charge [ATP + 1/2ADP/(ATP + ADP + AMP)] was 0.78 (Fig. 2F).
To investigate the consequences of a decrease in oxygen for energy
metabolism and Suc transport in the phloem, we exposed a 5-cm stem
segment of intact replicate plants to a continuous stream of gaseous
nitrogen (0% [v/v] oxygen) for 90 min. The oxygen concentration
inside the N2-treated stem segment decreased to 2.0% ± 0.34% (v/v) in the peripheral stem tissue and to 3.6% ± 0.24% (v/v) in the hollow central part of the stem (mean ± SE, n = 4). Oxygen concentration also
decreased to 10% to 15% (v/v) in the phloem exudate that was
collected approximately 3 cm below the treated segment. As pointed out
above, this is likely to be an overestimate of the true concentration.
The decrease in oxygen led to a decrease in the energy state of the
phloem. In the phloem exudate collected below the
N2 girdle, there was a 2-fold decrease of ATP
(Fig. 2A), ATP/ADP (Fig. 2D), and total adenine nucleotides (Fig. 2E),
and a decrease in the adenylate energy charge down to 0.68 (Fig. 2F).
The decrease in adenylate energy state was accompanied by a marked
decrease in the Suc concentration in the phloem sap (Fig. 2G). The
concentration of Glc6P decreased only slightly (Fig. 2H). In phloem
exudate collected 3 cm above the treated segment, oxygen and Suc
concentrations remained high (data not shown).
In a further experiment, phloem sap was collected 10 cm below and 10 cm
above the N2 girdle to analyze exudation rate and Suc concentration in parallel (Table
I). There was a 3-5-fold decrease in
exudation rate and a 1.3-fold decrease in Suc concentration below the
nitrogen girdle, compared with the values monitored above the girdle or
in normoxic plants. The data were used to estimate the absolute
rates of Suc translocation (calculated by multiplying exudation
rate and Suc concentration). In stems treated with gaseous
nitrogen, Suc transport rates decreased by 73% and 82% below the
girdle, compared with the rates above the girdle or in control plants
exposed to air respectively (Table I).
Interestingly, substantial levels of oxygen remained inside stem
segments that were exposed to an atmosphere containing zero oxygen. The
oxygen gradient was reversed, increasing from 0% (v/v) at the
surface to 2% (v/v) in the cortex to 3.6% (v/v) in the hollow center
of the stem.
Internal Oxygen Tensions and Phloem Energy Status in
Seedlings
Germinating R. communis seedlings were used to analyze
the influence of oxygen tensions on transport and energy metabolism in
the phloem in more detail. To analyze the in situ oxygen tension in the
vicinity of the cotyledons where phloem loading occurs, an oxygen
microsensor was introduced into the endosperm of both 6- and 10-d-old
seedlings germinating in the dark. The oxygen concentration measured in
the endosperm facing the cotyledons depended on the developmental stage
of the seedling. At 6 DAG, the lowest oxygen tension measured in the
endosperm was 14.3% ± 1.3 (mean ± SE,
n = 5), whereas 4 d later, this value
significantly decreased to 6.3% ± 3.4% (Fig.
3A). This may be related to the higher
rates of respiration as the endosperm is mobilized. In situ oxygen
tensions were also measured in hypocotyl transects. The oxygen
concentration in the inner part of the stem was 11.9% ± 0.8 and
5.0% ± 1.0 at 6 and 10 DAG, respectively (Fig. 3B). This
suggests that developmental changes in oxygen tension within the
endosperm affect the oxygen tension inside the hypocotyl.
After severing the hypocotyls from 6-d-old seedlings, phloem sap was
collected from the residual stump and used for metabolic analysis. The
concentrations of Suc, ATP, ADP, and AMP were 350 ± 8, 1.31 ± 0.06, 0.213 ± 0.02, and 0.08 ± 0.01 mM,
respectively, yielding in an ATP to ADP ratio of 6.1 ± 0.43 and
an adenylate energy charge of 0.88 ± 0.01 (mean ± SE, n = 5 seedlings).
Influence of the Oxygen Tension on Exudation Rate and Suc
Concentration in the Phloem Sap of Seedlings
To investigate the influence of a stepwise decrease in the
external oxygen concentration on phloem transport and energy metabolism in more detail, we removed the endosperm and incubated cotyledons of
6-d-old seedlings in Suc solutions with different oxygen concentrations (0.5%, 3%, 6%, or 21% [v/v]). After 3 h, the hypocotyl was
severed, and phloem exudate was collected for further analysis.
Seedlings which were exposed to 100 mM Suc, and 21% (v/v)
oxygen revealed an exudation rate of around 8 µL
h1 and a Suc concentration of approximately 300 mM in the tube sap (Fig. 4, A
and B). This is in agreement with previous studies by
Kallarackal et al. (1989). When the external oxygen
tension was decreased, exudation rates decreased slightly at 6% (v/v) oxygen (by 20%) and more dramatically at 3% and 0.5% oxygen (v/v; by
60% and 75%, respectively; Fig. 4A). Suc concentration in the tube
sap remained unaltered when oxygen was decreased to 6% (v/v), but
decreased by 20% and 50% when external oxygen was decreased to 3%
and 0.5% (v/v), respectively (Fig. 4B). The estimated absolute rate of
Suc translocation decreased slightly (by 20%) in 6% (v/v) oxygen and
more markedly in 3% and 0.5% (v/v) oxygen (by 64% and 84%,
respectively; Fig. 4C). The results indicate a slight inhibition of
phloem loading and translocation at 6% (v/v) oxygen and a marked and
progressive inhibition at 3% and 0.5% (v/v) external oxygen.
Influence of the Oxygen Tension on the Concentrations of
Nucleotides, Pi, and Inorganic PPi in the Phloem Sap of
Seedlings
Phloem sap derives from a pure cytosolic compartment; therefore,
metabolite analysis will reveal corresponding changes in cytosolic
concentrations of various metabolites, organic acids, Pi, inorganic
PPi, and nucleotides (Geigenberger et al., 1993). Decreasing oxygen tensions led to a progressive decrease of ATP (Fig.
5A), an increase of ADP (Fig. 5B) and AMP
(Fig. 5C), and a marked decrease of the ATP to ADP ratio (Fig. 5D) and
the adenylate energy charge in the phloem sap (Fig. 5E). The overall
concentration of adenine nucleotides in the phloem declined, even
though the incubation only lasted a few hours (Fig. 5F). There were
already marked changes of adenine nucleotides when oxygen was decreased from 21% to 6% (v/v). Total adenylates decreased by 30%, the ATP to
ADP ratio decreased from 8 to 4, and the adenylate energy charge decreased from 0.9 to 0.8. These parameters showed a further
progressive decrease when oxygen was reduced to 3% and 0.5% (v/v). At
0.5% (v/v) oxygen, the ATP to ADP ratio was around 1.5, and the
adenylate energy charge was approximately 0.64. Adenine nucleotide
levels responded in a similar manner to low oxygen concentrations in seedlings and adult plants. The absolute values of total adenine nucleotide concentrations, ATP to ADP ratios, and adenylate energy charge in the phloem of normoxic adult plants (see Fig. 2) resembled those found in the phloem of seedlings incubated with 6% (v/v) oxygen (see Fig. 5). Based on our previous measurements (see Fig. 1),
the oxygen concentrations in the transport tissue of intact adult
plants would have been in this range.
Uridine nucleotides serve as cofactors in the pathway of Suc
degradation via Suc synthase (SuSy) and UDP-Glc pyrophosphorylase (Geigenberger and Stitt, 1993; Loef et al.,
1999). Overall uridine nucleotide concentrations (Fig. 5G)
declined in parallel with the adenine nucleotides. UDP-Glc accounted
for the majority of the uridine nucleotide pool in the phloem and
declined progressively as the oxygen tension was decreased (Fig. 5H).
UTP concentration remained unaltered as oxygen was decreased from 21%
to 3% (v/v), and declined sharply in 0.5% (v/v) oxygen (Fig. 3I). UDP
rose progressively as the oxygen tension was decreased (Fig. 5J). UDP is the substrate of SuSy, which is responsible for Suc mobilization in
the phloem complex. The UTP to UDP ratio fell progressively from
approximately 8 in 21% (v/v) oxygen to 1.7 in 0.5% (v/v) oxygen (Fig.
5K), similar to the ATP to ADP ratio (for comparison, see Fig. 5D).
GTP, GDP, and the overall guanine nucleotide concentrations were
approximately 90% lower than the corresponding adenine nucleotide concentrations and showed a similar response to oxygen (data not shown).
The sieve tube concentration of PPi was high in 21% (v/v) oxygen,
decreased only gradually at 6% and 3% (v/v) oxygen, and fell to very
low levels at 0.5% (v/v) oxygen (Fig. 5L). Pi increased gradually as
the oxygen concentration decreased (Fig. 5M). Because phloem sap is
pure cytosolic, values for Pi can be used to calculate the
phosphorylation potential of ATP, UTP, and PPi directly. The ATP
phosphorylation potential (ATP × ADP1 × Pi1) was approximately 1,200 M1 at 21% (v/v) oxygen, decreased
more than 50% at 6% (v/v) oxygen, and showed a further marked
decrease at 3% and 0.5% (v/v) oxygen (Fig. 5N). The phosphorylation
potential of UTP (Fig. 5O) was similar to that of ATP (Fig. 5N) and
showed the same response when oxygen was decreased. The phosphorylation
potential of PPi (Fig. 5P) was much lower than that of ATP and UTP,
decreased only slightly at 6% (v/v) oxygen, and dropped markedly at
3% and 0.5% (v/v) oxygen.
Influence of the Oxygen Tension on the Concentrations of
Glycolytic Metabolites, Organic Acids, and Ethanol in the Phloem Sap of
Seedlings
Figure 6 summarizes the effect of
low oxygen tensions on glycolytic metabolites and organic acids in the
phloem. The concentrations of Glucose-1-Phosphate (Glc1P),
Glucose-6-Phosphate (Glc6P), and Fructose-6-Phosphate (Fru6P)
increased 1.3-fold when oxygen was decreased to 6% (v/v), remained
high at 3% (v/v) oxygen, and decreased by approximately 50% when
oxygen was further reduced to 0.5% (v/v; Fig. 6, A-C).
Fructose-1,6-bisPhosphate (Fru1,6bP) (Fig. 6D) and dihydroxyacetone phosphate (Fig. 6E) increased only slightly at 6%
(v/v) oxygen, rose 3-fold and 1.5-fold, respectively, in 3% (v/v)
oxygen, and stayed high at 0.5% (v/v) oxygen. Glycerate-3-phosphate decreased gradually (by 40%) from 21% to 3% (v/v) oxygen and
declined by a further 50% at 0.5% (v/v) oxygen (Fig. 6F). Pyruvate
concentration showed a biphasic response increasing nearly 2-fold when
oxygen was decreased from 21% to 6% (v/v), remaining high when oxygen was decreased to 3% (v/v), and decreasing markedly when oxygen was
further decreased down to 0.5% (v/v; Fig. 6G). The concentration of
lactate was approximately 2 mM in 21% (v/v) oxygen,
increased slightly in 6% and 3% (v/v) oxygen, and increased
more dramatically in 0.5% (v/v) oxygen (Fig. 6H). Malate was high (12 mM) in 21% (v/v) oxygen and decreased progressively by
45%, 80%, and 63% in 6%, 3%, and 0.5% (v/v) oxygen, respectively
(Fig. 6I). Succinate concentration was approximately 3 mM
in 21% (v/v) oxygen, did not change in 6% (v/v) oxygen, but increased
up to 5 and 7 mM in 3% and 0.5% (v/v) oxygen,
respectively (Fig. 6J). Ethanol concentration was low (approximately 1 mM), except in 0.5% (v/v) oxygen where it rose
approximately 4-fold (Fig. 6K).
Influence of the Oxygen Tension on the NAD+ Reduction
State in the Phloem of Seedlings
The NAD+ reduction state in the cytosol is
an important parameter of cellular metabolism (Stryer,
1990), reflecting the balance between
NAD+ reduction via glycolysis and NADH
reoxidation via respiratory reactions. However, cytosolic
concentrations of NADH cannot be measured accurately because the
reduction state of NAD+ in the cytosol is very
low and most of the NADH will be bound to enzymes (Heineke et
al., 1991). Alternatively, NADH to NAD+
ratios can be estimated from the concentrations of metabolites supposed
to be in near equilibrium with the NADH/NAD+
couple in the cytosol (Heineke et al., 1991). Assuming
the reaction catalyzed by lactate dehydrogenase is close to equilibrium
in vivo, the NADH to NAD+ ratio can be calculated
according to the following equation:
Influence of the Oxygen Tension on the Concentrations of Amino
Acids and the C to N Ratio in the Sieve Tube Sap of
Seedlings
Amino acids are transported in significant concentrations in the
phloem symplast of R. communis plants (see Komor et
al., 1989; Schobert and Komor, 1989). In 21%
(v/v) oxygen, the total amino acid concentration in the sieve tube sap
of the seedlings was approximately 19 mM (Fig.
7A). Glu (Fig. 7B) and Gln (Fig. 7C) were
the main amino acids transported (contributing to 32% of total amino
acids).
When external oxygen was decreased, the total amino acid concentration
in the phloem rose up to 45, 52, and 71 mM in 6%, 3%, and
0.5% (v/v) oxygen, respectively. There were also major changes in the
pattern of individual amino acids in response to low oxygen. A decrease
in the oxygen tension to 6%, 3%, and 0.5% (v/v) led to a gradual
decrease in the concentrations of Glu, Gln, and Ser (Fig. 7, B-D). The
contribution of Glu, Gln, and Ser to the total amino acid pool in the
phloem decreased markedly from 16.0%, 16.0%, and 17.4% of the total
pool in 21% (v/v) oxygen to 2.5%, 2.1%, and 2.6% of the total pool
in 0.5% (v/v) oxygen, respectively (calculated from the data in Fig.
7, A-D). The concentrations of the other amino acids either decreased
only slightly (Arg and Gly; Fig. 7, S and T) or increased in response
to low oxygen (Fig. 7, E-R and U). There was a massive increase in the
concentrations of Ala (7-fold) and GABA (5.5-fold) when oxygen was
decreased from 21% to 6% (v/v; Fig. 7, E and F). This trend was
further accentuated in 3% and 0.5% (v/v) oxygen, where Ala increased
12- and 14-fold and GABA 5.8- and 6.4-fold, respectively, compared with
21% (v/v) oxygen. Interestingly, under low oxygen, Ala and GABA were
the main amino acids in the phloem, counting for 42% and 15% of the
total amino acids and reaching concentrations of 22 and 8 mM at 3% (v/v) oxygen, respectively. There were also major
increases in the concentrations of Ile (Fig. 7G), Leu (Fig. 7H), Val
(Fig. 7I), Met (Fig. 7J), and Asn (Fig. 7O), whereas Phe (Fig. 7K), Tyr
(Fig. 7M), Asp (Fig. 7N), Thr (Fig. 7P), Lys (Fig. 7Q), His (Fig. 7R),
and citrulline (Fig. 7U) increased only moderately.
From the data in Figure 7, the transport of total N can be calculated
(Fig. 8). In low oxygen, there was a
marked increase in the amount of total N in the sieve tube sap (sum of
all the nitrogen in amino acids; Fig. 8A). Because this was largely
paralleled by a decrease in the exudation rate, there were no
substantial changes in the rate of total N transport (Fig. 8B;
calculated by multiplying the total N in Fig. 8A by the exudation rates
in Fig. 4A), except for 6% (v/v) oxygen, where the total N transport rate was nearly 2-fold increased. The Suc to amino acid ratio was
approximately 15 in 21% (v/v) oxygen and decreased
continuously to 7, 5, and 4 in 6%, 3%, and 0.5% (v/v) oxygen,
respectively (calculated from Figs. 4B and 7A), indicating that low
oxygen affects the C/N balance in the phloem. The C to N ratio in the phloem was calculated directly by dividing the amount of total C (sum
of the carbons in amino acids, calculated from Fig. 7, plus the carbons
in Suc, calculated from Fig. 4A) by the amount of total N (Fig. 8A) in
the tube sap. When oxygen was decreased, there was a continuous
decrease in the phloem C to N ratio from 150 to 25 (Fig. 8C).
Oxygen Concentrations Are Low inside the Phloem in
Planta
Our results indicate that transport phloem is hypoxic. Direct
measurements of oxygen profiles across stems of adult R. communis plants using microsensors showed that oxygen was
decreased down to approximately 7% (v/v) in the vascular regions (Fig.
1), although plants were growing in the light at 21% (v/v) external
oxygen. Oxygen levels down to 15% (v/v) were measured in the phloem
sap exuding from small incisions in the bark. The tissues in which the
transport phloem is embedded in may form a serious oxygen diffusion
barrier. In respect to this, it is interesting that the hollow center
of the stem acts as a buffer to counteract changes in oxygen
availability (Fig. 1). In many stems, the central part has prominent
intercellular spaces or is destroyed during growth (Esau,
1977). Such gas-filled spaces (aerenchyma) are known to facilitate internal oxygen transport (for review, see Drew,
1997), and as shown in the present study, the inner gas space
prevented total anoxia in the stem tissue when external oxygen was
deprived (see above).
Oxygen concentrations also fall to low levels within R. communis seedlings germinating in 21% (v/v) oxygen. Within the
endosperm embedding the cotyledons where Suc is loaded into the phloem, oxygen decreased from approximately 14% (v/v) in 6-d-old seedlings down to 6% (v/v) in 10-d-old seedlings. This decrease during seedling development is reflected in the transport phloem in the hypocotyl (Fig.
3).
The presence of hypoxic conditions within the phloem provides an
explanation why specific SuSy genes like Sh1 from
maize (Zea mays; Yang and Russell,
1990), Asus1 from Arabidopsis (Martin et al.,
1993), and potato StSus3 (Fu and Park,
1995) that are known to be up-regulated by hypoxia are
preferentially expressed in the phloem.
Phloem Energy State and Suc Transport Rate Are Decreased at the Low
Oxygen Levels Found in the Phloem of Intact Plants
This study shows that the oxygen concentrations occurring in the
phloem of normoxic plants (approximately 5%-7% [v/v]) are in a
range where they limit energy metabolism (Fig. 5) and where they start
to become limiting for phloem transport (Fig. 4). When oxygen levels
within the phloem are decreased further, phloem function is severely
inhibited (Fig. 2). This is probably due to decreased Suc import or
reloading (retrieval) into the phloem, resulting from energy deprival
in the tissue.
Energy levels in phloem tissue of normoxic plants are fairly low
already. Under full aerobic conditions, the ATP to ADP ratios measured
in the cytosol of plant leaves or in animal tissues are in the range of
9 to 10 and the adenylate energy charge is over 0.9 (Lilley et
al., 1982; Stitt et al., 1982; Stryer,
1990). In contrast, the values determined for the phloem of
stems of intact normoxic plants are 4.1 and 0.78, respectively (Fig.
2). In seedlings, the phloem energy state (ATP to ADP ratio = 6.1; adenylate energy charge = 0.88) seems to be higher than
in adult stems, but it must be noted that severing the hypocotyl
will increase the access of oxygen from the atmosphere (21% [v/v])
to the phloem tissue in the residual hypocotyl stump. This could have
led to a partial recovery of the adenylate energy state measured in the exudate.
In the case of seedlings, phloem ATP to ADP ratio and adenylate energy
state increased when their endosperm was removed and cotyledons were
exposed to a continuous stream of 21% (v/v) oxygen. This confirms that
the endosperm is acting as a diffusion barrier and that removal of this
barrier allows better access of oxygen to the phloem tissues within the
cotyledons, leading to a relief of energy metabolism within the phloem.
R. communis cotyledons are only 100 µm thick, and the
diffusion path of oxygen from the incubation medium to the sieve
elements is very short (in the 10-µm range; Kriedemann
and Beevers, 1969). When external oxygen around the cotyledons
was decreased from 21% to 6% (v/v), which is comparable with the in
planta oxygen concentration in the vicinity of the phloem in stems, the
adenylate energy state decreased markedly inside the phloem (Fig. 5).
Interestingly, the relation between oxygen tension and ATP to ADP ratio
within the phloem (Fig. 9) is similar to
that previously described for potato tuber discs (Geigenberger
et al., 2000).
All together, this study shows by using three independent parameters,
namely ATP to ADP ratio, adenylate energy charge, and ATP
phosphorylation potential, that a stepwise decrease in oxygen leads to
a progressive reduction in the phloem energy state. Similar parameters
of the UTP and PPi energy systems showed a similar response. Because
phloem sap derives purely from the cytosol, all these parameters could
be measured without complication due to subcellular compartmentation.
This allows a direct comparison of ATP to ADP and UTP to UDP ratios.
Interestingly, these ratios matched very well (compare Fig. 5, K with
D), indicating that the UTP and ATP systems are equilibrated via
nucleoside diphosphate kinase in the phloem symplast. This apparently
contrasts with analyses of whole tissues like leaves (Dancer et
al., 1990) or tubers (Loef et al., 2001), where
the overall values for the ATP to ADP ratios are always smaller than
those for the UTP to UDP ratios. The reason for this difference lies in
the differential compartmentation of adenine and uridine nucleotides in
plant cells. In leaves (Stitt et al., 1982;
Dancer et al., 1990) and tubers (Farré et al., 2001), uridine nucleotides
are predominantly located in the cytosol, whereas adenine nucleotides
are present in the cytosol and the plastid. Subcellular analysis of
leaves (Stitt et al., 1982) and tubers (Tiessen
et al., 2002) demonstrated lower ATP to ADP ratios in the
plastid compared with the cytosol.
Low Oxygen Leads to a Sequential Induction of Fermentative Pathways
and to Large Changes in the Composition of the Phloem Sap
The decrease in oxygen has complex consequences on the composition
of the phloem sap (Figs. 6 and 7). Remarkable are the increased levels
of total N in the phloem under low oxygen (Fig. 8). Two factors appear
to be responsible for this: (a) the massive increase in the
concentrations of Ala and GABA, especially at 6% (v/v) oxygen, and (b)
the decreased loading of Suc, especially at 3% and 0.5% (v/v) oxygen,
leading to a lower phloem flux that will result in a rise in amino acid
concentrations even when the entry of amino acids into the phloem
remains unaltered. Obviously, the transport of N is less sensitive to
low oxygen than the transport of C. The more than proportional increase
in the concentrations of Ala and GABA could be due to a selective
increase in the import of these individual amino acids into the phloem
or to changes in phloem metabolism in response to low oxygen.
The latter alternative is more likely because accumulation of Ala and
GABA has been reported frequently as an early response to hypoxia and
often precedes the accumulation of succinate (Davies, 1980). Ala and GABA are synthesized by Ala aminotransferase and Glu decarboxylase, respectively, both enzymes being induced by low
oxygen (Klok et al., 2002) and using Glu as a common
substrate. Accumulation of Ala and GABA in the phloem was paralleled by
a decrease in Glu (Fig. 7). Ala aminotransferase also leads to the production of oxoglutarate, which is one of the substrates of a
fermentative pathway that leads to accumulation of succinate. This
pathway was initially discovered in facultative anaerobic mollusks
(Hochachka et al., 1973) and is also supposed to be
active in plants (Davies, 1980).
Our results indicate that a stepwise decrease in the oxygen
concentration leads to a successive induction of biochemical pathways in the phloem, resulting in accumulation of Ala and GABA at 6% (v/v)
external oxygen, succinate at 3% (v/v) external oxygen, and lactate
and ethanol at 0.5% (v/v) external oxygen. The onset of lactic and
ethanol fermentation was paralleled by a steep increase in the
estimated cytosolic NADH to NAD+ ratio (Fig. 6L),
which indicates that the phloem is entering anoxic metabolism. Under
these conditions, cytochrome oxidase becomes oxygen limited
(Km [O2] is 14 µM [Drew, 1997], corresponding to 0.01% [v/v] oxygen), ATP formation via oxidative phosphorylation is inhibited, and ATP has to be produced by fermentation (Drew, 1997). In contrast to this, induction of the pathways to Ala, GABA, and succinate occurred at oxygen concentrations that were much
higher than the Km
(O2) of cytochrome oxidase and were not accompanied by any substantial changes in the
NAD+ reduction state. This indicates that these
pathways can be induced well before anoxic conditions are reached. GABA
(Shelp et al., 1999) and succinate (Menegus et
al., 1989) synthesis have been proposed to play a role in
counteracting cytoplasmatic acidification in low oxygen. Recent studies
document that acidosis occurs rapidly and is due to proton-releasing
hydrolysis of nucleotide-5-triphosphates when oxygen falls (Gout
et al., 2001). This will require rapid synthesis of GABA, Ala,
and succinate in response to relatively small decreases in oxygen tensions.
Low Oxygen Leads to Adaptive Changes in Phloem
Metabolism
Based on studies in growing potato tubers, Geigenberger et
al. (2000) concluded that falling internal oxygen leads to: (a) a restriction of glycolysis and respiration that decreases the adenylate energy status, (b) a widespread decrease in biosynthetic activity which decreases ATP consumption, and (c) a switch to pathways
which consume less ATP. They proposed that this represents a metabolic
acclimation to decrease oxygen consumption and prevent the tissue from
driving itself into anoxia. It was clearly separated from the
inhibition of cytochrome oxidase and the switch to lactic fermentation,
which does not occur until much lower oxygen concentrations. Our
results provide evidence for a similar adaptive response in the phloem.
First, there is a continuous decrease in phloem energy state while the
NAD+ reduction state remains low, indicating a
coordinated inhibition of glycolysis and respiration in response to low
oxygen. This occurs at oxygen levels that are far higher than the
Km (O2) of cytochrome
oxidase. The increase in hexose phosphate levels under these conditions
is consistent with an inhibition of glycolysis. Second, there is a
decrease in total nucleotide levels with decreasing oxygen levels,
indicating inhibition of nucleotide biosynthesis in the phloem.
Inhibition of biosynthetic processes will save ATP and reduce
respiration rates. Third, the need to conserve energy and oxygen
provides an explanation why Suc is metabolized by SuSy and UGPase in
the phloem (Geigenberger et al., 1993; Nolte and
Koch, 1993), which costs less energy (only 1 mol PPi
mol1 Suc) compared with degradation via
invertase and hexokinase (2 mol ATP mol1 Suc;
Huber and Akazawa, 1986). Interestingly, phloem
transport is strongly impaired when PPi is removed by phloem-specific
overexpression of pyrophosphatase, indicating an important role of
PPi-dependent Suc degradation via SuSy in the phloem (Lerchl et
al., 1995; Geigenberger et al., 1996). Low
oxygen leads to increased expression of specific SuSy genes and to
repression of invertase in maize roots (Zeng et al.,
1999) and potato tubers (K.L. Bologa, A.R. Fernie, A. Leisse, M. Ehlers Loureiro, and P. Geigenberger, unpublished data).
These considerations imply that plant metabolism follows a similar
defense strategy as initially described in hypoxia tolerant animals
(Hochachka et al., 1997). This includes a reduction in energy turnover to reach an optimal hypometabolic steady state and an
improved energy efficiency of the remaining metabolic processes to
prevent internal anoxia when oxygen is falling. These metabolic acclimations occur at oxygen levels that are higher than the
Km (O2) for
cytochrome oxidase, indicating that oxygen is acting as a regulator in
addition to its role as respiratory substrate. Oxygen sensing systems
have been elaborated in bacteria and yeast (see Bunn and Poyton,
1996) and still have to find their counterparts in higher
organisms (Wenger, 2000). Current models of oxygen
sensing in mammals are based on a haem protein capable of reversibly
binding oxygen and the production of reactive oxygen species by NAD(P)H oxidases and mitochondria (López-Barneo et al.,
2001). In plants, non-symbiotic hemoglobins have been suggested
to be involved in oxygen sensing (Appleby et al., 1988),
but more studies are needed to identify the molecular sensor and the
cellular mechanism(s) involved.
Plant Material
Seeds of Ricinus communis cv Carmencita (Jelitto,
Hamburg, Germany) were germinated in sterile conditions and grown under continuous aeration (21% [v/v]) in hydroculture in the dark as in
Kallarackal et al. (1989). Unless stated otherwise in
the text, 6-d-old seedlings were used for the experiments. Adult plants were grown on soil in a growth chamber at 300 µmol photons
m2 s1 and 14 h of light/8 h of dark at
20°C and 50% relative humidity and were used after 4 weeks when they
were approximately 1 m tall. Plants were used for experiments in
the middle of the light period.
Experiments with Adult Plants
A stem segment of approximately 5 cm of an intact adult plant
was exposed to a continuous stream of gaseous nitrogen (zero oxygen)
using a plastic cuvette. After 90 min, phloem exudate was collected
from small incisions with a sharp razor blade into the bark of the stem
3 to 10 cm above or below the treated segment (as described by
Smith and Milburn, 1980) and frozen in liquid nitrogen.
Experiments with Seedlings
The endosperm of 6-d-old seedlings was carefully removed, and
the cotyledons were placed in 100 mL of 2.5 mM
KH2PO4 buffer (pH 5.5) containing 100 mM Suc and incubated for 3 h before the hypocotyl was
severed and phloem sap was collected with graded micro-capillaries in
an enclosed atmosphere at 95% to 100% relative humidity as described
by Kallarackal et al. (1989). In all cases, sap was
collected continuously for approximately 2 h, subsequent subsamples being immediately frozen in liquid nitrogen every 5 min
(Geigenberger et al., 1993). A detailed time course
revealed that fluctuations of the exudation rate of individual
seedlings over this time interval were less than 30% of the mean value
(data not shown). During the whole experiment, the cotyledons were
incubated at different external oxygen concentrations (0.5%, 3%, 6%,
or 21% [v/v]) by using premixed gases (Messer, Griesheim, Germany) streaming through the incubation solution. To avoid complication due to
atmospheric oxygen (21% [v/v]) entering the phloem via the cut
surface, the hypocotyl stump was exposed to the specific oxygen
tensions, too. The oxygen concentration in the solution was measured by
using an oxygen electrode (see below). During the 3-h pre-incubation
period, the roots of the seedlings were immersed in a solution
containing 0.5 mM CaCl2 at 21% (v/v) oxygen. The whole experimental setup was placed in a water bath to maintain a
constant temperature of 27°C.
Metabolite Analysis
The frozen exudate was extracted with trichloroacetic acid, and
phosphorylated intermediates (ATP, ADP, AMP, PPi, Pi, and pyruvate)
were measured as by Geigenberger et al. (1993). Uridine and guanine nucleotides were analyzed by HPLC as by Geigenberger et al. (1997), amino acids by HPLC as by Geigenberger et
al. (1996), organic acids and ethanol according to
Bergmeyer (1987), and Suc as in
Geigenberger et al. (1996).
Analysis of Oxygen Tensions
In situ oxygen tensions were measured using an oxygen
microsensor with a tip diameter of approximately 30 µm connected to a
fiber optic oxygen meter (MicroxTX2, Presens, Regensburg, Germany). This type of sensor enables oxygen measurements both in solution and in
dry gas. It is very sensitive and reacts to changes in oxygen very
fast. Furthermore, unlike conventional electrodes, the sensor does not
consume oxygen. The microsensor was pierced through the tissue using a
micromanipulator, and the location of the tip was derived from its
scaling. At each position, the reading equilibrated for approximately
30 s before the oxygen tension was registered.
Stems of 4-week-old flowering plants were clamped with a laboratory
stand to fix their position toward the micromanipulator, and oxygen
tensions were measured throughout a transect perpendicular to the axis
of the stem. The oxygen concentration of phloem sap was determined by
placing the microsensor directly in a droplet of phloem exudate freshly
appearing from an incision in the stem of adult plants. Oxygen tensions
in the hypocotyl of seedlings 6 and 10 DAG were determined at the site
were the hypocotyl makes a sharp hook. Seedlings were fixed on
permanently kneadable sealant (Terostat-IX, Henkel Teroson GmbH,
Heidelberg) to prevent moving during the measurement. Endosperm was
impaled with the microsensor perpendicular to the surface of the cotyledons.
We thank Mark Stitt for stimulating discussions and helpful
Received November 6, 2002; returned for revision January 12, 2003; accepted February 21, 2003.
1
This work was supported by the Deutsche
Forschungsgemeinschaft (grant no. Ge 878/1-3 to P.G.) and by the
Max-Planck Society (to J.T.v.D.).
*
Corresponding author; e-mail
geigenberger{at}mpimp-golm.mpg.de
Article, publication date, and citation information can be found at.
This article has been cited by other articles: | http://www.plantphysiol.org/cgi/content/full/131/4/1529 | crawl-002 | refinedweb | 7,163 | 53.71 |
Northwest vs. Co-Lin - September 5, 2013
Northwest hosts reigning state champions and 9th-ranked Copiah-Lincoln in Senatobia.
$500 SPOTLIGHT PLAYER KENDALL CARR & JOSH GASTON SEPTEMBER 5, 2013 • NORTHWEST RANGERS VS. COPIAH-LINCOLN WOLFPACK 2013 COAHOMA TIGERS MACJC MASTER SCHEDULE = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = AUG 29 MISSISSIPPI GULF COAST A SEPT 5 HINDS H SEPT 12 NORTHWEST MISSISSIPPI H SEPT 19 PEARL RIVER H SEPT 28 EAST MISSISSIPPI A OCT 5 NORTHEAST MISSISSIPPI A OCT 12 ITAWAMBA HC OCT 19 MISSISSIPPI DELTA A OCT 24 HOLMES H = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = AUG 29 HINDS H SEPT 5 PEARL RIVER A SEPT 12 ITAWAMBA A SEPT 19 EAST MISSISSIPPI H SEPT 26 HOLMES H OCT 5 NORTHWEST MISSISSIPPI A OCT 12 EAST CENTRAL A OCT 19 COAHOMA HC OCT 24 NORTHEAST MISSISSIPPI A = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = AUG 29 COAHOMA H SEPT 5 HOLMES H SEPT 12 HINDS A SEPT 19 JONES COUNTY H SEPT 26 NORTHEAST MISSISSIPPI A OCT 3 PEARL RIVER A OCT 10 SOUTHWEST MISSISSIPPI H OCT 19 COPIAH-LINCOLN HC OCT 24 EAST CENTRAL A MISSISSIPPI DELTA TROJANS = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = AUG 29 NORTHEAST MISSISSIPPI H SEPT 5 NORTHWEST MISSISSIPPI A SEPT 12 EAST CENTRAL A SEPT 19 HINDS H SEPT 28 JONES COUNTY A OCT 3 ITAWAMBA H OCT 12 PEARL RIVER HC OCT 19 MISSISSIPPI GULF COAST A OCT 24 SOUTHWEST MISSISSIPPI H COPIAH-LINCOLN WOLVES MISS. GULF COAST BULLDOGS = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = AUG 29 ITAWAMBA A SEPT 5 EAST MISSISSIPPI A SEPT 12 COPIAH-LINCOLN H SEPT 19 SOUTHWEST MISSISSIPPI A SEPT 26 HINDS A OCT 3 JONES COUNTY H OCT 12 MISSISSIPPI DELTA HC OCT 19 PEARL RIVER A OCT 24 MISSISSIPPI GULF COAST H EAST CENTRAL WARRIORS = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = AUG 29 PEARL RIVER A SEPT 5 EAST CENTRAL H SEPT 12 SOUTHWEST MISSISSIPPI H SEPT 19 MISSISSIPPI DELTA A SEPT 28 COAHOMA HC OCT 3 HOLMES A OCT 10 NORTHEAST MISSISSIPPI H OCT 17 NORTHWEST MISSISSIPPI A OCT 24 ITAWAMBA H EAST MISSISSIPPI LIONS n lCOPIAH-LINCOLN, EAST CENTRAL, Hinds, Jones County, Mississippi Gulf Coast, Pearl River, and Southwest Mississippi comprise the MACJC South Division, while Coa-homa, East Mississippi, Holmes, Itawamba, Mississippi Delta, Northeast Mississippi, and Northwest Mississippi comprise the North Division. The first round of the state playoffs (North No. 1 vs. South No. 2, South No. 1 vs. North No. 2) are set for Saturday, Nov. 2, with the first-round winners playing for the state championship Saturday, Nov. 9. The 2013 MACJC state champion earns hosting rights to the fifth-annual Mississippi Bowl scheduled for Sunday, Dec. 8, in Indian Stadium at Biloxi High School in Biloxi. ( ) DENOTES NORTH, SOUTH DIVISION GAMES = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = AUG 29 COPIAH-LINCOLN A SEPT 5 JONES COUNTY H SEPT 12 HOLMES H SEPT 19 NORTHWEST MISSISSIPPI A SEPT 26 MISSISSIPPI GULF COAST H OCT 5 COAHOMA HC OCT 10 EAST MISSISSIPPI A OCT 17 ITAWAMBA A OCT 24 MISSISSIPPI DELTA H NORTHEAST MISSISSIPPI TIGERS NORTHWEST MISSISSIPPI RANGERS = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = AUG 29 SOUTHWEST MISSISSIPPI H SEPT 5 COPIAH-LINCOLN H SEPT 12 COAHOMA A SEPT 19 NORTHEAST MISSISSIPPI H SEPT 28 ITAWAMBA A OCT 5 MISSISSIPPI DELTA HC OCT 12 HOLMES A OCT 17 EAST MISSISSIPPI H OCT 26 JONES COUNTY A = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = AUG 29 MISSISSIPPI DELTA A SEPT 5 COAHOMA A SEPT 12 MISSISSIPPI GULF COAST H SEPT 19 COPIAH-LINCOLN A SEPT 26 EAST CENTRAL H OCT 5 SOUTHWEST MISSISSIPPI A OCT 10 JONES COUNTY A OCT 17 HOLMES HC OCT 24 PEARL RIVER H HINDS EAGLES = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = AUG 29 EAST CENTRAL H SEPT 5 SOUTHWEST MISSISSIPPI A SEPT 12 MISSISSIPPI DELTA H SEPT 19 HOLMES A SEPT 28 NORTHWEST MISSISSIPPI HC OCT 3 COPIAH-LINCOLN A OCT 12 COAHOMA A OCT 17 NORTHEAST MISSISSIPPI H OCT 24 EAST MISSISSIPPI A ITAWAMBA INDIANS = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = AUG 29 EAST MISSISSIPPI H SEPT 5 MISSISSIPPI DELTA H SEPT 14 JONES COUNTY A SEPT 19 COAHOMA A SEPT 26 SOUTHWEST MISSISSIPPI H OCT 3 MISSISSIPPI GULF COAST H OCT 12 COPIAH-LINCOLN A OCT 19 EAST CENTRAL HC OCT 24 HINDS A PEARL RIVER WILDCATS = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = AUG 29 JONES COUNTY H SEPT 5 MISSISSIPPI GULF COAST A SEPT 12 NORTHEAST MISSISSIPPI A SEPT 19 ITAWAMBA H SEPT 26 MISSISSIPPI DELTA A OCT 3 EAST MISSISSIPPI H OCT 12 NORTHWEST MISSISSIPPI HC OCT 17 HINDS A OCT 24 COAHOMA A HOLMES BULLDOGS = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = AUG 29 HOLMES A SEPT 5 NORTHEAST MISSISSIPPI A SEPT 14 PEARL RIVER H SEPT 19 MISSISSIPPI GULF COAST A SEPT 28 COPIAH-LINCOLN H OCT 3 EAST CENTRAL A OCT 10 HINDS H OCT 17 SOUTHWEST MISSISSIPPI A OCT 26 NORTHWEST MISSISSIPPI HC JONES COUNTY BOBCATS = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = AUG 29 NORTHWEST MISSISSIPPI A SEPT 5 ITAWAMBA H SEPT 12 EAST MISSISSIPPI A SEPT 19 EAST CENTRAL H SEPT 26 PEARL RIVER A OCT 5 HINDS HC OCT 10 MISSISSIPPI GULF COAST A OCT 17 JONES COUNTY H OCT 24 COPIAH-LINCOLN A SOUTHWEST MISSISSIPPI BEARS BOARD OF TRUSTEES . . . . . . . . . . . . . . 2 PRESIDENT . . . . . . . . . . . . . . . . . . . . . . . 3 PLAYER SPOTLIGHT . . . . . . . . . . . . . . . 4 SOUTHWEST GAME RECAP . . . . . . . . . 6 CO-LIN GAME PREVIEW . . . . . . . . . . . . 7 HEAD COACH . . . . . . . . . . . . . . . . . . . . 10 FOOTBALL STAFF . . . . . . . . . . . . . . . . 14 SUPPORT STAFF . . . . . . . . . . . . . . . . . 16 ATHLETIC DIRECTOR . . . . . . . . . . . . . 17 RANGER PLAYERS . . . . . . . . . . . . . . . . 18 GAMEDAY ROSTERS . . . . . . . . . . . . . . 20 SEASON STATISTICS . . . . . . . . . . . . . . 22 ALL-AMERICANS . . . . . . . . . . . . . . . . . 24 BAND, CHEER & DANCE . . . . . . . . . . . 28 FOOTBALL FACILITIES . . . . . . . . . . . . 30 Northwest Football Gameday Programs are a publication of the NWCC Sports Information Office and are available for purchase at all home football games for $5. This publication was written and edited by fourthyear SID Kevin Maloney. Additional editing provided by Sarah Sapp and the NWCC Communications Office. Cover design by Andrew Bartolotta. Photography was provided by Justin Ford, Kevin Maloney, Brett Brown, JUCO Weekly, Jim Biever (Green Bay Packers), NFL Creative, Miami Dolphins, Getty Images, US Presswire and the Brazos Valley Bowl. Please Note: Visit the website at nwccrangers.com to view the online version of the 2013 Northwest Football Almanac (seperate publication) with single-game, single-season and career records that were compiled in the summer of 2011 from old computer and paper files, yearbooks, etc. Yearly stats are not available prior to the 1991 season. We strongly encourage you to email kmaloney@northwestms.edu with information to help fill in any gaps between missing seasons. Weekly game programs are printed by Paulsen Printing in Memphis. This is NORTHWEST RANGER FOOTBALL NORTHWEST MISSISSIPPI COMMUNITY COLLEGE BOARD OF TRUSTEES Vice Chairman • Charleston JAMIE ANDERSON DR. RACHELL ANDERSON Tunica JERRY BARRETT Senatobia JOHNNY BLAND Marks JOHN G. BURT Calhoun City BERNARD CHANDLER Tunica BILL DAWSON Byhalia JACK GADD Ashland DIANA GRIST Hickory Flat DAVID HARGETT Charleston SAMMY HIGDON Water Valley BRENDA J. HOPSON Marks JAMIE HOWELL SR. Batesville MILTON KUYKENDALL Chairman • Ashland Board Attorney • Senatobia JOHN T. LAMAR JR. JERRY MOORE Holly Springs MIKE MOORE Pittsboro MARY ALICE MOORMAN Water Valley DR. ADAM PUGH Oxford DR. ROBERT SMITH Hernando STEVE WHITE Oxford DOROTHY WILBOURN Como 2 SPEARS DR. GARY LEE PRESIDENT u 9TH YEAR Dr. Gary Lee Spears is in his ninth academic year as president of Northwest Mississippi Community College. While he is proud of all the accomplishments the college has achieved during his tenure as president, he is particularly proud of the Building on Tradition campaign in which he has played a major role. Students and visitors to the main campus in Senatobia can see evidence of the college’s ongoing building campaign with the recent completions of Tate Hall, McLendon Student Union, Division of Nursing Building and Ranger Outdoor Complex. You can’t spend more than a few minutes with Dr. Spears before you see that his love of the college runs deep. In 2007, Dr. Spears was named Alumnus of the Year by the Northwest Alumni Association and recognized during Homecoming festivities. Prior to being named president July 1, 2005, Dr. Spears served as registrar and director of Admissions and Records for 25 years. A native of Eudora in DeSoto County, Dr. Spears has held positions at the college including instructor, vocational counselor, assistant to the DeSoto Center director and vice president for Student Affairs. Dr. Spears is a graduate of Hernando High School. He earned an Associate of Applied Science degree and an Associate of Education degree from Northwest. He went on to earn a bachelor’s degree in social science and a master’s degree in counseling from Delta State University. In 1991, Dr. Spears earned a doctorate in educational leadership at the University of Mississippi, where he has taught courses in higher education as an adjunct instructor. His profound love for Northwest inspired him to write a history of the college for his doctoral dissertation. He began his career in education at Leland Consolidated School District, where he taught American history while working on his master’s degree. He came to Northwest in 1975. Dr. Spears is a past president of the Senatobia Rotary Club, where he was honored as a prestigious Paul Harris Fellow, and has been a board member of the Tate County Economic Development Foundation. The Northwest Foundation Board of Directors, his wife, Marilyn, and friends of the college created the Dr. Gary Lee Spears Endowed Scholarship in May 2011 for his lifelong dedication to education and the college. In May 2010 the Spears family joined the college in celebrating the dedication of the Marilyn R. Spears Building for the Early Childhood Education Technology program, named for Northwest First Lady Marilyn Spears, a Northwest graduate who retired from the college in spring 2005 after 25 years as an instructor in that program. Dr. and Mrs. Spears have two adult sons, Jared and Daniel, who are also Northwest graduates. Jared graduated from Delta State and earned a Master of Fine Arts terminal degree at The University of Mississippi. A member of the UM faculty, Jared is a musician and sculptor outside of the university and resides in Taylor. Daniel also completed a bachelor’s degree from Ole Miss. He is a recreation therapist with the North Mississippi Regional Center and a musician. He and his wife, Julie, an architect with Julie Spears Architecture, live in Oxford and have two sons—Jack, 1, and Samuel, born August 13. The Spears family has lived in Tate County for 37 years and are active members of the First Baptist Church in Senatobia. They moved into the college’s President’s Home on the Senatobia campus in March of 2009. 3 Question & Answer with Josh Gaston BY KEVIN MALONEY Q. How long have you been playing football? What is your primary position. A. Since I was eight years old. I played defensive end and linebacker, but I enjoy tight end the most. Q. What made you choose Northwest out of high school? A. I didn’t have any other offers out of high school until I went up to Hargrave. After that, I had 12 different schools that were interested in me. Q. What Division I schools have shown interest since you’ve been at Northwest? A. Memphis, Delta State and Middle Tennessee State. Q. What are your personal & team goals for 2013? A. For me, to get a Division I offer. As far as the team, as young as we are, just to win as many games as possible. Q. How different is it this year with a new staff? A. The coaching styles are a lot different from last year, but that’s to be expected. My role is still the same. Q. What game are you looking forward to the most? A. East Mississippi. But also this week’s game against Co-Lin because they won the state last year. 4 Book Channel Class Gameday moment Meal Memory as a Ranger Movie Restaurant Vacation Spot FAVORITES Goosebumps USA Criminal Justice Starting the 3rd quarter Steak & Potatoes 2012 Brazos Valley Bowl Iron Man Texas de Brazil Beach Question & Answer with Kendall Carr BY KEVIN MALONEY Q. How long have you been playing football? A. I started playing in junior high and have been playing on the defensive line since my sophomore year of high school. Q. What made you choose Northwest out of high school? A. It’s right down the road from Batesville, convenient for my family and it’s always been a great program. Q. You sing a lot in your free time. Talk about that. A. I’ve been singing since I was little at church. Our group is called Young Anointed Men of Christ and we’ve been together for about a year and a half now. Q. How different is it this year with a new staff? A. We had to make a lot of adjustments with practices, meetings and a new system. But it’s been good because this is how it will be on the next level. Q. What are your personal & team goals for 2013? A. Personally, I want to pass all my classes and make a 3.0 or better. I want to lead my team to victory, practice hard, be dedicated and stay focused. The team goal is to win every game from here on out and not give up any points on defense. Q. What game are you looking forward to the most? A. East Mississippi. We were supposed to win that game last year and this year I plan on there being a different outcome. Q. What Division I schools have shown interest in you? A. Southern Mississippi, Memphis, Middle Tennessee State, Louisiana-Lafayette, Troy, Texas A&M and Auburn. FAVORITES Book The Adventures of Sherlock Holmes Channel Starz Class Philosophy Gameday moment Pregame Stretching Meal Filet of Fish Memory as a Ranger 2012 Brazos Valley Bowl Movie Transformers Restaurant Olive Garden Vacation Spot Biloxi 5 Rangers Drop 2013 Season-Opener to Southwest Mississippi, 19-15 From NWCCRANGERS.com • August 29, 2013 SENATOBIA – After jumping out to an early 15-0 lead behind a pair of scores from sophomore D’Montrise Swinney and a safety, visiting Southwest rallied for 19 unanswered points and shutout Northwest in the second half as they knocked off the Rangers in the 2013 season-opener, 19-15. Northwest had won four consecutive openers dating back to 2009. Despite outgaining the Bears 366-237 on the night, Northwest was just 1-for-4 in the red zone with two special teams miscues and a turnover on downs late in the fourth quarter. Joshua Barry setup the Rangers’ first score of the season when he picked off Jamil Golden and returned it to the Southwest 23-yard line. Karsten Millet then connected with D’Montrise Swinney three plays later from 20 yards out for a 7-0 lead. A safety on the ensuing kickoff made it 9-0 Northwest after one quarter. The best drive of the night, a 10-play, 84-yard drive, stretched the Northwest lead to 15-0 with 10:08 left in the second and Miller again connected with Swinney, this time from 30 yards, for the touchdown. Southwest looked to have its first score of the night on the ensuing possession, but Chris Jones fumbled into the end zone for a touchback which was recovered by Terrell White. Jones and the Bears made up for the turnover just 4:49 later, when the freshman scored from 14 yards out to make it 15-7 at the half. The drive went 52 yards on eight plays over 3:01. Southwest quickly pulled within 15-13 on its first possession of the second half, driving 65 yards on 11 plays. Jones moved the Bears down the field on the ground with six carries for 33 yards and Golden connected with him from 19 yards out on 3rd-and-16. Northwest’s second drive of the second half was all for naught, as Matt Bratton missed a 30-yard field goal attempt on a lengthy 14-play, 68-yard drive over 8:44. The Bears then took their first lead of the night at the 10:19-mark of the fourth quarter when Tim Lewis picked off Miller’s pass and returned it 71 yards for the eventual game-winning score. Northwest’s last drive of the night was another extended one, covering 61 yards on 17 plays over 8:57, but again the Rangers came up short with no points after 1st-and-goal from the 5-yard line. Miller went 5-for-8 on the drive and hit Kentrell Spencer with a swing pass that appeared to be the go-ahead score, but the official ruled him down despite Spencer never touching the ground and rolling over the top of the defender. Miller finished the night 17-of-30 for 193 yards, two touchdowns and an interception, while Damian Baker rushed 27 times for 143 yards. Swinney was the team’s leading receiver, hauling in eight passes for 116 yards and two first-half touchdowns. Southwest was led offensively by Jones who rushed 20 times for 114 yards and a touchdown. Golden was 10-for18 for 89 yards and a touchdown. Alec Michael and C.J. O’Quin each had 10 tackles for their respective teams. Sophomore wide receiver D’Montrise Swinney of Itta Bena had eight catches for 116 yards and two touchdowns against the Bears. He eclipsed 100 yards receiving for the third time in his career. Southwest Northwest Scoring Summary: 1st 11:34 11:25 2nd 10:19 2:27 3rd 10:57 4th 10:25 0 7 6 6 - 19 9 6 0 0 - 15 NWCC - D’Montrise Swinney 20 yd pass from Karsten Miller (Matt Bratton kick) NWCC - TEAM safety NWCC - D’Montrise Swinney 30 yd pass from Karsten Miller (Bratton kick failed) SWCC - Chris Jones 14 yd run (Michal McDaniel kick) SWCC - Chris Jones 19 yd pass from Jamil Golden (Jamil Golden pass failed) SWCC - Tim Lewis 71 yd interception return (Chris Jones rush failed) Southwest/Northwest Game SWCC 14 32-148 89 18-10-1 50-237 0-0 1--3 2-43 1-71 4-34.2 2-1 5-55 20:47 6 of 10 0 of 0 2-3 1-1 NWCC 21 40-173 193 30-17-1 70-366 0-0 0-0 5-77 1-36 4-32.0 0-0 9-73 39:13 7 of 17 2 of 4 1-4 1-2 Game Notes: First season-opening loss for Northwest since 2008 Southwest snapped an 11-game losing streak dating back Oct. 2011 Southwest scored 19 unanswered points over the final 3 quarters Northwest was just 1-for-4 in the red zone and 7-of-17 on 3rd down D’Montrise Swinney had eight catches for 116 yards/2 TD, his 3rd career 100-yard receiving game Attendance: 977 6 Rangers Face Reigning State Champions #9 Co-Lin Northwest is looking for its first win of the 2013 season on Thursday night against the defending state champions and 9th-ranked Copiah-Lincoln Wolfpack. Northwest held the edge against Southwest in time of possession, yards and turnovers last week, but was just 1-for-4 in the red zone and couldn’t capitalize on several chances to take the lead. In the game’s final minutes, Kentrell Spencer scored the go-ahead touchdown but was then ruled down by contact. Replays on NJCAA-TV showed he clearly wasn’t down, nevertheless, the Rangers must regroup quickly against a very good opponent riding an impressive regular season winning streak. The Rangers handily beat the Wolfpack 42-21 in Wesson a year ago and led 42-0 late in the third quarter. Overall, Northwest has outscored Co-Lin 73-21 in the last two meetings and has won 14 of the last 18 meetings. Co-Lin is very balanced with 24 sophomores while Northwest will start 13 freshmen, including five on the offensive line. The battle in the trenches will most likely decide the outcome with both teams boasting a solid running game. Special teams could also play a major role. • Notebook Northwest leads the all-time series with Copiah-Lincoln, 23-13-1 and has won 14 of 18. The Rangers have outscored the Wolfpack 73-21 in the last two meetings. • Northwest’s loss to Southwest last week snapped a streak of winning four consecutive season-openers dating back to 2009. • Since 2007, Northwest has only lost back-to- back games twice (2007, 2011). • Sophomore Damian Baker, who rushed for 143 yards on 27 carries last week vs. Southwest, is now 980 yards away from breaking the school’s career rushing record. He needs to average 122.5 yards the final eight games. • Copiah-Lincoln enters the game with a Top-10 ranking. The Rangers are just 6-14 in the last 20 games against ranked opponents. • • Co-Lin sophomore running back Van Lee was the Wolfpack’s workhorse in the season- opener, rushing for 166 yards and two TDs on 25 carries. He had 422 yards all of last season. Comparing total offenses in Week 1, Northwest out-gained Co-Lin 366 to 311. Karsten Miller (NWCC) and Daniel Fitzwater (CLCC) had nearly identical numbers in the passing game. Sophomore Damian Baker rushed 27 times for 143 yards in a 19-15 loss to Southwest. He’s 980 yards shy of breaking the school’s career rushing record set during the 1991-92 season. Northwest Record: 0-1 Ranking: No. 21 JCGridiron.com (preseason ranking) Last Game: August 29 in Senatobia (lost to Southwest Mississippi, 19-15) Head Coach: Brad LaPlante (Winona State, 2001) Career Record: 64-17 (eight seasons) At Northwest: 0-1 (first season) 2013 Schedule Aug. 29 Sept. 5 Sept. 12 Sept. 19 Sept. 28 Oct. 5 Oct. 12 Oct. 17 Oct. 26 Statistical Leaders Rushing Copiah-Lincoln Record: 1-0 Ranking: No. 9 NJCAA.org (preseason ranking) Last Game: August 29 in Wesson (defeated Northeast, 29-20) Head Coach: Glenn Davis (Delta State, 1982) Career Record: 45-37 (nine seasons) At Co-Lin: same 2013 Schedule Aug. 29 Sept. 5 Sept. 12 Sept. 19 Sept. 28 Oct. 3 Oct. 12 Oct. 19 Oct. 24 Statistical Leaders Rushing • The Co-Lin defense forced a fumble on the first offensive play from scrimmage for Northeast. Tigers quarterback Jerrard Randall was sacked by Carroll Phillips and the ball was stripped and recovered by the Wolfpack defense. W, 29-20 6:30 p.m. 6:30 p.m. 7 p.m. 7 p.m. 7 p.m. 3 p.m. 2 p.m. 7 p.m. SOUTHWEST MISSISSIPPI COPIAH-LINCOLN at Coahoma* NORTHEAST MISSISSIPPI* at Itawamba* MISSISSIPPI DELTA* (HC) at Holmes* EAST MISSISSIPPI* at Jones County Att. Yds. TD L, 15-19 6:30 p.m. 6:30 p.m. 6:30 p.m. 4 p.m. 2 p.m. 6 p.m. 6:30 p.m. 2 p.m. NORTHEAST at Northwest at East Central* HINDS* at Jones County* ITAWAMBA PEARL RIVER* (HC) at Gulf Coast* SOUTHWEST MISSISSIPPI* Att. Yds. TD • • Co-Lin upset the No. 6 ranked Mississippi Gulf Coast Bulldogs 41-37 to win the 2012 MACJC State Championship. It was the Pack’s first state championship since 1985. Live video will be available for tonight’s game at and live stats will be available at. com/northwestms/football. Both are available on your smartphone. Damian Baker Boston Newsome Passing 27 7 Att. 143 17 Comp. 0 0 Yds. TD INT Van Lee Passing 25 Att. 166 Comp. 2 Yds. TD INT Daniel Fitzwater Receiving 33 Rec. 19 Yds. 179 TD 1 2 Karsten Miller Receiving 30 Rec. 17 Yds. 193 TD 2 1 D’Montrise Swinney 8 Kentrell Spencer 2 Defense Tkls. 116 22 Sacks 2 0 INT Courtney Foy Van Lee Defense 5 4 Tkls. 57 48 Sacks 0 0 INT Alec Michael Terrell White 10 7 0 0 0 0 Jordan Harris Carroll Phillips Jymal Ellis 19 10 9 0.5 0 0 0 0 0 7 GO RANGERS! 662-895-2151 After hours, weekends and holidays, call 1-866-438-2642 4600 Northcentral Way Olive Branch, MS 38654 LaPLANTE BRAD HEAD COACH u 1ST YEARoffensive. Brad LaPlante was named the 28th head football coach in Northwest history on January 17, HS where he served as the offensive coordinator and offensive line coach. Coaching Experience 2012: Manvel High School (Special Teams Coordinator/Defensive Line) 2011: Alvin High School (Offensive Coordinator/Offensive Line) 2004-10: Rochester Community and Technical College (Head Coach) 1999-02: Rochester Community and Technical College (Co-Off. Coordinator/OL) 10 Question & Answer with Brad LaPlante entering the 2013 season Once again we’re preseason ranked. We are unranked in the NJCAA Poll, but come in at No. 21 by JCGridiron.com. “It’s just awesome that we have so many good teams in this league. When you add in the NJCAA and California teams, that’s a pretty good list to be on. It’s a credit to this fine program and its history.” Talk about the spring and battling the weather. “We started on April 1, and the weather was the biggest issue during the spring. To get quality practices, whether they were in the gym or on the grass, was difficult. We only had a handful of actual grass practices to work with.” Talk about the fall. “We are way tougher, more aggressive and got more plays in than we did in spring ball. I think our quarterbacks are coming along and we’re athletic at the receiver and running back positions. We have some guys on the defensive line that are very explosive, while the secondary is very athletic and explosive. Things are looking up and up for the Rangers.” Entering the season, tell me about some guys that may standout. “Quarteback Karsten Miller and running back Damian Baker have showed a lot of leadership, poise and technique. Kendall Carr and Tarow Barney on the defensive line have showed a lot of great extension and good explosiveness, while Chris Fox and Terrell White have looked good in the secondary. White is the most aggressive player we have on defense and is always flying around on every play.” We signed 37 players on National Signing Day and only have about a dozen players returning. Talk about the youth of this team. “We only had 12 players from last years roster to work with and have a lot of youth. We had a few tryouts and will have to work to get to our final 55-man roster and the additional redshirts that we’re given. As the year progresses, we hope to show the brand of football that we’re going to play. With so many new kids, you may not see that in Week 1, but we’re certainly excited to get started.” How much pressure do you feel coming in to win in your first season? “We’re just coming in here to work and demand a lot from each other as a staff. We want to do things right and we’re going to hold our players accountable. We want them to have a future after Northwest and that’s why we have study tables and grade checks. If you’re doing things right, there’s no way that success can’t happen.” On challenging the fans to come out with five home games this year. “It’s for the kids. When you take the rules in our league with just eight out-ofstaters, a majority of our roster is in-state kids. There’s no reason to not come out and support our Mississippi kids. There are some tough games against some tough opponents, but we’re excited to have five out of those nine in Senatobia. We’re going to have a new defense, new offense and a different look on special teams. ” 11 CLINE TOURS Birmingham• Ridgeland • Memphis • Little Rock • Oxford Charter Buses, Shuttle Buses, Packages Tours For more information please call 601-605-4483 or 800-233-5307 P.O. Box 1498, Ridgeland, MS 39158 Cline can now serve you better with the addition of Callahan Charters to the Cline group of companies. To celebrate this new branch, we have the largest eet of 2014 motor coaches in the country ordered for all of our locations. They are GREAT!!!!!! MIKE BEAGLE Offensive Coordinator Offensive Line RICKY COON Defensive Coordinator Defensive Line SCOTT OAKLEY Wide Receivers Mike Beagle enters his first season as Northwest's offensive coordinator and will also be working with the offensive line. A native of Richmond, Va., Beagle brings 29 years of coaching experience with stints at every level of college football. This will mark his fifth stop in the junior college circuit, spending time in Alabama, Mississippi and Kansas. His coaching career began at Richmond as a student coach. Beagle's tutored over 20 professional players in the NFL, CFL and AFL in his career. Beagle spent last season as the associate head coach for offense at Division II Chowan University and boasted one of the CIAA's best offenses. The Hawks led the league in rushing (181.1 ypg) and ranked second in the league in scoring (32.8 ppg) and third in total offense (430.7 ypg). Prior to Chowan, Beagle was the head coach at Highland Community College from 2007-11. He oversaw all aspects of the football program as well as taught classes in the health and physical education department and served on the NJCAA Football Coaches Committee as the president for a term. Prior to his five year stint at HCC, Beagle served as head coach (2002-06) and athletic director at North Dakota State College of Science (2004-06). He took the Wildcats to the Graphic Edge Bowl twice and won on both occasions. Beagle's previous experience in the MACJC dates all the way back to 1992 with stops at Jones Junior College, Gulf Coast and at Southwest Mississippi Community College. He's also had stops at Cumberland College, Troy University, the U.S. Military Academy and the University of Tennessee at Martin. As an undergrad, Beagle attended Ferrum College where he was team captain and a member of the 1977 NJCAA National Championship football team. He finished his career at the University of Richmond, where he was the starting center. He holds a master's degree from Troy University and a bachelor's degree from Richmond. Mike has one daughter, Morgan, who is a high school cheerleader and honor student. Ricky Coon enters his first season as the Rangers’ defensive coordinator and defensive line coach and has six years of prior experience at the junior college level. Coon spent last season at NCAA Division II Southwest Baptist University as the defensive line coach. Prior to SBU, Coon served three seasons (2009-12) as the assistant head coach and defensive coordinator at Ellsworth Community College where 18 of his players received all-conference recognition and three were named NJCAA All-Americans. Coon helped the Panthers to the 2009 NJCAA Region XI Championship, two Midwest Football Conference Playoff Championships (2009, 2010) and two NJCAA bowl game appearances. In 2009, Coon’s defensive unit set a school record for the least amount of yards given up in a bowl game. Prior to his three-year stint at Ellsworth CC, Coon worked at Highland Community College where he served as defensive coordinator and head strength and conditioning coordinator from 2007-09. Coon’s defensive units finished in the Top 20 in the NJCAA in each of his two seasons, and the defensive unit put together, statistically, the best two defensive units in school history. Seven defensive players were received all-conference honors during his two years. Coon spent the 2006 season at Division II Northern State University where he was the academic coordinator and defensive line coach. A native of Wichita, Kan., Coon got his start in coaching as the defensive line coach and head strength and conditioning coordinator at his alma mater, Bethel College. Coon was a two-time all-conference defensive lineman at Dodge City Community College and Bethel College. Coon also had the privilege of playing two seasons of professional football in the Arena Football League for the Wichita Stealth(AF2) and the Wichita Aviators (APFL). Coon is married to the former Amanda Sanchez. Together they have four children, Taryn (9), Zane (6), Gunner (5) and Bryson (1). A familiar face around the city of Senatobia and the longest tenured coach on staff, Scott Oakley begins his 10th season leading the Rangers’ wide receiver unit. Under his tutelage, a total of nine receivers/tight ends have gone on to collect MACJC All-State honors (six first teamers). Most recently, Division I signees Lance Ray (East Carolina), Myles White (Louisiana Tech) and Jamal Mosley (Ole Miss). He’s also coached a trio of All-Americans in Ray (2011), Michael Lindsey (2009) and two-time selection, John Harris (2002-03). As a unit, the Rangers’ receiving corps has flourished the previous four seasons since his return, hauling in 190 or more passes each year for over 2,000 yards. The 2008 season saw the unit catch 208 passes (fourth in single-season history), while last year’s squad racked up 2,633 yards and 28 touchdowns which both rank seventh in single-season school history. Oakley’s first stint with the Northwest football program came as an assistant from the 2002-05 seasons under legendary coach Bobby Franklin, serving as the running backs and wide receivers coach. He was a student assistant for the Rangers during the 1998-99 seasons while earning his degree. Oakley then transferred to Ole Miss where he was a football manager for three years and head equipment manager during the 2001 season. While at Ole Miss, Oakley earned a bachelor’s degree in secondary education and was part of the Rebel football program that earned bowl berths in both 1999 and 2001. Away from the gridiron, Oakley also recently finished up his eighth season as an assistant coach for the Ranger softball program. During his eight years, the Rangers have compiled an overall record of 253-118-1, including a 125-49 mark against opponents from the MACJC north division. Northwest has also captured two division titles during his stay, while boasting four seasons of 30 or more wins. A native of Senatobia, Oakley graduated from Senatobia High School in 1997 and lettered two years in football and three seasons in baseball. He was a member of the Warrior football team that claimed back-to-back district championships. Oakley’s family has been a part of Ranger sports for many years. His grandfather, the late W.C. “Bill” Oakley, is a member of the Sports Hall of Fame while his twin brother, Shane, enters his ninth season as an assistant on the men’s basketball staff. WILFRED Linebackers THOMAS MARCUS Running Backs WINDHAM TRES SULLIVAN Quarterbacks Wilfred Thomas enters his first season as linebackers coach. Over a coaching career that spans almost 20 years, Thomas is no stranger to success. Thomas was a part of back-to-back conference football championships at Rochester Community and Technical College and won a conference title with the Carolina Eagles. He also won a state title at West Charlotte High School in track and field. Thomas rejoins his fellow counterpart, Brad LaPlante, after working with him during the 2010 season at RCTC. Thomas coached special teams and the secondary for two seasons, with his unit leading the nation in interceptions in 2011 with 38 during the YellowJackets’ undefeated season. The Sanford, Fla., native most recently coached at King High School in Tampa, Fla., working with quarterbacks for the varsity team and serving as head coach for the junior varsity team during the 2012 season. King’s offense ranked second in the county in scoring in his only season. Thomas began coaching football in 1998 in Chattanooga, Tenn., for the Brainerd Bills Pop Warner team. Since then, he’s had stops at high schools and colleges all around the country including stints in North Carolina, Minnesota, Connecticut and Florida. As the running backs and special teams coach at Hamline University in St. Paul, Minn., from 2006-09, Thomas tutored a backfield that ran for over 1,800 yards on the season and had just two fumbles. Other stops for Thomas include Orchard Knob Middle School (1999-2001), West Charlotte High School (2001-03), Barber Scotia College (2003-04), Atlantic College (2005), Brisbane Academy (2006-07) and AFC Rangers High School (2010). He also spent one season with the Carolina Eagles, a semipro team, as quarterbacks coach and special teams coordinator. In 2007, he and the coaching staff led the team to an 11-1 record and a championship year while averaging over 40 points per game. Thomas is a 1979 graduate of Bethune-Cookman College where he earned his bachelors in biology. Marcus Windham is in his first year as the running backs coach at Northwest, joining new head coach Brad LaPlante’s staff on March 25, 2013. Windham, 28, comes to Northwest from Colquitt County High School (Ga.) where he spent the 2012 season as the receivers coach on Rush Propst’s staff. The Packers went 10-4 in his only season and lost in the semifinals of the GHSA Playoffs. At season’s end, he coached receivers in the War of the Border Georgia vs. Florida All-Star Game. Prior to Colquitt County, Windham spent the 2008-12 seasons at his alma mater Southwest Baptist University as the pass game coordinator and receivers coach. He was also the Bearcats’ film coordinator, academic liaison and assistant travel coordinator. While at SBU, the Bearcats had one of the most prolific offenses in all of NCAA Division II, ranking in the Top 5 in total offense in 2008, 2009 and 2010. He was heavily involved in offensive game planning, preparation and distribution of the defensive scouting report. As a player, Windham was a wide receiver/punt returner at Itawamba CC (2003-05) and Southwest Baptist University (2005-07). He ended his SBU career with 142 receptions for 1,255 yards and 10 touchdowns and was twice named an AllMIAA selection. Off the field, Windham was a two-year member of the Student-Athlete Advisory Committee (SAAC) in 2006-07. A native of Macon, Miss., Windham earned a bachelor’s degree in community recreation from SBU in 2009 and is currently working on his master’s in science. Tres Sullivan enters his first season as the Rangers’ quarterbacks coach, having played the position at both the collegiate level and in the Arena Football League. Sullivan coached the 2011 season at NCAA Division III Rhodes College in Memphis, working with cornerbacks and also assisting with special teams and defensive game planning. Prior to Rhodes, Sullivan spent the 2007-09 seasons at the University of California at Davis. His first season was as an administrative assistant for the defensive staff, while his final two seasons were as the receivers coach. The Aggies went 16-18 overall during his stay. Sullivan went to UC Davis following a coaching stop in the AFL and AFL2 from 2001-06.. Sullivan is married to the former Leslie Rendfrey and the couple have a 4-year-old son, Sully. MORRIS LOLAR DANNY RAY COLE Defensive Backs Special Teams Coordinator Head Strength Coach Morris Lolar enters his first season as the defensive backs coach and special teams coordinator, joining the staff in August 2013. Lolar comes to Senatobia from Wichita, Kan., where he spent the past five seasons with the CPIFL’s Wichita Wild, the last three as the head coach. Lolar led the Wild to a 12-2 record and league championship in 2013 and earned Honorable Mention honors as the CPIFL Coach of the Year. During the fall of 2008-12, Lolar was the defensive secondary coach at Friends University, and prior to that, was the defensive coordinator at Wichita East High School in 2007-08. Lolar spent the 2006 season on the coaching staff at Texas A&M Commerce assigned to the defensive secondary, where he coached four All-Lone Star Conference selections, including an NCAA Division II first team All-American. Upon completion of the 1998 season, Lolar began coaching at his alma mater, Friends University, where he was the secondary coach. Lolar coached three all-conference selections, including a two-time NAIA All-American. Following two years at Friends University, he went on to Wichita Northwest High School, where he coached four all-city defensive players, including the State of Kansas Player of the Year, high school All-American, NFL first round draft pick and current Tennessee Titans defensive end, Kamerion Wimbley. Lolar moved on from Northwest to Wichita North High School, where he served as the defensive coordinator. Lolar’s efforts were instrumental in the biggest win-loss turnaround in Wichita North school history. Lolar lettered his freshman season at Minnesota, playing six games in the secondary. He transferred to Friends University in 1990 and was a three-year starter and two-time All-American. Lolar went on to play professionally, spending time at training camp with the Kansas City Chiefs before signing with the Edmonton Eskimos of the Canadian Football League (CFL). In three seasons with Edmonton, Lolar recorded 125 tackles and 11 interceptions - three of which were returned for touchdowns. After earning a starting spot on the defense in his first season with Edmonton, Lolar led the Eskimos to a Grey Cup championship. Lolar graduated from Friends University with a bachelor’s in organizational management in 2008 and received his master’s in management in 2010. Danny Ray Cole is beginning his 12th season at Northwest and his third as the head strength and conditioning coach for all 12 athletic programs starting in July 2011. Named the Junior College Strength Coach of the Year by Samson’s in the March 2010 issue of American Football Monthly magazine, Cole serves as the football team’s strength coach and also was the defensive line coach his first eight seasons from 2001-08. He also teaches fitness and conditioning classes Monday-Thursday and evening classes on the Senatobia campus. Cole, who is a member of the Mississippi Coaches Association, came to Northwest from South Panola High School where he coached the defensive line and was strength and conditioning coach from 1991 through 2000. During his 10-year stay at South Panola, Cole helped the Tigers reach the Class 5A State Championship game on four occasions and won it in both 1993 and 1999. A 1980 graduate of South Panola, Cole attended Northwest for one year and majored in physical education. After Northwest, he earned his B.S. degree in physical education from the University of Arkansas at Monticello in 1991. Away from the playing field, Cole lifts weights as a hobby, which has earned him a place as one of the “Strongest Men in Mississippi” with the Mississippi High School Coaches Association. Cole competed in the super heavyweight category of 300 pounds and up and can bench press 600 pounds and squat 900 and once qualified for the 1986 Olympic team as a world-class bencher. LORI URETSKY Head Athletic Trainer Lori Uretsky enters her third season as the head athletic trainer, joining the Northwest family from Rutgers University in July 2011. Uretsky spent the 2008-11 seasons with the Scarlet Knights, responsible for the prevention, care, and rehabilitation of the women’s basketball, men’s/women’s track and field and men’s/women’s golf teams. Prior to Rutgers, the Mercerville, N.J., native spent the 2007-08 season as the head athletic trainer for Nevada’s women’s basketball program, as well as assisting with football, softball, women’s volleyball and overseeing several graduate assistants. Uretsky spent several weeks in the summer of 2008 as a volunteer athletic trainer at the United States Olympic Training Center in Colorado Springs, Colo. While volunteering with the USOC, she provided medical coverage for the men’s boxing team, the men’s volleyball Junior National Team, the A2 Select Team and the men’s gymnastics team. She also provided care to athletes from the men’s and women’s weightlifting, wrestling, women’s volleyball, Paralympics cycling, judo, modern pentathlon, triathlon, Junior National synchronized swimming and men’s cycling and bobsled teams. A collegiate softball player at Waynesburg College in Waynesburg, Pa., from 1995-98, Uretsky was the conference Freshman of the Year in 1995 and a four-time President’s Athletic Conference All-Conference selection. She attended the US Olympic Softball Team Trials in 1998 and 2002. Uretsky earned a bachelor’s degree in sports medicine and a minor in biology in 1998 from Waynesburg. She completed her master’s degree in health education with a health science concentration from The College of New Jersey in 1999 and also graduated from the Myotherapy Institute of Massage in Salt Lake City in August 2009. BLOUNT CAMERON ATHLETIC DIRECTOR u 4TH YEAR A new direction for Northwest began in June 2010 with the hiring of Cameron Blount as director of athletics and intramural sports, replacing Donny Castle who retired after 10 seasons. Blount has worked at Northwest since 2002, and his duties include overseeing a 10-sport athletic department in addition to intramural sports and supervising the newly renovated McClendon Center, dance studio and game room. Blount also serves as an adjunct instructor for health classes such as tennis, badminton, golf and fitness and conditioning. In his three years as the director of athletics and intramural sports, Blount has hit the ground running and pushed the major issue of upgrading Northwest’s athletic facilities. Just to name a few advancements, lights have been added to the baseball field, a new basketball gym floor was installed in Howard Coliseum and both locker rooms were completely renovated, and new dugouts were built at the softball complex. Before his employment at Northwest, Blount worked for eight years at the Baddour Center in Senatobia as a resident manager and director of vocational services from 1995 through 2002. A Northwest alumnus, Blount played baseball for the Rangers during the 1987 and 1988 seasons. An all-state, all-district and all-region nod during his stay, Blount played second base and led Northwest to a record of 33-12 during his sophomore year in 1988. The Rangers were Region 23 and MACJC North Division champions that season and runners-up for the state title. Blount finished his baseball career at Arkansas-Little Rock where he was selected All-TAAC Conference in 1990. Blount also earned a bachelor’s degree in health education and a minor in sociology. Blount lettered four seasons as a member of the baseball team at Independence High School where he graduated in 1986. Blount is married to the former Kenda Davis of Dallas, Texas. They have three sons – Kyle (21), a senior baseball player at Mississippi College, Cayman (15) and Kenzee (13). 17 1 Derrell Lovelady So. • WR Tunica, Miss. 5 Josh Hamilton So. • WR Tupelo, Miss. 8 Kentrell Spencer Fr. • WR Starkville, Miss. 9 Robert Liggins So. • WR Oxford, Miss. 10 Karsten Miller Fr. • QB Lexington, N.C. 11 Joshua Barry Fr. • DB Oxford, Miss. 12 D’Montrise Swinney 13 Alex Jones Fr. • WR Tunica, Miss. 14 Jonathan Barnett Fr. • DB Moss Point, Miss. 16 Terrell White So. • DB Orlando, Fla. 17 Taylor Rotenberry So. • FB/TE Batesville, Miss. 18 Kyle Morgan Fr. • QB Southaven, Miss. So. • WR Itta Bena, Miss. 19 Boone Frederick Fr. • K/P Olive Branch, Miss. 20 Brandon Mack Fr. • DB Oxford, Miss. 21 Keith Reynolds Jr. So. • DB Durant, Miss. 22 Shuntez Smith So. • WR Southaven, Miss. 24 Damian Baker So. • RB Columbus, Miss. 25 Marcel Newson Fr. • DB Coldwater, Miss. 26 Raphael McClain Fr. • DB Starkville, Miss. 27 Patrick Purnell Fr. • RB Winona, Miss. 28 Chris Fox Fr. • DB Yazoo City, Miss. 30 LaTroyce Murden Fr. • DB Southaven, Miss. 31 Wayne County, Miss. 32 Boston Newsome Fr. • RB New Albany, Miss. Leevan Bonner Fr. • FS 34 Ja’Vinte Gilliam Fr. • LB Horn Lake, Miss. 35 Sharkey Luna Fr. • LB Coldwater, Miss. 36 Josh Gaston So. • TE Olive Branch, Miss. 42 Quinterio Bailey Fr. • LB Water Valley, Miss. 44 Hunter Lawrence So. • FB Batesville, Miss. 58 Bobby Billingsley Fr. • OL Memphis, Tenn. 18 45 Alec Michael Fr. • LB Oxford, Miss. 50 Kalen Coleman Fr. • LB Oxford, Miss. 51 Josh Rea Fr. • OL Olive Branch, Miss. 53 David Green Fr. • LB Yazoo City, Miss. 55 Justin McCammon Fr. • OL Water Valley, Miss. 56 Cortez Coleman Fr. • DE Oxford, Miss. 57 Jordan Hall Fr. • OL Olive Branch, Miss. 59 Demetrius Farmer Fr. • DT Dover, Ohio 60 Rolandeis Tolliver Fr. • DT Horn Lake, Miss. 69 T.J. Scales Fr. • OT Potts Camp, Miss. 75 Nic Thomas Fr. • OL Olive Branch, Miss. 76 Samuel Edmondson Fr. • OL Fairview, Tenn. 77 DeAndre Wilson Fr. • OL Opelika, Ala. 80 Matt Bratton Fr. • K/P Olive Branch, Miss. 85 Deuce Lyons Fr. • DE Olive Branch, Miss. 88 Jamarius Mabry Fr. • WR Jackson, Miss. 89 Kamian Lucas Fr. • TE Cleveland, Miss. 90 Joseph Phillips So. • DE Childersburg, Ala. 91 Johnny Russell Fr. • DE Cleveland, Miss. 93 Austin Howard Fr. • DE New Albany, Miss. My Kaywa QR-Code 94 Markevious Garner Fr. • DT Tunica, Miss. 95 Tarow Barney So. • DT Bainbridge, Ga. 99 Kendall Carr So. • DL Batesville, Miss. 68 Rodrickus Hunt Fr. • DL Batesville, Miss. Use your smartphone to scan the QR Code which will take you to the 2013 online roster. There you can access full player bios. 19 2013 NORTHWEST MISSISSIPPI RANGERS Football Staff NO NAME POS HT WT CL HOMETOWN / PREVIOUS SCHOOL Head Coach Brad LaPlante (1st Season) Winona State University, 2001 Offensive Coordinator/OL Mike Beagle (1st Season) Richmond University, 1981 Defensive Coordinator/DL Ricky Coon (1st Season) Bethel College, 2005 Defensive Backs Morris Lolar (1st Season) Friends University, 2008 Wide Receivers Scott Oakley (10th Season) Ole Miss, 2001 Linebackers Wilfred Thomas (1st Season) Bethune-Cookman, 1979 Running Backs Marcus Windham (1st Season) Southwest Baptist, 2009 Quarterbacks Tres Sullivan (1st Season) Univ. of New Mexico, 1996 Head Strength Coach Danny Ray Cole (12th Season) Arkansas-Monticello, 1991 Team Managers Kaalyn Clinton, Deyondre Gaston, Angelica Hopkins, Joshua Kidd, Quinneshia Mays, Greg O’Neal, Alex Owens, Cortel Sandridge, Dominique Williams Support Staff Athletic Director Cameron Blount (4th Year) Arkansas-Little Rock, 1992 Sports Information Director Kevin Maloney (4th Year) Mississippi State, 2005 Head Athletic Trainer Lori Uretsky (3rd Year) Waynesburg University, 1998 Athletics Secretary Allison Eoff (6th Year) Delta State, 1993 1 5 8 9 10 11 12 13 14 16 17 18 19 20 21 22 24 25 26 27 28 30 31 32 34 35 36 42 44/67 45 50 51 53 55 56 57 58 59 60 68 69 75 76 77 80 85 88 89 90 91 93 94 95 99 Derrell Lovelady Josh Hamilton Kentrell Spencer Robert Liggins Karsten Miller Joshua Barry D’Montrise Swinney Alex Jones Jonathan Barnett Terrell White Taylor Rotenberry Kyle Morgan Boone Frederick Brandon Mack Keith Reynolds, Jr. Shuntez Smith Damian Baker Marcel Newson Raphael McClain Patrick Purnell Chris Fox LaTroyce Murden Leevan Bonner Boston Newsome Ja’Vinte Gilliam Sharkey Luna Josh Gaston Quinterio Bailey Hunter Lawrence Alec Michael Kalen Coleman Josh Rea David Green Justin McCammon Cortez Coleman Jordan Hall Bobby Billingsley Demetrius Farmer Rolandeis Toliver Rodrickus Hunt T.J. Scales Nic Thomas Samuel Edmondson DeAndre Wilson Matt Bratton Deuce Lyons Jamarius Mabry Kamian Lucas Joseph Phillips Johnny Russell Austin Howard Markevious Garner Tarow Barney Kendall Carr WR WR WR WR QB DB WR WR DB DB FB QB K/P DB DB WR RB DB DB RB FS DB FS RB LB LB TE LB FB LB LB OL LB OL DE OL OL DT DT DL OT OL OL OL K/P DE WR TE DE DE DE DT DT DL 5-6 6-2 5-9 6-3 6-3 6-1 6-2 5-8 5-8 5-11 6-1 5-11 6-1 6-1 6-0 5-10 5-8 5-11 5-9 5-8 5-11 5-9 6-0 5-8 6-1 6-1 6-3 5-6 6-2 6-0 5-9 6-0 6-0 6-2 6-2 6-2 6-3 6-2 6-2 6-0 6-4 6-5 6-5 6-6 5-10 6-4 6-4 6-3 6-6 6-1 6-0 6-0 6-1 6-0 160 200 160 210 210 195 170 160 155 175 245 195 195 180 175 180 180 185 170 190 175 160 160 180 210 205 265 210 265 215 205 290 210 260 250 270 295 260 270 335 315 315 280 350 185 245 185 205 250 260 245 290 260 285 So. So. Fr. So. R-Fr. Fr. So. Fr. Fr. So. R-So. Fr. Fr. Fr. So. So. So. Fr. Fr. Fr. Fr. Fr. Fr. Fr. Fr. Fr. So. Fr. So. Fr. Fr. Fr. Fr. Fr. Fr. Fr. Fr. Fr. Fr. Fr. Fr. Fr. Fr. Fr. Fr. Fr. Fr. Fr. So. Fr. Fr. Fr. So. So. Tunica, Miss. / Rosa Fort HS Tupelo, Miss. / Tupelo HS Starkville, Miss. / Starkville HS Oxford, Miss. / Oxford HS Lexington, N.C. / UNC Charlotte Oxford, Miss. / Lafayette HS Itta Bena, Miss. / Leflore County HS Tunica, Miss. / Lake Cormorant HS Moss Point, Miss. / Moss Point HS Orlando, Fla. / Edgewater HS Batesville, Miss. / Ole Miss Southaven, Miss. / DeSoto Central HS Olive Branch, Miss. / Center Hill HS Oxford, Miss. / Lafayette HS Durant, Miss. / Durant HS Southaven, Miss. / Northeast Mississippi CC Columbus, Miss. / Columbus HS Coldwater, Miss. / Coldwater HS Starkville, Miss. / Starkville HS Winona, Miss. / Winona HS Yazoo City, Miss. / Yazoo County HS Southaven, Miss. / Southaven HS Wayne County, Miss. / Wayne County HS New Albany, Miss. / New Albany HS Horn Lake, Miss. / Horn Lake HS Coldwater, Miss. / Magnolia Heights Olive Branch, Miss. / Olive Branch HS Water Valley, Miss. / Water Valley HS Batesville, Miss. / South Panola HS Oxford, Miss. / Lafayette HS Oxford, Miss. / Lafayette HS Olive Branch, Miss. / Lewisburg HS Yazoo City, Miss. / Yazoo City HS Water Valley, Miss. / Water Valley HS Oxford, Miss. / Lafayette HS Olive Branch, Miss. / Olive Branch HS Memphis, Tenn. / Memphis East HS Dover, Ohio / Dover HS Horn Lake, Miss. / Horn Lake HS Batesville, Miss. / South Panola HS Potts Camp, Miss. / Potts Camp HS Olive Branch, Miss. / DeSoto Central HS Fairview, Tenn. / Fairview HS Opelika, Ala. / Opelika HS Olive Branch, Miss. / Lewisburg HS Olive Branch, Miss. / Center Hill HS Jackson, Miss. / Forest Hill HS Cleveland, Miss. / Cleveland Eastside HS Childersburg, Ala. / Southwest Mississippi CC Cleveland, Miss. / Cleveland Eastside HS New Albany, Miss. / New Albany HS Tunica, Miss. / Rosa Fort HS Bainbridge, Ga. / Bainbridge HS Batesville, Miss. / South Panola HS 20 2013 COPIAH-LINCOLN WOLFPACK NO NAME POS HT WT CL PREVIOUS SCHOOL / HOMETOWN Football Staff 1 2 3 4 5 6 7 8 9 10 14 15 18 19 20 21 22 23 24 25 30 31 32 33 35 36 37 40 41 43 44 45 47 48 49 51 54 55 56 57 59 64 67 72 73 74 75 81 84 85 88 90 95 96 98 Greg Sims Jordan Harris Javon Washington Courtney Foy Bubba Keene Kalen Jackson Carroll Phillips Casey Gladney Jonathan Calvin Arthur Maulet Zack Smith Daniel Fitzwater Ross Hill, Jr. De’Vante Nichols Edward Muldrow Jimmy Barnes Koy McFarland Diquan Davis Ricky Green Chris Richmond Bejay Welch Josh Russell Roy Bibbs Jymal Ellis Kelton Smith Van Lee Joshua Bates Gabe Terry Justin Morgan DeLance Turner Darius Woodcox Desmond King Teron Fitzgerald Blayne Jones Trent Furr Xavier Dampeer Ryan Proctor Garrett Keating DeMorris Bedford Cullen Greer Terry Smith David Adams Quintarius Willis Jocquell Johnson Zechariah Ray Jacob Fleming Nick Luckey Darrion Hutcherson Germie Martin Tyson McDonald Philanteus Jarrett Anthony Cunningham Darrell Vanerson Ryan Duckworth Demond Tucker RB/DB LB WR WR WR DB LB/DE WR DT DB QB QB WR WR LB LB WR WR DB DB DB DB DB LB RB WR/RB DB LB DB RB LB LB LB K K OL OL OL DT OL LS OL OL OL OL OL OL TE WR TE DL DL DL DL DL 5-10 6-0 5-10 5-10 6-4 6-1 6-4 6-0 6-3 5-11 6-1 6-6 6-2 5-8 6-4 6-1 5-10 5-11 5-10 6-0 6-2 5-10 6-2 6-3 5-11 6-0 5-10 6-3 6-2 5-11 5-11 5-11 6-2 5-10 5-10 6-2 6-5 6-4 6-1 6-0 5-10 6-4 6-3 6-5 6-6 6-5 6-3 6-6 6-0 6-3 6-3 6-1 6-3 6-2 6-1 175 235 180 180 190 205 245 185 265 195 185 230 185 170 220 215 165 185 180 200 196 180 190 210 205 190 180 200 200 195 215 225 180 160 165 300 300 275 265 280 240 275 260 305 315 295 280 245 175 235 280 260 270 265 285 So. So. So. Fr. So. So. Fr. So. Fr. Fr. Fr. Fr. So. So. So. So. Fr. Fr. Fr. So. Fr. Fr. Fr. So. So. So. Fr. So. Fr. Fr. So. Fr. Fr. Fr. Fr. So. So. Fr. Fr. Fr. Fr. So. Fr. So. Fr. Fr. Fr. So. Fr. So. So. So. Fr. Fr. Fr. Brookhaven / Brookhaven, Miss. Clarksdale / Clarksdale, Miss. Natchez / Natchez, Miss. Midfield / Birmingham, Ala. Brookhaven Academy / Brookhaven, Miss. Magee / Magee, Miss. Miami Central / Miami, Fla. Glen Forest / Columbia, S.C. Murrah / Jackson, Miss. Bonnabel / Harvey, La. Brookhaven / Brookhaven, Miss. Calvary / Shreveport, La. Brookhaven / Brookhaven, Miss. Pearl / Pearl, Miss. South Gwinnett / Snellville, Ga. Franklin County / Meadville, Miss. Wesson / Wesson, Miss. Greenville Weston / Greenville, Miss. South Delta / Rolling Fork, Miss. Brandon / Brandon, Miss. Northwest Rankin / Flowood, Miss. Jim Hill / Jackson, Miss. McComb / McComb, Miss. Ridgeland / Ridgeland, Miss. Copiah Academy / Wesson, Miss. Mendenhall / Mendenhall. Miss. Provine / Jackson, Miss. Palm Beach Central / Wellington, Fla. Senatobia / Senatobia, Miss. Perry Central / New Augusta, Miss. Callaway / Jackson, Miss. Southaven / Southaven, Miss. West Gadsden / Hattiesburg, Miss. St. Joseph / Madison, Miss. Ackerman / Ackerman, Miss. Mendenhall / Mendenhall, Miss. Brandon / Brandon, Miss. Adams Christian / Natchez, Miss. John F. Kennedy / Mound Bayou, Miss. Wesson / Wesson, Miss. Port Gibson / Port Gibson, Miss. South Delta / Rolling Fork, Miss. Greenville Weston / Greenville, Miss. Callaway / Jackson, Miss. Yazoo City / Yazoo City, Miss. North Pike / McComb, Miss. Magee / Magee, Miss. Dadeville / Dadeville, Ala. Bogue Chitto / Bogue Chitto, Miss. Magee / Magee, Miss. Hollendale / Hollendale, Miss. Wayne County / State Line, Miss. McComb / McComb, Miss. Taylorsville / Taylorsville, Miss. Hazlehurst / Hazlehurst, Miss. Head Coach Glenn Davis (10th Season) Delta State University, 1982 Offensive Line Coach Robert McFarland (2nd Season) McNeese State, 1985 Defensive Coordinator Otis Yelverton (1st Season) North Carolina A&T Defensive Backs Calvin M. Green (20th Season) Alcorn State University Running Backs/Special Teams Bill Hemingway (6th Season) Delta State University Defensive Assistant Maurice Johnson (1st Season) Florida A&M University, 1999 Asst Coach/Video Coordinator Dan Reich (2nd Season) University of Central Florida Support Staff Athletic Director Gwyn Young (25th Year) Mississippi College Sports Information Director Natalie Davis Asst Sports Information Director Cliff Furr Head Athletic Trainer Matt McClain, ATC Assistant Athletic Trainer Jill Koenig, ATC 21 2013 Northwest Team Statistics Kick Return Average PUNT RETURNS: #-Yards Punt Return Average INT RETURNS: #-Yards Int Return Average FUMBLES-LOST PENALTIES-Yards Average Per Game PUNTS-Yards Average Per Punt Net punt average TIME OF POSSESSION/Game 3RD-DOWN Conversions 3rd-Down Pct 4TH-DOWN Conversions 4th-Down Pct SACKS BY-Yards TOUCHDOWNS SCORED FIELD GOALS-ATTEMPTS ON-SIDE KICKS RED-ZONE SCORES Red Zone Percentage RED-ZONE TOUCHDOWNS Red Zone TD Percentage PAT-ATTEMPTS PAT Percentage ATTENDANCE Games/Avg Per Game NWCC OPP 15 19 15.0 19.0 21 14 8 9 10 4 3 1 173 148 198 158 25 10 40 32 4.3 4.6 173.0 148.0 0 1 193 89 17-30-1 10-18-1 6.4 4.9 11.4 8.9 193.0 89.0 2 1 366 237 70 50 5.2 4.7 366.0 237.0 5-77 2-43 15.4 21.5 0-0 1--3 0.0 -3.0 1-36 1-71 36.0 71.0 0-0 2-1 9-73 5-55 73.0 55.0 4-128 4-137 32.0 34.2 32.8 34.2 39:13 20:47 7/17 6/10 41% 60% 2/4 0/0 50% 0% 1-2 1-1 2 3 0-1 0-0 0-0 0-0 1-4 2-3 25% 67% 1-4 2-3 25% 67% 1-2 1-1 50% 100% 977 0 1/977 0/0 2013 Northwest Individual Statistics (as of Aug. 29) RUSHING Damian Baker Boston Newsome Karsten Miller Kentrell Spencer Kyle Morgan Total Opponents PASSING Karsten Miller Total Opponents GP Att Gain Loss Net Avg TD Long Avg/G 1 27 165 22 143 5.3 0 35 143.0 1 7 19 2 17 2.4 0 6 17.0 1 4 9 1 8 2.0 0 6 8.0 1 1 3 0 3 3.0 0 3 3.0 1 1 2 0 2 2.0 0 2 2.0 1 40 198 25 173 4.3 0 35 173.0 1 32 158 10 148 4.6 1 14 148.0 GP Effic Cmp-Att-Int 1 126.04 17-30-1 1 126.04 17-30-1 1 104.31 10-18-1 No Yds 8 116 2 22 2 16 2 13 1 12 1 11 1 3 17 193 10 89 Pct Yds TD Lng Avg/G 56.7 193 2 30 193.0 56.7 193 2 30 193.0 55.6 89 1 23 89.0 Avg TD Long Avg/G 14.5 2 30 116.0 11.0 0 16 22.0 8.0 0 11 16.0 6.5 0 14 13.0 12.0 0 12 12.0 11.0 0 11 11.0 3.0 0 3 3.0 11.4 2 30 193.0 8.9 1 23 89.0 Total Avg/G 201 201.0 143 143.0 17 17.0 3 3.0 2 2.0 366 366.0 237 237.0 RECEIVING GP D’Montrise Swinney 1 Kentrell Spencer 1 Josh Gaston 1 Damian Baker 1 Jamarius Mabry 1 Derrell Lovelady 1 Robert Liggins 1 Total 1 Opponents 1 TOTAL OFFENSE G Plays Rush Pass Karsten Miller 1 34 8 193 Damian Baker 1 27 143 0 Boston Newsome 1 7 17 0 Kentrell Spencer 1 1 3 0 Kyle Morgan 1 1 2 0 Total 1 70 173 193 Opponents 1 50 148 89 2013 Scoring by Quarters BY QUARTERS Northwest Opponents 1st 9 0 2nd 6 7 3rd 0 6 4th 0 6 Total 15 19 Quarterback Karsten Miller 22 2013 Northwest Defensive Statistics (as of Aug. 29) TACKLES SACKS PASS DEFENSE FUMBLES Blocked DEFENSIVE LEADERS GP-GS Solo Ast Total TFL/Yds No-Yds Int-Yds BrUp QBH Rcv-Yds FF Kicks Saf 45 Alec Michael 1 3 7 10 . . . . 1 . . . . 16 Terrell White 1 4 3 7 . . . . . 1-0 . . . 28 Chris Fox 1 2 4 6 . . . . . . . . . 95 Tarow Barney 1 3 3 6 4.0-7 0.5-1 . . 2 . . . . 99 Kendall Carr 1 1 3 4 0.5-1 . . . . . . . . 21 Keith Reynolds Jr. 1 3 1 4 1.0-4 . . . . . . . . 50 Kalen Coleman 1 1 2 3 . . . . . . . . . 90 Joseph Phillips 1 1 2 3 . . . . . . . . . 11 Joshua Barry 1 . 2 2 . . 1-36 . . . . . . 93 Austin Howard 1 2 . 2 . . . . . . . . . 20 Brandon Mack 1 2 . 2 . . . 1 . . . . . 26 Raphael McClain 1 1 1 2 . . . . . . . . . 56 Cortez Coleman 1 1 1 2 . . . . . . . . . 25 Marcel Newson 1 . 1 1 . . . . . . . . . 80 Matt Bratton 1 . 1 1 . . . . . . . . . 59 Demetrius Farmer 1 . 1 1 0.5-1 0.5-1 . . . . . . . TM TEAM 1 . . . . . . . . . . . 1 Total 1 24 32 56 6-13 1-2 1-36 1 3 1-0 . . 1 Opponents 1 39 42 81 9.0-26 1-1 1-71 5 1 . . . . SCORING D’Montrise Swinney TEAM Matt Bratton Total Opponents FIELD GOALS Matt Bratton PUNTING Matt Bratton Total Opponents KICKOFFS Matt Bratton Total Opponents TD FGs Kick Rush Rcv Pass DXP Saf Points 2 0-0 0-0 0-0 0 0-0 0 0 12 0 0-0 0-0 0-0 0 0-0 0 1 2 0 0-1 1-2 0-0 0 0-0 0 0 1 2 0-1 1-2 0-0 0 0-0 0 1 15 3 0-0 1-1 0-1 0 0-1 0 0 19 Pct 0.0 01-19 20-29 30-39 40-49 50+ 0-0 0-0 0-1 0-0 0-0 Lg 0 Blk 0 FGM-FGA 0-1 No. Yds Avg Long TB FC I20 Blkd 4 128 32.0 37 0 0 1 0 4 128 32.0 37 0 0 1 0 4 137 34.2 44 0 1 2 0 No. Yds 3 169 3 169 5 285 Avg TB OB Retn Net YdLn 56.3 0 1 . . . 56.3 0 1 43 42.0 23 57.0 0 0 77 41.6 23 Safety Terrell White NJCAA First Team All-Americans Keith Drayton 1994 Emarlos Leroy 1996 Connie Moore 1997 Les Binkley 1998 Johnathan Shaw 1999 Jamaal Jackson 2002 Chris Herring 2003 John Harris 2003 DeVon Hicks 2006 R.J. Brisbon 2006 Michael Lindsey 2009 Donald Hawkins 2011 **Northwest has a combined 27 NJCAA First Team All-Americans (not all pictured) 1957: 1958: 1959: 1960: 1962: 1979: 1982: 1983: 1985: 1986: 1987: 1988: 1989: 1990: 1991: 1992: 1993: 1994: 1995: 1996: 1997: 1998: Edwin Thomas; Danny Cranford David Vaughn, C; Bobby Houge, QB Bobby Hogue (honorable mention); David Vaughn (honorable mention) Bryce McCullough; Tommy Poff R.L. Lance (Williamson AA); Billy Gold (Williamson AA) Donnell Townsend, NJCAA (honorable mention); Jimmy Franklin, NJCAA (second team) Eric Schwartz, OG, NJCAA (first team); Terry Lawrence, RB, NJCAA (first team); Bobby Gaston, NJCAA (second team); Henry Williams, RS (first team) John Armstrong, CB, NJCAA (first team) Gerald Perry, OG, NJCAA (first team); Houston Agnew, NJCAA (honorable mention); Jimmy Neal, NJCAA (second team) Leatrice Pickett, RB, NJCAA (second team); James Holloman, NJCAA (honorable mention) Cortez Kennedy, DT, NJCAA (first team); Ricky Blake, RB, NJCAA (first team) Mike McClenton, LB, NJCAA (first team); J.C. Gridwire (first team); Wesley Carroll, WR, NJCAA (hon. mention); JoJo Wright, DB, J.C. Gridwire (scholar athlete); Eddie Blake, OL, J.C. Gridwire (first team) Mike McClenton, LB, NJCAA (first team); J.C. Gridwire (first team); Vince Powell, RB, NJCAA (first team); Eddie Blake, OL, J.C. Gridwire (first team) Kelvin Simmons, QB, NJCAA (honorable mention); J.C. Gridwire (honorable mention); Ray Barksdale, RB, J.C. Gridwire (honorable mention); Andre Thompson, DT, J.C. Gridwire (honorable mention) Damon Primus, DT, NJCAA (first team); J.C. Gridwire (first team); Alonzo Horner, LB, NJCAA (first team); Russell Evans, QB, NJCAA (second team); Lonny Calicchio, P/K, J.C. Gridwire (honorable mention) Russell Evans, QB, NJCAA (first team); J.C. Gridwire (first team); Bill McCollins, LB, NJCAA (first team); Lonny Calicchio, P/K, NJCAA (first team); Jeff Miller, OL, NJCAA (second team); Eric Smith, WR, NJCAA (second team); Bryant Mix, DT, NJCAA (honorable mention); J.C. Gridwire (honorable mention); Lavelle Danzy, RB, J.C. Gridwire (honorable mention) Phillip Benton, LB, NJCAA (first team); J.C. Gridwire (first team); Fred Thomas, DB, NJCAA (second team); Keith Drayton, DT, NJCAA (honorable mention); J.C. Gridwire (honorable mention) Keith Drayton, DT, NJCAA (first team); J.C. Gridwire (first team); Andre Rone, WR, NJCAA (second team); John Avery, RB, J.C. Gridwire (honorable mention) Cletidus Hunt, DT, NJCAA (second team); Andre Rone, WR, NJCAA (honorable mention) Emarlos Leroy, DT, NJCAA (first team); Shane Hargett, P, NJCAA (second team); Deon Porter, DB, J.C. Gridwire (honorable mention) Connie Moore, WR, NJCAA (first team); Kevin Jones, RB, J.C. Gridwire (honorable mention) Les Binkley, PK, NJCAA (first team); J.C. Gridwire (hon. mention); Dee Miller, DB, NJCAA (second team), J.C. Gridwire (honorable mention); Kevin Jones, RB, J.C. Gridwire (honorable mention); Andre Heard, WR, J.C. Gridwire (honorable mention); Colston Weatherington, DE, J.C. Gridwire (honorable mention) 24 1999: 2000: 2001: 2002: 2003: 2004: 2006: 2007: 2008: 2009: 2010: 2011: 2012: Johnathan Shaw, SS, NJCAA (first team); J.C. Gridwire (honorable mention); Michael Allen, OL, NJCAA (second team); J.C. Gridwire (second team); Jason Johnson, QB, NJCAA (honorable mention); J.C. Gridwire (honorable mention); Jason Jones, LB, J.C. Gridwire (honorable mention); Omar Rayford, WR, NJCAA (hon. mention); J.C. Gridwire (honorable mention); Shae Orrell, PK, J.C. Gridwire (honorable mention) Anton Paige, WR, J.C. Gridwire (first team); NJCAA (honorable mention); Will Hall, QB, J.C. Gridwire (second team); NJCAA (honorable mention); Johnathan Shaw, SS, J.C. Gridwire (honorable mention); Andrew Oetzel, OT, NJCAA (honorable mention); Shae Orrell, PK, J.C. Gridwire (honorable mention) Durell Robinson, WR, J.C. Gridwire (honorable mention); Colby Simmons, LB, J.C. Gridwire (honorable mention) Jamaal Jackson, CB, NJCAA (first team); J.C. Gridwire (honorable mention); Isaac Harris, OT, J.C. Gridwire (first team); NJCAA (honorable mention); John Harris, WR, NJCAA (second team); J.C. Gridwire (third team); Bobby Robison, QB, NJCAA (honorable mention); J.C. Gridwire (honorable mention) John Harris, WR, NJCAA (first team); J.C. Gridwire (hon. (mention); Chris Herring, DT, NJCAA (first team); J.C. Gridwire (second team); Terrell Howard, OT, J.C. Gridwire (honorable mention); Terrence Smith, LB, J.C. Gridwire (first team) Eldra Buckley, RB, NJCAA (second team); J.C. Gridwire (second team); Marcus Conner, CB, NJCAA (second team); J.C. Gridwire honorable mention; Jess McDonald, OG, NJCAA (second team); J.C. Gridwire (second team) Billy Bishop, PK, J.C. Gridwire (honorable mention); Rodney Brisbon, OT, NJCAA (first team); J.C. Gridwire (second team); DeVon Hicks, DE, NJCAA (first team); J.C. Gridwire (honorable mention); Marcus Johnson, LB, NJCAA (second team) Patrick Trahan, LB, NJCAA (second team); J.C. Gridwire (second team); Daniel Thomas, QB/RB, J.C. Gridwire (honorable mention) Chris Strong, DT, NJCAA (honorable mention) Michael Lindsey, WR, NJCAA (first team) Sam Small, LB, NJCAA (second team); Kevin Buford, K/P, NJCAA (honorable mention) Donald Hawkins, LT, NJCAA (first team); Lance Ray, KR, NJCAA (honorable mention); David Conner, LB, NJCAA (honorable mention) Austin Douglas, C, NJCAA (second team) NJCAA Academic All-Americans Brent Smith 2001 Justin Brewer 2002 Hayden Sullivant 2003 Denny Hansen 2009 NJCAA Football Hall of Fame Cortez Kennedy 1996 Inductee Gerald Perry 1997 Inductee Henry Williams 1997 Inductee Mike McClenton 2000 Inductee Bobby Franklin 2005 Inductee 25 congratulations cortez kennedy 2012 PRO FOOTBALL HALL OF FAME The road to the NFL runs through ALL-TIME John Armstrong, CB John Avery, RB Jeff Blackshear, OT Willie Blade, DT Eddie Blake, DT Ricky Blake, RB Eldra Buckley, RB Len Burton, OG Lonny Calicchio, K Wesley Carroll, WR Kory Chapman, RB Dan Footman, DT Roy Hart, DT Chris Herring, DT DeVon Hicks, DE Bill Houston, WR Cletidus Hunt, DT Cortez Kennedy, DT Emarlos Leroy, DT NFL PLAYERS Jeff Miller, OT Bryant Mix, DT Ronnie Monaco, LB Alton Montgomery, SS Gerald Perry, OT Roell Preston, RS Andre Rone, WR Ron Shegog, S Eric Smith, WR Curtis Steele, RB Daniel Thomas, RB Fred Thomas, DB Tom Thompson, RB Patrick Trahan, LB Colston Weatherington, DE Leonard Wheeler, FS Henry Williams, RS Mitch Young, DT • 20 All-Time NFL Draft Picks • 5 Current Professional Players • 1 NFL Hall of Famer • 1 CFL Hall of Famer Facebook: Northwest Rangers Twitter: @NWCC_Rangers John Ungurait Ranger Band Directors 2013-14 2013-14 Northwest Color Guard Pictured front row (L to R): Tori Summers, Anastasija Markic, Mallory Pounds, Tammy Davis Middle Row: Kayce Young, Audrey Jones, Sammie Talbert, Shelby Smith, T.J., Meghan Browning Back row: Haleigh Ferguson, Ashley Simon, Rachel Jackson, Ashlee Walker, Ashley Weaver. Aime Anderson, Advisor 2013-14 Rangerettes Front Row: Carolin Ouch, Brittany Burns, Captain Elainna Ferrell, Fenisha Chatmon, Allie Mahoney Second Row: Straunje’ Jackson, Alicia Lemons, Savannah Mask, Shanda Cunningham, Candace Hubbert, Briana Patton Back Row: Shay Dudley, Samantha Staggs, Heather Pate, Ashley Hunt, Madison Pickett 28 Jeff Triplett John Mixon 2013-14 Northwest Cheerleaders Pictured front row (L to R): Chance Simmons, Megan Wootten, Kayla Witt, Madison Morgan, Shelbi Dunlap, Courtney Mitchell, Georgia Dulin, Lee Williams. Middle Row: Gerald Johnson, Breanna Bess, Amanda Rayburn, Katelyn McCluskey, KK Williams, John Cotton. Back Row: Greg Traylor, Lauren Carson, Lindsay Abston, Kayla Lunamand, Celeste Romanoli, Brandon Casey. 2013-14 Team Captains Lauren Carson and Shelbi Dunlap. Coaches & Sponsor Nolan Shackleford, Liesl Davenport and Trey Griffin. Do you have spirit? The Ranger Cheerleaders are high-energy, have loads of personality and love to cheer. The co-ed squad supports the college’s athletic teams while boosting fan support and having fun. They represent Northwest at football and basketball games and travel to bowl games and tournaments around the nation. Although they are non-competitive, certain requirements must be met at tryouts held each spring. Members must be proficient in stunting, motions, toe touches and cheering, maintain a certain fitness level and receive a positive recommendation from their most recent cheer sponsor. For more information contact: Liesl D. Davenport, Cheer Sponsor Work: (662) 562-3899 E-mail: ldavenport@northwestms.edu 29 BOBBY FRANKLIN FIELD uRanger Stadium at Bobby Franklin Field is the home of Northwest Ranger football. This beautifully landscaped, lighted facility features home/visitor concession stands, seating for approximately 3,000 spectators and newly-constructed restroom facilities. In 2005, the field at Ranger Stadium was named for longtime head coach Bobby Franklin who retired at the end of the 2004 season. BOBBY FRANKLIN FIELD TOP ATTENDANCE GAMES Yearly Attendance Year Record Pct. Total 2005 0-4 .000 3,100 2006 3-2 .600 2,900 2007 3-1 .750 3,300 2008 3-1 .750 3,000 2009 2-3 .400 4,200 2010 5-1 .833 8,222 2011 2-2 .500 8,558 2012 4-0 1.000 7,625 2013 0-1 .000 977 Totals 22-15 .595 41,882 Top 10 Bobby Franklin Field Crowds 1. 9/29/11 #15 Northeast L, 28-34 2. 9/27/12 #20 Itawamba W, 49-7 3. 9/15/11 #8 East Mississippi L, 42-45 4. 9/13/12 Coahoma W, 44-6 5. 9/1/11 #8 Pearl River W, 56-55 6. 10/16/10 Mississippi Delta W, 33-3 7. 9/23/10 Coahoma W, 37-7 8. 10/22/11 Holmes W, 66-41 9. 11/6/10 #12 Gulf Coast L, 24-52 10. 9/9/10 East Central W, 41-26 Avg. 775 580 825 750 840 1,370 2,140 1,906 977 1,131 2,772 2,669 2,219 2,102 2,101 1,733 1,489 1,466 1,452 1,339 30 McLENDON CENTER uThe McClendon Center, which houses the student union and was reopened this fall, has two recreational gyms and separate weight rooms for student-athletes and faculty/staff/students. The athletic weight room has four multi-stations with four double-sided platforms, a leg press, three treadmills, three elliptical machines, a jammer and a dumbell rack ranging from 5 to 95 pounds. 31 Proud supporters of our Northwest Rangers! Find out more about scholarships available For northwest transFer students at Courses are offered in day, evening, and online settings to fit your busy schedule. Junior and senior-level courses offered in: • Accountancy • Business (finance, management, marketing, MIS) • Criminal Justice (corrections, homeland security, law enforcement) • Education (elementary and secondary) • General Studies (Choose any 3 minors) • Integrated Marketing Communications • Health Sciences • Liberal Studies (English, history, psychology, sociology) • Paralegal Studies • Social Work Numerous master’s-level programs are also offered for area working professionals. 5197 W. E. Ross Parkway Southaven, MS 38671 662-342-4765 | http://issuu.com/northwest_mississippicc/docs/game2 | CC-MAIN-2014-49 | refinedweb | 12,636 | 73.27 |
clock_nanosleep - high resolution sleep with specifiable clock
[CX]
#include <time.h>#include <time.h>
int clock_nanosleep(clockid_t clock_id, int flags,
const struct timespec *rqtp, struct timespec *rmtp);
If.
If). The rqtp and rmtp arguments can point to the same object. If the rmtp argument is NULL, the remaining time is not returned. The absolute clock_nanosleep() function has no effect on the structure referenced by rmtp.
If clock_nanosleep() fails, it shall return the corresponding error value..
None.
Calling clock_nanosleep() with the value TIMER_ABSTIME not set in the flags argument and with a clock_id of CLOCK_REALTIME is equivalent to calling nanosleep() with the same rqtp and rmtp arguments.
The nanosleep() POSIX.1-2008
XBD <time.h>
First released in Issue 6. Derived from IEEE Std 1003.1j-2000.
The clock_nanosleep() function is moved from the Clock Selection option to the Base.
POSIX.1-2008, Technical Corrigendum 2, XSH/TC2-2008/0068 [909] is applied.
return to top of pagereturn to top of page | http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_nanosleep.html | CC-MAIN-2016-50 | refinedweb | 161 | 69.28 |
en.wikipedia.org/wiki/Rule_of_72
In finance, the
A shortcut to estimate the number of years required to double your money at a
given annual rate of return (see compound annual growth rate). The
Do you know the
betterexplained.com/articles/the-rule-of-72/
Jan 25, 2007
genxfinance.com/use-the-rule-of-72-to-understand-compound-interest/
If you want to quickly determine how long it will take for your money to double, the
beginnersinvest.about.com/cs/21jumpstreet/a/012501a.htm
Mar 28, 2016
How to Use the
For example, using the
Dec 29, 2014
Jan 19, 2016
Using the
Take a closer look. You are 24 and have $3,000 in savings. You put it in an
account that you expect to earn 8%. According to the Power of | http://www.ask.com/web?q=Rule+of+72&oo=2603&o=0&l=dir&qsrc=3139&gc=1&qo=popularsearches | CC-MAIN-2016-22 | refinedweb | 133 | 58.18 |
Introduction
One of the benefits of the Flash Player technology is being able to write applications in the manner that best suits you. For example, you can use Flash 8 to develop high-impact animations or use Flex to build compelling business applications.
What is even better is being able to combine them together. It turns out that creating an animiation in Flash and incorporating it into a Flex application is not uncommon. And because both Flex and Flash are language driven via ActionScript, the Flex application could control the Flash animiation or vice-versa.
Doing this with Flash 8, Flash MX 2004 or Flash MX and Flex 1.5 was relatively easy. But that is not the case with Flex 2 and Flash Player 9. I’ll show how to do this and I hope you see that this is in fact, a better way to do it.
As you may know, a Flex 2 SWF requires Flash Player 9. That’s because Flex 2 uses ActionScript version 3 (AS3) and Flash Player 9 was developed (from the ground up, I’m told) to use ActionScript 3. ActionScript 3 with its stronger data typing and object-oriented structure provides a better platform for a higher performing Flash Player.
But as with all versions of the Flash Player, Flash Player 9 is backward-compatible. That is, it will run SWFs built for earlier Flash Player versions. But this happens differently than before. When the Flash Player 9 loads a SWF that uses ActionScript 2 (or less), it creates a virtual machine – a self-contained area which is loaded with the logic to run ActionScript 2 SWFs. We call this an AVM. When Flash Player 9 has loaded a Flex 2 SWF which then requests to load an AS2 SWF, that SWF is loaded into its own AVM. Thus the two SWFs run in different areas of the Flash Player. Different and isolated areas.
What this means is that your Flex 2 application cannot address the AS2 SWF and reach inside and reference its functions, variables, and timeline. Likewise, the AS2 SWF cannot get at anything in the Flex 2 application simply by referencing it.
The solution is to use LocalConnection – the Flash Player to Flash Player messaging system. If you haven’t used LocalConnection before, take a moment and read up on it. You might get some inspiration for your next project.
To see a demonstration of this, click this link: Flex 2 and Flash Demo and be sure your browser has Flash Player 9. This will open in a new window.
Briefly, LocalConnection lets one Flash Player send messages to one or more other Flash Players running on the same desktop. The Flash Players can be on the same HTML page, in different frames, or even in different browsers. For example, suppose you are creating an HTML page with 3 frames: a top one for a banner, a side one for a menu, and a center one for content. You want to have the banner and menu be Flash movies. You’d also like any selection from the menu SWF change the content of the banner SWF. Since these SWFs are running inside of different Flash Players, you can use LocalConnection to have the menu SWF send messages to the banner SWF.
LocalConnection is a one-way message. One SWF listens for messages that another SWF sends. If you want bi-directional communication, both SWFs need to create LocalConnections and name them uniquely.
LocalConnection also works between Flash Player 9 AVMs.
Flash
In your Flash application create a LocalConnection object and add to it functions that you want the Flex application to call. These are the ‘messages’ I’ve been mentioning.
var fromFlex_lc:LocalConnection = new LocalConnection(); fromFlex_lc.stopMe = function() { stop(); } fromFlex_lc.playMe = function() { play(); } fromFlex_lc.connection( "lc_from_flex" );
The stopMe and playMe functions are very simple and just stop and play the timeline. But they can of course, be much more complex. Flex is going to invoke them when the user clicks a button.
Flex
In your Flex application, create a LocalConnection object and use it to invoke the stopMe and playMe functions in the Flash SWF.
import flash.net.LocalConnection; var toFlash_lc:LocalConnection = new LocalConnection(); <mx:Button <mx:Button
The buttons invoke the LocalConnection.send() method, naming the connection that the Flash SWF is listening on. The second argument to the send() method is the name of the function to invoke. If the functions have any arguments, they follow the method name.
Flash to Flex
As you might expect, having the Flash SWF send messages to the Flex SWF is just the reverse. And that is true with the exception of where you define the messages the LocalConnection.send() method invokes.
In the Flex application you create an object which has the functions you want invoked from the LocalConnection. For example:
<mx:Application xmlns: <mx:Script> <![CDATA[ import flash.net.LocalConnection; public function showDetails() : void { // do something } private var fromFlash_mc:LocalConnection; private function initApp() : void { fromFlash_lc = new LocalConnection(); fromFlash_lc.client = this; fromFlash_lc.connect("lc_from_flash"); } ]]> </mx:Script> ... </mx:Application>
The Flash SWF can now invoke any public method defined on the object named as the “client” to the LocalConnection. In this case the intent is to have the Flash SWF invoke the showDetails() method. | http://blogs.adobe.com/peterent/2006/07/12/using_actionscr/ | CC-MAIN-2015-14 | refinedweb | 884 | 65.52 |
On Thu, 2010-10-28 at 10:29 +0200, Nils Breunese wrote:
> Jeffrey M. Barber wrote:
>
> > Is it a good idea to have a single application work inside of a single
> > CouchDB database?
> >
> > Right now, I'm making sure each document I put into the CouchDB has a 'ns'
> > field (for namespace) so I can pull it out for indexing, but I'm thinking
> > that as this grows this may be a bad idea. Is it worth pulling out each ns
> > into a database? or is this just going to be a pre-optimization in the long
> > term.
>
> Using an ns-like property is a commonly used pattern in CouchDB databases. I don't think
it's worth it to start splitting up your database. You lose some flexibility as functions
exist on a database-level and cannot work across different databases and I don't see any real
advantage in doing it.
>
> Nils.
> ------------------------------------------------------------------------
> VPRO
> phone: +31(0)356712911
> web:
> ------------------------------------------------------------------------
I'm very glad to hear this, as it is the pattern I opted for also.
Dan | http://mail-archives.apache.org/mod_mbox/incubator-couchdb-user/201010.mbox/%3C1288457259.24561.0.camel@dirac.home%3E | CC-MAIN-2015-35 | refinedweb | 177 | 78.48 |
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: and I've pasted the full text below. I've tried to be more explicit about the goals -- the make statement is mostly syntactic sugar for:: class <name> <tuple>: __metaclass__ = <callable> <block> so that you don't have to lie to your readers when you're not actually creating a class. I've also added some new examples and expanded the discussion of the old ones to give the statement some better motivation. And I've expanded the Open Issues discussions to consider a few alternate keywords and to indicate some of the difficulties in allowing a ``__make_dict__`` attribute for customizing the dict in which the block is executed. PEP: 359 Title: The "make" Statement Version: $Revision: 45366 $ Last-Modified: $Date: 2006-04-13 07:36:24 -0600 (Thu, 13 Apr 2006) $ Author: Steven Bethard <steven.bethard at gmail.com> Status: Draft Type: Standards Track Content-Type: text/x-rst Created: 05-Apr-2006 Python-Version: 2.6 Post-History: 05-Apr-2006, 06-Apr-2006, 13-Apr-2006 Abstract ======== This PEP proposes a generalization of the class-declaration syntax, the ``make`` statement. The proposed syntax and semantics parallel the syntax for class definition, and so:: make <callable> <name> <tuple>: <block> is translated into the assignment:: <name> = <callable>("<name>", <tuple>, <namespace>) where ``<namespace>`` is the dict created by executing ``<block>``. This is mostly syntactic sugar for:: class <name> <tuple>: __metaclass__ = <callable> <block> and is intended to help more clearly express the intent of the statement when something other than a class is being created. Of course, other syntax for such a statement is possible, but it is hoped that by keeping a strong parallel to the class statement, an understanding of how classes and metaclasses work will translate into an understanding of how the make-statement works as well. The PEP is based on a suggestion [1]_ from Michele Simionato on the python-dev list. Motivation ========== Class statements provide two nice facilities to Python: (1) They execute a block of statements and provide the resulting bindings as a dict to the metaclass. (2) They encourage DRY (don't repeat yourself) by allowing the class being created to know the name it is being assigned. Thus in a simple class statement like:: class C(object): x = 1 def foo(self): return 'bar' the metaclass (``type``) gets called with something like:: C = type('C', (object,), {'x':1, 'foo':<function foo at ...>}) The class statement is just syntactic sugar for the above assignment statement, but clearly a very useful sort of syntactic sugar. It avoids not only the repetition of ``C``, but also simplifies the creation of the dict by allowing it to be expressed as a series of statements. Historically, type instances (a.k.a. class objects) have been the only objects blessed with this sort of syntactic support. The make statement aims to extend this support to other sorts of objects where such syntax would also be useful. Example: simple namespaces -------------------------- Let's say I have some attributes in a module that I access like:: mod.thematic_roletype mod.opinion_roletype mod.text_format mod.html_format and since "Namespaces are one honking great idea", I'd like to be able to access these attributes instead as:: mod.roletypes.thematic mod.roletypes.opinion mod.format.text mod.format.html I currently have two main options: (1) Turn the module into a package, turn ``roletypes`` and ``format`` into submodules, and move the attributes to the submodules. (2) Create ``roletypes`` and ``format`` classes, and move the attributes to the classes. The former is a fair chunk of refactoring work, and produces two tiny modules without much content. The latter keeps the attributes local to the module, but creates classes when there is no intention of ever creating instances of those classes. In situations like this, it would be nice to simply be able to declare a "namespace" to hold the few attributes. With the new make statement, I could introduce my new namespaces with something like:: make namespace roletypes: thematic = ... opinion = ... make namespace format: text = ... html = ... and keep my attributes local to the module without making classes that are never intended to be instantiated. One definition of namespace that would make this work is:: class namespace(object): def __init__(self, name, args, kwargs): self.__dict__.update(kwargs) Given this definition, at the end of the make-statements above, ``roletypes`` and ``format`` would be namespace instances. Example: gui objects -------------------- In gui toolkits, objects like frames and panels are often associated with attributes and functions. With the make-statement, code that looks something like:: root = Tkinter.Tk() frame = Tkinter.Frame(root) frame.pack() def say_hi(): print "hi there, everyone!" hi_there = Tkinter.Button(frame, text="Hello", command=say_hi) hi_there.pack(side=Tkinter.LEFT) root.mainloop() could be rewritten to group the the Button's function with its declaration:: root = Tkinter.Tk() frame = Tkinter.Frame(root) frame.pack() make Tkinter.Button hi_there(frame): text = "Hello" def command(): print "hi there, everyone!" hi_there.pack(side=Tkinter.LEFT) root.mainloop() Example: custom descriptors --------------------------- Since descriptors are used to customize access to an attribute, it's often useful to know the name of that attribute. Current Python doesn't give an easy way to find this name and so a lot of custom descriptors, like Ian Bicking's setonce descriptor [2]_, have to hack around this somehow. With the make-statement, you could create a ``setonce`` attribute like:: class A(object): ... make setonce x: "A's x attribute" ... where the ``setonce`` descriptor would be defined like:: class setonce(object): def __init__(self, name, args, kwargs): self._name = '_setonce_attr_%s' % name self.__doc__ = kwargs.pop('__doc__', None)) Note that unlike the original implementation, the private attribute name is stable since it uses the name of the descriptor, and therefore instances of class A are pickleable. Example: property namespaces ---------------------------- Python's property type takes three function arguments and a docstring argument which, though relevant only to the property, must be declared before it and then passed as arguments to the property call, e.g.:: class C(object): ... def get_x(self): ... def set_x(self): ... x = property(get_x, set_x, "the x of the frobulation") This issue has been brought up before, and Guido [3]_ and others [4]_ have briefly mused over alternate property syntaxes to make declaring properties easier. With the make-statement, the following syntax could be supported:: class C(object): ... make block_property x: '''The x of the frobulation''' def fget(self): ... def fset(self): ... with the following definition of ``block_property``:: def block_property(name, args, block_dict): fget = block_dict.pop('fget', None) fset = block_dict.pop('fset', None) fdel = block_dict.pop('fdel', None) doc = block_dict.pop('__doc__', None) assert not block_dict return property(fget, fset, fdel, doc) Example: interfaces ------------------- Guido [5]_ and others have occasionally suggested introducing interfaces into python. Most suggestions have offered syntax along the lines of:: interface IFoo: """Foo blah blah""" def fumble(name, count): """docstring""" but since there is currently no way in Python to declare an interface in this manner, most implementations of Python interfaces use class objects instead, e.g. Zope's:: class IFoo(Interface): """Foo blah blah""" def fumble(name, count): """docstring""" With the new make-statement, these interfaces could instead be declared as:: make Interface IFoo: """Foo blah blah""" def fumble(name, count): """docstring""" which makes the intent (that this is an interface, not a class) much clearer. Specification ============= Python will translate a make-statement:: make <callable> <name> <tuple>: <block> into the assignment:: <name> = <callable>("<name>", <tuple>, <namespace>) where ``<namespace>`` is the dict created by executing ``<block>``. The ``<tuple>`` expression is optional; if not present, an empty tuple will be assumed. A patch is available implementing these semantics [6]_. The make-statement introduces a new keyword, ``make``. Thus in Python 2.6, the make-statement will have to be enabled using ``from __future__ import make_statement``. Open Issues =========== Keyword ------- Does the ``make`` keyword break too much code? Originally, the make statement used the keyword ``create`` (a suggestion due to Nick Coghlan). However, investigations into the standard library [7]_ and Zope+Plone code [8]_ revealed that ``create`` would break a lot more code, so ``make`` was adopted as the keyword instead. However, there are still a few instances where ``make`` would break code. Is there a better keyword for the statement? Some possible keywords and their counts in the standard library (plus some installed packages): * make - 2 (both in tests) * create - 19 (including existing function in imaplib) * build - 83 (including existing class in distutils.command.build) * construct - 0 * produce - 0 The make-statement as an alternate constructor ---------------------------------------------- Currently, there are not many functions which have the signature ``(name, args, kwargs)``. That means that something like:: make dict params: x = 1 y = 2 is currently impossible because the dict constructor has a different signature. Does this sort of thing need to be supported? One suggestion, by Carl Banks, would be to add a ``__make__`` magic method that if found would be called instead of ``__call__``. For types, the ``__make__`` method would be identical to ``__call__`` and thus unnecessary, but dicts could support the make-statement by defining a ``__make__`` method on the dict type that looks something like:: def __make__(cls, name, args, kwargs): return cls(**kwargs) Of course, rather than adding another magic method, the dict type could just grow a classmethod something like ``dict.fromblock`` that could be used like:: make dict.fromblock params: x = 1 y = 2 So the question is, will many types want to use the make-statement as an alternate constructor? And if so, does that alternate constructor need to have the same name as the original constructor? Customizing the dict in which the block is executed --------------------------------------------------- Should users of the make-statement be able to determine in which dict object the code is executed? This would allow the make-statement to be used in situations where a normal dict object would not suffice, e.g. if order and repeated names must be allowed. Allowing this sort of customization could allow XML to be written without repeating element names, and with nesting of make-statements corresponding to nesting of XML elements:: make Element html: make Element body: text('before first h1') make Element h1: attrib(style='first') text('first h1') tail('after first h1') make Element h1: attrib(style='second') text('second h1') tail('after second h1') If the make-statement tried to get the dict in which to execute its block by calling the callable's ``__make_dict__`` method, the following code would allow the make-statement to be used as above:: class Element(object): class __make_dict__(dict): def __init__(self, *args, **kwargs): self._super = super(Element.__make_dict__, self) self._super.__init__(*args, **kwargs) self.elements = [] self.text = None self.tail = None self.attrib = {} def __getitem__(self, name): try: return self._super.__getitem__(name) except KeyError: if name in ['attrib', 'text', 'tail']: return getattr(self, 'set_%s' % name) else: return globals()[name] def __setitem__(self, name, value): self._super.__setitem__(name, value) self.elements.append(value) def set_attrib(self, **kwargs): self.attrib = kwargs def set_text(self, text): self.text = text def set_tail(self, text): self.tail = text def __new__(cls, name, args, edict): get_element = etree.ElementTree.Element result = get_element(name, attrib=edict.attrib) result.text = edict.text result.tail = edict.tail for element in edict.elements: result.append(element) return result Note, however, that the code to support this is somewhat fragile -- it has to magically populate the namespace with ``attrib``, ``text`` and ``tail``, and it assumes that every name binding inside the make statement body is creating an Element. As it stands, this code would break with the introduction of a simple for-loop to any one of the make-statement bodies, because the for-loop would bind a name to a non-Element object. This could be worked around by adding some sort of isinstance check or attribute examination, but this still results in a somewhat fragile solution. It has also been pointed out that the with-statement can provide equivalent nesting with a much more explicit syntax:: with Element('html') as html: with Element('body') as body: body.text = 'before first h1' with Element('h1', style='first') as h1: h1.text = 'first h1' h1.tail = 'after first h1' with Element('h1', style='second') as h1: h1.text = 'second h1' h1.tail = 'after second h1' And if the repetition of the element names here is too much of a DRY violoation, it is also possible to eliminate all as-clauses except for the first by adding a few methods to Element. [9]_ So are there real use-cases for executing the block in a dict of a different type? And if so, should the make-statement be extended to support them? Optional Extensions =================== Remove the make keyword ------------------------- It might be possible to remove the make keyword so that such statements would begin with the callable being called, e.g.:: namespace ns: badger = 42 def spam(): ... interface C(...): ... However, almost all other Python statements begin with a keyword, and removing the keyword would make it harder to look up this construct in the documentation. Additionally, this would add some complexity in the grammar and so far I (Steven Bethard) have not been able to implement the feature without the keyword. Removing __metaclass__ in Python 3000 ------------------------------------- As a side-effect of its generality, the make-statement mostly eliminates the need for the ``__metaclass__`` attribute in class objects. Thus in Python 3000, instead of:: class <name> <bases-tuple>: __metaclass__ = <metaclass> <block> metaclasses could be supported by using the metaclass as the callable in a make-statement:: make <metaclass> <name> <bases-tuple>: <block> Removing the ``__metaclass__`` hook would simplify the BUILD_CLASS opcode a bit. Removing class statements in Python 3000 ---------------------------------------- In the most extreme application of make-statements, the class statement itself could be deprecated in favor of ``make type`` statements. References ========== .. [1] Michele Simionato's original suggestion () .. [2] Ian Bicking's setonce descriptor () .. [3] Guido ponders property syntax () .. [4] Namespace-based property recipe () .. [5] Python interfaces () .. [6] Make Statement patch () .. [7] Instances of create in the stdlib () .. [8] Instances of create in Zope+Plone () .. [9] Eliminate as-clauses in with-statement XML () Copyright ========= This document has been placed in the public domain. .. Local Variables: mode: indented-text indent-tabs-mode: nil sentence-end-double-space: t fill-column: 70 coding: utf-8 End: | http://mail.python.org/pipermail/python-dev/2006-April/063847.html | CC-MAIN-2013-20 | refinedweb | 2,400 | 54.02 |
This document takes you through the basics of using NetBeans IDE 4.0 to develop
web applications. This document is designed to get you going as quickly as possible.
For more information on working with NetBeans IDE, see the Support
and Docs page on the NetBeans website.
We.
Sample Projects
Just want to play with some projects?
In the IDE, choose File > New Project, then look under the
Samples folder. The IDE includes both web apps and J2SE sample projects.
extends Object implements Serializable
String name;
name = null;
package org.me.hello;
public class NameHandler {
private String username;
public NameHandler() {
setUsername(null);
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
<body>
<form method="post" action="response.jsp">
Enter your name: <input type="text" name="username">
<br>
<input type="submit" value="Ok">
</form>
</body>
<jsp:useBean
<jsp:setProperty
<h1>Hello, <jsp:getProperty!</h1>
setUsername
This tutorial shows you how to create a
web application with interactions between a JavaServer Pages page, a
JavaBeans component, and a Java servlet.
This tutorial shows you how to build, deploy, and execute a web application
that contains JavaServer Pages pages and Java servlets and that uses tags from the JSTL
tag library. It also shows how to use the HTTP monitor to view the requests and
responses between the server and the web browser.
Bookmark this page | http://www.netbeans.org/kb/articles/quickstart-webapps-40.html | crawl-001 | refinedweb | 227 | 57.37 |
I have just added two variables to an object, which was already working, to a class of mine.. author and isbn. Here is a section of the code.
The errors are caused by the following linesThe errors are caused by the following linesCode:#include<iostream> #include<fstream> #include<stdlib> #include<time> #include<string> #include<ctype> #define KBYTE 1024 using namespace std; class bookobject { protected: //new fields here which means char name[KBYTE]; //changeing the edit function char author[KBYTE]; //and books2file - char isbn[KBYTE]; //so new constructor << = int number; //and methods to access and change fields //keep getName() setName() getNumber() setNumber() private: public: bookobject(void) { strcpy(name, ""); strcpy(author, ""); strcpy(isbn, ""); number = -1; }
char author[KBYTE];
char isbn[KBYTE];
I get these errors for both lines
1."Cannot convert 'std::basic_string<char,std::string_char_traits<ch ar>,std::allocator<char>>' to 'char *'
2."Type mismatch in parameter '_dest' in call to 'strcpy(char *, const char *)'
Hope that's the relevent bit, didn't want to post the whole lot. Thanks! (Full code attached if needed!) | http://cboard.cprogramming.com/cplusplus-programming/52533-small-errors.html | CC-MAIN-2014-42 | refinedweb | 174 | 50.46 |
So, here is part two of my RCP tutorial. Last time I build a small RCP application that grabbed a list of all my files on the root of my drive (in my case, C:/) and displayed them in a tree. While I had intended to build a JAR file to incorporate with my app that used the Google web API to query Google, wouldn’t you know it, Google went and dropped their web API. THE MODEL for web services, and they drop it. Others believe that this is a signal of the end of the web-services bubble. Personally, I think it’s a sign that Google is become less of the good guy and more like “Evil” shit-heads more concerned with the bottom line. Regardless of motive, I have to change course here…
So as a substitute to the formerly awesome Google web service, I had to build my own simple web service using Tomcat. For this article, I will build a simple web service that returns the string “My Test Webservice” in Eclipse. Nothing fancy, I just didn’t feel like going with Hello World.
First thing first, make sure you have the Eclipse Web Tools project installed. For me, I am using the BIRT All-In-One install of Eclipse 3.2 Catalina, with WTP installed separately via the update manager. The WTP also has a separate All-in-One package. Make sure you also have configured a Server and Server Runtime for testing and debugging. Certain aspects of the application development did not work properly without them. So here, I will walk through the process of creating the server.
First, I went up to File/New and chose Other. I chose the Server category, and chose a Server project. Since I am using Apache Tomcat 4.1 (which I keep around for other projects compatibility) I choose Tomcat 4.1 as my server type. The next screen sets up the server runtime, so I need to set the install directory for Tomcat 4.1, and I set up the JRE location to where my JDK is installed. I am using Java 1.5.09, which when I set the directory, the JRE Name and JRE Libraries automatically filled themselves out. Once setup, I just click Next, and then Finish to complete the setup. Now, I can start and stop this server configuration by going up to Window, Show View, Other, and choose server. A server tab opens up in the same area where the Console tab and the Properties tab are.
Figure 1. Server Configuration
Figure 2. Servers Tab
With that installed, I created a new Dynamic Web Project called MyWebService. I make sure that my Target Runtime is set to the Runtime configured in my server project configuration. On the next screen, I do not set any other configurations and keep things default (Dynamic Web Module and Java are checked, JavaServer faces is not). I keep the Context Root set to MyWebService and the content directory to default. Once done I click Finish.
Figure 3. New Dynamic Web Project
With my project created, I create a new Java class in my project called MyWebService in the com.digiassn.blogspot package. I write the following code for this class:
Once done, I save the file, then in the Project Explorer, I right-mouse click on the MyWebService.java file, go to Web Services, and choose Create Web Service. I use the following settings:Once done, I save the file, then in the Project Explorer, I right-mouse click on the MyWebService.java file, go to Web Services, and choose Create Web Service. I use the following settings:
package com.digiassn.blogspot;
public class MyWebService
{
public String outputResponse()
{
return "My Test Webservice";
}
}
Figure 4. Web Service Configuration
I also choose to create a WSDL file to for other future programs to consume this service, which will include the finalization of the RCP application. On the next few screens, I have to start the Server in order to proceed, which publishes the project. I also choose not to publish to a UDDI registry.
Now, I want to test my installation, so I go to the following URL:
And the WSDL file is located here:
So now I want to test my web service to make sure it works. This is actually incredibly easy in Eclipse with WTP, a lot easier than I would have thought. One way I can test is to right-mouse click on the MyWebService.java file, choose web service, and select Generate Sample JSP. I get a Web Services Test Client page with some buttons and some panes with the example outputs. I can also go to the WebContent/wsdl/MyWebService.wsdl file and choose “Test with Web Services Explorer”. From here, I can launch various test pages and view the SOAP envelope messages that get sent back and forth.
Now I can publish to the server and I have my web service to consume in the RCP application. | http://digiassn.blogspot.com/2006_12_01_archive.html | CC-MAIN-2018-22 | refinedweb | 838 | 72.97 |
static data path to end of our plugin in file helloworld.py:
def get_htdocs_dir(self): """ Return the absolute path of a directory containing additional static resources (such as images, style sheets, etc). """ from pkg_resources import resource_filename return resource_filename(__name__, 'htdocs')
Remember to load stylesheet
To make Trac to load our stylesheet you need to modify process_request method starting from line 23 to following:
def process_request(self, req): add_stylesheet(req, 'css/helloworld.css') return 'helloworld.cs', None
Back to images
We need to add our image to template to see it.
Our new helloworld.cs:
<?cs include "header.cs" ?> <?cs include "macros.cs" ?> <div id="content" class="helloworld"> <h1>Hello world!</h1> <img src="<?cs var:htdocs_location ? athomas 11 years ago.
The Python code needs updating, as it no longer works with Trac (as of 0.9b2)
- helloworld-plugin-3-trac-0.9.5.tar.gz (20.9 KB) - added by maxb 11 years ago.
Tutorial files, updated for Trac 0.9.5
Download all attachments as: .zip | https://trac-hacks.org/wiki/EggCookingTutorial/AdvancedEggCooking2?version=3 | CC-MAIN-2017-04 | refinedweb | 167 | 62.14 |
Type: Posts; User: Nightwolf629
the URL does not set the variable itself. You need to pull it out of the $_POST or $_GET array first.
In this case you are using GET.
<?php
if (isset($_GET['name'])){
$name =...
Its is reloading the page, but it shouldn't be. It should just be going to 'portal-submit-rpc.php'.
It is important to note that even though the page looks like it just reloads... the...
there is nothing on that page that could redirect to the first one.
here is the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"...
I am having a strange issue with this form built in PHP and html:
<form name="submit_call" id="submit_call" method="post" action="rpc/portal-submit-rpc.php" >
<?...
THANK YOU!!!!!!!!!!!
that fixed it... wow, i feel like a fool wasting all this time over a case sensitivity issue.
thank you SOOOOOO much PeejAvery, you are a lifesaver!
I tried your code, needed to make 1 small change (the final else did not need a comparison).
But sadly, I had the same result.
IE6 works fine with it, but Firefox will not.
Seems like a lot of things could cause that.
Not sure what it could be myself, but this was suggested for this error on another forum:
1) Check all qualifiers (all owners and tables and...
Ok, looks like the http request object is being created ok.
I proved this with the alerts, but I still have the same issue.
So i figure something else must be wrong with the rest of my...
i think this is what you want:
if (isset($_GET["Ex"]))
{
if ($_GET["Ex"] == "false") echo "</pre>";
}
no problem, glad to help
I was returning the ro object in the second example i posted before.
i just copied in your code and it still does not work.
Still works in IE6 though, nothing in firefox.
... im at...
correct,
the "else if" that is used to set the variable to 0 would no longer be needed
Ok, you have me pretty confused now...
Did you try anything I suggested?
Are you still having a problem?
...Im pretty sure you never even asked a question.
That will work, but there is a simpler way.
The problem is that if the checkbox does not get marked, the p# does not get a value.
The easy fix is to declare p3-p10 as =0 in the begining of...
Come on now... I would have figured you would get this part on your own. Its pretty much the same problem you just fixed.
Add up the values of all your checkboxes, and you get 34.
You need...
as for the calculate button,
replace "return (total_price);" with this:
document.getElementByID('total_price').value = total_price;
the name property determines the radio groups, not the id
<fieldset name="General">
<legend class="alignleft">General</legend>
<p>
<input name="General" id="General_0"...
I am familiar with php, but I have never used perl
In this case though, you want to go with PeejAvery's suggestion, and use a multi-dimensional array.
you cannot use the $j variable in the way...
Sorry... don't know how i missed that about the checkboxes.
Anyways, the id for each element must be different.
So you shouldn't have 4 radio inputs with id = "General"
maybe try: id =...
actually... now that I look at it again,
you would need to run sub-queries for the SUM()'s
you can't just tack on a where statment after them.
SELECT B,C,D,E,
((SELECT SUM(F) FROM...
One problem I notice is your where statement for the second SUM():
where A= 'George' and A ='Kevin'
this will always be 0, because 'George' does not = 'Kevin'
you are probably looking for:
...
First of all, getElementById will, well, get the element by id.
all of your elements are described by the name property, but they have no id property.
Secondly, the checkboxes that have the...
Thank you for your help PeejAvery
first I tried this:
function createRequestObject() {
var ro;
try {ro = new XMLHttpRequest();}
catch(e) {
This AJAX works fine in IE 6, but nothing happens in Firefox
This is the html of the page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"... | http://forums.codeguru.com/search.php?s=25e556ab71a7ff0d3458587aaca58f99&searchid=6639503 | CC-MAIN-2015-14 | refinedweb | 710 | 83.66 |
This In-Depth Tutorial on Binary Tree in C++ Explains Types, Representation, Traversal, Applications, and Implementation of Binary Trees in C++:
A Binary tree is a widely used tree data structure. When each node of a tree has at most two child nodes then the tree is called a Binary tree.
So a typical binary tree will have the following components:
- A left subtree
- A root node
- A right subtree
=> Watch Out The Complete List Of C++ Tutorials In This Series.
What You Will Learn:
- Binary Tree In C++
- Types Of Binary Tree
- Binary Tree Representation
- Binary Tree Implementation in C++
- Binary Tree Traversal
- Applications Of Binary Tree
- Conclusion
- Recommended Reading
Binary Tree In C++
A pictorial representation of a binary tree is shown below:
In a given binary tree, the maximum number of nodes at any level is 2l-1 where ‘l’ is the level number.
Thus in case of the root node at level 1, the max number of nodes = 2 1-1 = 20 = 1
As every node in a binary tree has at most two nodes, the maximum nodes at the next level will be, 2*2l-1.
Given a binary tree of depth or height of h, the maximum number of nodes in a binary tree of height h = 2h – 1.
Hence in a binary tree of height 3 (shown above), the maximum number of nodes = 23-1 = 7.
Now let us discuss the various types of binary trees.
Types Of Binary Tree
Following are the most common types of binary trees.
#1) Full Binary Tree
A binary tree in which every node has 0 or 2 children is termed as a full binary tree.
Above shown is a full binary tree in which we can see that all its nodes except the leaf nodes have two children. If L is the number of leaf nodes and ‘l’ is the number of internal or non-leaf nodes, then for a full binary tree, L = l + 1.
#2) Complete Binary Tree
A complete binary tree has all the levels filled except for the last level and the last level has all its nodes as much as to the left.
The tree shown above is a complete binary tree. A typical example of a complete binary tree is a binary heap which we will discuss in the later tutorials.
#3) Perfect Binary Tree
A binary tree is termed perfect when all its internal nodes have two children and all the leaf nodes are at the same level.
A binary tree example shown above is a perfect binary tree as each of its nodes has two children and all the leaf nodes are at the same level.
A perfect binary tree of height h has 2h – 1 number of nodes.
#4) A Degenerate Tree
A binary tree where each internal node has only one child is called a degenerate tree.
The tree shown above is a degenerate tree. As far as the performance of this tree is concerned, the degenerate trees are the same as linked-lists.
#5) Balanced Binary Tree
A binary tree in which the depth of the two subtrees of every node never differs by more than 1 is called a balanced binary tree.
The binary tree shown above is a balanced binary tree as the depth of the two subtrees of every node is not more than 1. AVL trees which we are going to discuss in our subsequent tutorials are a common balanced tree.
Binary Tree Representation
A binary tree is allocated memory in two ways.
#1) Sequential Representation
This is the simplest technique to store a tree data structure. An array is used to store the tree nodes. The number of nodes in a tree defines the size of the array. The root node of the tree is stored at the first index in the array.
In general, if a node is stored at the ith location then it’s left and right child is stored at 2i and 2i+1 location respectively.
Consider the following Binary Tree.
The sequential representation of the above binary tree is as follows:
In the above representation, we see that the left and right child of each node is stored at locations 2*(node_location) and 2*(node_location)+1 respectively.
For Example, the location of node 3 in the array is 3. So it’s left child will be placed at 2*3 = 6. Its right child will be at the location 2*3 +1 = 7. As we can see in the array, children of 3 which are 6 and 7 are placed at location 6 and 7 in the array.
The sequential representation of the tree is inefficient as the array which is used to store the tree nodes takes up lots of space in memory. As the tree grows, this representation becomes inefficient and difficult to manage.
This drawback is overcome by storing the tree nodes in a linked list. Note that if the tree is empty, then the first location storing the root node will be set to 0.
#2) Linked-list Representation
In this type of representation, a linked list is used to store the tree nodes. Several nodes are scattered in the memory in non-contiguous locations and the nodes are connected using the parent-child relationship like a tree.
Following diagram shows a linked list representation for a tree.
As shown in the above representation, each linked list node has three components:
- Left pointer
- Data part
- Right pointer
The left pointer has a pointer to the left child of the node; the right pointer has a pointer to the right child of the node whereas the data part contains the actual data of the node. If there are no children for a given node (leaf node), then the left and right pointers for that node are set to null as shown in the above figure.
Binary Tree Implementation in C++
Next, we develop a binary tree program using a linked list representation in C++. We use a structure to declare a single node and then using a class, we develop a linked list of nodes.
Binary Tree Traversal
We have already discussed traversals in our basic tutorial on trees. In this section, let us implement a program that inserts nodes in the binary tree and also demonstrates all the three traversals i.e. inorder, preorder and postorder, for a binary tree.
#include<iostream> using namespace std; //binary tree node declaration struct bintree_node{ bintree_node *left; bintree_node *right; char data; } ; class bintree_class{ bintree_node *root; public: bintree_class(){ root=NULL; } int isempty() { return(root==NULL); } void insert_node(int item); void inorder_seq(); void inorder(bintree_node *); void postorder_seq(); void postorder(bintree_node *); void preorder_seq(); void preorder(bintree_node *); }; void bintree_class::insert_nodeintree_class::inorder_seq() { inorder(root); } void bintree_class::inorder(bintree_node *ptr) { if(ptr!=NULL){ inorder(ptr->left); cout<<" "<<ptr->data<<" "; inorder(ptr->right); } } void bintree_class::postorder_seq() { postorder(root); } void bintree_class::postorder(bintree_node *ptr) { if(ptr!=NULL){ postorder(ptr->left); postorder(ptr->right); cout<<" "<<ptr->data<<" "; } } void bintree_class::preorder_seq() { preorder(root); } void bintree_class::preorder(bintree_node *ptr) { if(ptr!=NULL){ cout<<" "<<ptr->data<<" "; preorder(ptr->left); preorder(ptr->right); } } int main() { bintree_class bintree; bintree.insert_node('A'); bintree.insert_node('B'); bintree.insert_node('C'); bintree.insert_node('D'); bintree.insert_node('E'); bintree.insert_node('F'); bintree.insert_node('G'); cout<<"Inorder traversal:"<<endl; bintree.inorder_seq(); cout<<endl<<"Postorder traversal:"<<endl; bintree.postorder_seq(); cout<<endl<<"Preorder traversal:"<<endl; bintree.preorder_seq(); }
Output:
Inorder traversal:
A B C D E F G
Postorder traversal:
G F E D C B A
Preorder traversal:
A B C D E F G
Applications Of Binary Tree
A binary tree is used in many applications for storing data.
Some of the important applications of binary trees are listed below:
- Binary Search Trees: Binary trees are used to construct a binary search tree that is used in many searching applications like sets and maps in many language libraries.
- Hash Trees: Used to verify hashes mainly in specialized image signature applications.
- Heaps: Heaps are used for implementing priority queues that are used for routers, scheduling processors in the operating system, etc.
- Huffman Coding: Huffman coding tree is used in compression algorithms (like image compression) as well as cryptographic applications.
- Syntax Tree: Compilers often construct syntax trees which are nothing but binary trees to parse expressions used in the program.
Conclusion
Binary trees are widely used data structures across the software industry. Binary trees are the trees whose nodes have at most two child nodes. We have seen various types of binary trees like a full binary tree, a complete binary tree, a perfect binary tree, a degenerated binary tree, a balanced binary tree, etc.
Binary tree data can also be traversed using inorder, preorder and postorder traversal techniques which we have seen in our previous tutorial. In memory, a binary tree can be represented using a linked list (non-contiguous memory) or arrays (sequential representation).
Linked list representation is more efficient when compared to arrays, as arrays take up a lot of space. | https://www.softwaretestinghelp.com/binary-tree-in-cpp/ | CC-MAIN-2021-17 | refinedweb | 1,496 | 50.77 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.